feat(web): arrow through a message's images as one gallery - #9134
Closed
brahimhamichan wants to merge 1 commit into
Closed
feat(web): arrow through a message's images as one gallery#9134brahimhamichan wants to merge 1 commit into
brahimhamichan wants to merge 1 commit into
Conversation
Clicking an inline markdown image opened the expanded preview with just that image, even when the response contained several. Preview-enabled images in the same message body now form one gallery in document order, so the dialog's existing navigation (arrow keys, chevrons, counter) works across them. Each image registers its full preview item, keeping originalUrl and media actions intact for every gallery entry. Fixed with Claude Fable 5 on Claude Code.
Contributor
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This changes the default interaction for expandable markdown images by introducing gallery navigation across images in a message. The implementation is localized and tested, but the user-facing behavior is a new capability on an existing production path. You can add or adjust custom eligibility rules. Learn more. |
Member
|
Superseded by #10625 (merged) — markdown images in a message now form one gallery with arrow navigation on main. |
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.
Problem
When an assistant response embeds several images, clicking one opens the expanded preview with only that image. The dialog already supports multi-image navigation (arrow keys, chevrons, an n/m counter) — user attachment rows use it — but markdown images always pass a single-item list, so sequential images can't be flipped through.
Change
Preview-enabled markdown images in the same message body now form one gallery in document order. Each image registers its full preview item (including
originalUrland media actions) keyed by its element, and a click assembles the gallery from the message scope, so the existing dialog navigation works across all of them. Linked images and link favicons stay out of the gallery, and images outside a message body (e.g. the work-log viewed image) keep their single-image preview.No new UI: this only feeds the existing
ExpandedImageDialognavigation, so there's no added rendering cost while the timeline is idle.Verification
vp test run apps/web/src/components/ChatMarkdown.gallery.test.tsx— 5 passed.Written by Claude Fable 5 on Claude Code.
Note
Low Risk
Localized chat markdown preview behavior with unit tests; reuses existing
ExpandedImageDialognavigation and no auth or data-path changes.Overview
Markdown image previews in a single message now open as one gallery, so the existing expanded-image dialog can move between them in document order (arrows/chevrons) instead of always showing only the clicked image.
Preview-enabled standalone images register their full
ExpandedImageItem(includingoriginalUrland media actions) on mount via adata-preview-imagemarker and aWeakMap; on expand,markdownImageGalleryPreviewgathers all marked siblings under the same.chat-markdownscope. Linked images and link favicons stay excluded (still gated byMarkdownLinkContext), and images outside a message body fall back to a single-item preview.Adds
ChatMarkdown.gallery.test.tsxcovering gallery ordering/index, skipped unregistered siblings, orphan fallback, and membership vs linked-image exclusion.Reviewed by Cursor Bugbot for commit 208b0dd. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add arrow-through image gallery preview to
ChatMarkdownmessagesWeakMapregistry andregisterMarkdownGalleryImageutility that associate each mounted preview-enabled markdown image element with its expanded-image item.markdownImageGalleryPreview, which finds marked images under the clicked image's nearest.chat-markdownancestor, returns their registered items in document order with the correct clicked index, and falls back to a single-image preview outside a message scope.expandableMarkdownImagePropsto register each image via ref, emit the gallery marker attribute, and pass the computed gallery preview to the expansion callback instead of a one-image preview.markdownImageGalleryPreviewrelies on the.chat-markdownancestor and the marker attribute onimgelements in ChatMarkdown.tsx; images rendered outside that scope or without registration fall back to single-image preview.Macroscope summarized 208b0dd.
Screenshots
Four inline images in one assistant response:
After clicking the first image and pressing the right arrow key — the dialog shows the second image with the (2/4) counter and both navigation chevrons: