diff options
| author | Nate Sesti <sestinj@gmail.com> | 2023-07-04 12:47:28 -0700 | 
|---|---|---|
| committer | Nate Sesti <sestinj@gmail.com> | 2023-07-04 12:47:28 -0700 | 
| commit | 2ec0b4118bd092a528a1171df6ae4ffcd7cfb33b (patch) | |
| tree | 3fbde3a47bb235395f9ae0ffd16df0e955d64d54 /extension/react-app/src/tabs | |
| parent | 2a524193d26ffca7ef62445f2069773e106f68a8 (diff) | |
| download | sncontinue-2ec0b4118bd092a528a1171df6ae4ffcd7cfb33b.tar.gz sncontinue-2ec0b4118bd092a528a1171df6ae4ffcd7cfb33b.tar.bz2 sncontinue-2ec0b4118bd092a528a1171df6ae4ffcd7cfb33b.zip  | |
better control over context
Diffstat (limited to 'extension/react-app/src/tabs')
| -rw-r--r-- | extension/react-app/src/tabs/gui.tsx | 23 | 
1 files changed, 18 insertions, 5 deletions
diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx index 0a9e48fb..c2ff101a 100644 --- a/extension/react-app/src/tabs/gui.tsx +++ b/extension/react-app/src/tabs/gui.tsx @@ -70,10 +70,13 @@ 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([ +    { filepath: "abc.txt", range: { start: { line: 2 }, end: { line: 4 } } }, +  ]);    const [availableSlashCommands, setAvailableSlashCommands] = useState<      { name: string; description: string }[]    >([]); +  const [pinned, setPinned] = useState(false);    const [showDataSharingInfo, setShowDataSharingInfo] = useState(false);    const [stepsOpen, setStepsOpen] = useState<boolean[]>([      true, @@ -185,9 +188,9 @@ function GUI(props: GUIProps) {    const mainTextInputRef = useRef<HTMLInputElement>(null); -  const deleteContextItem = useCallback( -    (idx: number) => { -      client?.deleteContextAtIndices([idx]); +  const deleteContextItems = useCallback( +    (indices: number[]) => { +      client?.deleteContextAtIndices(indices);      },      [client]    ); @@ -241,6 +244,13 @@ function GUI(props: GUIProps) {        setUserInputQueue((queue) => {          return [...queue, input];        }); + +      // Delete all context items unless locked +      if (!pinned) { +        client?.deleteContextAtIndices( +          highlightedRanges.map((_, index) => index) +        ); +      }      }    }; @@ -345,7 +355,10 @@ function GUI(props: GUIProps) {            onInputValueChange={() => {}}            items={availableSlashCommands}            highlightedCodeSections={highlightedRanges} -          deleteContextItem={deleteContextItem} +          deleteContextItems={deleteContextItems} +          onTogglePin={() => { +            setPinned((prev: boolean) => !prev); +          }}          />          <ContinueButton onClick={onMainTextInput} />        </TopGUIDiv>  | 
