Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(web): preview document attachments in the file viewer #9292

Mergedjuliusmarmingemerged 2 commits intomain fromrefs/pull/9292/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

What changed

  • Clicking a sent PDF or HTML attachment opens it in the right-panel file viewer, with a separate download button next to it. Other attachments download as before.
  • The attachment asset resource gains an optional disposition. A document viewer sends inline; generic attachments still download by default and the server only honors inline for application/pdf and text/html, with the same CSP HTML previews already get.
  • FilePreviewPanel takes an optional attachment and hides the workspace tree, breadcrumbs, editor, and "open in browser" affordances for it. shouldShowFileExplorer is the one place that decides whether the tree shows.
  • Attachment surfaces live under attachment:<id> in the right panel store so they never collide with a workspace file at a matching path, and they survive the workspace going away.

Why

Agents and users share PDFs and HTML reports as attachments all the time, and until now the only thing you could do with one was download it. Workspace files already preview in place; attachments should too.

Split out of #9253, which stays a refactor.

Testing

  • rightPanelStore.test.ts, MessagesTimeline.test.tsx, FilePreviewPanel.test.ts (web)
  • AssetAccess.test.ts, http.test.ts (server)
  • Web, server, and contracts typecheck; lint and format on changed files

Created with Claude Fable 5 using the Claude Code harness in T3 Code.

🤖 Generated with Claude Code


Note

Medium Risk Changes attachment serving and inline HTML/PDF headers (security-sensitive), but extension checks and existing HTML sandboxing limit exposure; mostly UI and signed-URL claim logic.

Overview PDF and HTML chat attachments can be opened in the right-panel file viewer on web/desktop, with a separate download control. Other file types still download when clicked.

The attachment asset contract adds optional disposition (inline / attachment). The preview panel requests inline; the server only honors it when the attachment id’s stored extension is pdf, html, or htm—not the client-supplied MIME type—so a zip cannot be forced inline. Inline PDF/HTML responses get the same Content-Type and HTML CSP behavior as workspace document previews; non-document inline requests stay download-forced.

Right panel gains openAttachment and attachment:<id> surfaces (disjoint from workspace file: tabs). Attachment previews work without an active workspace and survive workspace reconciliation. FilePreviewPanel accepts an optional attachment, loads a signed URL in a shared document iframe, and shouldShowFileExplorer hides the tree for attachments and host paths.

Messages timeline shows preview + download for browser-preview attachments (isBrowserPreviewAttachment) instead of a single download link.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 807c0feaf163595beeb12d1ccd118331455e7f86. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. 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.4 KiB13.3 KiB−148 B (−1.1%)15.1 KiB✅
      CodexThread snapshot wire6.9 KiB6.9 KiB+3 B (+0.0%)7.3 KiB✅
      CodexLive turn WebSocket wire6.5 KiB6.4 KiB−151 B (−2.3%)7.8 KiB✅
      CodexLive turn WebSocket decoded57.0 KiB55.6 KiB−1.4 KiB (−2.5%)66.4 KiB✅
      CodexLive turn messages10100 (0.0%)21✅
      ClaudeTotal thread wire13.3 KiB13.5 KiB+204 B (+1.5%)15.1 KiB✅
      ClaudeThread snapshot wire6.9 KiB6.9 KiB−1 B (−0.0%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.4 KiB6.6 KiB+205 B (+3.1%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded56.3 KiB57.8 KiB+1.5 KiB (+2.7%)66.4 KiB✅
      ClaudeLive turn messages810+2 (+25.0%)21✅

      Baseline: dbc7bfa · PR result: 807c0fe · 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: 109.4 KiB
      • Claude decoded thread snapshot: 110.1 KiB

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

    3. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor Bugbot Autofix is [ON](https://www.cursor.com/dashboard/bugbot), but a cloud agent failed to start. Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d3f08212cfae445822ccddbd42e3d1634a32d523. Configure [here](https://www.cursor.com/dashboard/bugbot).
    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This cross-layer feature changes the default handling of PDF/HTML attachments and adds inline document serving with browser iframe execution and new right-panel state. It also broadens an existing lint suppression while moving the PDF/HTML security boundary, so the runtime and review-policy implications require human review.

      Not approved because:

      • Monthly spending limit reached (workspace setting). Approvability relies on correctness review in order to determine eligibility
      Review your spending limits in [Billing settings](https://app.macroscope.com/pingdotgg/settings/billing). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. juliusmarminge merged this7751299

    6. juliusmarminge closed this

Sign in to join this conversation.