From f210faf09d36805f58ff3a843383d665027c036f Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 19 Nov 2024 23:57:11 -0800 Subject: [PATCH] chat symbols - active file working --- gui/src/components/mainInput/resolveInput.ts | 8 +------- gui/src/hooks/useChatHandler.ts | 7 ++++++- gui/src/hooks/useHistory.tsx | 3 +-- gui/src/pages/edit/index.tsx | 2 ++ gui/src/util/symbols.ts | 1 + 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/gui/src/components/mainInput/resolveInput.ts b/gui/src/components/mainInput/resolveInput.ts index a933bd1a3..b12804d72 100644 --- a/gui/src/components/mainInput/resolveInput.ts +++ b/gui/src/components/mainInput/resolveInput.ts @@ -10,11 +10,7 @@ import { import { stripImages } from "core/llm/images"; import { IIdeMessenger } from "../../context/IdeMessenger"; import { Dispatch } from "@reduxjs/toolkit"; -import { - setIsGatheringContext, - updateFileSymbols, -} from "../../redux/slices/stateSlice"; -import { updateFileSymbolsFromContextItems } from "../../util/symbols"; +import { setIsGatheringContext } from "../../redux/slices/stateSlice"; interface MentionAttrs { label: string; @@ -175,8 +171,6 @@ async function resolveEditorContent( ); contextItems.push(...defaultContextItems.flat()); - await updateFileSymbolsFromContextItems(contextItems, ideMessenger, dispatch); - if (contextItemsText !== "") { contextItemsText += "\n"; } diff --git a/gui/src/hooks/useChatHandler.ts b/gui/src/hooks/useChatHandler.ts index b9342d4e9..a4aeb799e 100644 --- a/gui/src/hooks/useChatHandler.ts +++ b/gui/src/hooks/useChatHandler.ts @@ -37,6 +37,7 @@ import { import { resetNextCodeBlockToApplyIndex } from "../redux/slices/stateSlice"; import { RootState } from "../redux/store"; import useHistory from "./useHistory"; +import { updateFileSymbolsFromContextItems } from "../util/symbols"; function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) { const posthog = usePostHog(); @@ -256,7 +257,11 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) { } } - // dispatch(addContextItems(contextItems)); + await updateFileSymbolsFromContextItems( + selectedContextItems, + ideMessenger, + dispatch, + ); const message: ChatMessage = { role: "user", diff --git a/gui/src/hooks/useHistory.tsx b/gui/src/hooks/useHistory.tsx index b52271ab4..4bdd1e2c1 100644 --- a/gui/src/hooks/useHistory.tsx +++ b/gui/src/hooks/useHistory.tsx @@ -6,8 +6,7 @@ import { useCallback, useContext } from "react"; import { useSelector } from "react-redux"; import { IdeMessengerContext } from "../context/IdeMessenger"; import { useLastSessionContext } from "../context/LastSessionContext"; -import { defaultModelSelector } from "../redux/selectors/modelSelectors"; -import { newSession, updateFileSymbols } from "../redux/slices/stateSlice"; +import { newSession } from "../redux/slices/stateSlice"; import { RootState } from "../redux/store"; import { getLocalStorage, setLocalStorage } from "../util/localStorage"; import { updateFileSymbolsFromContextItems } from "../util/symbols"; diff --git a/gui/src/pages/edit/index.tsx b/gui/src/pages/edit/index.tsx index 2e93a16aa..26fbacbb1 100644 --- a/gui/src/pages/edit/index.tsx +++ b/gui/src/pages/edit/index.tsx @@ -177,6 +177,8 @@ function Edit() { dispatch, ); + // Note, not currently updating file symbols in edit mode + const prompt = [ ...contextItems.map((item) => item.content), stripImages(userInstructions), diff --git a/gui/src/util/symbols.ts b/gui/src/util/symbols.ts index 98848053a..5c4e1be12 100644 --- a/gui/src/util/symbols.ts +++ b/gui/src/util/symbols.ts @@ -29,6 +29,7 @@ export async function updateFileSymbolsFromContextItems( } } } catch (e) { + // Catch all - don't want file symbols to break the chat experience for now console.error("Error updating file symbols from context items", e); } }