-
Notifications
You must be signed in to change notification settings - Fork 36.8k
Description
From https://github.com/microsoft/vscode-copilot/issues/12961:
The agent have to stream a codeblock annotated with a URI, then TextEdits are streamed for it async. Today, we expect:
- Markdown codeblock is opened
codeblockUriresponse part is streamed- Codeblock contents are streamed
- TextEdits are streamed and associated with that codeblock, these can come after other content was streamed
This is a bit complicated, eg leads to this weird code in the editfile tool
vscode/src/vs/workbench/contrib/chat/common/tools/editFileTool.ts
Lines 98 to 109 in c659faf
| model.acceptResponseProgress(request, { | |
| kind: 'markdownContent', | |
| content: new MarkdownString('\n````\n') | |
| }); | |
| model.acceptResponseProgress(request, { | |
| kind: 'codeblockUri', | |
| uri | |
| }); | |
| model.acceptResponseProgress(request, { | |
| kind: 'markdownContent', | |
| content: new MarkdownString(parameters.code + '\n````\n') | |
| }); |
Since either Edits or agent mode know that a file is being edited, we add complexity by going edit -> markdown -> special rendered pill, when the response stream could just include an entry indicating a codeblock with some URI and content. The disconnect between the markdown and the codeblockURI part adds confusion in the code that handles these things.
One idea:
Just have a codeblock response stream part. In the API it looks like
codeblockStart(uri);
codeblockContent(content: string);
codeblockEnd();
In the ChatModel, we merge these calls into a codeblock response part. Rendering is much simpler, we don't have to parse markdown or wait for the codeblockUri to come in. TextEdits also get associated with the codeblock somehow.