diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-08-11 13:42:59 -0700 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-08-11 13:42:59 -0700 |
commit | 4eaf254b3fa974ef8a7ab6b08418ea8283a4f22a (patch) | |
tree | 0e6789f8f80e08d0ae497f08c76baa9876bebc34 /extension/react-app/src/components | |
parent | 1936f725d226bea2e13d5d88c1dd7a9a02ddd259 (diff) | |
parent | 48ee1334dfd21dbe55cf66f39da1249619103e81 (diff) | |
download | sncontinue-4eaf254b3fa974ef8a7ab6b08418ea8283a4f22a.tar.gz sncontinue-4eaf254b3fa974ef8a7ab6b08418ea8283a4f22a.tar.bz2 sncontinue-4eaf254b3fa974ef8a7ab6b08418ea8283a4f22a.zip |
Merge branch 'main' into ci-testing
Diffstat (limited to 'extension/react-app/src/components')
-rw-r--r-- | extension/react-app/src/components/ComboBox.tsx | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/extension/react-app/src/components/ComboBox.tsx b/extension/react-app/src/components/ComboBox.tsx index bf32fc5a..4e564000 100644 --- a/extension/react-app/src/components/ComboBox.tsx +++ b/extension/react-app/src/components/ComboBox.tsx @@ -24,7 +24,8 @@ import { setBottomMessage, setBottomMessageCloseTimeout, } from "../redux/slices/uiStateSlice"; -import { useDispatch } from "react-redux"; +import { useDispatch, useSelector } from "react-redux"; +import { RootStore } from "../redux/store"; const SEARCH_INDEX_NAME = "continue_context_items"; @@ -136,6 +137,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { const searchClient = new MeiliSearch({ host: "http://127.0.0.1:7700" }); const client = useContext(GUIClientContext); const dispatch = useDispatch(); + const workspacePaths = useSelector((state: RootStore) => state.config.workspacePaths); const [history, setHistory] = React.useState<string[]>([]); // The position of the current command you are typing now, so the one that will be appended to history once you press enter @@ -181,10 +183,16 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { // Get search results and return setCurrentlyInContextQuery(true); const providerAndQuery = segs[segs.length - 1] || ""; - const [provider, query] = providerAndQuery.split(" "); + // Only return context items from the current workspace - the index is currently shared between all sessions + const workspaceFilter = + workspacePaths && workspacePaths.length > 0 + ? `workspace_dir IN [ ${workspacePaths.map((path) => `"${path}"`).join(", ")} ]` + : undefined; searchClient .index(SEARCH_INDEX_NAME) - .search(providerAndQuery) + .search(providerAndQuery, { + filter: workspaceFilter, + }) .then((res) => { setItems( res.hits.map((hit) => { @@ -410,7 +418,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { // Prevent Downshift's default 'Enter' behavior. (event.nativeEvent as any).preventDownshiftDefault = true; - if (props.onEnter) props.onEnter(event); + if (props.onEnter) {props.onEnter(event);} setCurrentlyInContextQuery(false); } else if (event.key === "Tab" && items.length > 0) { downshiftProps.setInputValue(items[0].name); @@ -423,7 +431,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { ) { (event.nativeEvent as any).preventDownshiftDefault = true; } else if (event.key === "ArrowUp") { - if (positionInHistory == 0) return; + if (positionInHistory == 0) {return;} else if ( positionInHistory == history.length && (history.length === 0 || |