Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(server): accept PDF, ZIP, and other file uploads up to 50MB #8235

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

T3 Code currently accepts only image attachments. This PR adds the server contract, streaming upload, storage, and download support for generic files up to 50 MiB. The web and mobile file pickers remain separate in #8236 and #8237.

Each provider adapter chooses which attachments it sends as native inputs. The prompt includes the real path for every attachment, so unsupported native inputs still reach the agent as paths.

The takeover fixes interrupted upload cleanup, returns HTTP 400 for unfinished oversize uploads instead of resetting the socket, encodes extended download filenames correctly, keeps mobile from rendering files as images before its file UI ships, and corrects the rollback documentation.

Compatibility warning: the tolerant schema only helps updated clients. Older clients cannot decode messages with file attachments. Older servers can also fail startup for the whole environment when event replay reaches a file-bearing message. Do not treat rollback as a per-thread failure.

Theo Browne wrote the original implementation with Claude Fable 5 in Claude Code. The original commit authorship and co-author trailers are preserved.

Built with GPT-5.6 Sol in the Codex harness.


Note

Medium Risk Touches attachment auth tokens, streaming upload I/O, and download response headers (XSS via mime/disposition), plus persisted event schemas—version skew can break whole-environment replay on rollback.

Overview Adds generic file attachments (PDF, ZIP, etc.) alongside images: contracts expose ChatFileAttachment, type: "file" upload URLs (50 MiB cap), and environment capability fileAttachments.maxUploadBytes. Upload and storage stream bodies to .part files with size enforcement and cleanup on failure or interrupt; attachment IDs can carry a sanitized extension suffix so paths resolve without directory scans. Downloads bake download, fileName, and mimeType into signed asset tokens and serve attachment disposition, sandbox CSP, and vetted Content-Type (HTML/XML/SVG forced to octet-stream).

Provider turns append an on-disk path line for every attachment; image-only adapters skip non-images for native input while OpenCode sends supported PDFs/text/images under a size cap. Projection and cleanup handle file attachments; mobile thread feed shows images only until file UI ships; web gains isImageAttachment so file members typecheck without image-only UI.

Compatibility: tolerant ChatUnknownAttachment decoding on messages; legacy upload tokens default to image; older clients/servers and file-bearing persisted events remain a documented skew risk.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 88b541d8d456ad08bfa8f34b14f855e3d4d6a019. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Add support for generic file uploads up to 50MB with streaming

  • Adds schemas for ChatFileAttachment and FileAttachmentCreateUploadUrlInput in orchestration.ts and assets.ts to validate generic files up to 50 MiB (PROVIDER_SEND_TURN_MAX_FILE_BYTES)
  • Modifies storeAttachmentUpload in AttachmentUpload.ts to stream uploads to a .part file and enforce size limits, rejecting oversized or mismatched uploads with a 400 status
  • Extends attachment IDs in attachmentStore.ts with a validated file extension suffix (e.g., -pdf) to allow direct path resolution without scanning directories
  • Implements download headers (Content-Disposition, sandbox CSP) and safe mime type validation in http.ts for serving generic files
  • Updates provider adapters in apps/server/src/provider/Layers/ to filter non-image attachments from native image ingestion paths, relying on prompt path lines for generic file access
  • Risk: attachmentRelativePath now returns null for unknown attachment types; ProviderService.sendTurn no longer sets input.attachments to an empty array when absent, so downstream adapters may receive undefined
Macroscope summarized 88b541d.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: ae0e9152-6daa-46d3-a592-6ff68346f32f

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    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.3 KiB13.3 KiB+4 B (+0.0%)15.1 KiB✅
      CodexThread snapshot wire6.9 KiB6.9 KiB−13 B (−0.2%)7.3 KiB✅
      CodexLive turn WebSocket wire6.4 KiB6.4 KiB+17 B (+0.3%)7.8 KiB✅
      CodexLive turn WebSocket decoded55.6 KiB55.6 KiB+44 B (+0.1%)66.4 KiB✅
      CodexLive turn messages1011+1 (+10.0%)21✅
      ClaudeTotal thread wire13.3 KiB13.4 KiB+12 B (+0.1%)15.1 KiB✅
      ClaudeThread snapshot wire6.9 KiB6.9 KiB+7 B (+0.1%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.5 KiB6.5 KiB+5 B (+0.1%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded56.4 KiB56.4 KiB0 B (0.0%)66.4 KiB✅
      ClaudeLive turn messages11110 (0.0%)21✅

      Baseline: f276e63 · PR result: 88b541d · 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.

    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 introduces generic file uploads and downloads up to 50 MiB, including streaming filesystem I/O, signed download metadata, provider-specific attachment handling, and persisted schema changes. The broad runtime and compatibility impact, plus security-sensitive MIME and browser-disposition behavior, warrants human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 826e1e3af3905692fe68c7b6ea11a9f038ffbac6. Configure [here](https://www.cursor.com/dashboard/bugbot).

Sign in to join this conversation.