Skip to content

fix(daemon): don't persist browser previews to the transcript#167

Merged
edwin-zvs merged 1 commit into
mainfrom
no-persist-browser-preview
May 23, 2026
Merged

fix(daemon): don't persist browser previews to the transcript#167
edwin-zvs merged 1 commit into
mainfrom
no-persist-browser-preview

Conversation

@edwin-zvs

Copy link
Copy Markdown
Contributor

Browser preview events (SessionEvent::BrowserPreview) carry a full-size Chrome screenshot as a base64 PNG. They were falling through to append_event, so each screenshot was written as a line in transcript.jsonl.

Why this is a problem

  • Bloat: the browser tool base64-encodes the raw, full-resolution screenshot (adapter-zarvis/.../tools/browser.rs — no shrink before emit; base64 adds ~33%). Every browser_open / browser_screenshot preview added a 50 KB–500 KB+ line.
  • Slow loads: read_transcript reads and JSON-parses every line, and session.transcript ships the whole result over the wire — so each client load (TUI hydration / webui loadTranscript) paid for all those big lines.
  • No consumer: after feat(webui): browser preview as top-right terminal overlay + session-scoped, ephemeral thumbnails #162, both clients render previews only from the live broadcast and explicitly skip BrowserPreview during transcript replay. The persisted images were pure dead weight.
  • Model leak: agentd_get_transcript (MCP) returns the raw transcript JSON to the model, so persisted previews could dump full base64 screenshots into model context — exactly what BrowserPreview's doc says not to do.

Fix

Skip persistence for BrowserPreview and broadcast to live clients only — the same treatment AgentStatus (also ephemeral live UI state) already gets. Returns before append_event.

The live overlay + matrix-rain wallpaper are unaffected (both fed by the broadcast, not the transcript). Existing transcript.jsonl files are left as-is (not retroactively cleaned).

Tests

  • New browser_preview_is_not_persisted_to_transcript: emits a BrowserPreview + a control Message via handle_event, then asserts the transcript contains the Message but not the BrowserPreview.
  • Full daemon suite (36) + e2e (web_smoke, tui_smoke, restart, remote_control) green locally.

🤖 Generated with Claude Code

Browser preview events (`SessionEvent::BrowserPreview`) carry a full-size
Chrome screenshot as a base64 PNG. They were falling through to
`append_event`, writing each screenshot as a line in transcript.jsonl —
bloating the file and slowing every load (`read_transcript` reads and
JSON-parses every line, and `session.transcript` ships the lot over the
wire). Since previews are ephemeral, live-only UI that clients now render
only from the live broadcast (never from transcript replay), the persisted
images had no consumer; they also leaked into model context via
`agentd_get_transcript`.

Skip persistence and broadcast to live clients only — the same treatment
`AgentStatus` already gets. The live overlay + matrix-rain wallpaper are
unaffected (both fed by the broadcast). Existing transcripts are left
as-is.
@edwin-zvs
edwin-zvs merged commit af6383e into main May 23, 2026
1 check passed
@edwin-zvs
edwin-zvs deleted the no-persist-browser-preview branch May 23, 2026 13:48
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