-
Notifications
You must be signed in to change notification settings - Fork 738
supportFileAttachment in new coding agent editor #7744
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,7 +5,7 @@ | |||||
|
|
||||||
| import * as pathLib from 'path'; | ||||||
| import * as marked from 'marked'; | ||||||
| import vscode from 'vscode'; | ||||||
| import vscode, { ChatPromptReference } from 'vscode'; | ||||||
| import { parseSessionLogs, parseToolCallDetails, StrReplaceEditorToolData } from '../../common/sessionParsing'; | ||||||
| import { COPILOT_ACCOUNTS } from '../common/comment'; | ||||||
| import { CopilotRemoteAgentConfig } from '../common/config'; | ||||||
|
|
@@ -573,7 +573,7 @@ export class CopilotRemoteAgentManager extends Disposable { | |||||
| return `${header}\n\n${collapsedContext}`; | ||||||
| }; | ||||||
|
|
||||||
| const problemStatement: string = `${prompt} ${problemContext ? `: ${problemContext}` : ''}`; | ||||||
| const problemStatement: string = `${prompt}\n${problemContext ?? ''}`; | ||||||
| const payload: RemoteAgentJobPayload = { | ||||||
| problem_statement: problemStatement, | ||||||
| event_type: 'visual_studio_code_remote_agent_tool_invoked', | ||||||
|
|
@@ -751,12 +751,42 @@ export class CopilotRemoteAgentManager extends Disposable { | |||||
| return fullText; | ||||||
| } | ||||||
|
|
||||||
| public async provideNewChatSessionItem(options: { prompt?: string; history: ReadonlyArray<vscode.ChatRequestTurn | vscode.ChatResponseTurn>; metadata?: any; }, token: vscode.CancellationToken): Promise<ChatSessionWithPR | ChatSessionFromSummarizedChat> { | ||||||
| const { prompt, history } = options; | ||||||
| if (!prompt) { | ||||||
| extractFileReferences(references: readonly ChatPromptReference[] | undefined): string | undefined { | ||||||
| if (!references || references.length === 0) { | ||||||
| return; | ||||||
| } | ||||||
| // 'file:///Users/jospicer/dev/joshbot/.github/workflows/build-vsix.yml' -> '.github/workflows/build-vsix.yml' | ||||||
| const parts: string[] = []; | ||||||
| for (const ref of references) { | ||||||
| if (ref.value instanceof vscode.Uri && ref.value.scheme === 'file') { // TODO: Add support for more kinds of references | ||||||
| const workspaceFolder = vscode.workspace.getWorkspaceFolder(ref.value); | ||||||
| if (workspaceFolder) { | ||||||
| const relativePath = pathLib.relative(workspaceFolder.uri.fsPath, ref.value.fsPath); | ||||||
| parts.push(` - ${relativePath}`); | ||||||
| } | ||||||
|
Comment on lines
+762
to
+766
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be relative to the workspace folder, not the git repo. Instead, you should use vscode-pull-request-github/src/github/utils.ts Lines 1462 to 1463 in 91c5123
|
||||||
| } | ||||||
| } | ||||||
|
|
||||||
| if (!parts.length) { | ||||||
| return; | ||||||
| } | ||||||
|
|
||||||
| parts.unshift('The user has attached the following files as relevant context:'); | ||||||
| return parts.join('\n'); | ||||||
| } | ||||||
|
|
||||||
| cleanPrompt(prompt: string): string { | ||||||
| // Remove #file:xxxx from the prompt | ||||||
| return prompt.replace(/#file:\S+/g, '').trim(); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We want to keep the file name (or relative file path) in the prompt, for example, user might write
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||||||
| } | ||||||
|
|
||||||
| public async provideNewChatSessionItem(options: { request: vscode.ChatRequest; prompt?: string; history: ReadonlyArray<vscode.ChatRequestTurn | vscode.ChatResponseTurn>; metadata?: any; }, token: vscode.CancellationToken): Promise<ChatSessionWithPR | ChatSessionFromSummarizedChat> { | ||||||
| const { request, history } = options; | ||||||
| if (!options.prompt) { | ||||||
| throw new Error(`Prompt is expected to provide a new chat session item`); | ||||||
| } | ||||||
|
|
||||||
| const prompt = this.cleanPrompt(options.prompt); | ||||||
| const { source, summary } = options.metadata || {}; | ||||||
|
|
||||||
| // Ephemeral session for new session creation flow | ||||||
|
|
@@ -775,7 +805,10 @@ export class CopilotRemoteAgentManager extends Disposable { | |||||
|
|
||||||
| const result = await this.invokeRemoteAgent( | ||||||
| prompt, | ||||||
| (await this.extractHistory(history)), | ||||||
| [ | ||||||
| this.extractFileReferences(request.references), | ||||||
| await this.extractHistory(history) | ||||||
| ].join('\n\n').trim(), | ||||||
| false, | ||||||
| ); | ||||||
| if (result.state !== 'success') { | ||||||
|
|
||||||
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.
Should be private