Skip to content

fix(web-ui): resolve relative markdown images in chat - #1473

Merged
wgqqqqq merged 1 commit into
GCWing:mainfrom
Horizonll:main
Jul 10, 2026
Merged

fix(web-ui): resolve relative markdown images in chat#1473
wgqqqqq merged 1 commit into
GCWing:mainfrom
Horizonll:main

Conversation

@Horizonll

@Horizonll Horizonll commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Resolve relative Markdown image paths in assistant chat messages against the active session workspace, so model output such as ![ReLU 图像](relu.png) can render the generated image inline.

Fixes #1473

Type and Areas

Type: bug fix

Areas: web UI, flow chat, Markdown rendering

Motivation / Impact

Agents can generate images into the workspace and reference them from assistant Markdown output. Before this change, relative Markdown image paths in chat messages were not reliably anchored to the active session workspace, so inline image previews could fail.

This change passes the active session workspace path into the chat Markdown renderer and uses that path when resolving relative Markdown image links. The existing workspace file-reading path is reused for loading image content.

Verification

  • pnpm --dir src/web-ui run test:run src/component-library/components/Markdown/Markdown.test.tsx
    • Passed after the clean history rewrite: 1 test file, 5 tests.
  • pnpm run type-check:web
    • Not completed after the clean history rewrite because the command was interrupted locally.
    • The same equivalent code change passed this check before the branch history cleanup.
预览relu图片_07-08-18-29

Copilot AI review requested due to automatic review settings July 8, 2026 10:43

Copilot AI left a comment

Copy link
Copy Markdown

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 fixes Web UI chat rendering so relative Markdown image links emitted by the assistant (e.g. ![ReLU 图像](relu.png)) are resolved against the active session workspace, enabling inline previews for images generated into the workspace.

Changes:

  • Pass the active session workspace path from FlowTextBlock into the Markdown renderer as basePath.
  • Update the Markdown image render path to resolve images using basePath when present, otherwise fall back to the resolved currentWorkspacePath.
  • Add a unit test asserting that relative Markdown images are loaded via workspaceAPI.readFileContent using the provided basePath.

Reviewed changes

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

File Description
src/web-ui/src/flow_chat/components/FlowTextBlock.tsx Provides a workspace-derived basePath to the chat Markdown renderer so relative images resolve in-session.
src/web-ui/src/component-library/components/Markdown/Markdown.tsx Ensures <img> rendering uses basePath or currentWorkspacePath so relative image sources resolve reliably.
src/web-ui/src/component-library/components/Markdown/Markdown.test.tsx Adds coverage for loading relative Markdown images via the provided basePath and avoids unnecessary workspace lookups.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@GCWing
GCWing requested a review from bobleer July 9, 2026 02:10
@bobleer
bobleer requested review from wsp1911 and removed request for bobleer July 9, 2026 02:34
@wgqqqqq
wgqqqqq merged commit 891f03f into GCWing:main Jul 10, 2026
4 checks passed
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