Repository navigation
fix(mobile): show workspace images in session Markdown tabs - #36970
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
e0a806ff-327a-49a9-9cc4-03f26d0b5346
Files selected for processing: 12-
mobile/src/components/MobileRichMarkdownEditor.tsxmobile/src/components/rich-markdown/document-host-seams.tsmobile/src/components/rich-markdown/document-scope.tsmobile/src/components/rich-markdown/editor-content.test.tsmobile/src/components/rich-markdown/editor-content.tsmobile/src/components/rich-markdown/html-inline-markdown.tsmobile/src/components/rich-markdown/markdown-inline-render.tsmobile/src/components/rich-markdown/rich-markdown-web-document-mount.tsmobile/src/files/mobile-markdown-image-source.test.tsmobile/src/files/mobile-markdown-image-source.tsmobile/src/session/MobileSessionActiveContent.tsxmobile/src/session/MobileSessionMarkdownReader.tsx
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
-
| editorElement(scope) | ||
| .querySelectorAll<HTMLImageElement>(`img[${WORKSPACE_IMAGE_PATH_ATTRIBUTE}]:not([src])`) |
There was a problem hiding this comment.
Load workspace paths inserted through the Image toolbar.
When a user enters images/diagram.png in the Image toolbar, insertImage creates an <img> with src. This selector skips that image, so the workspace loader does not run. The controller accepts the emitted Markdown without an immediate re-render; the image remains broken during editing. Classify relative src values and move them to data-workspace-path before loading. Add a test that inserts an image through the toolbar, rather than constructing an image that already has data-workspace-path. (raw.githubusercontent.com)
0c98371 to
2c7345c
Compare
ELI5
When you open a Markdown file as a tab on the phone, pictures saved next to it in the project now show up. Before, each one was a broken-image icon.
What Changed
Before: in the phone's session view, a Markdown tab with
showed a broken image. The same file opened from the file explorer showed the picture.After: the session tab shows the picture too.
How it works: the rich Markdown editor runs inside the mobile web page, and it wrote the Markdown path straight into
<img src>. The page then looked forimages/diagram.pngon its own origin and got a 404. Now an image whose path is a workspace file (as the sharedrouteMarkdownHrefrouter decides) is rendered with the path indata-workspace-pathand nosrc. The editor then asks the page for a source through a newloadImageSourceseam. The session tab answers withloadMarkdownPreviewImage, thefiles.readPreviewloader the file-explorer preview already uses, resolved against the tab'srelativePath. Saving readsdata-workspace-pathbeforesrc, so the file keepsimages/diagram.pngand never gets a data URI.Loads are cached per render. An image that comes back through undo or paste gets its source from the cache with no new request. Remote,
data:andblob:images still usesrcdirectly, as before.Why
The file-explorer preview already loads workspace images safely: paths stay inside the workspace, only image types are read, and it works with SSH and folder workspaces. Reusing that loader gives the session tab the same rules with no second copy. Showing the tab through the read-only preview instead would have taken away in-place editing, which is what this tab is for.
Linked Issue
Fixes #36332
Visual Proof
Mobile web bundle on the session route (390×844). A shell double answers
session.tabs.list,markdown.readTabandfiles.readPreviewfordocs/NOTES.md, which contains.On main, the page fetched
images/diagram.pngfrom its own origin (404) and sent nofiles.readPreview. With the fix, it sends onefiles.readPreviewfordocs/images/diagram.pngand draws the image. An inlinedata:image in the same file still renders directly.Testing
Reproduced on main and verified the fix with the mobile web render harness in headless Chromium (macOS). Results above.
New document-level tests: a workspace image loads through the host and saves back as its Markdown path, while a remote image keeps
src. An image brought back by an edit reuses the load. Both fail without the fix.New loader test: a document outside the workspace (an external-file tab with an absolute path) reads no workspace images.
Ran the focused mobile suites (rich-markdown, files, session Markdown reader, RPC recordings), mobile typecheck, tests typecheck, oxlint/oxfmt on changed files, and the changed-code quality and React Doctor gates.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Codex and a Claude reviewer reviewed it over three rounds. Fixed from review: images restored by undo or paste stayed blank, a whitespace-padded or entity-encoded scheme URL was treated as a workspace path, a required prop broke the tests typecheck, the loader ref is now updated in a layout effect, and external-file tabs could resolve images to a wrong in-workspace path.
Declined:
"title"or<angle brackets>, behave as they did before. These are existing limits of the parser and the command, and links have them too.Agent skill upstream boundary
Notes
..escapes and absolute document paths, and reads only image or SVG types. The result goes into<img>as a data URI, which the shell CSP already allows (img-src data:).clientandworktreeIdasmarkdown.readTab, so the host routes the read like the file preview.files.readPreviewleave the image unloaded, as the file preview does.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)