Skip to content

Simplify codeblock rendering in chat markdown - #305845

Merged
roblourens merged 6 commits into
mainfrom
roblou/chat-codeblock-simplify
Mar 30, 2026
Merged

Simplify codeblock rendering in chat markdown#305845
roblourens merged 6 commits into
mainfrom
roblou/chat-codeblock-simplify

Conversation

@roblourens

@roblourens roblourens commented Mar 27, 2026

Copy link
Copy Markdown
Member

Fixes #305974

Copilot AI review requested due to automatic review settings March 27, 2026 22:15
@roblourens roblourens self-assigned this Mar 27, 2026
@vs-code-engineering vs-code-engineering Bot added this to the Backlog milestone Mar 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 markdown/codeblock rendering by removing the shared CodeBlockModelCollection layer and shifting code block text-model creation/updates into CodeBlockPart, with corresponding updates across chat/inline-chat/tool-invocation rendering paths. It also adds a focused unit test suite for ChatMarkdownContentPart codeblock behavior (multi-block indexing, php prefixing, etc.).

Changes:

  • Remove CodeBlockModelCollection and stop threading it through chat rendering contexts/view models.
  • Update ChatMarkdownContentPart and tool-related parts to pass raw code text into CodeBlockPart, which now owns its text model lifecycle.
  • Add ChatMarkdownContentPart browser tests to validate multi-codeblock rendering and text handling.

Reviewed changes

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

Show a summary per file
File Description
src/vs/workbench/test/browser/componentFixtures/chatTerminalCollapsible.fixture.ts Updates fixture render context to match removed codeBlockModelCollection.
src/vs/workbench/test/browser/componentFixtures/chatQuestionCarousel.fixture.ts Updates fixture render context to match removed codeBlockModelCollection.
src/vs/workbench/test/browser/componentFixtures/chatProgressContentPart.fixture.ts Updates fixture render context to match removed codeBlockModelCollection.
src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.ts Switches inline-chat codeblock lookup to rely on rendered codeblock infos + IModelService.
src/vs/workbench/contrib/chat/test/browser/widget/chatContentParts/chatToolProgressPart.test.ts Removes CodeBlockModelCollection usage from tool progress part tests.
src/vs/workbench/contrib/chat/test/browser/widget/chatContentParts/chatThinkingContentPart.test.ts Removes CodeBlockModelCollection usage from thinking part tests.
src/vs/workbench/contrib/chat/test/browser/widget/chatContentParts/chatSubagentContentPart.test.ts Removes CodeBlockModelCollection usage from subagent part tests.
src/vs/workbench/contrib/chat/test/browser/widget/chatContentParts/chatMarkdownContentPart.test.ts New unit tests for markdown content part codeblock extraction/rendering behavior.
src/vs/workbench/contrib/chat/common/widget/codeBlockModelCollection.ts Deletes the shared codeblock model collection implementation.
src/vs/workbench/contrib/chat/common/model/chatViewModel.ts Removes codeBlockModelCollection from ChatViewModel construction/state.
src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts Stops creating/clearing/passing CodeBlockModelCollection; updates ChatViewModel instantiation accordingly.
src/vs/workbench/contrib/chat/browser/widget/chatListWidget.ts Removes optional codeBlockModelCollection option/plumbing.
src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts Removes codeblock content provider/collection wiring; uses synchronous uri on codeblock infos.
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatToolInvocationPart.ts Updates tool invocation part construction after removing CodeBlockModelCollection dependency.
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatToolConfirmationSubPart.ts Reworks tool-confirmation code editor creation to use CodeBlockPart-owned models instead of inlineTextModels/model collection.
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatTerminalToolProgressPart.ts Updates terminal tool progress markdown rendering call sites for new ChatMarkdownContentPart signature.
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatTerminalToolConfirmationSubPart.ts Removes custom URI/model creation; relies on CodeBlockPart to create/manage the model from text.
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/codeBlockPart.ts Makes CodeBlockPart create/update its own text model (stable URI) from provided text.
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatToolOutputContentSubPart.ts Updates tool output code blocks to pass text directly and use CodeBlockPart-generated URI.
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatToolInputOutputContentPart.ts Updates collapsible IO codeblocks to pass text directly (no explicit model creation).
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatSubagentContentPart.ts Removes CodeBlockModelCollection parameter plumbing.
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatMarkdownContentPart.ts Moves codeblock text processing (vulns/php prefix/codemapper URI extraction) into markdown rendering and passes text to codeblocks.
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatContentParts.ts Removes codeBlockModelCollection from render context type and updates comments.
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatConfirmationWidget.ts Updates markdown part creation call signature after removing codeBlockModelCollection.
src/vs/workbench/contrib/chat/browser/chat.ts Removes uriPromise from IChatCodeBlockInfo contract.
src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionHoverWidget.ts Updates hover widget view model creation to no longer allocate a per-widget CodeBlockModelCollection.

Comment thread src/vs/workbench/contrib/chat/browser/widget/chatContentParts/codeBlockPart.ts Outdated
Comment thread src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.ts
roblourens and others added 2 commits March 27, 2026 15:30
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
@roblourens roblourens modified the milestones: Backlog, 1.115.0 Mar 29, 2026
roblourens and others added 2 commits March 28, 2026 20:44
Co-authored-by: Copilot <copilot@github.com>
@roblourens
roblourens marked this pull request as ready for review March 30, 2026 17:30
@roblourens
roblourens enabled auto-merge (squash) March 30, 2026 17:30
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Johannes Rieken (@jrieken)

Matched files:

  • src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.ts

@roblourens
roblourens merged commit 11f363e into main Mar 30, 2026
27 of 29 checks passed
@roblourens
roblourens deleted the roblou/chat-codeblock-simplify branch March 30, 2026 18:23
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators May 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

createModelReference leak in chatMarkdownContentPart.ts — ref not disposed when store already disposed

3 participants