Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix: tool screenshots show as images, not base64 text #16199

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 4 commits intomain fromrefs/pull/16199/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Problem

When an agent takes a device screenshot (or a preview snapshot with an image), expanding the tool row shows a wall of base64 JSON instead of the image.

Screenshots are 300 to 630 KB. The detail read for an expanded tool row caps output at 256 KB, so the server cut the output into a JSON string and clients printed it as text. Under the cap, clients only showed [image].

Change

Image bytes no longer go over the WebSocket. Clients load each image over HTTP, through the same signed /api/assets URLs that attachments use.

  • Detail read (WireProjection.ts): replaces each image's bytes with { type: "image", mimeType } and keeps its position. On real rows the expanded output went from about 600 KB to under 1 KB. If the remaining text is still too large, the truncated text keeps the image markers.
  • New asset resource tool-output-image { threadId, itemId, index }: the server reads the stored item, decodes the image, and serves the bytes with nosniff and a private cache. When it signs the URL, it also returns the pixel size, so clients reserve the right box before the image loads.
  • Parser (shared/toolOutput.ts): reads the MCP { data, mimeType } shape and the { source: { media_type, data } } shape that Claude stores. Only PNG, JPEG, GIF, and WebP are served, so an agent cannot get SVG or HTML served inline. At most 8 images per tool call, and an image larger than a provider turn accepts (10 MB) is not decoded.
  • Web and desktop: the image shows in the tool inspector. Click it to open the full-size view.
  • Mobile: the image shows in the expanded work-log row. Tap it to open the preview.

Not changed:

  • Claude Read image rows already show the file from its path.
  • Codex: the adapter keeps only structuredContent for MCP results, so Codex threads store no screenshot bytes and show no image. Codex rows still show structured JSON, not base64. Storing screenshot bytes for Codex is a separate storage decision (see #11295).

Scope and approval

Maintainer request. Theo reported this from a real thread.

Verification

  • Web, isolated dev server seeded from real data: expanding "Took a screenshot of the device" in the reported thread shows the 920x2000 PNG. Clicking it opens the full-size view. The asset returns 200 image/png (447 KB) with nosniff and a private cache. A tampered token returns 404.
  • iOS (iPhone 17 Pro Max simulator), same backend: the expanded row shows the screenshot, and tapping it opens the full-size preview.
  • Tests: parser shapes and type allowlist, 8-image cap, detail read without bytes, markers kept for oversized output, asset sign and serve with pixel size, size cap before decoding, client text and image helpers.
  • Checks: typecheck passes in contracts, shared, client-runtime, server, web, and mobile.
Before (web)After (web)
Expanded screenshot row shows base64 JSONExpanded screenshot row shows the image

Full-size view on web:

Clicking the screenshot opens the full-size view

iOS inlineiOS preview
Expanded screenshot row on iOS shows the imageTapping the screenshot on iOS opens the preview

On iOS the work group keeps its existing 256 pt height cap and scrolls inside, so a tall screenshot shows partly until you scroll the group or tap it. This is the same as the viewed-image rows.

Reviewed with sol-loop: 4 rounds with GPT-6.1-Sol on high.

Created with Claude Opus 5.5 in Claude Code.

🤖 Generated with Claude Code

    1. juliusmarminge added labelsmacroscope-review

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This change adds a cross-platform production path that extracts tool screenshots, serves decoded bytes through signed asset URLs, and renders them in web and mobile work logs. An unresolved High-severity finding also reports that base64 whitespace can cause valid images within the size limit to be rejected.

      Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB4.9 KiB−23 B (−0.5%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB−23 B (−1.9%)2.0 KiB✅
      CodexLive turn WebSocket decoded20.9 KiB20.8 KiB−41 B (−0.2%)29.3 KiB✅
      CodexLive turn messages21−1 (−50.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB−31 B (−0.6%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB−31 B (−2.5%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB−41 B (−0.2%)29.3 KiB✅
      ClaudeLive turn messages21−1 (−50.0%)8✅

      Baseline: 24238fe · PR result: 766602e · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    5. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
      • Review profile: CHILL
      • Plan: Team
      • Run ID: 099c3644-8b82-4ec8-9814-3e6757556bfc
      📥 Commits

      Reviewing files that changed from the base of the PR and between 24238fee321e2c6bc711832b8cf3698b1f6b30ca and 766602e54e3ed375fafc3bfca8dc41748ce020f4.

      📒 Files selected for processing (17)
      • apps/mobile/src/features/threads/ThreadFeed.tsx
      • apps/mobile/src/features/threads/ThreadMarkdownImage.tsx
      • apps/mobile/src/features/threads/thread-work-log.tsx
      • apps/server/src/assets/AssetAccess.test.ts
      • apps/server/src/assets/AssetAccess.ts
      • apps/server/src/http.ts
      • apps/server/src/orchestration-v2/WireProjection.test.ts
      • apps/server/src/orchestration-v2/WireProjection.ts
      • apps/server/src/ws.ts
      • apps/web/src/components/ChatMarkdown.tsx
      • apps/web/src/components/chat/MessagesTimeline.tsx
      • apps/web/src/components/chat/V2ItemInspector.tsx
      • packages/client-runtime/src/work-log/itemDetail.test.ts
      • packages/client-runtime/src/work-log/itemDetail.ts
      • packages/contracts/src/assets.ts
      • packages/shared/src/toolOutput.test.ts
      • packages/shared/src/toolOutput.ts

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


      📝 Walkthrough

      Walkthrough

      Dynamic-tool output can include supported inline images. The change extracts images into indexed asset resources, serves them through signed asset URLs, and renders them in web and mobile tool-output views with preview handling.

      Changes

      Tool-output image handling

      Layer / File(s)Summary
      Image contracts and extraction
      packages/contracts/src/assets.ts, packages/shared/src/toolOutput.ts, packages/shared/src/toolOutput.test.ts, packages/client-runtime/src/work-log/itemDetail.ts, packages/client-runtime/src/work-log/itemDetail.test.ts
      The asset contract adds indexed tool-output-image resources. Shared helpers extract supported MCP and Anthropic base64 images, cap results at eight, and omit image bytes. Item-detail helpers expose indexed assets and exclude readable images from extracted text.
      Tool-output wire projection
      apps/server/src/orchestration-v2/WireProjection.ts, apps/server/src/orchestration-v2/WireProjection.test.ts
      Dynamic-tool detail projection omits image bytes, retains image markers in order, and bounds output. Tests cover oversized text and image counts.
      Signed image asset delivery
      apps/server/src/assets/AssetAccess.ts, apps/server/src/assets/AssetAccess.test.ts, apps/server/src/ws.ts, apps/server/src/http.ts
      The server issues and resolves signed URLs for indexed tool-output images. The HTTP route returns image bytes with their MIME type, a private cache policy, and nosniff. Tests cover dimensions, bytes, missing indexes, and oversized images.
      Web and mobile image rendering
      apps/web/src/components/ChatMarkdown.tsx, apps/web/src/components/chat/*, apps/mobile/src/features/threads/*
      Web and mobile tool-output views render extracted images. The timeline and work-log paths pass image expansion or preview callbacks to the image components.

      Priority: ⬇️ Low

      Estimated code review effort: 4 (Complex) | ~40 minutes

      Change: Bug fix

      Sequence Diagram(s)

      sequenceDiagram
        participant WireProjection
        participant V2ItemInspector
        participant assetsCreateUrl
        participant AssetAccess
        participant Orchestrator
        participant HTTPAssetRoute
        WireProjection->>V2ItemInspector: bounded output with image markers
        V2ItemInspector->>assetsCreateUrl: indexed tool-output-image resource
        assetsCreateUrl->>AssetAccess: issue asset URL
        AssetAccess->>Orchestrator: getTurnItem(threadId, itemId)
        Orchestrator-->>AssetAccess: stored turn item
        AssetAccess-->>V2ItemInspector: signed asset URL
        V2ItemInspector->>HTTPAssetRoute: request image asset
        HTTPAssetRoute->>AssetAccess: resolve signed claims
        AssetAccess-->>HTTPAssetRoute: image bytes and MIME type
        HTTPAssetRoute-->>V2ItemInspector: image response

      Suggested reviewers: juliusmarminge, maria-rcks

      Merge Risk: ⚪ Minimal · up to 76660

      No identified issue blocks merging the tool-output image change after normal checks.

      🚥 Pre-merge checks | ✅ 4 | ❌ 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 17 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Title check✅ PassedThe title clearly summarizes the main change: tool screenshots now display as images instead of base64 text.
      Description check✅ PassedThe description covers the problem, change, scope, and verification. It also includes before-and-after screenshots and platform-specific results. The scope section says this was a maintainer request b…
      • Fix all pre-merge checks with AI
      ✨ 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
      • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Sign in to join this conversation.