Skip to content

refactor(client-runtime): share the Effect attachment upload registry with web - #37743

Merged
juliusmarminge merged 4 commits into
t3/mobile-outbox-per-thread-fibersfrom
t3/client-runtime-shared-attachment-uploads
Nov 16, 2026
Merged

juliusmarminge merged 4 commits into
t3/mobile-outbox-per-thread-fibersfrom
t3/client-runtime-shared-attachment-uploads

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Mobile and web each had their own attachment upload queue, with the same concepts: a job per attachment, a few uploads at a time per environment, cancel, retry, and a send that waits on the running upload. Web's 700-line queue ran all of it on zustand, promises, a pump, settled promises and cancelled/abort flags. This moves the Effect registry from #37682 into client-runtime and runs both clients on it.

Shared in client-runtime

  • state/attachment-uploads (createAttachmentUploadRegistry): an RcMap of upload fibers keyed by a caller-supplied key, with per-environment concurrency, explicit holds plus a sync for a set of requests, joining (upload), current to await an upload without holding it, and optional statuses.
  • An upload is interrupted once nothing holds it. Transports are plain Effect.tryPromise calls, whose signal aborts the native upload or XHR on interruption.
  • runAttachmentUploadCycle and verifyPersistedAttachmentUpload are Effects. Interrupting the cycle aborts the transfer and deletes the fresh mint, even when the interruption lands while minting. That replaces onMinted cancel and the abort handoff. A failure still returns the minted id so the caller decides between retry and release.

Mobile's composer worker creates the registry directly with its key, environment and concurrency, and uploadComposerAttachment is an Effect over the shared cycle. Its failures use the shared AttachmentUploadError.

Web keeps its upload policy and public API: previous uploads across environment switches, release deletes, retry on reconnect, expiry checks, draft stamping, and its zustand states. Each upload is now a registry hold running an Effect, which replaces the job map, pump, settled promises and cancel flags. Uploads start inside the holder's call, as web's queue did.

Verification

  • The registry's tests move from mobile to client-runtime. Web's 20 queue tests, its other queue users, and the useQueuedRunEdit browser test pass unchanged. That includes "does not let stalled uploads block another environment", which covers per-environment concurrency.
  • In a real browser against a dev server, attaching an image uploads it at once (minted URL, then a 204 POST of the bytes), and sending claims it into the thread:

Web composer: an attached image sent as part of the first message

vp run check:changed passes (typecheck across all 41 dependent packages). Stacked on #37725.

Done by Claude Opus 5.5 in Claude Code via T3 Code.

🤖 Generated with Claude Code

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🚀 Mobile Continuous Deployment Trigger Expo preview build size:XXL 1,000+ changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant