Skip to content

Add chat markdown plain text fast path#316808

Draft
roblourens wants to merge 3 commits into
mainfrom
agents/would-it-be-practical-to-have-a-route-5fa025ed
Draft

Add chat markdown plain text fast path#316808
roblourens wants to merge 3 commits into
mainfrom
agents/would-it-be-practical-to-have-a-route-5fa025ed

Conversation

@roblourens
Copy link
Copy Markdown
Member

Summary:

  • Add a chat markdown renderer fast path for plain text content with no markdown-significant syntax
  • Preserve the expected rendered-markdown/p DOM shape while avoiding marked and sanitizer work
  • Add focused tests for fast-path shape and target reuse

Validation:

  • npm run compile-check-ts-native -- --pretty false
  • ./scripts/test.sh --run src/vs/workbench/contrib/chat/test/browser/widget/chatMarkdownRenderer.test.ts
  • node --experimental-strip-types build/hygiene.ts src/vs/workbench/contrib/chat/browser/widget/chatContentMarkdownRenderer.ts src/vs/workbench/contrib/chat/test/browser/widget/chatMarkdownRenderer.test.ts

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 16, 2026 22:39
Copy link
Copy Markdown
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

Adds a fast path to ChatContentMarkdownRenderer.render that bypasses marked and the sanitizer when the input has no markdown-significant syntax, producing the same <div class="rendered-markdown"><p>…</p></div> shape directly.

Changes:

  • New renderPlainTextMarkdown helper that returns a rendered-markdown element when the value matches none of three exclusion regexes (inline syntax chars, GFM autolinks, block-level syntax).
  • render() short-circuits to the fast path when applicable; otherwise falls back to the existing pipeline.
  • Two new unit tests cover the fast path's DOM shape and target-element reuse.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/browser/widget/chatContentMarkdownRenderer.ts Adds plain-text fast path with regex guards and a target-truncation step.
src/vs/workbench/contrib/chat/test/browser/widget/chatMarkdownRenderer.test.ts Adds tests verifying fast-path DOM shape and target reuse.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 1

Comment thread src/vs/workbench/contrib/chat/browser/widget/chatContentMarkdownRenderer.ts Outdated
roblourens and others added 2 commits May 16, 2026 15:52
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…actical-to-have-a-route-5fa025ed

# Conflicts:
#	src/vs/workbench/contrib/chat/browser/widget/chatContentMarkdownRenderer.ts
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.

2 participants