diff --git a/core/index.d.ts b/core/index.d.ts index d15c73b50..7cd734c16 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -704,6 +704,7 @@ export interface IdeSettings { userToken: string; continueTestEnvironment: "none" | "production" | "staging" | "local"; pauseCodebaseIndexOnStart: boolean; + addFileContext: boolean } export interface FileStats { diff --git a/core/util/filesystem.ts b/core/util/filesystem.ts index ff7906e91..78c72599f 100644 --- a/core/util/filesystem.ts +++ b/core/util/filesystem.ts @@ -54,6 +54,7 @@ class FileSystemIde implements IDE { userToken: "", continueTestEnvironment: "none", pauseCodebaseIndexOnStart: false, + addFileContext: false }; } async getGitHubAuthToken(args: GetGhTokenArgs): Promise { diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 4ea6bddfd..71ba82d2a 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -141,6 +141,11 @@ "type": "number", "default": 60, "description": "The period of time in minutes between automatic syncs." + }, + "continue.addFileContext": { + "type": "boolean", + "default": false, + "description": "Adds the current file context when you start a chat." } } }, diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts index 4a553ef60..7a09effc5 100644 --- a/extensions/vscode/src/VsCodeIde.ts +++ b/extensions/vscode/src/VsCodeIde.ts @@ -774,6 +774,7 @@ class VsCodeIde implements IDE { "pauseCodebaseIndexOnStart", false, ), + addFileContext: settings.get("addFileContext", false), }; return ideSettings; } diff --git a/gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts b/gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts index 26fa47a7b..fe660133d 100644 --- a/gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts +++ b/gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts @@ -1,7 +1,8 @@ import { Editor } from "@tiptap/react"; import { InputModifiers } from "core"; import { rifWithContentsToContextItem } from "core/commands/util"; -import { MutableRefObject } from "react"; +import { MutableRefObject, useContext } from "react"; +import { IdeMessengerContext } from "../../../context/IdeMessenger"; import { useWebviewListener } from "../../../hooks/useWebviewListener"; import { useAppSelector } from "../../../redux/hooks"; import { clearCodeToEdit } from "../../../redux/slices/editModeState"; @@ -185,12 +186,14 @@ export function useMainEditorWebviewListeners({ (state) => state.config.config.contextProviders, ); const mode = useAppSelector(state=>state.session.mode); + const ideContext = useContext(IdeMessengerContext) useWebviewListener( "newSession", async () => { - // do not insert current file context mention if we are in edit mode - if(!editor || mode === 'edit') return; + // do not insert current file context mention if we are in edit mode or if addFileContext is disabled + const settings = await ideContext.ide.getIdeSettings() + if(!editor || mode === 'edit' || !settings.addFileContext) return; insertCurrentFileContextMention(editor, activeContextProviders); }, [editor, activeContextProviders, mode],