Skip to content

Clean up streaming codeblocks + edits #283379

@roblourens

Description

@roblourens

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
  • codeblockUri response 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

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.

Metadata

Metadata

Labels

chatdebtCode quality issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions