Skip to content

Render images agents produce in the conversation (#39) - #60

Merged
currentbits merged 3 commits into
mainfrom
coder/images-produced-by-agents-are-not-displa-fde965
Aug 15, 2026
Merged

currentbits merged 3 commits into
mainfrom
coder/images-produced-by-agents-are-not-displa-fde965

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Fixes #39.

Why

An agent could take a screenshot and Read it back, reason about it perfectly, and the user saw nothing — just the tool call and a text description. Every visual verification workflow (UI changes, screenshot diffs, design review) ended with "open the PNG from /tmp by hand".

Root cause

flattenContent (electron/claude.js) folded every non-text content block through JSON.stringify. An image block became truncated base64 in the tool output pane, and the bytes were dropped everywhere else. Nothing downstream ever knew an image existed.

What changed

  • electron/tool-images.js (new): extractImages / saveToolImages / readToolImage. Bytes are written to userData/tool-images, never into the store JSON — that is one file rewritten in full on every event, and a full-page screenshot in there would be brutal. readToolImage takes a basename only, so a name from the renderer can never traverse.
  • electron/runner.js: the tool_result handler saves any image blocks and records the filenames on tool.images. Its two near-duplicate branches (paired msgId vs. fallback lookup by tool.id) collapsed into one, so both paths get the fix rather than just the one the repro happened to take.
  • files:image channel returns a data URL (the app's CSP allows data:, not file:), wired through preload / wireClient / devCoder / useCoder / App to ToolCallCard, which fetches lazily the first time the card is expanded.
  • Tool output text now reads [image] instead of a wall of base64.

Scope is the Claude path: codex, opencode and kimi parse their own text-only tool output and never carry image blocks.

Verification

  • electron/test/tool-images.test.js: extraction, disk round-trip to a data URL, and rejection of traversal / non-image names.
  • electron/test/claude.test.js: a new tool-image fake-CLI scenario emits a Read-of-a-PNG tool_result — the file lands on disk byte-identical, the message holds only the filename, and no base64 appears anywhere in the transcript.
  • test/threadView.test.tsx: mounted card renders no <img> while collapsed; after a click it requests the image and renders <img src="data:image/png;base64,…">.
  • tsc --noEmit clean. Renderer suite 741 pass / 0 fail. Electron suite 714 pass / 9 fail — those 9 (memory-sup, orch-server) fail identically on main with these changes stashed.

Verified by tests, not by looking at the running app: launching a second Electron instance would share userData with the live one.

Known gap: image files are never pruned (marked with a ponytail: comment). Nothing else in userData is pruned either; an age sweep on boot is the fix if the directory ever grows.

  • PR created by the Claude Code agent

Willem and others added 3 commits August 15, 2026 16:11
… Kept-alive Claude CLIs: 30-minute idle hold with no cap
… Budget exhaustion kills orchestration silently
A tool_result carrying an image block (Read of a PNG, a Playwright
screenshot) was JSON.stringified into the tool output, so the user saw a
truncated base64 blob and never the picture.

Images now go to userData/tool-images (never into the store JSON, which is
rewritten in full on every event) and the tool message carries the file
names; the tool card fetches them as data URLs when it opens.

Co-Authored-By: Claude Opus 5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@currentbits
currentbits merged commit b0a7351 into main Aug 15, 2026
1 check passed
@currentbits
currentbits deleted the coder/images-produced-by-agents-are-not-displa-fde965 branch October 3, 2026 16:07
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.

Images produced by agents are not displayed in the app

1 participant