From 8907266540a7303ec6ce1223962cbaf2fa0e2d38 Mon Sep 17 00:00:00 2001 From: hitesh-1997 Date: Sat, 4 Jan 2025 18:39:37 +0530 Subject: [PATCH 1/4] suggestion mode UI --- agent/src/AgentWorkspaceConfiguration.test.ts | 2 +- .../com/sourcegraph/config/ConfigUtilTest.kt | 6 ++--- lib/shared/src/configuration.ts | 15 +++++++++++ vscode/package.json | 25 +++++++++++-------- .../create-inline-completion-item-provider.ts | 2 +- vscode/src/configuration.test.ts | 15 ++++++----- vscode/src/configuration.ts | 10 ++++++-- vscode/src/testutils/mocks.ts | 2 +- vscode/test/e2e/auto-edits.test.ts | 3 ++- web/lib/agent/agent.client.ts | 4 +-- 10 files changed, 57 insertions(+), 27 deletions(-) diff --git a/agent/src/AgentWorkspaceConfiguration.test.ts b/agent/src/AgentWorkspaceConfiguration.test.ts index 791698a2838c..a5d8eb564c36 100644 --- a/agent/src/AgentWorkspaceConfiguration.test.ts +++ b/agent/src/AgentWorkspaceConfiguration.test.ts @@ -72,7 +72,7 @@ describe('AgentWorkspaceConfiguration', () => { expect(config.get('cody.telemetry.level')).toBe('agent') // clientName undefined because custom JSON specified telemetry with level alone. expect(config.get('cody.telemetry.clientName')).toBe('test-client') - expect(config.get('cody.autocomplete.enabled')).toBe(true) + expect(config.get('cody.suggestions.mode')).toBe('autocomplete') expect(config.get('cody.autocomplete.advanced.provider')).toBe('anthropic') expect(config.get('cody.autocomplete.advanced.model')).toBe('claude-2') expect(config.get('cody.advanced.agent.running')).toBe(true) diff --git a/jetbrains/src/test/kotlin/com/sourcegraph/config/ConfigUtilTest.kt b/jetbrains/src/test/kotlin/com/sourcegraph/config/ConfigUtilTest.kt index 1922ce8919a9..63a23045e87e 100644 --- a/jetbrains/src/test/kotlin/com/sourcegraph/config/ConfigUtilTest.kt +++ b/jetbrains/src/test/kotlin/com/sourcegraph/config/ConfigUtilTest.kt @@ -16,7 +16,7 @@ class ConfigUtils { """ { "cody.debug": true, - "cody.autocomplete.enabled": true + "cody.suggestions.mode": "autocomplete" } """ val result = ConfigUtil.getCustomConfiguration(mockProject, input) @@ -39,7 +39,7 @@ class ConfigUtils { """ { "cody.debug": true, - "cody.autocomplete.enabled": true, + "cody.suggestions.mode": "autocomplete" } """ val result = ConfigUtil.getCustomConfiguration(mockProject, input) @@ -55,7 +55,7 @@ class ConfigUtils { { // This is a comment "cody.debug": true, - "cody.autocomplete.enabled": true, + "cody.suggestions.mode": "autocomplete" } """ val result = ConfigUtil.getCustomConfiguration(mockProject, input) diff --git a/lib/shared/src/configuration.ts b/lib/shared/src/configuration.ts index 7659244cec19..fc5d5dcbfe95 100644 --- a/lib/shared/src/configuration.ts +++ b/lib/shared/src/configuration.ts @@ -188,6 +188,21 @@ export enum CodyIDE { StandaloneWeb = 'StandaloneWeb', } +export enum CodyAutoSuggestionMode { + /** + * The suggestion mode where suggestions come from the OpenAI completions API. This is the default mode. + */ + Autocomplete = 'autocomplete', + /** + * The suggestion mode where suggestions come from the Cody AI agent chat API. + */ + SuggestionAgent = 'suggestion agent', + /** + * Disable Cody suggestions altogether. + */ + Off = 'off', +} + export type AutocompleteProviderID = keyof typeof AUTOCOMPLETE_PROVIDER_ID export const AUTOCOMPLETE_PROVIDER_ID = { diff --git a/vscode/package.json b/vscode/package.json index 82bad6f18f9a..e0e746576de1 100644 --- a/vscode/package.json +++ b/vscode/package.json @@ -409,13 +409,13 @@ "command": "cody.autocomplete.openTraceView", "category": "Cody", "title": "Open Autocomplete Trace View", - "enablement": "cody.activated && config.cody.autocomplete.enabled" + "enablement": "cody.activated && config.cody.suggestions.mode === 'autocomplete'" }, { "command": "cody.autocomplete.manual-trigger", "category": "Cody", "title": "Trigger Autocomplete at Cursor", - "enablement": "cody.activated && config.cody.autocomplete.enabled && !editorReadonly && !editorHasSelection && !inlineSuggestionsVisible" + "enablement": "cody.activated && config.cody.suggestions.mode === 'autocomplete' && !editorReadonly && !editorHasSelection && !inlineSuggestionsVisible" }, { "command": "cody.chat.signIn", @@ -578,7 +578,7 @@ { "command": "cody.command.autoedits-manual-trigger", "title": "Autoedits Manual Trigger", - "enablement": "cody.activated && config.cody.experimental.autoedits.enabled" + "enablement": "cody.activated && config.cody.suggestions.mode == 'suggestion agent'" } ], "keybindings": [ @@ -687,7 +687,7 @@ { "command": "cody.autocomplete.manual-trigger", "key": "alt+\\", - "when": "editorTextFocus && !editorHasSelection && config.cody.autocomplete.enabled && !inlineSuggestionsVisible" + "when": "editorTextFocus && !editorHasSelection && config.cody.suggestions.mode === 'autocomplete' && !inlineSuggestionsVisible" }, { "command": "cody.fixup.acceptNearest", @@ -739,7 +739,7 @@ { "command": "cody.supersuggest.testExample", "key": "ctrl+alt+enter", - "when": "cody.activated && config.cody.experimental.autoedits.enabled" + "when": "cody.activated && config.cody.suggestions.mode == 'suggestion agent'" } ], "submenus": [ @@ -1001,11 +1001,16 @@ } ] }, - "cody.autocomplete.enabled": { - "order": 5, - "type": "boolean", - "markdownDescription": "Enables code autocompletions.", - "default": true + "cody.suggestions.mode": { + "type": "string", + "enum": ["autocomplete", "suggestion agent", "off"], + "enumDescriptions": [ + "Enable standard autocomplete mode", + "Enable suggestion agent mode", + "Disable all suggestions" + ], + "default": "autocomplete", + "markdownDescription": "Controls the suggestion mode for Cody" }, "cody.autocomplete.triggerDelay": { "order": 5, diff --git a/vscode/src/completions/create-inline-completion-item-provider.ts b/vscode/src/completions/create-inline-completion-item-provider.ts index 9b029696fcf2..c4a1e7441d9f 100644 --- a/vscode/src/completions/create-inline-completion-item-provider.ts +++ b/vscode/src/completions/create-inline-completion-item-provider.ts @@ -41,7 +41,7 @@ export function createInlineCompletionItemProvider({ ) { throw new Error( 'The setting `config.autocomplete` evaluated to `false`. It must be true when running inside the agent. ' + - 'To fix this problem, make sure that the setting cody.autocomplete.enabled has the value true.' + 'To fix this problem, make sure that the setting cody.suggestions.mode has the value autocomplete.' ) } return NEVER diff --git a/vscode/src/configuration.test.ts b/vscode/src/configuration.test.ts index 635a00b57e7b..54b34cfff3f5 100644 --- a/vscode/src/configuration.test.ts +++ b/vscode/src/configuration.test.ts @@ -1,7 +1,12 @@ import { assert, describe, expect, it } from 'vitest' import type * as vscode from 'vscode' -import { type ClientConfiguration, OLLAMA_DEFAULT_URL, ps } from '@sourcegraph/cody-shared' +import { + type ClientConfiguration, + CodyAutoSuggestionMode, + OLLAMA_DEFAULT_URL, + ps, +} from '@sourcegraph/cody-shared' import type { ChatModelProviderConfig } from '@sourcegraph/cody-shared/src/models/sync' import { getConfiguration } from './configuration' @@ -28,8 +33,8 @@ describe('getConfiguration', () => { 'Cache-Control': 'no-cache', 'Proxy-Authenticate': 'Basic', } - case 'cody.autocomplete.enabled': - return false + case 'cody.suggestions.mode': + return CodyAutoSuggestionMode.Off case 'cody.autocomplete.languages': return { '*': true } case 'cody.commandCodeLenses': @@ -95,8 +100,6 @@ describe('getConfiguration', () => { return false case 'cody.experimental.supercompletions': return false - case 'cody.experimental.autoedits.enabled': - return undefined case 'cody.experimental.autoedits-renderer-testing': return false case 'cody.experimental.autoedits.config.override': @@ -166,7 +169,7 @@ describe('getConfiguration', () => { agenticContextExperimentalShell: false, agenticContextExperimentalOptions: { shell: { allow: ['git'] } }, experimentalSupercompletions: false, - experimentalAutoeditsEnabled: undefined, + experimentalAutoeditsEnabled: false, experimentalAutoeditsConfigOverride: undefined, experimentalAutoeditsRendererTesting: false, experimentalMinionAnthropicKey: undefined, diff --git a/vscode/src/configuration.ts b/vscode/src/configuration.ts index a619ff054cba..40963e43e171 100644 --- a/vscode/src/configuration.ts +++ b/vscode/src/configuration.ts @@ -2,6 +2,7 @@ import * as vscode from 'vscode' import { type ClientConfiguration, + CodyAutoSuggestionMode, type CodyIDE, OLLAMA_DEFAULT_URL, type PickResolvedConfiguration, @@ -46,6 +47,11 @@ export function getConfiguration( debugRegex = /.*/ } + const codyAutoSuggestionsMode = config.get( + CONFIG_KEY.suggestionsMode, + CodyAutoSuggestionMode.Autocomplete + ) + return { net: { mode: config.get(CONFIG_KEY.netMode, undefined), @@ -68,7 +74,7 @@ export function getConfiguration( debugVerbose: config.get(CONFIG_KEY.debugVerbose, false), debugFilter: debugRegex, telemetryLevel: config.get<'all' | 'off'>(CONFIG_KEY.telemetryLevel, 'all'), - autocomplete: config.get(CONFIG_KEY.autocompleteEnabled, true), + autocomplete: codyAutoSuggestionsMode === CodyAutoSuggestionMode.Autocomplete, autocompleteLanguages: config.get(CONFIG_KEY.autocompleteLanguages, { '*': true, }), @@ -119,7 +125,7 @@ export function getConfiguration( experimentalTracing: getHiddenSetting('experimental.tracing', false), experimentalSupercompletions: getHiddenSetting('experimental.supercompletions', false), - experimentalAutoeditsEnabled: getHiddenSetting('experimental.autoedits.enabled', undefined), + experimentalAutoeditsEnabled: codyAutoSuggestionsMode === CodyAutoSuggestionMode.SuggestionAgent, experimentalAutoeditsConfigOverride: getHiddenSetting( 'experimental.autoedits.config.override', undefined diff --git a/vscode/src/testutils/mocks.ts b/vscode/src/testutils/mocks.ts index d22b053a60c4..7e4eeb028296 100644 --- a/vscode/src/testutils/mocks.ts +++ b/vscode/src/testutils/mocks.ts @@ -898,7 +898,7 @@ export const DEFAULT_VSCODE_SETTINGS = { }, commandCodeLenses: false, experimentalSupercompletions: false, - experimentalAutoeditsEnabled: undefined, + experimentalAutoeditsEnabled: false, experimentalAutoeditsRendererTesting: false, experimentalAutoeditsConfigOverride: undefined, experimentalMinionAnthropicKey: undefined, diff --git a/vscode/test/e2e/auto-edits.test.ts b/vscode/test/e2e/auto-edits.test.ts index 8b32befef516..b5764774ea17 100644 --- a/vscode/test/e2e/auto-edits.test.ts +++ b/vscode/test/e2e/auto-edits.test.ts @@ -1,5 +1,6 @@ import { expect } from '@playwright/test' import type { Frame, Page } from '@playwright/test' +import { CodyAutoSuggestionMode } from '@sourcegraph/cody-shared' import * as mockServer from '../fixtures/mock-server' import { sidebarExplorer, sidebarSignin } from './common' import { @@ -66,7 +67,7 @@ const test = baseTest .extend({ dotcomUrl: mockServer.SERVER_URL }) .extend({ extraWorkspaceSettings: { - 'cody.experimental.autoedits.enabled': true, + 'cody.suggestions.mode': CodyAutoSuggestionMode.SuggestionAgent, 'cody.experimental.autoedits.use-mock-responses': true, }, }) diff --git a/web/lib/agent/agent.client.ts b/web/lib/agent/agent.client.ts index c3bccb2ec1dd..64fe2604fe4d 100644 --- a/web/lib/agent/agent.client.ts +++ b/web/lib/agent/agent.client.ts @@ -1,4 +1,4 @@ -import { FILE_CONTEXT_MENTION_PROVIDER } from '@sourcegraph/cody-shared' +import { CodyAutoSuggestionMode, FILE_CONTEXT_MENTION_PROVIDER } from '@sourcegraph/cody-shared' import type { ClientInfo, ServerInfo } from 'cody-ai/src/jsonrpc/agent-protocol' import { BrowserMessageReader, @@ -86,7 +86,7 @@ export async function createAgentClient({ ...(customHeaders ?? {}), }, customConfiguration: { - 'cody.autocomplete.enabled': false, + 'cody.suggestions.mode': CodyAutoSuggestionMode.Off, 'cody.experimental.urlContext': true, // Will be replaced with vite in build time // @ts-ignore From 1116bc211c945f22f05d3a088c595604f3c413ba Mon Sep 17 00:00:00 2001 From: hitesh-1997 Date: Mon, 6 Jan 2025 19:56:25 +0530 Subject: [PATCH 2/4] update name to auto-edits --- lib/shared/src/configuration.ts | 5 ++++- vscode/package.json | 12 ++++++------ vscode/src/configuration.ts | 2 +- vscode/test/e2e/auto-edits.test.ts | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/shared/src/configuration.ts b/lib/shared/src/configuration.ts index fc5d5dcbfe95..187e83900291 100644 --- a/lib/shared/src/configuration.ts +++ b/lib/shared/src/configuration.ts @@ -188,6 +188,9 @@ export enum CodyIDE { StandaloneWeb = 'StandaloneWeb', } +/** + * These values must match the enum values in cody.suggestions.mode in vscode/package.json + */ export enum CodyAutoSuggestionMode { /** * The suggestion mode where suggestions come from the OpenAI completions API. This is the default mode. @@ -196,7 +199,7 @@ export enum CodyAutoSuggestionMode { /** * The suggestion mode where suggestions come from the Cody AI agent chat API. */ - SuggestionAgent = 'suggestion agent', + Autoedits = 'auto-edits (Experimental)', /** * Disable Cody suggestions altogether. */ diff --git a/vscode/package.json b/vscode/package.json index e0e746576de1..e6b536439001 100644 --- a/vscode/package.json +++ b/vscode/package.json @@ -578,7 +578,7 @@ { "command": "cody.command.autoedits-manual-trigger", "title": "Autoedits Manual Trigger", - "enablement": "cody.activated && config.cody.suggestions.mode == 'suggestion agent'" + "enablement": "cody.activated && config.cody.suggestions.mode == 'auto-edits (Experimental)'" } ], "keybindings": [ @@ -739,7 +739,7 @@ { "command": "cody.supersuggest.testExample", "key": "ctrl+alt+enter", - "when": "cody.activated && config.cody.suggestions.mode == 'suggestion agent'" + "when": "cody.activated && config.cody.suggestions.mode == 'auto-edits (Experimental)'" } ], "submenus": [ @@ -1003,11 +1003,11 @@ }, "cody.suggestions.mode": { "type": "string", - "enum": ["autocomplete", "suggestion agent", "off"], + "enum": ["autocomplete", "auto-edits (Experimental)", "off"], "enumDescriptions": [ - "Enable standard autocomplete mode", - "Enable suggestion agent mode", - "Disable all suggestions" + "Enables standard autocomplete mode for suggestions.", + "Offers advanced context-aware suggestions by integrating autocompletion with inline editing, surpassing traditional autocomplete. Experimental feature for Pro and Enterprise users.", + "Disables all suggestions." ], "default": "autocomplete", "markdownDescription": "Controls the suggestion mode for Cody" diff --git a/vscode/src/configuration.ts b/vscode/src/configuration.ts index 40963e43e171..e5b147cdab8e 100644 --- a/vscode/src/configuration.ts +++ b/vscode/src/configuration.ts @@ -125,7 +125,7 @@ export function getConfiguration( experimentalTracing: getHiddenSetting('experimental.tracing', false), experimentalSupercompletions: getHiddenSetting('experimental.supercompletions', false), - experimentalAutoeditsEnabled: codyAutoSuggestionsMode === CodyAutoSuggestionMode.SuggestionAgent, + experimentalAutoeditsEnabled: codyAutoSuggestionsMode === CodyAutoSuggestionMode.Autoedits, experimentalAutoeditsConfigOverride: getHiddenSetting( 'experimental.autoedits.config.override', undefined diff --git a/vscode/test/e2e/auto-edits.test.ts b/vscode/test/e2e/auto-edits.test.ts index b5764774ea17..09010a794dce 100644 --- a/vscode/test/e2e/auto-edits.test.ts +++ b/vscode/test/e2e/auto-edits.test.ts @@ -67,7 +67,7 @@ const test = baseTest .extend({ dotcomUrl: mockServer.SERVER_URL }) .extend({ extraWorkspaceSettings: { - 'cody.suggestions.mode': CodyAutoSuggestionMode.SuggestionAgent, + 'cody.suggestions.mode': CodyAutoSuggestionMode.Autoedits, 'cody.experimental.autoedits.use-mock-responses': true, }, }) From a393484ad38b40cc4c5d2941c81acc605bcd0ef4 Mon Sep 17 00:00:00 2001 From: hitesh-1997 Date: Mon, 6 Jan 2025 20:01:40 +0530 Subject: [PATCH 3/4] update name to auto-edits --- vscode/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vscode/package.json b/vscode/package.json index e6b536439001..d0fab5ce2530 100644 --- a/vscode/package.json +++ b/vscode/package.json @@ -1006,7 +1006,7 @@ "enum": ["autocomplete", "auto-edits (Experimental)", "off"], "enumDescriptions": [ "Enables standard autocomplete mode for suggestions.", - "Offers advanced context-aware suggestions by integrating autocompletion with inline editing, surpassing traditional autocomplete. Experimental feature for Pro and Enterprise users.", + "Offers advanced context-aware suggestions by integrating autocompletion with inline editing. Experimental feature for Pro and Enterprise users.", "Disables all suggestions." ], "default": "autocomplete", From f72b35d3d132c3cfe101df2a2157730411a1989b Mon Sep 17 00:00:00 2001 From: hitesh-1997 Date: Mon, 6 Jan 2025 20:59:30 +0530 Subject: [PATCH 4/4] update description --- vscode/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vscode/package.json b/vscode/package.json index d0fab5ce2530..51eb5bdcc7e7 100644 --- a/vscode/package.json +++ b/vscode/package.json @@ -1005,8 +1005,8 @@ "type": "string", "enum": ["autocomplete", "auto-edits (Experimental)", "off"], "enumDescriptions": [ - "Enables standard autocomplete mode for suggestions.", - "Offers advanced context-aware suggestions by integrating autocompletion with inline editing. Experimental feature for Pro and Enterprise users.", + "Suggests standard code completions as you type.", + "Suggests advanced context-aware code edits as you navigate the codebase. Experimental feature for Pro and Enterprise users.", "Disables all suggestions." ], "default": "autocomplete",