Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 1c10cca

Browse files
authored
cody: move inline chat out of experimental (#54315)
1 parent 27cafcf commit 1c10cca

18 files changed

+101
-93
lines changed

client/cody-shared/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/cody-shared/src/chat/recipes/inline-chat.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ import { truncateText } from '../../prompt/truncation'
66
import { Interaction } from '../transcript/interaction'
77

88
import { ChatQuestion } from './chat-question'
9-
import { FileTouch } from './file-touch'
109
import { Fixup } from './fixup'
1110
import { commandRegex } from './helpers'
11+
import { InlineTouch } from './inline-touch'
1212
import { Recipe, RecipeContext, RecipeID } from './recipe'
1313

14-
export class InlineAssist implements Recipe {
14+
export class InlineChat implements Recipe {
1515
public id: RecipeID = 'inline-chat'
1616

1717
constructor(private debug: (filterLabel: string, text: string, ...args: unknown[]) => void) {}
1818

1919
public async getInteraction(humanChatInput: string, context: RecipeContext): Promise<Interaction | null> {
2020
// Check if this is a touch request
2121
if (commandRegex.touch.test(humanChatInput)) {
22-
return new FileTouch(this.debug).getInteraction(humanChatInput.replace(commandRegex.touch, ''), context)
22+
return new InlineTouch(this.debug).getInteraction(humanChatInput.replace(commandRegex.touch, ''), context)
2323
}
2424

2525
// Check if this is a fixup request
@@ -39,14 +39,13 @@ export class InlineAssist implements Recipe {
3939

4040
// Reconstruct Cody's prompt using user's context
4141
// Replace placeholders in reverse order to avoid collisions if a placeholder occurs in the input
42-
const promptText = InlineAssist.prompt
42+
const promptText = InlineChat.prompt
4343
.replace('{humanInput}', truncatedText)
4444
.replace('{selectedText}', truncatedSelectedText)
4545
.replace('{fileName}', selection.fileName)
4646

4747
// Text display in UI fpr human that includes the selected code
48-
const displayText =
49-
humanChatInput + InlineAssist.displayPrompt.replace('{selectedText}', selection.selectedText)
48+
const displayText = humanChatInput + InlineChat.displayPrompt.replace('{selectedText}', selection.selectedText)
5049

5150
return Promise.resolve(
5251
new Interaction(

client/cody-shared/src/chat/recipes/file-touch.ts renamed to client/cody-shared/src/chat/recipes/inline-touch.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import { Recipe, RecipeContext, RecipeID } from './recipe'
2020
/** ======================================================
2121
* Recipe for Generating a New File
2222
====================================================== **/
23-
export class FileTouch implements Recipe {
24-
public id: RecipeID = 'file-touch'
23+
export class InlineTouch implements Recipe {
24+
public id: RecipeID = 'inline-touch'
2525
private workspacePath = vscode.workspace.workspaceFolders?.[0].uri
2626

2727
constructor(private debug: (filterLabel: string, text: string, ...args: unknown[]) => void) {}
@@ -43,7 +43,7 @@ export class FileTouch implements Recipe {
4343
// Create file path from selection.fileName and workspacePath
4444
const currentFilePath = `${this.workspacePath.fsPath}/${selection.fileName}`
4545
const currentDir = currentFilePath.replace(/\/[^/]+$/, '')
46-
this.debug('FileTouch:currentDir', 'currentDir', currentDir)
46+
this.debug('InlineTouch:currentDir', 'currentDir', currentDir)
4747

4848
// Create new file name based on the user's input
4949
const newFileName = commandRegex.noTest.test(humanInput)
@@ -60,15 +60,15 @@ export class FileTouch implements Recipe {
6060
// Create file if it doesn't exist
6161
workspaceEditor.createFile(fileUri, { ignoreIfExists: true })
6262
await vscode.workspace.applyEdit(workspaceEditor)
63-
this.debug('FileTouch:workspaceEditor', 'createFile', fileUri)
63+
this.debug('InlineTouch:workspaceEditor', 'createFile', fileUri)
6464

6565
const truncatedText = truncateText(humanInput, MAX_HUMAN_INPUT_TOKENS)
6666
const MAX_RECIPE_CONTENT_TOKENS = MAX_RECIPE_INPUT_TOKENS + MAX_RECIPE_SURROUNDING_TOKENS * 2
6767
const truncatedSelectedText = truncateText(selection.selectedText, MAX_RECIPE_CONTENT_TOKENS)
6868

6969
// Reconstruct Cody's prompt using user's context
7070
// Replace placeholders in reverse order to avoid collisions if a placeholder occurs in the input
71-
const prompt = FileTouch.newFilePrompt
71+
const prompt = InlineTouch.newFilePrompt
7272
const promptText = prompt
7373
.replace('{newFileName}', newFsPath)
7474
.replace('{humanInput}', truncatedText)
@@ -88,7 +88,7 @@ export class FileTouch implements Recipe {
8888
return
8989
}
9090
await this.addContentToNewFile(workspaceEditor, fileUri, content)
91-
this.debug('FileTouch:responseMultiplexer', 'BufferedBotResponseSubscriber', content)
91+
this.debug('InlineTouch:responseMultiplexer', 'BufferedBotResponseSubscriber', content)
9292
})
9393
)
9494

@@ -168,11 +168,11 @@ export class FileTouch implements Recipe {
168168
const contextMessages: ContextMessage[] = []
169169
// Add selected text and current file as context and create context messages from current directory
170170
const selectedContext = ChatQuestion.getEditorSelectionContext(selection)
171-
const currentDirContext = await FileTouch.getEditorDirContext(currentDir)
171+
const currentDirContext = await InlineTouch.getEditorDirContext(currentDir)
172172
contextMessages.push(...selectedContext, ...currentDirContext)
173173
// Create context messages from open tabs
174174
if (contextMessages.length < 10) {
175-
contextMessages.push(...FileTouch.getEditorOpenTabsContext(currentDir))
175+
contextMessages.push(...InlineTouch.getEditorOpenTabsContext(currentDir))
176176
}
177177
return contextMessages.slice(-10)
178178
}
@@ -238,7 +238,7 @@ export class FileTouch implements Recipe {
238238

239239
// Get display text for human
240240
private getHumanDisplayText(humanChatInput: string, fileName: string): string {
241-
return '**✨Touch✨** ' + humanChatInput + FileTouch.displayPrompt + fileName
241+
return '**✨Touch✨** ' + humanChatInput + InlineTouch.displayPrompt + fileName
242242
}
243243

244244
private async getInstructionFromInput(): Promise<string> {

client/cody-shared/src/chat/recipes/recipe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export type RecipeID =
1818
| 'context-search'
1919
| 'explain-code-detailed'
2020
| 'explain-code-high-level'
21-
| 'file-touch'
21+
| 'inline-touch'
2222
| 'find-code-smells'
2323
| 'fixup'
2424
| 'generate-docstring'

client/cody-shared/src/configuration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface Configuration {
1111
customHeaders: Record<string, string>
1212
autocomplete: boolean
1313
experimentalChatPredictions: boolean
14-
experimentalInline: boolean
14+
inlineChat: boolean
1515
experimentalGuardrails: boolean
1616
experimentalNonStop: boolean
1717
autocompleteAdvancedProvider: 'anthropic' | 'unstable-codegen' | 'unstable-huggingface'

client/cody-shared/src/telemetry/EventLogger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function getInlineFromConfig(config: vscode.WorkspaceConfiguration): boolean {
2424
if (!config) {
2525
return false
2626
}
27-
return config.get<boolean>('cody.experimental.inline', false)
27+
return config.get<boolean>('cody.inlineChat.enabled', false)
2828
}
2929

3030
function getNonStopFromConfig(config: vscode.WorkspaceConfiguration): boolean {

client/cody/CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@ Starting from `0.2.0`, Cody is using `major.EVEN_NUMBER.patch` for release versi
3939
- Refactored authentication process. [pull/53434](https://github.com/sourcegraph/sourcegraph/pull/53434)
4040
- New sign-in and sign-out flow. [pull/53434](https://github.com/sourcegraph/sourcegraph/pull/53434)
4141
- Analytical logs are now displayed in the Output view. [pull/53870](https://github.com/sourcegraph/sourcegraph/pull/53870)
42-
- Renamed Inline Assist to Inline Chat. [pull/53725](https://github.com/sourcegraph/sourcegraph/pull/53725)
42+
- Inline Chat: Renamed Inline Assist to Inline Chat. [pull/53725](https://github.com/sourcegraph/sourcegraph/pull/53725) [pull/54315](https://github.com/sourcegraph/sourcegraph/pull/54315)
4343
- Chat: Link to the "Getting Started" guide directly from the first chat message instead of the external documentation website. [pull/54175](https://github.com/sourcegraph/sourcegraph/pull/54175)
4444
- Codebase status icons. [pull/54262](https://github.com/sourcegraph/sourcegraph/pull/54262)
4545
- Changed the keyboard shortcut for the file touch recipe to `ctrl+alt+/` to avoid conflicts. [pull/54275](https://github.com/sourcegraph/sourcegraph/pull/54275)
46+
- Inline Chat: Do not change current focus when Inline Fixup is done. [pull/53980](https://github.com/sourcegraph/sourcegraph/pull/53980)
47+
- Inline Chat: Replace Close CodeLens with Accept. [pull/53980](https://github.com/sourcegraph/sourcegraph/pull/53980)
48+
- Inline Chat: Moved to Beta state. It is now enabled by default. [pull/54315](https://github.com/sourcegraph/sourcegraph/pull/54315)
4649

4750
## [0.2.5]
4851

client/cody/package.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
{
111111
"id": "inline-assist",
112112
"title": "Inline Chat (Experimental)",
113-
"description": "Chat with Cody without leaving your file. Click the + button next to any line number in a file to bring up Inline Chat.\n[Enable in Settings](command:cody.walkthrough.enableInlineAssist)",
113+
"description": "Chat with Cody without leaving your file. Click the + button next to any line number in a file to bring up Inline Chat.\n[Enable in Settings](command:cody.walkthrough.enableInlineChat)",
114114
"media": {
115115
"markdown": "walkthroughs/inline-assist.md"
116116
}
@@ -356,38 +356,38 @@
356356
"title": "Show Explain"
357357
},
358358
{
359-
"command": "cody.walkthrough.enableInlineAssist",
359+
"command": "cody.walkthrough.enableInlineChat",
360360
"category": "Cody Walkthrough",
361361
"title": "Show Inline Chat"
362362
},
363363
{
364364
"command": "cody.comment.add",
365365
"title": "Ask Cody",
366366
"category": "Cody Inline Chat",
367-
"when": "cody.activated && cody.inline-assist.enabled",
367+
"when": "cody.activated && config.cody.inlineChat.enabled",
368368
"enablement": "!commentIsEmpty"
369369
},
370370
{
371371
"command": "cody.comment.delete",
372372
"title": "Remove Comment",
373373
"category": "Cody Inline Chat",
374-
"when": "cody.activated && cody.inline-assist.enabled",
374+
"when": "cody.activated && config.cody.inlineChat.enabled",
375375
"enablement": "!commentThreadIsEmpty",
376376
"icon": "$(trash)"
377377
},
378378
{
379379
"command": "cody.comment.load",
380380
"title": "Loading",
381381
"category": "Cody Inline Chat",
382-
"when": "cody.activated && cody.inline-assist.enabled",
382+
"when": "cody.activated && config.cody.inlineChat.enabled",
383383
"enablement": "!commentThreadIsEmpty",
384384
"icon": "$(sync~spin)"
385385
},
386386
{
387387
"command": "cody.inline.new",
388388
"title": "Start a new Inline Chat session (Ctrl+Shift+C)",
389389
"category": "Cody Inline Assist",
390-
"when": "cody.activated && cody.inline-assist.enabled",
390+
"when": "cody.activated && config.cody.inlineChat.enabled",
391391
"enablement": "!commentIsEmpty"
392392
},
393393
{
@@ -397,7 +397,7 @@
397397
"enablement": "config.cody.experimental.guardrails && editorHasSelection"
398398
},
399399
{
400-
"command": "cody.recipe.file-touch",
400+
"command": "cody.recipe.inline-touch",
401401
"category": "Cody",
402402
"title": "Touch"
403403
},
@@ -472,7 +472,7 @@
472472
"when": "cody.activated && editorHasSelection && !editorReadonly"
473473
},
474474
{
475-
"command": "cody.recipe.file-touch",
475+
"command": "cody.recipe.inline-touch",
476476
"key": "ctrl+alt+/",
477477
"mac": "cmd+alt+/",
478478
"when": "cody.activated && editorTextFocus && !editorReadonly"
@@ -508,7 +508,7 @@
508508
"when": "cody.activated && editorHasSelection"
509509
},
510510
{
511-
"command": "cody.recipe.file-touch",
511+
"command": "cody.recipe.inline-touch",
512512
"when": "cody.activated && editorHasSelection"
513513
},
514514
{
@@ -605,7 +605,7 @@
605605
"when": "false"
606606
},
607607
{
608-
"command": "cody.walkthrough.enableInlineAssist",
608+
"command": "cody.walkthrough.enableInlineChat",
609609
"when": "false"
610610
}
611611
],
@@ -629,8 +629,8 @@
629629
"when": "cody.activated"
630630
},
631631
{
632-
"command": "cody.recipe.file-touch",
633-
"when": "cody.activated && cody.inline-assist.enabled"
632+
"command": "cody.recipe.inline-touch",
633+
"when": "cody.activated && config.cody.inlineChat.enabled"
634634
},
635635
{
636636
"command": "cody.recipe.generate-unit-test",
@@ -725,24 +725,24 @@
725725
{
726726
"command": "cody.comment.add",
727727
"group": "inline",
728-
"when": "cody.activated && commentController =~ /^cody-inline/ && cody.inline-assist.enabled"
728+
"when": "cody.activated && commentController =~ /^cody-inline/ && config.cody.inlineChat.enabled"
729729
},
730730
{
731731
"command": "cody.focus",
732732
"group": "inline",
733-
"when": "!cody.activated && commentController =~ /^cody-inline/ && cody.inline-assist.enabled"
733+
"when": "!cody.activated && commentController =~ /^cody-inline/ && config.cody.inlineChat.enabled"
734734
}
735735
],
736736
"comments/commentThread/title": [
737737
{
738738
"command": "cody.comment.delete",
739739
"group": "inline@1",
740-
"when": "cody.activated && commentController =~ /^cody-inline/ && cody.replied && !commentThreadIsEmpty && cody.inline-assist.enabled"
740+
"when": "cody.activated && commentController =~ /^cody-inline/ && cody.replied && !commentThreadIsEmpty && config.cody.inlineChat.enabled"
741741
},
742742
{
743743
"command": "cody.comment.load",
744744
"group": "inline@2",
745-
"when": "cody.activated && commentController =~ /^cody-inline/ && cody.reply.pending && cody.inline-assist.enabled"
745+
"when": "cody.activated && commentController =~ /^cody-inline/ && cody.reply.pending && config.cody.inlineChat.enabled"
746746
}
747747
],
748748
"view/item/context": [
@@ -819,18 +819,18 @@
819819
"markdownDescription": "Enables inline code suggestions in your editor.",
820820
"default": true
821821
},
822-
"cody.experimental.chatPredictions": {
822+
"cody.inlineChat.enabled": {
823823
"order": 6,
824+
"title": "Cody Inline Chat",
824825
"type": "boolean",
825-
"default": false,
826-
"markdownDescription": "Adds suggestions of possible relevant messages in the chat window."
826+
"markdownDescription": "Enables asking questions and requesting code changes directly from within the code editor. Use the + button next to any line of code to start an inline chat.",
827+
"default": true
827828
},
828-
"cody.experimental.inline": {
829+
"cody.experimental.chatPredictions": {
829830
"order": 7,
830-
"title": "Cody Inline Chat",
831831
"type": "boolean",
832-
"markdownDescription": "Enables asking questions and requesting code changes directly from within the code editor. Use the + button next to any line of code to start an inline chat.",
833-
"default": false
832+
"default": false,
833+
"markdownDescription": "Adds suggestions of possible relevant messages in the chat window."
834834
},
835835
"cody.experimental.guardrails": {
836836
"order": 8,

client/cody/src/chat/recipes.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { ChatQuestion } from '@sourcegraph/cody-shared/src/chat/recipes/chat-que
22
import { ContextSearch } from '@sourcegraph/cody-shared/src/chat/recipes/context-search'
33
import { ExplainCodeDetailed } from '@sourcegraph/cody-shared/src/chat/recipes/explain-code-detailed'
44
import { ExplainCodeHighLevel } from '@sourcegraph/cody-shared/src/chat/recipes/explain-code-high-level'
5-
import { FileTouch } from '@sourcegraph/cody-shared/src/chat/recipes/file-touch'
65
import { FindCodeSmells } from '@sourcegraph/cody-shared/src/chat/recipes/find-code-smells'
76
import { Fixup } from '@sourcegraph/cody-shared/src/chat/recipes/fixup'
87
import { GenerateDocstring } from '@sourcegraph/cody-shared/src/chat/recipes/generate-docstring'
@@ -11,7 +10,8 @@ import { ReleaseNotes } from '@sourcegraph/cody-shared/src/chat/recipes/generate
1110
import { GenerateTest } from '@sourcegraph/cody-shared/src/chat/recipes/generate-test'
1211
import { GitHistory } from '@sourcegraph/cody-shared/src/chat/recipes/git-log'
1312
import { ImproveVariableNames } from '@sourcegraph/cody-shared/src/chat/recipes/improve-variable-names'
14-
import { InlineAssist } from '@sourcegraph/cody-shared/src/chat/recipes/inline-chat'
13+
import { InlineChat } from '@sourcegraph/cody-shared/src/chat/recipes/inline-chat'
14+
import { InlineTouch } from '@sourcegraph/cody-shared/src/chat/recipes/inline-touch'
1515
import { NextQuestions } from '@sourcegraph/cody-shared/src/chat/recipes/next-questions'
1616
import { NonStop } from '@sourcegraph/cody-shared/src/chat/recipes/non-stop'
1717
import { OptimizeCode } from '@sourcegraph/cody-shared/src/chat/recipes/optimize-code'
@@ -40,14 +40,14 @@ function init(): void {
4040
new ContextSearch(),
4141
new ExplainCodeDetailed(),
4242
new ExplainCodeHighLevel(),
43-
new FileTouch(debug),
4443
new FindCodeSmells(),
4544
new Fixup(),
4645
new GenerateDocstring(),
4746
new GenerateTest(),
4847
new GitHistory(),
4948
new ImproveVariableNames(),
50-
new InlineAssist(debug),
49+
new InlineChat(debug),
50+
new InlineTouch(debug),
5151
new NextQuestions(),
5252
new NonStop(),
5353
new OptimizeCode(),

client/cody/src/configuration.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('getConfiguration', () => {
1515
autocomplete: true,
1616
experimentalChatPredictions: false,
1717
experimentalGuardrails: false,
18-
experimentalInline: false,
18+
inlineChat: true,
1919
experimentalNonStop: false,
2020
customHeaders: {},
2121
debugEnable: false,
@@ -50,7 +50,7 @@ describe('getConfiguration', () => {
5050
return true
5151
case 'cody.experimental.guardrails':
5252
return true
53-
case 'cody.experimental.inline':
53+
case 'cody.inlineChat.enabled':
5454
return true
5555
case 'cody.experimental.nonStop':
5656
return true
@@ -86,7 +86,7 @@ describe('getConfiguration', () => {
8686
autocomplete: false,
8787
experimentalChatPredictions: true,
8888
experimentalGuardrails: true,
89-
experimentalInline: true,
89+
inlineChat: true,
9090
experimentalNonStop: true,
9191
debugEnable: true,
9292
debugVerbose: true,

0 commit comments

Comments
 (0)