Skip to content

Support markdown fallback in agent debug panel#301634

Merged
pwang347 merged 1 commit intomainfrom
pawang/markdown
Mar 14, 2026
Merged

Support markdown fallback in agent debug panel#301634
pwang347 merged 1 commit intomainfrom
pawang/markdown

Conversation

@pwang347
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings March 14, 2026 00:31
@pwang347 pwang347 marked this pull request as ready for review March 14, 2026 00:32
@pwang347 pwang347 enabled auto-merge (squash) March 14, 2026 00:32
@vs-code-engineering vs-code-engineering bot added this to the 1.112.0 milestone Mar 14, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors chat debug event rendering to centralize formatting + syntax-highlighting logic for tool call, message, and model turn sections, and expands tokenization to cover non-JSON content using markdown tokenization.

Changes:

  • Introduces a shared tokenizeContent helper that pretty-prints JSON and otherwise tokenizes as markdown.
  • Updates tool call, user/agent message, and model turn renderers to reuse the helper and remove duplicated JSON/tokenization logic.
  • Adjusts imports accordingly (removes direct tokenizeToString usage from call sites).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugToolCallContentRenderer.ts Adds tokenizeContent helper and uses it for tool call input/output sections.
src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugModelTurnContentRenderer.ts Switches section rendering to use tokenizeContent instead of inline JSON parsing/tokenization.
src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugMessageContentRenderer.ts Switches prompt/response/resolve section rendering to use tokenizeContent instead of inline JSON parsing/tokenization.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 135 to 142
if (content.input) {
const result = tryParseJSON(content.input);
const plainText = result.isJSON ? JSON.stringify(result.parsed, null, 2) : content.input;
const tokenizedHtml = result.isJSON
? await tokenizeToString(languageService, plainText, 'json')
: undefined;
const { plainText, tokenizedHtml } = await tokenizeContent(content.input, languageService);
renderSection(sectionsContainer, localize('chatDebug.toolCall.arguments', "Arguments"), plainText, tokenizedHtml, disposables, false, clipboardService);
}

if (content.output) {
const result = tryParseJSON(content.output);
const plainText = result.isJSON ? JSON.stringify(result.parsed, null, 2) : content.output;
const tokenizedHtml = result.isJSON
? await tokenizeToString(languageService, plainText, 'json')
: undefined;
const { plainText, tokenizedHtml } = await tokenizeContent(content.output, languageService);
renderSection(sectionsContainer, localize('chatDebug.toolCall.output', "Output"), plainText, tokenizedHtml, disposables, false, clipboardService);
Comment on lines 82 to 86

for (const section of content.sections) {
const result = tryParseJSON(section.content);
const plainText = result.isJSON ? JSON.stringify(result.parsed, null, 2) : section.content;
const tokenizedHtml = result.isJSON
? await tokenizeToString(languageService, plainText, 'json')
: undefined;
const { plainText, tokenizedHtml } = await tokenizeContent(section.content, languageService);
renderSection(sectionsContainer, section.name, plainText, tokenizedHtml, disposables, false, clipboardService);
}
Comment on lines 30 to 36
DOM.append(sectionsContainer, $('div.chat-debug-message-sections-label', undefined,
localize('chatDebug.promptSections', "Prompt Sections ({0})", event.sections.length)));

for (const section of event.sections) {
const result = tryParseJSON(section.content);
const plainText = result.isJSON ? JSON.stringify(result.parsed, null, 2) : section.content;
const tokenizedHtml = result.isJSON
? await tokenizeToString(languageService, plainText, 'json')
: undefined;
const { plainText, tokenizedHtml } = await tokenizeContent(section.content, languageService);
renderSection(sectionsContainer, section.name, plainText, tokenizedHtml, disposables, false, clipboardService);
}
@pwang347 pwang347 merged commit 5fdf97c into main Mar 14, 2026
24 checks passed
@pwang347 pwang347 deleted the pawang/markdown branch March 14, 2026 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants