move cancel button to lump
This commit is contained in:
parent
d0339ecdf5
commit
7cd8105fce
4 changed files with 86 additions and 72 deletions
|
|
@ -11,7 +11,7 @@ import { fontSize } from "../../../util";
|
|||
import AssistantSelect from "../../modelSelection/platform/AssistantSelect";
|
||||
import HoverItem from "../InputToolbar/HoverItem";
|
||||
|
||||
interface TopToolbarIconProps {
|
||||
interface BlockSettingsToolbarIcon {
|
||||
tooltip: string;
|
||||
icon: React.ComponentType<any>;
|
||||
itemCount?: number;
|
||||
|
|
@ -19,7 +19,7 @@ interface TopToolbarIconProps {
|
|||
isSelected?: boolean;
|
||||
}
|
||||
|
||||
function TopToolbarIcon(props: TopToolbarIconProps) {
|
||||
function BlockSettingsToolbarIcon(props: BlockSettingsToolbarIcon) {
|
||||
return (
|
||||
<HoverItem className="px-0" onClick={props.onClick}>
|
||||
<div
|
||||
|
|
@ -61,16 +61,16 @@ function TopToolbarIcon(props: TopToolbarIconProps) {
|
|||
);
|
||||
}
|
||||
|
||||
interface TopInputProps {
|
||||
interface BlockSettingsTopToolbarProps {
|
||||
selectedSection: string | null;
|
||||
setSelectedSection: (value: string | null) => void;
|
||||
}
|
||||
|
||||
export function TopInputToolbar(props: TopInputProps) {
|
||||
export function BlockSettingsTopToolbar(props: BlockSettingsTopToolbarProps) {
|
||||
return (
|
||||
<div className="flex w-full items-center justify-between">
|
||||
<div className="xs:flex hidden items-center justify-center text-gray-400">
|
||||
<TopToolbarIcon
|
||||
<BlockSettingsToolbarIcon
|
||||
icon={CubeIcon}
|
||||
tooltip="Models"
|
||||
isSelected={props.selectedSection === "models"}
|
||||
|
|
@ -80,7 +80,7 @@ export function TopInputToolbar(props: TopInputProps) {
|
|||
)
|
||||
}
|
||||
/>
|
||||
<TopToolbarIcon
|
||||
<BlockSettingsToolbarIcon
|
||||
icon={PencilIcon}
|
||||
tooltip="Rules"
|
||||
isSelected={props.selectedSection === "rules"}
|
||||
|
|
@ -90,7 +90,7 @@ export function TopInputToolbar(props: TopInputProps) {
|
|||
)
|
||||
}
|
||||
/>
|
||||
<TopToolbarIcon
|
||||
<BlockSettingsToolbarIcon
|
||||
icon={BookOpenIcon}
|
||||
tooltip="Docs"
|
||||
isSelected={props.selectedSection === "docs"}
|
||||
|
|
@ -100,7 +100,7 @@ export function TopInputToolbar(props: TopInputProps) {
|
|||
)
|
||||
}
|
||||
/>
|
||||
<TopToolbarIcon
|
||||
<BlockSettingsToolbarIcon
|
||||
icon={ChatBubbleLeftIcon}
|
||||
tooltip="Prompts"
|
||||
isSelected={props.selectedSection === "prompts"}
|
||||
|
|
@ -120,7 +120,7 @@ export function TopInputToolbar(props: TopInputProps) {
|
|||
)
|
||||
}
|
||||
/> */}
|
||||
<TopToolbarIcon
|
||||
<BlockSettingsToolbarIcon
|
||||
icon={WrenchScrewdriverIcon}
|
||||
tooltip="Tools"
|
||||
isSelected={props.selectedSection === "tools"}
|
||||
|
|
@ -130,7 +130,7 @@ export function TopInputToolbar(props: TopInputProps) {
|
|||
)
|
||||
}
|
||||
/>
|
||||
<TopToolbarIcon
|
||||
<BlockSettingsToolbarIcon
|
||||
icon={Squares2X2Icon}
|
||||
tooltip="MCP"
|
||||
isSelected={props.selectedSection === "mcp"}
|
||||
72
gui/src/components/mainInput/Lump/TopToolbar.tsx
Normal file
72
gui/src/components/mainInput/Lump/TopToolbar.tsx
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
import { useContext } from "react";
|
||||
import styled from "styled-components";
|
||||
import { lightGray } from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
|
||||
import {
|
||||
clearLastEmptyResponse,
|
||||
setInactive,
|
||||
} from "../../../redux/slices/sessionSlice";
|
||||
import { getFontSize, getMetaKeyLabel } from "../../../util";
|
||||
import { BlockSettingsTopToolbar } from "./BlockSettingsTopToolbar";
|
||||
|
||||
const Container = styled.div`
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
width: 100%;
|
||||
`;
|
||||
|
||||
const StopButton = styled.div`
|
||||
font-size: ${getFontSize() - 3}px;
|
||||
color: ${lightGray};
|
||||
padding: 4px;
|
||||
cursor: pointer;
|
||||
`;
|
||||
|
||||
interface TopToolbarProps {
|
||||
selectedSection: string | null;
|
||||
setSelectedSection: (value: string | null) => void;
|
||||
}
|
||||
|
||||
export function TopToolbar(props: TopToolbarProps) {
|
||||
const dispatch = useAppDispatch();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const ttsActive = useAppSelector((state) => state.ui.ttsActive);
|
||||
const isStreaming = useAppSelector((state) => state.session.isStreaming);
|
||||
|
||||
if (ttsActive) {
|
||||
return (
|
||||
<Container>
|
||||
<StopButton
|
||||
onClick={() => {
|
||||
ideMessenger.post("tts/kill", undefined);
|
||||
}}
|
||||
>
|
||||
■ Stop TTS
|
||||
</StopButton>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
if (isStreaming) {
|
||||
return (
|
||||
<Container>
|
||||
<StopButton
|
||||
onClick={() => {
|
||||
dispatch(setInactive());
|
||||
dispatch(clearLastEmptyResponse());
|
||||
}}
|
||||
>
|
||||
{getMetaKeyLabel()} ⌫ Cancel
|
||||
</StopButton>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<BlockSettingsTopToolbar
|
||||
selectedSection={props.selectedSection}
|
||||
setSelectedSection={props.setSelectedSection}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
@ -5,8 +5,8 @@ import {
|
|||
vscCommandCenterInactiveBorder,
|
||||
vscInputBackground,
|
||||
} from "../..";
|
||||
import { TopInputToolbar } from "./TopInputToolbar";
|
||||
import { SelectedSection } from "./sections/SelectedSection";
|
||||
import { TopToolbar } from "./TopToolbar";
|
||||
|
||||
interface LumpProps {
|
||||
open: boolean;
|
||||
|
|
@ -61,7 +61,7 @@ export function Lump(props: LumpProps) {
|
|||
return (
|
||||
<LumpDiv open={open}>
|
||||
<div className="mt-0.5 px-2">
|
||||
<TopInputToolbar
|
||||
<TopToolbar
|
||||
selectedSection={selectedSection}
|
||||
setSelectedSection={setSelectedSection}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -13,12 +13,7 @@ import { useCallback, useContext, useEffect, useRef, useState } from "react";
|
|||
import { ErrorBoundary } from "react-error-boundary";
|
||||
import { useSelector } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
Button,
|
||||
defaultBorderRadius,
|
||||
lightGray,
|
||||
vscBackground,
|
||||
} from "../../components";
|
||||
import { Button, lightGray, vscBackground } from "../../components";
|
||||
import CodeToEditCard from "../../components/CodeToEditCard";
|
||||
import FeedbackDialog from "../../components/dialogs/FeedbackDialog";
|
||||
import FreeTrialOverDialog from "../../components/dialogs/FreeTrialOverDialog";
|
||||
|
|
@ -41,11 +36,9 @@ import { selectCurrentToolCall } from "../../redux/selectors/selectCurrentToolCa
|
|||
import { selectDefaultModel } from "../../redux/slices/configSlice";
|
||||
import { submitEdit } from "../../redux/slices/editModeState";
|
||||
import {
|
||||
clearLastEmptyResponse,
|
||||
newSession,
|
||||
selectIsInEditMode,
|
||||
selectIsSingleRangeEditOrInsertion,
|
||||
setInactive,
|
||||
} from "../../redux/slices/sessionSlice";
|
||||
import {
|
||||
setDialogEntryOn,
|
||||
|
|
@ -57,11 +50,7 @@ import { cancelStream } from "../../redux/thunks/cancelStream";
|
|||
import { exitEditMode } from "../../redux/thunks/exitEditMode";
|
||||
import { loadLastSession } from "../../redux/thunks/session";
|
||||
import { streamResponseThunk } from "../../redux/thunks/streamResponse";
|
||||
import {
|
||||
getFontSize,
|
||||
getMetaKeyLabel,
|
||||
isMetaEquivalentKeyPressed,
|
||||
} from "../../util";
|
||||
import { isMetaEquivalentKeyPressed } from "../../util";
|
||||
import {
|
||||
FREE_TRIAL_LIMIT_REQUESTS,
|
||||
incrementFreeTrialCount,
|
||||
|
|
@ -76,29 +65,6 @@ import { ToolCallButtons } from "./ToolCallDiv/ToolCallButtonsDiv";
|
|||
import ToolOutput from "./ToolCallDiv/ToolOutput";
|
||||
import { useAutoScroll } from "./useAutoScroll";
|
||||
|
||||
const StopButton = styled.div`
|
||||
background-color: ${vscBackground};
|
||||
width: fit-content;
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
font-size: ${getFontSize() - 2}px;
|
||||
border: 0.5px solid ${lightGray};
|
||||
border-radius: ${defaultBorderRadius};
|
||||
padding: 4px 8px;
|
||||
color: ${lightGray};
|
||||
cursor: pointer;
|
||||
box-shadow:
|
||||
0 4px 6px rgba(0, 0, 0, 0.1),
|
||||
0 1px 3px rgba(0, 0, 0, 0.08);
|
||||
transition: box-shadow 0.3s ease;
|
||||
|
||||
&:hover {
|
||||
box-shadow:
|
||||
0 6px 8px rgba(0, 0, 0, 0.15),
|
||||
0 3px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
`;
|
||||
|
||||
const StepsDiv = styled.div`
|
||||
position: relative;
|
||||
background-color: transparent;
|
||||
|
|
@ -141,7 +107,6 @@ export function Chat() {
|
|||
(store) => store.config.config.ui?.showSessionTabs,
|
||||
);
|
||||
const defaultModel = useAppSelector(selectDefaultModel);
|
||||
const ttsActive = useAppSelector((state) => state.ui.ttsActive);
|
||||
const isStreaming = useAppSelector((state) => state.session.isStreaming);
|
||||
const [stepsOpen, setStepsOpen] = useState<(boolean | undefined)[]>([]);
|
||||
const mainTextInputRef = useRef<HTMLInputElement>(null);
|
||||
|
|
@ -426,29 +391,6 @@ export function Chat() {
|
|||
))}
|
||||
</StepsDiv>
|
||||
<div className={`relative mt-1`}>
|
||||
<div className="absolute -top-8 right-2 z-30 flex flex-col gap-1">
|
||||
{ttsActive && (
|
||||
<StopButton
|
||||
className=""
|
||||
onClick={() => {
|
||||
ideMessenger.post("tts/kill", undefined);
|
||||
}}
|
||||
>
|
||||
■ Stop TTS
|
||||
</StopButton>
|
||||
)}
|
||||
{isStreaming && (
|
||||
<StopButton
|
||||
onClick={() => {
|
||||
dispatch(setInactive());
|
||||
dispatch(clearLastEmptyResponse());
|
||||
}}
|
||||
>
|
||||
{getMetaKeyLabel()} ⌫ Cancel
|
||||
</StopButton>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{toolCallState?.status === "generated" && <ToolCallButtons />}
|
||||
|
||||
{isInEditMode && history.length === 0 && <CodeToEditCard />}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue