Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(server): report image dimensions with signed asset URLs #10198

Mergedjuliusmarmingemerged 4 commits intomain fromrefs/pull/10198/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Stack 1/3 (#10201). Follow-ups: #10199 (mobile), #10200 (web).

Problem

Both clients reserve a 16:9 slot for a chat image while its bytes load, then resize to the natural size once decoded. That last resize moves every row below the image, and on mobile it can push the end of the thread behind the composer or leave the next tool call drawn under the image (see #10199). The clients can't do better without knowing the size up front.

Fix

The server already opens the file when it issues a signed asset URL, so it now reads the pixel size from the PNG, JPEG, GIF, or WebP header and returns it as an optional imageDimensions on AssetCreateUrlResult. packages/client-runtime threads it onto AssetUrlState.Success so both clients see it.

  • packages/shared/src/imageDimensions.ts — dependency-free header parser. JPEG honours the EXIF orientation tag (5–8 swap the axes), since every viewer applies it before display and phone photos are stored on their side.
  • For media-file resources the header is read through the same identity-checked handle used for the inode check, so there's no second open to swap. Only formats the parser understands are read (SVG, AVIF, ICO skip).
  • Best effort: unreadable or unsupported files omit the field and the client falls back to measuring after decode. Older clients ignore the field; older servers omit it.

Compatibility

Additive optional field. Schema.optional on the contract; unknown keys are ignored by older clients.

Verification

  • packages/shared: imageDimensions.test.ts — PNG, GIF, JPEG (with APP1 prefix, Huffman-table marker skip, EXIF orientation 6 vs 1), all three WebP flavours, truncated/zero-size/unsupported input. 7 passed.
  • apps/server: AssetAccess.test.ts — a real PNG header reports 1600×900, an mp4 and a malformed .png omit the field. 27 passed.
  • Typecheck clean for packages/shared, packages/contracts, packages/client-runtime, apps/server.

No visual change on its own; screenshots are on the client PRs.

Model: Claude Fable 5 · Harness: Claude Code in T3 Code

🤖 Generated with Claude Code

Note

Report image dimensions with signed asset URLs

  • Adds a shared image-header parser in imageDimensions.ts that extracts pixel width and height from PNG, GIF, WebP, and JPEG headers, returning null for unsupported or malformed input. JPEG parsing also applies EXIF orientation axis swaps for values 5-8.
  • Integrates parsing into AssetAccess.ts so issueAssetUrl reads a bounded header prefix from already-open media handles for supported extensions (png, jpg, jpeg, gif, webp) and includes imageDimensions in the result when parsing succeeds.
  • Updates assets.ts contracts and assets.ts client state to carry the optional imageDimensions field through successful asset URL results.
  • Risk: dimension extraction is best-effort and never blocks URL issuance, but callers reading AssetCreateUrlResult or AssetUrlState.Success should treat the new optional imageDimensions field as potentially absent.
Macroscope summarized 0c0d4ea.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. juliusmarminge changed the title

    3. 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 wire13.5 KiB13.6 KiB+27 B (+0.2%)15.1 KiB✅
      CodexThread snapshot wire7.0 KiB7.0 KiB−2 B (−0.0%)7.3 KiB✅
      CodexLive turn WebSocket wire6.5 KiB6.5 KiB+29 B (+0.4%)7.8 KiB✅
      CodexLive turn WebSocket decoded57.0 KiB57.0 KiB0 B (0.0%)66.4 KiB✅
      CodexLive turn messages880 (0.0%)21✅
      ClaudeTotal thread wire13.5 KiB13.6 KiB+23 B (+0.2%)15.1 KiB✅
      ClaudeThread snapshot wire7.0 KiB7.0 KiB−3 B (−0.0%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.5 KiB6.5 KiB+26 B (+0.4%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded57.8 KiB57.8 KiB+44 B (+0.1%)66.4 KiB✅
      ClaudeLive turn messages89+1 (+12.5%)21✅

      Baseline: f8b4c46 · PR result: 0c0d4ea · 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: 113.8 KiB
      • Claude decoded thread snapshot: 114.5 KiB

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

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

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This PR adds a new cross-package image-header parser and changes existing asset URL issuance to perform bounded file reads and return optional dimensions. Although the API addition is backward-compatible, the new production-path logic and user-facing capability warrant human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. Bugbot is paused — on-demand spend limit reached

      Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

      A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

    6. juliusmarminge merged thise2e6ce6

    7. juliusmarminge closed this

Sign in to join this conversation.