diff --git a/core/config/sharedConfig.ts b/core/config/sharedConfig.ts index b8ac20584..9d2a450d7 100644 --- a/core/config/sharedConfig.ts +++ b/core/config/sharedConfig.ts @@ -18,6 +18,7 @@ export const sharedConfigSchema = z useChromiumForDocsCrawling: z.boolean(), readResponseTTS: z.boolean(), promptPath: z.string(), + useCurrentFileAsContext: z.boolean(), // `ui` in `ContinueConfig` showSessionTabs: z.boolean(), @@ -106,8 +107,7 @@ export function modifyAnyConfigWithSharedConfig< sharedConfig.disableAutocompleteInFiles; } if (sharedConfig.modelTimeout !== undefined) { - configCopy.tabAutocompleteOptions.modelTimeout = - sharedConfig.modelTimeout; + configCopy.tabAutocompleteOptions.modelTimeout = sharedConfig.modelTimeout; } if (sharedConfig.debounceDelay !== undefined) { configCopy.tabAutocompleteOptions.debounceDelay = @@ -162,6 +162,10 @@ export function modifyAnyConfigWithSharedConfig< if (sharedConfig.readResponseTTS !== undefined) { configCopy.experimental.readResponseTTS = sharedConfig.readResponseTTS; } + if (sharedConfig.useCurrentFileAsContext !== undefined) { + configCopy.experimental.useCurrentFileAsContext = + sharedConfig.useCurrentFileAsContext; + } return configCopy; } diff --git a/core/index.d.ts b/core/index.d.ts index 71c5ae957..8c75b9ac8 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -704,7 +704,6 @@ export interface IdeSettings { userToken: string; continueTestEnvironment: "none" | "production" | "staging" | "local"; pauseCodebaseIndexOnStart: boolean; - addFileContext: boolean } export interface FileStats { @@ -1316,6 +1315,11 @@ export interface ExperimentalConfig { */ useChromiumForDocsCrawling?: boolean; modelContextProtocolServers?: ExperimentalMCPOptions[]; + + /** + * If enabled, will add the current file as context. + */ + useCurrentFileAsContext?: boolean; } export interface AnalyticsConfig { diff --git a/core/util/filesystem.ts b/core/util/filesystem.ts index 78c72599f..ff7906e91 100644 --- a/core/util/filesystem.ts +++ b/core/util/filesystem.ts @@ -54,7 +54,6 @@ 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 63a5cf8aa..3ac9d33c5 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -141,11 +141,6 @@ "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 7a09effc5..48a35fa69 100644 --- a/extensions/vscode/src/VsCodeIde.ts +++ b/extensions/vscode/src/VsCodeIde.ts @@ -335,7 +335,10 @@ class VsCodeIde implements IDE { const pathToLastModified: FileStatsMap = {}; await Promise.all( files.map(async (file) => { - const stat = await this.ideUtils.stat(vscode.Uri.parse(file), false /* No need to catch ENOPRO exceptions */); + const stat = await this.ideUtils.stat( + vscode.Uri.parse(file), + false /* No need to catch ENOPRO exceptions */, + ); pathToLastModified[file] = { lastModified: stat!.mtime, size: stat!.size, @@ -401,7 +404,8 @@ class VsCodeIde implements IDE { const configs: ContinueRcJson[] = []; for (const workspaceDir of workspaceDirs) { const files = await this.ideUtils.readDirectory(workspaceDir); - if (files === null) {//Unlikely, but just in case... + if (files === null) { + //Unlikely, but just in case... continue; } for (const [filename, type] of files) { @@ -753,7 +757,7 @@ class VsCodeIde implements IDE { async listDir(dir: string): Promise<[string, FileType][]> { const entries = await this.ideUtils.readDirectory(vscode.Uri.parse(dir)); - return entries === null? [] : entries as any; + return entries === null ? [] : (entries as any); } private getIdeSettingsSync(): IdeSettings { @@ -774,7 +778,6 @@ 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 fe660133d..a81d30561 100644 --- a/gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts +++ b/gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts @@ -1,8 +1,7 @@ import { Editor } from "@tiptap/react"; import { InputModifiers } from "core"; import { rifWithContentsToContextItem } from "core/commands/util"; -import { MutableRefObject, useContext } from "react"; -import { IdeMessengerContext } from "../../../context/IdeMessenger"; +import { MutableRefObject } from "react"; import { useWebviewListener } from "../../../hooks/useWebviewListener"; import { useAppSelector } from "../../../redux/hooks"; import { clearCodeToEdit } from "../../../redux/slices/editModeState"; @@ -185,17 +184,20 @@ export function useMainEditorWebviewListeners({ const activeContextProviders = useAppSelector( (state) => state.config.config.contextProviders, ); - const mode = useAppSelector(state=>state.session.mode); - const ideContext = useContext(IdeMessengerContext) + const useCurrentFileAsContext = useAppSelector( + (state) => state.config.config.experimental?.useCurrentFileAsContext, + ); + const mode = useAppSelector((state) => state.session.mode); + + console.log("debug1 current file", useCurrentFileAsContext); useWebviewListener( "newSession", async () => { // 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; + if (!editor || mode === "edit" || !useCurrentFileAsContext) return; insertCurrentFileContextMention(editor, activeContextProviders); }, - [editor, activeContextProviders, mode], + [editor, activeContextProviders, mode, useCurrentFileAsContext], ); } diff --git a/gui/src/pages/config/UserSettingsForm.tsx b/gui/src/pages/config/UserSettingsForm.tsx index 06f2ce32c..b15c9bbed 100644 --- a/gui/src/pages/config/UserSettingsForm.tsx +++ b/gui/src/pages/config/UserSettingsForm.tsx @@ -67,6 +67,8 @@ export function UserSettingsForm() { const readResponseTTS = config.experimental?.readResponseTTS ?? false; const displayRawMarkdown = config.ui?.displayRawMarkdown ?? false; const disableSessionTitles = config.disableSessionTitles ?? false; + const useCurrentFileAsContext = + config.experimental?.useCurrentFileAsContext ?? false; const allowAnonymousTelemetry = config.allowAnonymousTelemetry ?? true; const disableIndexing = config.disableIndexing ?? false; @@ -211,6 +213,16 @@ export function UserSettingsForm() { text="Enable Indexing" /> + + handleUpdate({ + useCurrentFileAsContext: !useCurrentFileAsContext, + }) + } + text="Add Current File by Default" + /> + {/*