Skip to content

#898 Show images inline as galleries in Session Chat - #911

Merged
ivanfenenko merged 5 commits into
mainfrom
feature/898-image-galleries
Oct 31, 2026
Merged

ivanfenenko merged 5 commits into
mainfrom
feature/898-image-galleries

Conversation

@ivanfenenko

@ivanfenenko ivanfenenko commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

#898

First slice of inline image galleries in Session Chat, on both platforms.

  • Keeps images that tools return (v1 attachments[], v2 content[type=file]) from REST history and live events instead of dropping them.
  • New OpenCodeImageGallery mosaic: 1 image inline, 2 columns, 3 as large tile + two stacked, 4+ as 2×2 with a +N tile. Loading and failed tile states.
  • Placed under the tool card or tool group, above user message text, and after assistant text.
  • New OpenCodeImageViewer/OpenCodeImageGalleryViewer: paged, pinch/double-tap zoom, swipe-down dismiss, share.
  • Viewer state lives on the Timeline region; Component Gallery entries and a design-system component doc added.

Work stays open on #898: path/markdown images, the other timeline styles, the preference, and the harness scenario.

Checks

  • iOS and Android both covered
  • Screenshots for UI changes (evidence comment to follow)
  • Tests run: iOS full suite passes; Android unit suite passes (one coroutine-timing test flaked once under load and passes alone)

Risks / Follow-ups

  • The v1 tool attachments shape is covered by unit tests only, not confirmed against a real v1 server yet.
  • Android tool-group screen keeps its images in memory, so they are gone after process death.
  • Share uses a system glyph (iOS) and a text button (Android) until the icon catalog gets a share icon.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Note

Medium Risk
Large chat UI and message projection changes with in-memory image decoding/caching and new share FileProvider paths; scope is timeline presentation rather than auth or payments.

Overview
Session Chat on Android and iOS now keeps images tools return (v1 attachments, v2 content[type=file]) through REST and live events, maps them onto MessagePart.Tool.images, and renders them in the timeline—not only user uploads.

The UI adds OpenCodeImageGallery (count-based mosaic with loading/failed tiles and +N overflow) and a paged full-screen viewer (zoom, swipe dismiss, share). Timeline building introduces ImageGallery blocks under tool cards/groups and for runs of two+ message images; Session Chat owns viewer state (SessionChatImageViewer / imageViewer in UI state) and wires taps from outgoing bubbles, assistant rows, and the tool-group route (Android stashes group member images in SessionToolGroupImages because the nav key cannot carry bytes). Decoding goes through a bounded bitmap cache and gallery loaders; Android share writes via shared-images/ FileProvider.

Supporting work: ToolResultImages filtering, preview cache warming for tool images, component gallery + design doc, iOS photo-library-add plist string, and unit tests for parsing and gallery block layout.

Reviewed by Cursor Bugbot for commit 6f41efd. Bugbot is set up for automated code reviews on this repo. Configure here.

ivanfenenko and others added 3 commits October 31, 2026 17:57
…roid

Keep images that tools return (v1 attachments, v2 file content) from REST
and live events, group them into a mosaic under the tool card or group,
above user text and after assistant text, and open any tile in a paged
viewer with zoom, swipe-down dismiss and share.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Keep images that tools return (v1 attachments, v2 file content) from REST
and live events, group them into a mosaic under the tool card or group,
above user text and after assistant text, and open any tile in a paged
viewer with zoom, swipe-down dismiss and share.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

Real-app evidence (scenario harness, scripted fake model)

Both apps run against a real opencode server through scripts/scenario-harness (new tool-image-gallery scenario: a read of image files, variants for 1, 2, 3, 4 and 7 images). Debug builds of this branch (6f41efdf), Standard timeline style, mock data only. Main pass on v1 (opencode-ai 1.19.5); v2 (dev) spot-checked live.

Tool images under the card: 1, 2, 3, 4, 7 (+4)

iOS Android
1 image ios single android single
2 images ios pair android pair
3 images ios trio android trio
4 images ios quad android quad
7 images (+4 tile) ios many android many

Viewer

iOS Android
Opened on tile 3 of 7 ios viewer android viewer
Swiped to 4 of 7 (a tile hidden behind +4) ios next android next
Double-tap zoom ios zoom android zoom
Share ios share android share

Swipe-down dismiss works on both.

User message with attached images (3 on iOS, 5 with +2 on Android)

iOS Android
ios user android user

v2 server (live, session open while the turn ran)

iOS 3 images iOS 7 images Android 3 images
ios v2 trio ios v2 many android v2 trio

Server shapes observed

  • v1 (1.19.5), GET /session/:id/message: part.state.attachments[] = {id, sessionID, messageID, type:"file", mime:"image/png", url:"data:image/png;base64,…"}. No filename. The server drops an unreadable image and says so in state.output ([1 image omitted: …]).
  • v2 (dev), GET /api/session/:id/message: content[].state.content[] = {type:"text",text:"Image read successfully"} plus {type:"file", uri:"data:image/png;base64,…", mime:"image/png", name:"assets/…png"}.

Both match what the adapters parse.

Found problems (not fixed here)

  1. A gallery disappears when the session is reopened from the session cache (both apps; reproduced on v1, the cache codec is shared with v2). It shows on the first open or live, and is gone after leaving and reopening the session or relaunching the app. SessionCacheCodec neither writes nor reads ToolPart.images (iOS Domain/SessionCache/SessionCacheCodec.swift ~709 and ~847, Android domain/sessioncache/SessionCacheCodec.kt ~266, ~488, ~550). Screenshots: ios-11-reopen-gallery-missing.png, android-11-reopen-gallery-missing.png.
  2. Activity Card timeline style (the Recommended default in the first-run picker) shows no gallery. Settled turns fold into "N steps · Read", and the steps sheet lists the files without their images. Standard shows them. Not checked: Chips, Step Rail.
  3. Android tool tiles are labelled "Image" (v1 attachments carry no filename); iOS shows no label there. v2 tiles show the file name on both.

Not verified: a failed or loading tile (the real servers never deliver a corrupt image: v1 omits it, v2 reads it as text), VoiceOver / TalkBack, scroll performance with many galleries on screen (only a few screens scrolled by hand, no hitching seen).

🤖 Generated with Claude Code

ios-11-reopen-gallery-missing

android-11-reopen-gallery-missing

@ivanfenenko
ivanfenenko marked this pull request as ready for review October 31, 2026 20:04
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6f41efd. Configure here.

@github-actions github-actions Bot 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.

Automated review: no finding that 2+ of 3 passes agreed on.

4 finding(s) from a single pass, not posted
  • android/app/src/main/java/dev/opencode/mobile/ui/components/chat/OpenCodeImageGalleryViewer.kt:143 high: Viewer chrome indexes pager page without bounds check (muse-spark-1.3-contributor)
  • android/app/src/main/java/dev/opencode/mobile/ui/sessionchat/view/SessionChatImageShare.kt:31 medium: Share deletes whole share directory before writing (muse-spark-1.3-contributor)
  • ios/OpenCode Mobile/OpenCode Mobile/Components/Chat/OpenCodeImageGallery.swift:133 low: Overflow accessibility label understates hidden images (muse-spark-1.3-contributor)
  • android/app/src/main/java/dev/opencode/mobile/ui/components/chat/OpenCodeImageGallery.kt:245 low: Overflow tile accessibility label off by one (glm-5.3-flash)

opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.133 · 1 pass(es) stopped early

ivanfenenko and others added 2 commits October 31, 2026 21:38
…verflow tile label

iOS: OpenCodeZoomingImageScrollView.setImage no longer resets zoom when a
sharper picture of the same aspect ratio replaces the one on screen.
Android: the overflow tile's accessibility label counts the images still
hidden (N - 1), and the viewer chrome clamps the pager page.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Keep image galleries alongside the steering/pending bubbles from #909 on both platforms: pending steers dim attachments and galleries, and pending steers keep no message actions.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@ivanfenenko
ivanfenenko merged commit 41e9a42 into main Oct 31, 2026
@ivanfenenko
ivanfenenko deleted the feature/898-image-galleries branch October 31, 2026 21:03
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.

1 participant