Fix raw markdown shown in image carousel caption#320754
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates chat image caption handling so tool invocation captions can carry Markdown metadata through extraction, while the carousel UI renders captions as plain text (matching chat rendering behavior).
Changes:
- Widen extracted image
captiontype to supportIMarkdownStringand propagate Markdown captions from tool invocations. - Convert captions to plain text in the image carousel (
renderAsPlaintext+stripIcons) to remove Markdown/link syntax. - Add/adjust tests for Markdown caption handling and text stripping.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/test/common/chatImageExtraction.test.ts | Updates assertions to account for extracted captions being IMarkdownString. |
| src/vs/workbench/contrib/chat/test/browser/chatImageCarouselService.test.ts | Adds a test ensuring Markdown is stripped from tool invocation captions in carousel output. |
| src/vs/workbench/contrib/chat/common/chatImageExtraction.ts | Propagates Markdown captions and widens the extracted image caption type. |
| src/vs/workbench/contrib/chat/browser/chatImageCarouselService.ts | Normalizes captions to plain text for display in carousel sections. |
|
@microsoft-github-policy-service agree |
|
В коді виникає проблема треба убрати |
hey @stasyu2009-ux, can you point me to the problem. |
|
Проблема в самому коді знаходиться |
|
Запусти код і побачиш проблему |
The code runs successfully on my end, and the fix is working as expected. Could you share the error you're encountering on your side ? @stasyu2009-ux I dont see any new error / warning diffrent from main and my dev branch as well. markdown.mov |
Fixes #307446
Problem
The image carousel's bottom caption shows raw markdown instead of readable text, e.g.:
Root cause:
invocationMessage/pastTenseMessagetypedstring | IMarkdownString. Copilot's view-image tool produces markdown likeViewed image [](file:///…/homepage.png)(the empty-text link renders as a file widget in chat, but is raw syntax anywhere else).chatImageExtraction.tsflattened the message to its raw markdown source via.valueand stored that as the image caption.captionText.textContent = …, per itscaption?: stringcontract), so the markdown syntax was displayed verbatim.Fix
Preserve the message as
string | IMarkdownStringinchatImageExtraction.ts(common layer), and convert it to display text at the presentation layer inchatImageCarouselService.tswith a smalltoCaptionText()helper:This is the same conversion the chat UI already applies when rendering these tool messages as labels (see
chatToolProgressPart.ts), so the carousel caption now matches what the user sees in chat:Viewed image homepage.png(useLinkFormatterresolves empty-text links to the file basename).Notes:
renderAsPlaintextis invs/base/browserandchatImageExtraction.tsis common-layer code.imageCarouselEditor.ts) is intentionally untouched — its plain-text caption contract is correct; the chat layer was handing it markdown.Tests
chatImageCarouselService.test.ts(strips markdown from tool invocation message captions) using the exact message shape from the issue, plus a passthrough assertion for plain-string messages.chatImageExtraction.test.tsassertions for the caption type change (captions fromIMarkdownStringmessages now assert on.value).Before / After
Before:

After:
