feat: render markdown images with click-to-enlarge lightbox#271
Merged
backnotprop merged 2 commits intobacknotprop:mainfrom Mar 12, 2026
Merged
feat: render markdown images with click-to-enlarge lightbox#271backnotprop merged 2 commits intobacknotprop:mainfrom
backnotprop merged 2 commits intobacknotprop:mainfrom
Conversation
Adds full inline image rendering to the Viewer for both annotate and plan review modes. Previously,  syntax was treated as plain text. ## What changed ### Viewer.tsx - Added `` regex to InlineMarkdown before the link pattern. Images starting with `!` were silently falling through to plain text because `!` was not in the special-character scan set — added it. - Added `imageBaseDir` prop (flows Viewer → BlockRenderer → InlineMarkdown) so relative image paths in markdown resolve against the annotated file's directory rather than the server's cwd. - Added `onImageClick` callback (same prop chain) to open lightbox on click. - Added `ImageLightbox` component: full-screen dark backdrop, image scaled to 90vw/85vh with object-contain, alt text caption, closes on Escape or backdrop click. Portaled to document.body. - Images render with `cursor-zoom-in` to hint they're clickable. ### App.tsx - Captures `filePath` from `/api/plan` response (already sent by annotate server) and derives `imageBaseDir` (directory of the markdown file). - Passes `imageBaseDir` to `<Viewer>`. ### ImageThumbnail.tsx - `getImageSrc()` now accepts an optional `base` parameter. For relative local paths, appends `&base=<dir>` to the `/api/image` query string. ### shared-handlers.ts - `handleImage` falls back to resolving the path relative to a `base` query param when the primary path doesn't exist and the path is relative. Covers the common case of `` in a markdown file opened from an arbitrary directory. ## Behavior - Remote URLs (https://...) render directly, no proxy. - Absolute local paths route through /api/image as before. - Relative paths resolve against the markdown file's directory via ?base=. - Click any image → lightbox. Escape or click outside → dismiss. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Owner
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds full
image rendering to the Viewer component. Previously, markdown image syntax was silently treated as plain text. Images now render inline with a click-to-enlarge lightbox overlay.What's included
Image rendering
markdown syntax now renders as actual<img>elementshttps://...) render directly; local paths proxy through/api/imagecursor-zoom-inon thumbnails hints they're interactiveRoot cause of the silent failure
The
InlineMarkdownspecial-character scanner (/[\*[]/)) did not include!, sohad its!consumed as plain text, leavingaltto match as a regular link. Fixed by adding!` to the scan set and placing the image regex before the link regex.Click-to-enlarge lightbox
90vw / 85vhzoom-outto make it obviousdocument.body— same pattern asImageAnnotatorRelative path resolution
Markdown files commonly reference images with relative paths (
./images/chart.png). The server'sprocess.cwd()is not necessarily the markdown file's directory, so these paths were 404ing.Fix:
getImageSrc()now accepts an optionalbasedirectory and appends?base=<dir>to the API URL.handleImageinshared-handlers.tsfalls back to resolving the path relative tobasewhen the primary path doesn't exist.App.tsxcapturesfilePathfrom the/api/planresponse (already sent by the annotate server) and derivesimageBaseDirto pass to<Viewer>.Files changed
packages/ui/components/Viewer.tsximageBaseDir/onImageClickprop chain,ImageLightboxcomponentpackages/ui/components/ImageThumbnail.tsxgetImageSrc(path, base?)optional base parampackages/editor/App.tsxfilePath→ deriveimageBaseDir→ pass to Viewerpackages/server/shared-handlers.tshandleImagefallback resolution via?base=query paramTest plan
— remote image renders— local image renders— absolute path renders[link](url)still works (not accidentally matched as image)🤖 Generated with Claude Code