Skip to content

#1039 Show tool-result images: cache thumbnails, full image on tap - #1040

Merged
ivanfenenko merged 6 commits into
mainfrom
fix/1039-tool-result-images
Nov 14, 2026
Merged

ivanfenenko merged 6 commits into
mainfrom
fix/1039-tool-result-images

Conversation

@ivanfenenko

@ivanfenenko ivanfenenko commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Images show after a fresh load. When the cached tail matches the fetched tail, the app now copies tool images (and blanked file data URLs) from the fetched page into the store by part id, instead of keeping the image-less cached copy. The tail identity also counts tool images, so a cache without them can't "match" a page that has them.
  • Thumbnails in the cache, not full images. Tool images are stored as small JPEG thumbnails (400 px long edge, 300 px fallback, at most 64 KB) under the platform Caches directory, keyed by a hashed connection, the session and the image id. The cache JSON keeps only metadata.
  • Bounded size. Newest 24 images and about 1 MB per session; 50 MB total, trimmed to 40 MB least recently viewed first. Thumbnails are removed on worktree/connection purge and clear-all, and an orphan sweep runs at launch. One thumbCache bytes= files= evicted= diagnostic line per pass.
  • Full image on tap. New single-message fetch on both protocols (v1 GET /session/{id}/message/{messageID}, v2 GET /api/session/{id}/message/{messageID} with its data envelope), behind the existing protocol-selected remote. The viewer goes thumbnail → loading → full | failed with Retry; Share is enabled only on the full image. Full images are held in a 32 MB in-memory cache that clears on memory pressure.
  • Same behaviour on iOS and Android. New strings: could_not_load_full, loading_full, retry under component.image_viewer.

Checks

  • iOS targeted suites (13 suites, 197 tests): pass. DefaultSessionCacheTests, ToolThumbnailStoreTests, ToolImageHydrationTests and MessageImageLoaderTests re-run 3 times: pass every time.
  • iOS full unit target: 3411 tests, 1 failure (DefaultSessionCacheTests.messageHandleSeedsAfterDebouncedFlush, a 40 × 20 ms polling test). It passed in all 3 re-runs, so it looks like timing while the machine was loaded.
  • Android :app:assembleDebug: pass. The 9 touched test classes (141 tests): pass.
  • Android full :app:testDebugUnitTest: 3461 tests, 3 failures, which also fail on the base commit: two decimal-separator tests under a non-English locale, and the flaky SseRecoveryFaultOracleTest.
  • scripts/check-string-keys.mjs: keys match. git diff --check: clean. ktlint: no new violations in changed lines.

Evidence

Pending. Screenshots of both platforms against the scenario harness will follow in a comment.

Issue

#1039

Risks / Follow-ups

  • Not yet run on a device or simulator UI. The encoder and viewer states are covered by unit tests only.
  • Android: the separate tool-group screen has no screen model, so a thumbnail-only image there can't fetch its full version yet. It still opens images already held in memory.
  • Image ids differ between platforms: iOS <toolPartID>:file:<n>, Android <toolPartID>:image:<n>. Each is consistent within its own platform.
  • The step-rail, chip and activity-card timeline modes don't draw tool image galleries; that was already true before this change.
  • The session-cache JSON still has no size or age limit; that needs its own issue.

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

ivanfenenko and others added 3 commits November 14, 2026 13:02
Cache each added path's worktree list and branches and seed them, with project resolutions, before the cold paint builds rows, so the live load no longer relabels every row. Start the first live session window at the size the cache painted, and reveal the full-screen Home and app-root loader only after a 300 ms grace. iOS and Android.
Port the cached worktree-layout seeding onto main's Home region split:
HomeWorktrees now seeds and remembers worktree layouts, and
HomeProjectList seeds them before the cached paint on both platforms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…firm, full image on tap

Tool images were dropped by the session cache codec, and a cache-confirmed tail kept the image-less cached copy. Both apps now hydrate media from the fetched page, keep bounded on-device thumbnails (400 px, <=64 KB, 24 per session, 50 MB total with LRU eviction and purge/orphan cleanup), and fetch the single message (v1 and v2) for the full image in the viewer.
@ivanfenenko
ivanfenenko marked this pull request as ready for review November 14, 2026 16:47
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