Skip to content

feat(chat): show pictures Claude Code reads, and a picture-only prompt as a turn - #1935

Merged
devswha merged 3 commits into
mainfrom
feat/chat-inline-images
Oct 25, 2026
Merged

devswha merged 3 commits into
mainfrom
feat/chat-inline-images

Conversation

@devswha

@devswha devswha commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Waiting for the maintainer's own review before merge.

Part of #992, the Claude Code part. pi, the omp family and Codex follow as separate PRs, one at a time.

Change

In a Claude Code pane, Chat dropped two kinds of picture:

  • A picture a tool returned. Claude Code's Read of a screenshot keeps the picture inline in tool_result.content[]. The parser kept only the result's text, so the row showed nothing.
  • A prompt that is only a picture. It was drawn, but the byte scanner that pages the transcript and follows a /rewind (opensTurn in server/transcript-turns.ts) needed text to see a prompt. So after a rewind, a screenshot sent as the next prompt left the abandoned turns on screen, and a page could not start at such a prompt.

What it does now:

  • Tool pictures: each one is named in the row's existing tool.images as <entry uuid>:<block>:<place in the result>, and GET /api/pane/conversation/image reads it back by that ref. The row loads it only once it is opened, like pi's. The conversation response carries refs only, never base64.
  • Picture-only prompts open a turn in the scanner as they do in the parser. A record longer than the 1 MiB the chain reader parses is read with its picture bytes cut to their first bytes, because on this PC 69 of 434 Claude picture prompts are longer than that (p90 1.5 MB). The cold history scan also carries such a record whole across its 16 MiB windows (up to the largest picture the chat shows), where it used to drop any record over 64 KiB at a window edge. A picture in the same record as a tool result opens nothing, so the result stays on the page of the call it answers.
  • One check, both sides: claudeImageType decides what is a picture for the parser and the endpoint alike: PNG, JPEG, GIF or WebP by declared type and by leading bytes, at most 8 MiB decoded (the cap Codex images already have). So the page never names a picture the endpoint refuses. This now also applies to pasted prompt pictures, which had no size cap or byte check before.
  • Same history as the page: the endpoint reads a Claude picture after the last /clear, on the branch a rewind left, and only from an entry the parser draws (not isMeta or a compaction under the same uuid), and a tool's picture only from a result the page draws: one that answers a call it shows, which no result before it answered. It searches the transcript a window at a time, reads a candidate record's shape a window at a time, and reads back whole only the picture it serves: never a record or the transcript whole.

HTTP contract: /api/pane/conversation/image accepts a third ref shape. There is no new endpoint and no new wire field (tool.images already exists). Since it changes what that endpoint answers, this needs a real review.

Remote bundle: the server files are in the remote PC bundle. REMOTE_BUNDLE_VERSION is not raised here; the release does that.

Design: no new UI. It uses the row's picture gallery and viewer that pi's tool pictures and pasted pictures already use (#951). It follows the Claude and Codex apps, which show a picture a tool read inline with that tool call.

Not in this PR: pi and omp-family user pictures, omp blob tool pictures, Codex tool-output pictures (separate PRs), and local Markdown images in answers.

Validation

  • Unit tests (server/conversation.test.ts, server/claude-incremental.test.ts), each new one shown failing without its fix:
    • a Read result's PNG is named <uuid>:<block>:<place> with no base64 in the page, and transcriptImage returns its exact bytes;
    • a picture-only prompt opens a turn (turnStarts), and after a recorded /rewind (Claude Code 2.1.304 fixture) a picture-only next prompt hides the abandoned turns, warm and cold, for a 16 B picture, a 900 KiB one, and a 2 MB one whose record crosses the cold scan's 16 MiB window;
    • refused, at the parser and the endpoint alike: an svg, non-raster bytes declared image/png, a picture past 8 MiB (exactly 8 MiB passes), a ref to the result's text, a ref with no picture, malformed refs, a picture from before /clear, one from a turn a rewind abandoned, and an isMeta record carrying the same uuid;
    • a tool result and a picture in one record stay on the page of the call, equal to a full parse;
    • live (incremental) parsing names the same refs as a cold parse;
    • existing <uuid>:<index> prompt pictures parse and serve as before.
  • Real transcripts on this PC (shapes only, nothing printed): 5 Claude transcripts with Read pictures (PNG and JPEG, one from a subagent): every picture passes the check, each is named once (Claude Code's api-request-blob copies are not), and no base64 reaches the page. 69 of 434 Claude picture prompts here are over 1 MiB, which is why the large-record path exists.
  • Browser (scripts/claude-image-browser-qa.ts, added to the CI browser lane): a Claude stand-in on an owned herdr pane, the real server and Chrome. A picture-only prompt sent after a rewind is its own turn with its thumbnail decoded and no empty bubble, the rewound turns stay hidden; the Read row fetches nothing while folded and decodes its picture once opened; a ref the transcript does not hold is 404. Desktop and phone (390 px, fresh mobile context) screenshots checked: the tool picture in the opened Read row, the picture-only prompt as its own turn with no empty bubble.
  • Reviews: omo-native-code-reviewer (one HIGH: a tools-typecheck error in the script; fixed) and Codex on Sol 6.1 (no HIGH; four MEDIUM and one LOW, all fixed with tests); a delta review of the fixes approved, and its one MEDIUM (the 16 MiB window case) is fixed with a test.
  • Rebased onto 4a4bdaa (0.4.16); the one conflict was an import in server/conversation.ts (main's claudeAttachSession). After the rebase: the touched suites pass (server/conversation.test.ts, server/claude-incremental.test.ts, scripts/ci-browser.test.ts: 163 pass), scripts/claude-image-browser-qa.ts passes all three checks, and a Codex (Sol 6.1) review of the rebase delta found nothing.
  • Merge pass gate review and re-check: the endpoint served an orphan tool result's picture, read the whole transcript, then still read a matching record whole and took one JSON spelling of ids. All fixed (03d6129, 0ba6e03): a picture only from a result the page draws, a window, a record's shape and the picture's own text at a time, ids matched however JSON writes them. Each finding has a test that fails before its fix; Codex (Sol 6.1) reviewed each step and its findings are fixed with tests (reply).
  • bun run check fast: passes on this head (workflow syntax, generated types and themes, typecheck, build, unit tests).
  • Before/after for the maintainer: screenshots (desktop and phone) and a short recording of each, from an isolated herdr test session, made with the same fixture on main and on this branch: (shared privately with the maintainer) (tailnet only, served while this PR is open). One synthetic session on both sides: a Read of a chart screenshot, a turn taken back with /rewind, then a prompt that is only a screenshot. On main the Read row has no picture and the rewound turn is still shown; on this branch the chart shows in the opened row (and opens in the viewer) and the rewound turn is hidden.

…t as a turn

Part of #992, for Claude Code.

- A picture a tool returned (Claude Code's Read of an image file keeps it
  inline in tool_result.content[]) is named in the tool row's images as
  <entry uuid>:<block>:<place in the result>, and the image endpoint reads
  it back by that ref. Bytes are fetched only when the row opens.
- A prompt that is only a picture opens a turn for paging and for the
  rewind fork detection, so an image-only prompt sent after a rewind hides
  the abandoned turns. A record over the chain reader's 1 MiB is read with
  its picture bytes cut, so a real screenshot is not too long for it, and
  the cold history scan carries such a record whole across its 16 MiB
  windows. A picture beside a tool result opens nothing.
- One check, claudeImageType, decides what is a picture for the page and
  the endpoint alike: PNG/JPEG/GIF/WebP by declared type and leading bytes,
  at most 8 MiB decoded.
- The endpoint reads Claude pictures as the page does: after the last
  /clear, on the branch a rewind left, from entries the parser draws.
- scripts/claude-image-browser-qa.ts runs it end to end on an owned pane
  in the CI browser lane.
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between b2ebd26 and 0ba6e03.

Files selected for processing: 2
  • server/conversation.test.ts
  • server/conversation.ts

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between ddee8be and b2ebd26.

Files selected for processing: 11
  • changelog.d/claude-chat-images.md
  • docs/guide.md
  • scripts/ci-browser.sh
  • scripts/claude-image-browser-qa.ts
  • server/claude-incremental.test.ts
  • server/claude-transcript.ts
  • server/codex-images.ts
  • server/conversation.test.ts
  • server/conversation.ts
  • server/transcript-turns.ts
  • tsconfig.tools.json

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

📝 Summary

Summary by CodeRabbit

  • New Features
    • Claude Code images from prompts and tool results now appear in Chat when their corresponding message or tool row is opened.
    • Image-only prompts are displayed as separate conversation turns.
  • Bug Fixes
    • Rewind and older conversation views now respect image-only prompts and active conversation branches.
    • Unsupported, oversized, or unavailable images are handled without displaying image data in the conversation text.

Claude transcript parsing now supports images in user prompts and tool results. Image-only prompts open turns, and image retrieval follows active conversation history. New browser QA checks image rendering, lazy loading, and rewind behavior.

Changes: Claude transcript images

Layer / File(s) Summary
Image recognition and references
server/claude-transcript.ts, server/codex-images.ts, server/claude-incremental.test.ts
Shared helpers validate image types, sizes, and references. Parsing attaches tool-result images to their tools and uses the same validation for prompt images.
Turn handling and image retrieval
server/transcript-turns.ts, server/conversation.ts, server/conversation.test.ts
Image-only prompts open turns, and branch scanning removes picture bytes before applying its parse limit. Image retrieval resolves prompt and tool-result images from history after clear and branch boundaries. Tests cover turn detection, paging, rewind, and retrieval limits.
Browser QA and behavior descriptions
scripts/claude-image-browser-qa.ts, scripts/ci-browser.sh, tsconfig.tools.json, docs/guide.md, changelog.d/claude-chat-images.md
Browser QA checks rewind visibility, image-only turns, and image loading when rows open. CI includes the script, and the guide and changelog describe the behavior.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Suggested reviewers: kilhyeonjun

Merge Risk: Minimal · up to b2ebd

No actionable merge-blocking risk remains from the reviewed change. Image-heavy sessions may incur repeated transcript reads, but that behavior predates this PR.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 64.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 8 files. (3 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main changes: displaying Claude Code pictures and treating picture-only prompts as turns.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The PR description follows the template: it has a Change section describing the problem (Claude Code tool-returned pictures and picture-only prompts being dropped) and the resulting behavior, and a Va…
Full details: Description check

Explanation

The PR description follows the template: it has a Change section describing the problem (Claude Code tool-returned pictures and picture-only prompts being dropped) and the resulting behavior, and a Validation section listing unit tests, real-transcript checks, browser QA, reviews, and the check run. It gives context on scope and what is excluded. Minor gap: the Change section does not link a maintainer-agreed issue for the feature, though it references #992 as the parent effort and #951 for the existing gallery pattern; the template asks for an issue link on features.

Full details: Docstring Coverage

Explanation

Docstring coverage is 64.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 8 files. (3 skipped: 3 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devswha

devswha commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

Merge pass gate review (Astra, gpt-6-astra) of b2ebd26: changes requested. The verdict is REJECT, on 2 findings, both reproduced. This goes with the maintainer's own review, which the PR is still waiting for. The full report, with reproduction code, is .omo/evidence/pr1935-gate-review.md in the merge pass worktree.

What holds (checked directly):

  • Legacy and nested refs are handled.
  • Malformed and out-of-range refs are rejected.
  • Raster signatures are checked, and the 8 MiB boundary holds exactly.
  • Small and large picture-only prompts are handled through a rewind and then a /clear.
  • The desktop and phone screenshots were inspected.

1. The endpoint serves a picture the page never draws (server/conversation.ts:1430-1438, server/claude-transcript.ts:386-395)

  • An orphan tool_result, one with no matching pending tool call, produces no conversation turn. Its nested image ref still returns the PNG bytes.
  • The PR states that the endpoint reads "only from an entry the parser draws". For tool results, that isn't enforced yet.
  • Needed: resolve a tool-result picture only when the parser would show that result, meaning it matches a tool call the parser kept. Add a test showing an orphan result's ref returns 404.

2. Image lookup reads the whole transcript into memory (server/conversation.ts:1420-1423, :180-194)

  • A 33,554,622-byte synthetic transcript was read in a single allocation of exactly that size before any picture was checked.
  • This whole-file read predates the PR. The new ref shape makes it reachable for every opened tool picture.
  • Needed, either: resolve the ref with a bounded read (locate the entry's line, then read only that record, up to the existing per-record cap); or the maintainer accepts it as a follow-up, since it isn't new.

Gate note: the locked review worktree had no dependencies, so the focused suites couldn't load there. The 163-test pass from the lane's log was not reproduced independently.

…aws, reading its record alone

The merge pass gate review of #1935 found two gaps in the image endpoint:

- A tool result that answers no call the page shows (an orphan, a second
  answer to the same call, or one answering a call in a hidden entry)
  draws nothing, yet its nested ref was served. A tool's picture is now
  served only when its result answers a call an assistant entry the
  parser draws made, and no result before it answered that call.
- The endpoint read the whole transcript after the last /clear into one
  buffer to find a ref's entry. It now searches it a 1 MiB window at a
  time and reads only the records a ref can name, up to the size the
  history scan follows.
@devswha

devswha commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

Both findings are fixed in 03d6129, with a test each that fails on b2ebd26:

  1. A picture the page never draws. A tool's picture is now served only when its result would be drawn, by the parser's own rule: the result answers a tool_use that an assistant entry the parser draws made (not isMeta, not a compaction), after the last /clear and on the branch the page shows, and no result before it answered that call, in an earlier entry or earlier in the same one. The call's id is matched as text, the way the parser keys pending calls (String(id)), and searched for as JSON writes it, so a numeric id and one that JSON escapes are found too. An orphan result, a second answer to an answered call, and an answer to a call in a hidden entry are now 404. Test: "serves a tool's picture only from a result the page draws, one that answers a call it shows". The page names exactly one of the five results there, and the endpoint serves exactly that one. On b2ebd26 the orphan's picture was served.
  2. Whole-transcript read. transcriptImage now searches the stream a 1 MiB window at a time for the lines that hold the ref's uuid (or, for a tool's call, its id). A needle cut by a window's edge is still found. It reads only those records, each one whole, as the page parses it. A first version capped them at CLAUDE_CARRY_BYTES, but Codex showed that cap gives false 404s for a result holding two 5 MiB pictures, and lets a later duplicate answer through, so there is no cap. Memory now holds one window and one record, never the transcript. Test: "reads a picture's record a window at a time, never the transcript whole" uses a 22 MB transcript whose picture uuid straddles a window edge. It checks the exact bytes and that no single allocation came near the transcript's size. On b2ebd26 one allocation was 23,068,678 bytes. A mutation that drops the edge carry fails it too.

On 03d6129: bun run check fast passes, scripts/claude-image-browser-qa.ts passes all three checks, and the touched suites pass (178). Codex (Sol 6.1) reviewed the fix and then its delta. Its findings (the record cap, as a MEDIUM, and two id-matching LOWs) are fixed, each with a case in "judges a tool's picture by every record the page reads, whatever its size or its call's id", which fails on the first version and under each of the three changes reverted. One check fast run on the way failed only on scripts/check.test.ts's wall-clock bound, which has nothing to do with this change; that is now #1939.

@devswha

devswha commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

Merge pass gate re-check of 03d6129 (Astra, changed range only). Still REJECT, on 2 findings. Both earlier findings are fixed. The full report is .omo/evidence/pr1935-gate-review-2.md.

Fixed:

  • P1: an orphan tool_result ref now resolves to null, which becomes a 404.
  • P2: on the 33 MiB transcript, the largest allocation is now 16 MiB.

Holds:

  • The focused suites pass (159), and so do both typechecks.
  • The window-boundary tests pass.
  • Direct probes confirm that /clear, a rewind, an isMeta call and an isMeta result are all still excluded.

1. No memory bound per record (server/conversation.ts:1450-1451)

  • claudeRecordAt reads a matching record whole.
  • A result padded to 33 MiB allocated 34,603,282 bytes before it was refused.
  • An oversized matching call allocated 34,603,125 bytes and then served the picture.
  • Needed: cap a record before reading it, for example at the 8 MiB picture cap plus framing. A larger record gets refused, or read with its picture bytes cut, as the scanner already does.

2. False 404 for a drawn result (server/conversation.ts:1462)

  • A call whose id is serialised as "toolu_\u0061" matches result "toolu_a" in the parser, so the page draws it and transcriptPage emits its picture ref.
  • The endpoint's raw-text prefilter doesn't find the call, so the request returns null.
  • This fails safe, since the picture is just not shown, and Claude Code doesn't write ids that way today.
  • Needed: match the parsed ids instead of assuming one serialisation, or prefilter on the escaped forms too.

Note: a call more than 33 MiB before its result can still be reached. That is acceptable.

The merge pass will recheck only the new commits.

…however JSON writes them

The merge pass gate re-check of #1935 found two gaps left in the image
endpoint:

- A matching record was still read whole: a result or a call padded to
  33 MiB took one 33 MiB allocation. A record is now read a 1 MiB window
  at a time for its shape, every string past 1 KiB cut and marked with
  where it lies, and only the picture's own base64 is read whole, up to
  the largest picture the chat shows. So a record of any size costs a
  window, its shape and the picture, and the endpoint still judges every
  record the page parses (no size cap that would refuse a picture the
  page names).
- The search for a ref's entry and a call's id took one serialisation: a
  call id written as "toolu_\u0061" matched the result "toolu_a" in the
  parser, so the page named the picture and the endpoint answered 404.
  The search now matches the text however JSON may write it (as itself,
  as a \u escape in either case, or its short escape), and compares the
  parsed values.

A Codex review of the first version found the shape read could still
judge a record differently from the page; it now holds to JSON's rules:
the bytes it does not keep are checked as JSON.parse checks them (an
invalid record is skipped, as the page skips it), a cut string's mark
carries a nonce made for that read so no record's own text can match it,
a cut string is decoded a window at a time (a leading BOM kept, as the
page keeps it) and limited by the text it decodes to (not by how it is
written), a line that is JSON but no object
is skipped, and a call id taken from a number is found in any of its
spellings (1e3 for "1000", 1e400 for "Infinity"). A record whose shape alone is past 4 MiB is not judged, and
nothing it could decide is served: a 404, never a picture the page does
not draw.
@devswha

devswha commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

Both re-check findings are fixed in 0ba6e03. Each has test cases that fail on 03d6129 and again when their part of the fix is undone:

  1. Memory per record. A candidate record is now read a 1 MiB window at a time for its shape only. A byte-level scan of its JSON strings keeps each string's first 1 KiB, cut between escapes. The rest is checked as JSON.parse checks it, so a record the page rejects is skipped here too. In its place goes a mark with a nonce made for that read, which no record's own text can match. Only the served picture's own base64 is read back whole, decoded a window at a time, up to the longest text claudeImageType accepts for a picture, and checked by it exactly as before. Call ids are compared after being read whole the same way. A record of any size therefore costs one window, its shape and the picture. There is no record-size cap, so the endpoint never refuses a picture the page names; a first, capped version of this did, as Codex showed. The one limit left is a record whose shape alone is past 4 MiB, meaning thousands of strings, which nothing writes. Such a record is not judged, and nothing it could decide is served: it can only give a 404, never a picture the page does not draw. Tests: "holds a window, a record's shape and the picture, never a record whole however large" uses a call and a result each padded with 20 MiB; after the history scan, no single allocation is over 1 MiB, where 03d6129 made one of 21,371,783 bytes. "serves nothing a record it cannot hold could decide, rather than guess" covers that last limit.
  2. One serialisation assumed. The search for a ref's entry and for a call's id now matches the text however JSON may write it inside a string: each character as itself, as a \u escape in either case, or as its short escape. It then compares the parsed values. A call id that came from a number is also looked for in every tool_use record, since a number has many spellings (1e3 is keyed "1000"). A call written "toolu_\u0065" and answered by "toolu_e", a prompt whose uuid is written with a \u0030, a picture whose every base64 character is a \u escape, a bare null line between a call and its result, a 1e3 call and a 1e400 one (keyed "Infinity") are all now served as the page names them, and a call whose id starts with a BOM stays a different call. An invalid escape past a cut is refused as the page refuses it. These cases are in "judges a tool's picture by every record the page reads, whatever its size or its call's id" and "reads a record's cut strings as JSON does: their escapes, their marks, their spelling".

On 0ba6e03: bun run check fast passes (6784 unit tests), scripts/claude-image-browser-qa.ts passes all three checks, and the touched suites pass (181). Codex (Sol 6.1) reviewed this commit twice. Its findings, all on hand-written records (a structure past 4 MiB, a picture written in \u escapes, invalid escapes past a cut, a cut-mark collision, a null line, number spellings, a leading BOM), are fixed with cases in the tests above. I left one LOW as it is: a string the endpoint must hold whole (a picture or a call id) is limited to the longest picture text, so a call id over 11 MiB gives a 404. That is the same bound the picture has, it fails safe, and nothing writes such ids.

@devswha

devswha commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@devswha

devswha commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

CodeRabbit reviewed b2ebd26 (no actionable comments) but was rate-limited for the two fix commits, 03d6129 and 0ba6e03. As AGENTS.md asks for a PR that changes an HTTP contract, here are the code-review agent's reviews that stand in for them: Codex on Sol 6.1 (gpt-6.1-sol, fast, xhigh), read-only, with each finding reproduced through the real page and endpoint functions.

Review Findings Resolution
Rebase onto 4a4bdaa none approved
1d2a5945 (first fix for the gate's two findings) MEDIUM: a per-record size cap refused pictures the page names, and let a later duplicate answer through. LOW: a numeric call id did not match the parser's String(id) key cap removed, id matched as text (03d6129); test case for each
95f952e0 (its delta) LOW: an id JSON escapes was missed by the raw-text search searched as JSON writes it (03d6129); test case
0ddf2756 (first fix for the gate re-check) MEDIUM: a record whose structure is past 4 MiB judged both ways; the picture limit measured written bytes, not decoded text; bytes past a cut skipped JSON validation; a cut-string mark could collide with a record's text. LOW: a 64 KiB id limit; a null line aborted the search; 1e3 spellings all fixed in 0ba6e03: validated discarded bytes, a per-read nonce in the mark, windowed decoding limited by decoded length, non-object lines skipped, every tool_use searched for number-like ids, and a record past 4 MiB of structure serves nothing it could decide (a 404, never a picture the page does not draw); test cases for each
3022c310 (its delta) MEDIUM: the decoder dropped a leading BOM the page keeps. LOW: 1e400 keyed "Infinity". LOW: an id over 11 MiB decoded gives a 404 first two fixed in 0ba6e03 with test cases; the last left as is: same bound as a picture, it fails safe, and nothing writes such ids

Every test case named above fails before its fix and with its part of the fix reverted. On 0ba6e03: bun run check fast and scripts/claude-image-browser-qa.ts pass.

@devswha

devswha commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

Merge pass gate re-check of 0ba6e03 (Astra, changed range only): APPROVE. Both round-2 blockers are resolved.

  • Memory: on the 33 MiB padded result and on the 33 MiB matching call, the largest allocation is 16 MiB cold and 1 MiB warm, and neither record is read whole.
  • Escaped call id: toolu_\u0061 now serves its picture.
  • Lookalikes: lookalike ids in prose, nested input, longer ids and literal \u strings do not authorize the wrong call.
  • Exclusions: orphan, /clear, rewind and isMeta exclusions still hold.
  • Tests: the 162 focused tests pass. The report is .omo/evidence/pr1935-gate-review-3.md.

The PR body asks for the maintainer's own review before merge, so the merge pass holds it until the maintainer approves.

@devswha

devswha commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

Merge pass review-work report. Overall: PASSED the merge pass gate. This PR changes the HTTP contract of /api/pane/conversation/image (a new ref shape on an endpoint that reads files), so it went through the Astra gate (omo-native-gate-reviewer, gpt-6-astra) three times.

Round Head Verdict
1 b2ebd26 REJECT: an orphan tool_result image was served, and the whole transcript was read into memory
2 03d6129 REJECT: no per-record memory bound (a 33 MiB record was read whole), and a false 404 for an escaped call id
3 0ba6e03 APPROVE

Holds on the final head:

  • Memory bound: on a 33 MiB padded result and on a 33 MiB matching call, the largest allocation was 16 MiB cold and 1 MiB warm. Neither record was read whole. The orphan result stays refused.
  • Escaped call ids: toolu_\u0061 now serves its picture.
  • Lookalike ids: none of these authorized the wrong call: lookalikes in prose, nested input, longer ids, literal \u strings.
  • History exclusions: /clear, rewinds, isMeta entries and orphan results are excluded.
  • Larger transcripts: at 66 MiB the warm read grows linearly, and the largest allocation stays at 1 MiB.
  • Tests: the focused suites pass (162), and so does the typecheck. git merge-tree is clean against main and fix(cmd): follow-ups from the Command Code support review #1934.
  • Picture checks: claudeImageType checks the leading bytes against the declared type and caps a picture at 8 MiB decoded.

The maintainer reviewed it as the PR body asks, and approved the merge (relayed by Dori).

CodeRabbit did not review this PR (rate-limited or skipped). The reviews above stand in for it.

@devswha
devswha merged commit b7b33f7 into main Oct 25, 2026
20 checks passed
@devswha
devswha deleted the feat/chat-inline-images branch October 25, 2026 15:20
devswha added a commit that referenced this pull request Oct 25, 2026
…turn (#1945)

Part of #992, the pi part. It follows #1935 (Claude Code), and uses the
same check and the same endpoint rules.

## Change

In a pi pane, Chat dropped the pictures sent to pi: a screenshot pasted
into a prompt was in the session file and never shown, and a prompt that
was only a picture opened no turn, so it vanished. Tool pictures were
shown, but checked only by declared type.

What it does now:

- **Prompt pictures:** a picture in a pi prompt, alone or beside words,
is named in the turn's image parts as `pi-prompt:<entry id>:<place among
its pictures>`, and `GET /api/pane/conversation/image` reads it back by
that ref. Only refs reach the page, never base64; the bytes are fetched
when the prompt is shown.
- **Picture-only prompts** are drawn as a turn and open one for paging
(`turnStarts`), as a prompt with words does.
- **One check:** `inlineImageType` (moved next to the Codex image code)
decides what is a picture for Claude and pi alike, for the parser and
the endpoint: PNG, JPEG, GIF or WebP by declared type and leading bytes,
at most 8 MiB decoded. pi tool pictures now pass it too, so a page never
names a picture the endpoint refuses.
- **Same history as the page:** the endpoint reads a pi picture on the
active `/tree` branch after the last clear, and as the parser draws it:
a tool's picture only from the first result that answers a call the page
shows (not an orphan result, a second answer, or a later block for the
same call), a prompt's only from a prompt the page shows. A clear or an
id is matched however JSON writes it. Records are read one at a time
(`piBranchRecords`, per-record cap), never the whole transcript.
- `scripts/pi-image-browser-qa.ts` now runs in the CI browser lane and
covers a picture-only prompt.

**HTTP contract:** `/api/pane/conversation/image` accepts one more ref
shape (`pi-prompt:`). No new endpoint, no new wire field.

**Design:** no new UI: the prompt thumbnails and the viewer pasted
pictures already use (#951).

## Validation

- **Unit tests** (`server/pi.test.ts`), each failing on the code before
its fix:
- prompt pictures named by entry and place, decoded on request; an svg
or non-raster bytes take no place; refs that name nothing are 404;
  - a picture-only prompt opens a page's turn;
- a picture a `/tree` or a clear left behind is out of the chat and out
of reach;
- a tool's picture only from the result the page draws: a call answered
twice, an answer with no picture before a duplicate, two result blocks
in one entry, a result answering no call, a call made again after an
answer with no picture;
- an escaped `context_clear` and an escaped prompt id, read as the
parser reads them.
- `server/pi-large-history.test.ts`: its tool-picture fixture now
includes the call its result answers (it relied on the endpoint serving
an orphan result's picture, which the page never names); fake image
bytes in `server/omp-incremental.test.ts` are real raster headers now.
- **Browser** (`scripts/pi-image-browser-qa.ts`, real Chrome): the
picture-only prompt is its own turn with its thumbnail decoded from the
served bytes and no empty bubble; the tool row fetches nothing while
folded and decodes both pictures once opened; a result whose pictures
vanish leaves no stranded <img>. Its stub server now answers
`/api/pane/commands` as its siblings do.
- **Reviews:** Codex (Sol 6.1) reviewed the change three times: three
MEDIUMs (escaped clear, a picture from a result the page ignores,
escaped prompt id), then one (a call made again after an answer with no
picture). All fixed with tests. The last review approved with no
findings. One known limit it noted: if a pi session reused a call id and
both results carried a picture, the page would name the same ref twice
and the endpoint serves the first; pi writes unique call ids.
- `bun run check fast`: passes on this head (workflow syntax, generated
types and themes, typecheck, build, 6797 unit tests).

Co-authored-by: mp <mp@local>
mattmarcin added a commit to mattmarcin/ovis that referenced this pull request Oct 25, 2026
Pictures a tool returned (a Read of a screenshot, a browser screenshot) were drawn only inside an
opened work row, and a settled turn's block starts folded, so what the agent saw was two clicks
away. Since devswha#1935 the conversation carries image refs only and Claude refs are served immutable,
so the load-on-open guard from devswha#262 no longer has to hold for a few small thumbnails.

Following the Claude app's folded "Read 2 files" line:
- a folded block's line ends in small thumbnails of every picture its tools returned; opened,
  each row's line carries its own, and an opened row keeps its larger gallery
- hover or keyboard focus shows a larger preview with the tool's id and "n of m", placed above,
  below or on the roomier side inside the viewport, and following the thumbnail as the chat
  scrolls; a touch opens the viewer at once
- a click opens the existing image viewer on all of the line's pictures at that one
- the latest four show (three on a coarse pointer, where each is a --touch-target square), the
  rest are one "+N" tile, so the line never wraps
- a picture that fails to load leaves the line, its count and the viewer

Client only: no endpoint, wire or server change. The pi and Claude image browser QA now expect
the thumbnails on the folded line instead of nothing before the row opens.

Refs devswha#1951, devswha#992
mattmarcin added a commit to mattmarcin/ovis that referenced this pull request Oct 26, 2026
Pictures a tool returned (a Read of a screenshot, a browser screenshot) were drawn only inside an
opened work row, and a settled turn's block starts folded, so what the agent saw was two clicks
away. Since devswha#1935 the conversation carries image refs only and Claude refs are served immutable,
so the load-on-open guard from devswha#262 no longer has to hold for a few small thumbnails.

Following the Claude app's folded "Read 2 files" line:
- a folded block's line ends in small thumbnails of every picture its tools returned; opened,
  each row's line carries its own, and an opened row keeps its larger gallery
- hover or keyboard focus shows a larger preview with the tool's id and "n of m", placed above,
  below or on the roomier side inside the viewport, and following the thumbnail as the chat
  scrolls; a touch opens the viewer at once
- a click opens the existing image viewer on all of the line's pictures at that one
- the latest four show (three on a coarse pointer, where each is a --touch-target square), the
  rest are one "+N" tile, so the line never wraps
- a picture that fails to load leaves the line, its count and the viewer

Client only: no endpoint, wire or server change. The pi and Claude image browser QA now expect
the thumbnails on the folded line instead of nothing before the row opens.

Refs devswha#1951, devswha#992
devswha pushed a commit that referenced this pull request Oct 26, 2026
…ne (#1952)

## Change

Closes #1951 (a UI follow-up to #992). #1951 has no maintainer reply
yet; I'm happy to change the approach or close this if the direction
isn't wanted.

Pictures a tool returned (a `Read` of a screenshot, a browser
screenshot) were drawn only inside an opened work row, and a settled
turn's work block starts folded, so what the agent saw was two clicks
away.
Since #1935 the conversation carries image refs only, and Claude refs
are served `private, max-age=86400, immutable`, so the load-on-open
guard from #262 (keeping base64 out of every poll) no longer has to hold
for a few small thumbnails.

This follows the Claude desktop app's folded `Read 2 files` line, in
three steps:

- **On the line:** a folded block's header line ends in small thumbnails
(2.5rem x 1.5rem) of the pictures its tools returned that the browser
caches: Claude's and pi's. Codex and OpenCode pictures are served
`no-store`, so they stay off the line and load only when their row is
opened, as on main. Opened, each row's line carries its own, and an
opened row keeps its existing larger gallery. The thumbnails sit beside
the header button, not inside it.
- **On hover or keyboard focus:** a larger preview (20rem, 16:9) with
the tool's id and its place (`4 of 6`), above the thumbnail where it
fits, else below, else on the roomier side, always inside the viewport.
It follows the thumbnail when the chat scrolls under it. A touch has no
hover: a tap opens the viewer.
- **On click:** the existing image viewer on all of the line's pictures,
at the one clicked.

Edge cases:

- The latest 4 show (3 on a coarse pointer, where each thumbnail is a
`--touch-target` square), and the rest are one `+N` tile that opens the
viewer at the first, so the line never wraps.
- A picture that fails to load leaves the line, its count and the viewer
instead of showing a broken icon.
- Thumbnails use `loading="lazy"` and only rows the virtualized timeline
mounts draw them.

Client only: no endpoint, wire or server change. The pure parts (which
pictures a line shows, where the preview goes) are in
`src/lib/workImages.ts`.

Behaviour change to note: a folded block now fetches up to 4 Claude or
pi pictures without a click. Each is fetched at full size, since there
is no server-side thumbnail, and only once per browser, since those refs
are served `private, max-age=86400, immutable`. Which refs a line may
fetch is an allowlist (`cachedImageRef` in `src/lib/workImages.ts`,
mirroring the cache rule in `server/pane-routes.ts`): Codex and OpenCode
refs (`no-store`) and any agent not on it load only when their row is
opened. A downscaled variant would be a contract change, so I left it
out.

The `DESIGN.md` entry is under Work block, and the changelog fragment is
`changelog.d/chat-work-line-images.md`.

## Validation

- `bun run typecheck`, `bun run build`, `bun run generate:types --check`
and `bun run generate:themes --check` pass.
- New unit tests in `src/lib/workImages.test.ts` (11 tests: picture
order, which refs a line may fetch with one sample ref per agent, the
line's shown and hidden pictures, preview placement including a viewport
too short for either side) pass, as does `src/lib/i18n.test.ts` with the
two new strings in ko, ja and zh.
- `scripts/pi-image-browser-qa.ts`, updated to the new behaviour, passes
in Chrome. It covers: six pictures giving four thumbnails and `+2` with
only those four fetched, the hover preview and its label, a click and
the tile opening the viewer at the right picture, an opened block and
row handing their pictures down, a picture whose fetch fails leaving the
line, the phone line (three 44px squares, a tap opening the viewer with
no preview) and a keyboard Enter then Escape.
- `scripts/claude-image-browser-qa.ts` is updated to expect the
thumbnail on the folded line, but I could not run it: it needs a Unix
process table and I worked on Windows. It still needs a run in the
browser lane.
- Checked by hand against a live Claude Code session in a preview
server: Read results of real screenshots show on the folded line, hover
and the viewer work.
- `bun run check fast` on the branch rebased onto main, in a Linux
`oven/bun:1.4.2` container: workflow syntax, generated types and themes,
typecheck, build and 7,020 unit tests pass. 61 tests in 6 files
(`server/codex-processes`, `server/copilot`, `server/shell-agent`,
`scripts/self-hosted-runner`, `scripts/ci-runner-route`,
`scripts/install-node-fallback`) fail there with ENOENT or "Executable
not found in $PATH". The same 61 fail identically on unchanged main in
that container, so they come from the bare image, not this PR; CI's Fast
checks run them on the real runner.
devswha pushed a commit that referenced this pull request Oct 26, 2026
…d a Codex tool's output

Part of #992, the omp and Codex part. It follows #1935 (Claude Code) and
devswha pushed a commit that referenced this pull request Oct 26, 2026
…d a Codex tool's output

Part of #992, the omp and Codex part. It follows #1935 (Claude Code) and
devswha added a commit that referenced this pull request Oct 26, 2026
… a Codex tool returns (#1998)

Part of #992, the omp and Codex part. It follows #1935 (Claude Code) and
#1945 (pi), with the same picture check and the same endpoint rules.

## Change

In an omp pane, Chat dropped every picture: a screenshot sent with a
prompt, a prompt that was only a picture, and the picture a `read`
returned. omp moves a picture's bytes out of the transcript into its
blob store and writes `blob:sha256:<digest>` in their place, so there
was nothing to decode. In a Codex pane, a picture a tool returned
(`view_image`, an image generation, a screenshot a command read) was
dropped too: only prompt pictures were read.

What it does now:

- **omp prompt pictures** are named as pi's are, `pi-prompt:<entry
id>:<place>`, and a prompt that is only a picture is a turn of its own
and opens one for paging (`turnStarts`).
- **omp tool pictures** are named `pi:<call id>:<place>` on the tool's
row. omp's call ids hold a `|` (`call_…|fc_…`), which the ref shape now
takes.
- **omp's blob store:** omp 18.8.7 keeps a session store at
`<data>/sessions` and its blobs at `<data>/blobs` (`getBlobsDir`, the
same `data` base), so `ompBlobStore` names the store beside the
transcript's real session store (the default agent directory, a
profile's, `PI_CODING_AGENT_DIR`'s or the XDG one), by layout alone,
whether omp has made it yet or not. A blob is read only by omp's own
64-hex digest and only when its bytes hash to that digest. The image
endpoint takes the store's identity from the objects that authorized the
pane's transcript (`ompAuthorizedTranscript`): the ownership check
returns the store's real root and the dev:ino of the transcript file it
opened, and the agent data directory is then opened once, without
following a link and held to the path named, and `sessions`, the path
down to that same transcript file (each component without following a
link) and `blobs` are all reached from that one held descriptor. It
reads a blob only from that very directory: the store is opened as a
directory without following a link, its descriptor must have that
identity (`fstat` dev:ino) and be the directory the path names
(`/proc/self/fd`), and the blob is opened through that descriptor
(`O_NOFOLLOW`). So no directory or link swapped in afterwards, at the
store or above it, can stand in for it. A store that is missing, a link,
or not a directory answers nothing. **Platform limit:** Node has no
descriptor-relative open on macOS or Windows (checked on macOS), and a
blob opened by name there follows whatever a directory above it is
swapped to for that moment, so there no omp blob is read: blob-backed
omp pictures are not shown on those PCs, while omp's inline pictures and
every Codex picture are (follow-up #2004). A session in a
`--session-dir` of its own names no data directory: its blob pictures
stay unnamed, and inline ones still show.
- **Codex tool pictures:** the `input_image` data URLs in a
`custom_tool_call_output` or `function_call_output` are named
`codex-tool:<call id>:<place>` on the tool's row, for any tool. The
`ImageView` and image-generation events that repeat them are not read,
so each picture shows once. They are served `no-store` like Codex's
other refs, so they load only when their row is opened (as #1952's work
line requires).
- **One check, both sides:** a blob or a data URL is a picture only as
PNG, JPEG, GIF or WebP by declared type and leading bytes, at most 8
MiB, and the parser and the endpoint ask the same question
(`inlineImageType`, `ompBlobPicture`), so the page never names a picture
the endpoint refuses.
- **Same history as the page:** the endpoint reads an omp picture after
the last clear (also one JSON writes with escapes), a tool's picture
only from the first result answering a call the page draws, a prompt's
only from a prompt it draws; a Codex tool's picture only from the first
output answering a call the page draws, in the rollouts the page reads
(`codexHistorySegments`, without the bytes a backtrack left). Ids are
matched however JSON writes them. Like Claude's, it searches a window at
a time and reads a record's shape a window at a time (`recordShape`,
which Claude's reader now shares), holding only the served picture
whole; a picture only counted on the way to the served one is checked by
a streaming scan that answers exactly as the whole-string check. The omp
and Codex readers run in steps a 1 MiB window apart, and every 32
records, and give the event loop its turn between them; the scan for
clears runs in steps too, on its own copy of what it keeps. So a lookup
never holds the bridge for more than a window's work (Claude's reader
and page reads run the same steps straight through, unchanged).

**HTTP contract:** `/api/pane/conversation/image` accepts one more ref
shape (`codex-tool:`) and answers omp's `pi:`/`pi-prompt:` refs. No new
endpoint, no new wire field (`tool.images` and image parts already
exist).

**Remote bundle:** the server files are in the remote PC bundle.
`REMOTE_BUNDLE_VERSION` is not raised here; the release does that
(0.4.18 raised it to 37 and its Release run has finished).

**Design:** no new UI: the prompt thumbnails, the work line, the row
gallery and the viewer that Claude and pi pictures already use.

**Not in this PR:** omo and gjc (no recorded sessions with pictures
here; they name none, as before), omp's `xd://generate_image` pictures
that live only in `details`, and local Markdown images in answers.

## Validation

- **Recorded fixtures** from real CLIs on this PC, picture bytes kept as
recorded:
- `server/fixtures/omp-pictures-18.8.7-session.jsonl` and its blob
`omp-pictures-18.8.7-blob.webp`: omp 18.8.7 (`omp -p --model
openai-codex/gpt-6-luna:medium`) with `@shot.png` and a question, a
`read` of shot.png (call id `call_…|fc_…`), and `@shot.png` alone. omp
turned the PNG into a WebP and moved it to its blob store.
- `server/fixtures/codex-pictures-0.163.0-rollout.jsonl`: codex-cli
0.163.0, `codex exec -i shot.png` then `codex exec resume` calling
`view_image` through the exec tool. Only the records the chat reads are
kept (no account ids, instructions, environment or encrypted reasoning).
- **Unit tests** (`server/omp-images.test.ts`, new;
`server/codex-images.test.ts`), each shown failing with its fix undone
(21 mutations, every one fails its test):
- the recorded sessions name their pictures by ref only (no base64, no
blob ref in the page) and the endpoint serves their exact bytes;
- refused, at the parser and the endpoint alike: an svg, non-raster
bytes under a raster type, a picture past 8 MiB (exactly 8 MiB passes),
a remote URL, a blob ref that is no digest omp writes, a missing blob,
bytes that do not hash to their name, a blob that is a link, malformed
refs;
- a blob that goes or changes while the bridge runs keeps its place: its
ref is a 404 and the next picture keeps its own ref;
- a tool's picture only from the result or output the page draws: an
orphan, a second answer, a call made again after an answer with no
picture, a `function_call` output as well as a custom tool's;
- a picture from before a clear (also an escaped `context_clear`) is out
of the chat and out of reach;
- call ids and entry ids written with JSON escapes (omp's `|` among
them) are named and served as the parser reads them;
- a picture-only omp prompt is its own turn and opens a page there
(`turnStarts`); a growing session names the same refs as a cold read;
- memory: a call and a result each padded with 20 MiB, two 3 MiB blobs,
and a 2 MiB escaped inline picture before the served one: no allocation
past a 1 MiB window except the served picture;
- the streaming checks answer exactly as `inlineImageType` and the data
URL check do, for every two-piece and many three-piece cuts, including a
cut inside the padding at exactly 8 MiB.
- `server/pi.test.ts`: the omp case of the picture-only `turnStarts`
test now expects a turn (omp draws its prompt pictures now).
- **HTTP contract** (`server/omp.contract.test.ts`,
`server/codex.contract.test.ts`, on an isolated herdr via `bun run check
run`): the recorded omp session's three refs answer `image/webp` with
the blob's exact bytes and `private, max-age=86400, immutable`; the
Codex `codex-tool:` ref answers `image/png` with the viewed PNG's bytes
and `no-store`, and 404 once the rollout no longer holds it; unnamed and
malformed refs are 404. 8/8 pass.
- **Real transcripts on this PC** (shapes only, nothing printed): 36 omp
sessions with 652 blob pictures name 650 refs (1 prompt, 649 tool) and
the endpoint serves all 650; 7 Codex rollouts name 23 tool-picture refs
and the endpoint serves all 23. No page carries base64 or a blob ref.
- **Browser** (`scripts/omp-codex-image-browser-qa.ts`, real Chrome,
added to the CI browser lane), served by the endpoint's own readers from
the recorded files: omp's three prompt pictures decode from the blob
store (200x200 WebP), the picture-only prompt is its own turn with no
empty bubble, the `read` picture shows on its folded work line, is
fetched by its `|` call id and opens the viewer; a Codex tool's picture
stays off the folded line with no element requesting it, and decodes
(32x32) once its row is opened, beside the prompt's own attachment; at
390 px nothing spills past the screen. Desktop and phone screenshots
checked.
- **Merge pass gate** (Astra), two rounds, every blocker fixed and
reviewed again (see the gate follow-up comments):
- On ae860b0: C1, a symlinked blobs directory served another store's
picture; C5, the readers blocked the event loop (225 ms on a warm 64 MiB
lookup).
- On 5c1bc56: B1, an agent directory swapped for a link after the
ownership check still moved the read (the store was found again from
`realpath`); B2, the macOS/Windows by-name open is racy on an
intermediate path; C5, 30,000 short records still held the loop 211 ms,
and the scan for clears was synchronous.
- On 64c8527: C1a, a directory swapped between the ownership check and
the anchor lent another store (the anchor walked the path again); then,
raised by Codex, the store's sessions reparented under another agent
directory. Fixed by the one-held-descriptor anchor above; tests swap the
agent directory, move another real sessions in, and reparent, through a
hook right after the data directory's open. On a947a19, round 4: moves
before the data directory's open adopt another data directory. Decided
trust boundary (a): write access to the user's own omp data directory;
the directory at that path when the anchor opens it is trusted, and the
transcript and blob store always come from that one held descriptor
(tests before and after the open, 1ef6bf8).
- Fixes, as described above: the descriptor-relative open held to the
identity taken at authorization; no blob read off Linux; yields every 32
records and per clear-scan window. Tests: through a test seam that acts
at each open, a link or another real store swapped in for the store, or
for the agent directory above it, at the store's or the blob's open; the
agent directory swapped after authorization; the non-Linux branch
forced; the longest stretch between loop turns bounded in buffers taken
(no clocks) over 30,000 records and 40 MiB, cold. Each defence is shown
failing its test when removed.
- Measured: 30,000 short records over 30.5 MB, longest event-loop stall
3.9 ms warm (omp), 33.5 ms cold (one 16 MiB window of the clear scan),
Codex 2.1 ms; a warm 64 MiB lookup 2.1 ms.
- On the way, the code reviewer found the store named null before omp
made it, so a live page missed pictures a cold read names (fixed: named
by layout), and Codex found a link, then another real directory, swapped
in at the open, and the anchor taken only after the async resolve (all
fixed as above). Both approve the final commits. One gap left as a known
one: the scan for clears working on its own copy has no test of its own
(without it, a page read in the middle of an image read redoes the
scan).
- **Reviews:**
- `omo-native-code-reviewer`: APPROVE on 4a9a574 (then 7005452d, before
the rebase), with one MEDIUM (a blob deleted while the bridge runs could
move the next picture into its ref) and four LOWs (refusals re-read
every poll, the blob cache surviving a reset, weak spots in the browser
QA, earlier inline pictures read whole to count them).
- Codex (Sol 6.1): REQUEST CHANGES on 4a9a574 (then 7005452d, before
the rebase): the same MEDIUM, a MEDIUM that a picture only counted on
the way to the served one was read whole (a blob hashed whole to name
it, a data URL rebuilt to count it), and a LOW that the browser QA could
pass on an undecoded picture.
- All fixed in ae860b0 (fcc0187a before the rebase) with tests: the
place model, a per-file blob cache that keeps refusals, streaming
checks, the QA's decode and error checks. Both reviewed the delta again:
APPROVE, every finding FIXED, no new finding from Codex. The code
reviewer's one new LOW is left as is: the served inline picture is read
from the file twice (once checked, once held), up to about 11 MB of
extra reading and no extra memory; holding it during the check would
mean holding a picture before it passes, which the memory rule forbids
for any picture not served.
- `bun run check fast` on 1ef6bf8: workflow syntax, generated types and
themes, typecheck and build pass, and 7265 of 7266 unit tests pass. The
one failure is the known slot-admission flake in `scripts/check.test.ts`
(`slots > gives its place up when it stops waiting`: ticket ports taken
on a busy host), in a file this PR does not touch, which passes 66/0
alone. The run before it had only an untouched load-timing failure
(`scripts/install-node-fallback.test.ts`, hung-host kill, 10/0 alone).
Counted as passed per the lane's rule for known slot-admission flakes;
GitHub CI runs the full suite.

---------

Co-authored-by: mp <mp@local>
devswha added a commit that referenced this pull request Oct 31, 2026
## Change

Part of #992 (pictures in Chat). Chat showed transcript pictures for
Claude, Codex, omp, pi and OpenCode, but not for GitHub Copilot CLI,
though Copilot keeps them in its own session file.

Copilot CLI 1.0.105 interns each picture once, as a root
`session.binary_asset` record (base64, `assetId: "sha256:<digest of the
bytes>"`). A prompt's `attachments[].assetId` and a tool's
`result.binaryResultsForLlm[].assetId` name it by that id (checked
against the SDK's `session-events.d.ts` and a real recording).

- **Parser** (`server/copilot.ts`): a prompt's attached pictures become
image parts and a tool's become its `images`, each named
`copilot:<digest>`. Only refs reach the page. A picture-only prompt
opens a turn, and `transcript-turns.ts` agrees for paging.
- **Endpoint** (`GET /api/pane/conversation/image`, no new route): reads
only the pane's own pinned Copilot session file (`openCopilotFile`). It
serves a root record only (no sub-agent), a raster within
`MAX_IMAGE_BYTES` (`inlineImageType` + magic bytes), and only bytes
whose sha256 equals the ref. It reads in 1 MiB windows and skips any
line longer than the largest picture record without holding it. Served
immutable because the ref is the content digest; `workImages` keeps
`copilot:` refs like Claude's and pi's.

Design: same image part, ref route and viewer as the pi/Claude pictures
(#1935, #1945); no new UI.

## Validation

- Real fixture: `server/fixtures/copilot-pictures-1.0.105-events.jsonl`,
recorded on this PC with `copilot -p ... --attachment red.png` plus the
`view` tool reading `blue.png` (redacted; reasoning blobs and usage
records dropped).
- Failing first: the new `server/copilot.test.ts` case failed on the
parser (`[]` instead of the image part), then passed.
- `bun run check fast`: all steps ok, unit **9828 pass, 0 fail, 41
skip** (on 946a6e6).
- `bun scripts/copilot-image-browser-qa.ts` (added to the CI browser
lane): desktop + phone, both pictures decoded at 48x48.
- `server/copilot.contract.test.ts` (new end-to-end case: pane-scoped
404, cache header) could not run locally. Its `beforeAll` fails with
"isolated Copilot stand-in not detected" on unchanged `origin/main` too
(herdr 0.9.5 here); CI runs it.

## Reviews

- omo-native-code-reviewer: **PASS / APPROVE**. Escape from the pinned
file, sub-agent records, SVG, symlink and fd swap were all probed and
refused. MEDIUM: whole-line memory in the lookup, fixed in 946a6e6.
- Codex Terra 6.1 fast xhigh, round 1: two MEDIUMs. (1) Unbounded line
memory: fixed, RSS for a 64 MiB junk line went from 173 MB to 33 MB, and
a test covers it. (2) A 16 MiB page window splits a turn holding big
tool pictures: this reproduces identically on `origin/main`, so it is
filed as #2478. Delta round: MEDIUM, a final record without a newline
was dropped. Fixed, with a test.
devswha added a commit that referenced this pull request Oct 31, 2026
## Change

Part of #992 (pictures in Chat), after #2479 (Copilot). Grok CLI 1.0.67
logs a session's pictures inline in its own `updates.jsonl`:
- a prompt's `user_message_chunk` with `content: { type: "image", data,
mimeType }`, and
- a tool update's `content: [{ type: "content", content: { type:
"image", ... } }]` (here `read_file` reading a PNG).

What changes:
- **Parser** (`server/grok.ts`): prompt pictures become image parts and
tool pictures become the tool's `images`, each named `grok-image:<sha256
of the bytes>`. Hidden prompt chunks are skipped, ACP's
replace-the-whole-`content` rule is honoured, and only refs reach the
page.
- **Endpoint** (`GET /api/pane/conversation/image`, no new route): reads
only the pane's own Grok update log (`resolveGrokStore`), over the
history `grokProjection` keeps active. A prompt that was rewound away
serves nothing, including one rewound while the lookup reads.
  - It checks that the file it opened is still the one the path names.
  - It reads 1 MiB windows with the event loop running between them.
- It serves a raster within `MAX_IMAGE_BYTES` whose sha256 matches the
ref, so the response is immutable.
- `workImages` keeps `grok-image:` refs, like Claude's, pi's and
Copilot's.

Design: same image part, ref route and viewer as the other agents'
pictures (#1935, #1945, #2479); no new UI.

## Validation

- Real fixture: `server/fixtures/grok/pictures-1.0.67.jsonl`, recorded
on this PC: `grok --prompt-json` with a red PNG, then `read_file
./blue.png`, through the owner's CLIProxy (`gpt-5.6-luna`, isolated
`GROK_HOME`). Paths are redacted.
- Failing first: the new `server/grok.test.ts` case failed on the parser
(`[]` instead of the image part), then passed. Added cases cover a
rewind before and during a lookup, a file swapped into the path during a
lookup (mutation-checked: fails without the identity pin), an escaped
`"im\u0061ge"`, and a missing digest.
- `bun run check fast` on 3a9858c: all steps ok, unit **9828 pass, 0
fail, 41 skip**.
- `bun scripts/grok-image-browser-qa.ts` (added to the CI browser lane):
desktop + phone, both pictures decode at 48x48.
- Lookup cost: a 6.6 MB text-only log with a missing digest takes 50 ms,
and a 10 ms timer keeps firing. The first version took 4 s or more on
2.4-4.8 MB logs.

## Reviews

- Codex Terra 6.1 fast xhigh:
- Round 1: HIGH (quadratic read with no yield), MEDIUM (a prompt rewound
during the lookup was still served), LOW (escaped type). All fixed in
3a9858c.
- Delta round: MEDIUM (a file swapped into the path during the lookup).
Fixed, with a test. MEDIUM (the final revalidation may catch up up to 32
MiB of new records synchronously): this is the same `SCAN_BYTES` bound
every Grok page poll already pays, so it is not new here.
- omo-native-code-reviewer: REQUEST_CHANGES on the same HIGH, now fixed.
L2 (open, then check the path still names it) is fixed too.
- L1 (a picture a later update replaced is still served from the active
history) is left as is: it is the pane's own history, so nothing leaks.
  - L4: the parser hashes each picture on every parse; not measured.
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