Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suggestion mode UI #6523

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion agent/src/AgentWorkspaceConfiguration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ConfigUtils {
"""
{
"cody.debug": true,
"cody.autocomplete.enabled": true
"cody.suggestions.mode": "autocomplete"
}
"""
val result = ConfigUtil.getCustomConfiguration(mockProject, input)
Expand All @@ -39,7 +39,7 @@ class ConfigUtils {
"""
{
"cody.debug": true,
"cody.autocomplete.enabled": true,
"cody.suggestions.mode": "autocomplete"
}
"""
val result = ConfigUtil.getCustomConfiguration(mockProject, input)
Expand All @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions lib/shared/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,24 @@ 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.
*/
Autocomplete = 'autocomplete',
/**
* The suggestion mode where suggestions come from the Cody AI agent chat API.
*/
Autoedits = 'auto-edits (Experimental)',
/**
* Disable Cody suggestions altogether.
*/
Off = 'off',
}

export type AutocompleteProviderID = keyof typeof AUTOCOMPLETE_PROVIDER_ID

export const AUTOCOMPLETE_PROVIDER_ID = {
Expand Down
25 changes: 15 additions & 10 deletions vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 == 'auto-edits (Experimental)'"
}
],
"keybindings": [
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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 == 'auto-edits (Experimental)'"
}
],
"submenus": [
Expand Down Expand Up @@ -1001,11 +1001,16 @@
}
]
},
"cody.autocomplete.enabled": {
"order": 5,
"type": "boolean",
"markdownDescription": "Enables code autocompletions.",
"default": true
"cody.suggestions.mode": {
"type": "string",
"enum": ["autocomplete", "auto-edits (Experimental)", "off"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the recent thread where we decided to hide this from users who do not have access to the feature, do you think we should change this PR to use a quick pick menu or something else that can be dynamically updated based on feature flag values?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on slack here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @valerybugakov
I will add a pop-up to communicate to the user why they are not eligible as per slack discussion.

It would be much easier for me to do this in #6463 this PR instead of current one, because it would create conflict between the PRs when I rebase. Would that be okay ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, let's do that!

"enumDescriptions": [
"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",
"markdownDescription": "Controls the suggestion mode for Cody"
},
"cody.autocomplete.triggerDelay": {
"order": 5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions vscode/src/configuration.test.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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':
Expand Down Expand Up @@ -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':
Expand Down Expand Up @@ -166,7 +169,7 @@ describe('getConfiguration', () => {
agenticContextExperimentalShell: false,
agenticContextExperimentalOptions: { shell: { allow: ['git'] } },
experimentalSupercompletions: false,
experimentalAutoeditsEnabled: undefined,
experimentalAutoeditsEnabled: false,
experimentalAutoeditsConfigOverride: undefined,
experimentalAutoeditsRendererTesting: false,
experimentalMinionAnthropicKey: undefined,
Expand Down
10 changes: 8 additions & 2 deletions vscode/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as vscode from 'vscode'

import {
type ClientConfiguration,
CodyAutoSuggestionMode,
type CodyIDE,
OLLAMA_DEFAULT_URL,
type PickResolvedConfiguration,
Expand Down Expand Up @@ -46,6 +47,11 @@ export function getConfiguration(
debugRegex = /.*/
}

const codyAutoSuggestionsMode = config.get<string>(
CONFIG_KEY.suggestionsMode,
CodyAutoSuggestionMode.Autocomplete
)

return {
net: {
mode: config.get<string | null | undefined>(CONFIG_KEY.netMode, undefined),
Expand All @@ -68,7 +74,7 @@ export function getConfiguration(
debugVerbose: config.get<boolean>(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,
}),
Expand Down Expand Up @@ -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.Autoedits,
experimentalAutoeditsConfigOverride: getHiddenSetting(
'experimental.autoedits.config.override',
undefined
Expand Down
2 changes: 1 addition & 1 deletion vscode/src/testutils/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ export const DEFAULT_VSCODE_SETTINGS = {
},
commandCodeLenses: false,
experimentalSupercompletions: false,
experimentalAutoeditsEnabled: undefined,
experimentalAutoeditsEnabled: false,
experimentalAutoeditsRendererTesting: false,
experimentalAutoeditsConfigOverride: undefined,
experimentalMinionAnthropicKey: undefined,
Expand Down
3 changes: 2 additions & 1 deletion vscode/test/e2e/auto-edits.test.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -66,7 +67,7 @@ const test = baseTest
.extend<DotcomUrlOverride>({ dotcomUrl: mockServer.SERVER_URL })
.extend<ExtraWorkspaceSettings>({
extraWorkspaceSettings: {
'cody.experimental.autoedits.enabled': true,
'cody.suggestions.mode': CodyAutoSuggestionMode.Autoedits,
'cody.experimental.autoedits.use-mock-responses': true,
},
})
Expand Down
4 changes: 2 additions & 2 deletions web/lib/agent/agent.client.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
Expand Down
Loading