-
Notifications
You must be signed in to change notification settings - Fork 275
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
Chat: add support to send terminal text to Cody chat #5543
base: main
Are you sure you want to change the base?
Conversation
The `cody.mention.selection` command now handles `selection` argument that enables users to send selected text from terminal to Cody chat. - Update `cody.mention.selection` command to send terminal text to Cody chat - Update mention selection command to handle text selection - Update package.json to enable terminal text mention command Note: Keybinding doesn't seem to work when terminal is focused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's cool!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's design the types to be easier to use.
Let's add a test.
Does this change the way sending context from files to chat works? Will that have args.selection
set or is that a totally different code path? (If so... why?)
I think the context could be richer that this is coming from a terminal. Like, why not treat that as a first class thing, maybe we want to pull in surrounding context later, etc.
It is worth keeping in mind that when
doesn't filter explicit invocations of commands so you should be defensive... This may not always be called with a terminal selection.
Please also do JetBrains, CC @taylorsperry
@@ -243,18 +243,27 @@ export class ChatsController implements vscode.Disposable { | |||
await vscode.commands.executeCommand('cody.chat.focus') | |||
} | |||
|
|||
private async sendEditorContextToChat(uri?: URI): Promise<void> { | |||
telemetryRecorder.recordEvent('cody.addChatContext', 'clicked', { | |||
private async sendEditorContextToChat(payload?: URI | string): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This API makes me nervous because we have been so burned by slinging URIs and file paths as URIs or strings etc.
Let's make this an object with properties like payload: { editorUri: URI } | { selection: string }
Why do we just want the string without a filename for context? Like @foo.ts:1-10 or whatever (we'd need to support character offsets...)
await provider.handleGetUserEditorContext(uri) | ||
|
||
if (isText) { | ||
await provider.handleTextToUserInput(payload as string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the object as suggested above you can avoid the as
here.
@beyang @chenkc805 could you also take a quick look if this is the right implementation for https://linear.app/sourcegraph/issue/CODY-3703/add-terminal-output-as-chat-context? @abeatrix would it be possible to add a top level shortcut instead of going into the Cody dropdown when you right click? I feel like that would make it easier to use |
@kalanchan just found a hacky way to do it. will continue |
CLOSE https://linear.app/sourcegraph/issue/CODY-3703/add-terminal-output-as-chat-context
The
cody.mention.selection
command now handlesselection
argument that enables users to send selected text from terminal to Cody chat.cody.mention.selection
command to send terminal text to Cody chatNote: Keybinding doesn't seem to work when terminal is focused?
Test plan
Select some text in your terminal and right click >
Add Selection to Cody Chat
:Screen.Recording.2024-09-10.at.3.53.37.PM.mov
Changelog
Chat: add support to send selected text from terminal to Cody chat