diff options
author | Ty Dunn <ty@tydunn.com> | 2023-07-06 12:22:20 -0700 |
---|---|---|
committer | Ty Dunn <ty@tydunn.com> | 2023-07-06 12:22:20 -0700 |
commit | 9017dce91c5adf6d089bd7bc88480a4e1befba65 (patch) | |
tree | 63dd7ce9431807118f8999ddeb7bc80904312e6b /extension/react-app/src/tabs/gui.tsx | |
parent | 9f32c906023c596a7610ee4d1d6cff9f1201a5dc (diff) | |
parent | 1e00942edec9c9aa4c69f2a8be7e43f06df684df (diff) | |
download | sncontinue-9017dce91c5adf6d089bd7bc88480a4e1befba65.tar.gz sncontinue-9017dce91c5adf6d089bd7bc88480a4e1befba65.tar.bz2 sncontinue-9017dce91c5adf6d089bd7bc88480a4e1befba65.zip |
Merge branch 'main' of github.com:continuedev/continue
Diffstat (limited to 'extension/react-app/src/tabs/gui.tsx')
-rw-r--r-- | extension/react-app/src/tabs/gui.tsx | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx index e5320c6a..ca369547 100644 --- a/extension/react-app/src/tabs/gui.tsx +++ b/extension/react-app/src/tabs/gui.tsx @@ -1,11 +1,13 @@ import styled from "styled-components"; -import { defaultBorderRadius, Loader } from "../components"; +import { defaultBorderRadius } from "../components"; +import Loader from "../components/Loader"; import ContinueButton from "../components/ContinueButton"; -import { useCallback, useEffect, useRef, useState } from "react"; +import { FullState, HighlightedRangeContext } from "../../../schema/FullState"; +import { useCallback, useEffect, useRef, useState, useContext } from "react"; import { History } from "../../../schema/History"; import { HistoryNode } from "../../../schema/HistoryNode"; import StepContainer from "../components/StepContainer"; -import useContinueGUIProtocol from "../hooks/useWebsocket"; +import { GUIClientContext } from "../App"; import { BookOpen, ChatBubbleOvalLeftEllipsis, @@ -52,6 +54,7 @@ interface GUIProps { } function GUI(props: GUIProps) { + const client = useContext(GUIClientContext); const posthog = usePostHog(); const vscMachineId = useSelector( (state: RootStore) => state.config.vscMachineId @@ -70,7 +73,9 @@ function GUI(props: GUIProps) { const [usingFastModel, setUsingFastModel] = useState(false); const [waitingForSteps, setWaitingForSteps] = useState(false); const [userInputQueue, setUserInputQueue] = useState<string[]>([]); - const [highlightedRanges, setHighlightedRanges] = useState([]); + const [highlightedRanges, setHighlightedRanges] = useState< + HighlightedRangeContext[] + >([]); const [addingHighlightedCode, setAddingHighlightedCode] = useState(false); const [availableSlashCommands, setAvailableSlashCommands] = useState< { name: string; description: string }[] @@ -112,7 +117,6 @@ function GUI(props: GUIProps) { const [feedbackDialogMessage, setFeedbackDialogMessage] = useState(""); const topGuiDivRef = useRef<HTMLDivElement>(null); - const client = useContinueGUIProtocol(); const [scrollTimeout, setScrollTimeout] = useState<NodeJS.Timeout | null>( null @@ -135,9 +139,16 @@ function GUI(props: GUIProps) { useEffect(() => { const listener = (e: any) => { - // Cmd + J to toggle fast model + // Cmd + i to toggle fast model if (e.key === "i" && e.metaKey && e.shiftKey) { setUsingFastModel((prev) => !prev); + // Cmd + backspace to stop currently running step + } else if ( + e.key === "Backspace" && + e.metaKey && + typeof history?.current_index !== "undefined" + ) { + client?.deleteAtIndex(history.current_index); } }; window.addEventListener("keydown", listener); @@ -145,10 +156,10 @@ function GUI(props: GUIProps) { return () => { window.removeEventListener("keydown", listener); }; - }, []); + }, [client, history]); useEffect(() => { - client?.onStateUpdate((state) => { + client?.onStateUpdate((state: FullState) => { // Scroll only if user is at very bottom of the window. setUsingFastModel(state.default_model === "gpt-3.5-turbo"); const shouldScrollToBottom = @@ -289,7 +300,7 @@ function GUI(props: GUIProps) { > {typeof client === "undefined" && ( <> - <Loader></Loader> + <Loader /> <p style={{ textAlign: "center" }}>Loading Continue server...</p> </> )} @@ -316,7 +327,8 @@ function GUI(props: GUIProps) { setStepsOpen(nextStepsOpen); }} onToggleAll={() => { - setStepsOpen((prev) => prev.map((_, index) => !prev[index])); + const shouldOpen = !stepsOpen[index]; + setStepsOpen((prev) => prev.map(() => shouldOpen)); }} key={index} onUserInput={(input: string) => { @@ -381,6 +393,7 @@ function GUI(props: GUIProps) { borderRadius: defaultBorderRadius, padding: "16px", margin: "16px", + zIndex: 100, }} hidden={!showDataSharingInfo} > |