Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat: let agents work with PDFs, ZIPs, and other files #8092

Closedt3dotgg(GitHub profile, opens in a new tab)wants to merge 14 commits intomain fromt3code/generic-file-uploadsopened View on GitHub

T3 Code only accepted image attachments. PDFs, ZIP archives, and large text files had no direct route to an agent.

Web, desktop, and mobile can now upload files up to 50 MB directly to their environment. Agents receive the saved file path, images keep their existing behavior, and mobile supports the system file picker and share sheet.

Uploads stream to disk, pending files reuse hard links, and downloaded documents cannot run as pages.

The mobile share-sheet change requires a new iOS and Android store build before later OTA updates work.

Built with GPT-5.6 Sol in the Codex harness.


Note

High Risk Changes attachment ingestion, local file lifecycle, outbox delivery, and server upload paths—failures can lose shares, leak disk, or send without proper uploads; share-sheet config needs a store build.

Overview Mobile now treats composer attachments as images or generic files, not images only. Thread and new-task composers can pick files (when the connected server advertises fileAttachments), show file thumbnails in the attachment strip, and offer Photos vs Files from the + control.

Files are copied into app-owned storage (with size checks for Android content:// URIs) instead of being read as base64. Sending uploads file bytes through signed upload URLs, stores pending attachment IDs on drafts/outbox messages for retries, and deletes pending server uploads after a successful turn. The outbox drain uploads before startTurn, rejects or restores undeliverable messages to the composer when uploads fail or the server lacks file support, and cleans up local files only when no draft or queued message still references them.

System share ingestion accepts file/audio/video payloads (broader Android MIME types and iOS file activation), persists shared files on disk, rolls back persisted files if the durable inbox write fails, and filters attachments by the destination server’s file limit when importing into a project draft.

Thread feed renders non-image attachments as tappable rows that open a signed asset URL. Server (in this slice) marks resolved attachment assets for download disposition when the attachment id carries a file extension.

Requires a new native build for expanded share-sheet / MIME registration in app.config.ts before OTA can rely on those targets.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 75199daf0b6406b1caa5de695736e4a73ceb97c9. 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 attachments (PDFs, ZIPs) across mobile, web, and server

  • Introduces ChatFileAttachment and PROVIDER_SEND_TURN_MAX_FILE_BYTES (50 MB) in orchestration.ts; environment descriptors now advertise fileAttachments.maxUploadBytes
  • Server streams file uploads instead of buffering them, embeds normalized file extensions in attachment IDs via attachmentFileExtension, and serves downloadable assets with Content-Disposition: attachment headers in http.ts
  • Web composer accepts files via button and paste in ChatComposer.tsx, uploads through the server queue, stashes/restores file references, and renders download links in MessagesTimeline.tsx
  • Mobile picks and persists files to app-owned storage in composerImages.ts, supports incoming file shares (including Android text+file intents via an expo-sharing patch), and uploads/restores file attachments during outbox drain in use-thread-outbox-drain.ts
  • Risk: makeProviderService.sendTurn in ProviderService.ts now filters attachments to images only and appends file paths to the text prompt; normalizeDispatchCommand in Normalizer.ts prefers hard links over copies when claiming uploads — verify provider adapters and filesystem permissions handle these correctly
Macroscope summarized 75199da.
    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: c5745e26-94bb-4d07-8515-e1a5cdc7d93f

      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

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      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) added labels📱 Native Change

    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 wire13.3 KiB13.3 KiB+41 B (+0.3%)15.1 KiB✅
      CodexThread snapshot wire6.9 KiB6.9 KiB+2 B (+0.0%)7.3 KiB✅
      CodexLive turn WebSocket wire6.4 KiB6.4 KiB+39 B (+0.6%)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.3 KiB−3 B (−0.0%)15.1 KiB✅
      ClaudeThread snapshot wire6.9 KiB6.9 KiB−4 B (−0.1%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.4 KiB6.4 KiB+1 B (+0.0%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded56.4 KiB56.4 KiB0 B (0.0%)66.4 KiB✅
      ClaudeLive turn messages11110 (0.0%)21✅

      Baseline: e67074f · PR result: 75199da · 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.

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

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This introduces a broad cross-platform file-attachment workflow, including native sharing, local persistence, streaming uploads, server-side storage, provider access, outbox recovery, and downloads. Its scope and runtime impact extend well beyond a small isolated change and should receive human review.

      No code changes detected at 75199da. Prior analysis still applies.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    6. One UI consistency finding in the new web composer file attachment row. Everything else in the changed web scope (the paperclip Button size="icon-sm" + Tooltip/TooltipTrigger render composition, the icon-xs retry/remove actions, the timeline download anchor, and the semantic color tokens used) matches the existing composer/timeline conventions.

      Posted via Macroscope — UI Consistency
    7. One finding in the changed web UI: the new attachment download link inside the user message bubble hovers to text-primary, which is the solid-control fill role rather than a foreground role owned by the message surface. Details inline. (The unbounded retry tooltip in ChatComposer.tsx file rows from the earlier review is still open; not re-posting it.)

      Posted via Macroscope — UI Consistency
    8. One new finding in scope, plus one carried-over finding that is still unresolved.

      New: the stashed-file count badge in ComposerStashMenu does not pin a type scale or an icon tone, so it renders larger than every sibling metadata span in the row and its icon is re-colored by the CommandItem primitive. Inline comment below.

      Still open from a previous run (not re-posted): apps/web/src/components/chat/MessagesTimeline.tsx:1075 — the file download link on the user message bubble takes its hover color from --primary, which index.css defines as the solid-control fill role rather than a text role owned by the bg-message surface, so the hover state is not guaranteed to stay legible in themed palettes. A message-surface-owned foreground (e.g. the existing text-message-foreground with an opacity/underline hover) keeps the hover state under the surface that renders it.

      Everything else in the changed web UI looks consistent: the new composer attach control uses Button variant="ghost" size="icon-sm" inside the standard Tooltip/TooltipTrigger render composition, the failed-upload tooltip now matches the image tile's max-w-64 whitespace-normal leading-tight cap, and the attach affordance is correctly gated out of the collapsed-mobile and approval footers.

      Posted via Macroscope — UI Consistency
    9. UI consistency review of the changed web files. Two findings, both about draft/stash surfaces that summarize composer attachments and were not updated for the new files list. The previously flagged message-link hover token and the uncapped retry tooltip in ChatComposer are both resolved in this revision.

      Posted via Macroscope — UI Consistency
    10. One consistency issue found in the new user-message file attachment rows. Everything else (composer file list, stash menu badge, sidebar draft count, paperclip trigger) follows the shared Button/Tooltip contracts.

      Posted via Macroscope — UI Consistency
    11. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High lib/attachmentUpload.ts:73

      Reused uploadedAttachmentId values are added to pendingAttachmentIds, so a failed startTurn cleanup deletes the server attachment while the draft still retains its ID. On retry, uploadMobileAttachments treats that missing ID as valid and skips uploading fileUri, causing the retry to fail; only newly created attachment IDs should be returned for cleanup.

      -        pendingAttachmentIds.push(attachment.uploadedAttachmentId);
      Also found in 1 other location(s)

      apps/mobile/src/features/threads/use-project-actions.ts:98

      deletePendingMobileAttachments runs even when startTurn returns a failure. This also deletes IDs reused from an edited queued task, while the draft still retains uploadedAttachmentId; on retry, uploadMobileAttachments treats that now-deleted ID as valid and skips re-uploading the local file, so the retry fails with a missing attachment until the user removes and re-adds the file.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @apps/mobile/src/lib/attachmentUpload.ts around line 73:
      
      Reused `uploadedAttachmentId` values are added to `pendingAttachmentIds`, so a failed `startTurn` cleanup deletes the server attachment while the draft still retains its ID. On retry, `uploadMobileAttachments` treats that missing ID as valid and skips uploading `fileUri`, causing the retry to fail; only newly created attachment IDs should be returned for cleanup.
      
      Evidence trail:
      ae9756a3 — apps/mobile/src/lib/attachmentUpload.ts:69-81,101-127; apps/mobile/src/features/threads/use-project-actions.ts:76-107; apps/mobile/src/features/threads/NewTaskDraftScreen.tsx:777-809; apps/server/src/assets/AttachmentUpload.ts:227-245; apps/server/src/attachmentStore.ts:159-182
      
      Also found in 1 other location(s):
      - apps/mobile/src/features/threads/use-project-actions.ts:98 -- `deletePendingMobileAttachments` runs even when `startTurn` returns a failure. This also deletes IDs reused from an edited queued task, while the draft still retains `uploadedAttachmentId`; on retry, `uploadMobileAttachments` treats that now-deleted ID as valid and skips re-uploading the local file, so the retry fails with a missing attachment until the user removes and re-adds the file.
      
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High state/use-thread-outbox-drain.ts:292

      Editing a queued message while its attachment upload is in flight loses the edit: persistQueuedAttachmentUploads writes the stale queuedMessage snapshot by messageId, then startTurn sends that same snapshot and completeDelivery removes the task. Revalidate the outbox version before persisting, or merge only the uploaded attachment IDs and reload the latest payload before sending.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @apps/mobile/src/state/use-thread-outbox-drain.ts around line 292:
      
      Editing a queued message while its attachment upload is in flight loses the edit: `persistQueuedAttachmentUploads` writes the stale `queuedMessage` snapshot by `messageId`, then `startTurn` sends that same snapshot and `completeDelivery` removes the task. Revalidate the outbox version before persisting, or merge only the uploaded attachment IDs and reload the latest payload before sending.
      
      Evidence trail:
      Reviewed commit `ae9756a`; `apps/mobile/src/state/use-thread-outbox-drain.ts:94-147,286-323,406-525`; `apps/mobile/src/state/thread-outbox-manager.ts:126-153`; `apps/mobile/src/features/threads/new-task-flow-provider.tsx:943-990`; `apps/mobile/src/features/threads/thread-list-items.tsx:325-372`. Repository: https://github.com/pingdotgg/t3code

Sign in to join this conversation.