fix(mobile): attachments in a host workspace no longer hang the composer (SUPER-3442)
Fixes SUPER-3442. Also covers Martin Jonsson's report: a ~3.5 MB photo fails on two Wi-Fi networks and on mobile data. Context: SUPER-3447 (composer upload cleanup, not done here).
Root cause
composerDraftsStore.addAttachments seeded uploads[id] = { progress: 0 } for every attachment. Since #9064, startAttachmentUploads returns early for a host draft (a workspace on a machine someone owns), because those bytes go to the host at send time. Nothing ever writes a fileId or an error to the seeded entry. So:
TerminalComposerpassesprogress: 0, and the native composer draws a 0% ring.ComposerModel.isUploadingis true, so Send is disabled and shows "Uploading" until the user removes the photo.
Network and file size play no part. This explains why it fails "on two Wi-Fi networks and mobile data".
Evidence (PostHog, mobile)
| build | attachment_added | attachment_removed |
|---|---|---|
| 113 (1.1.3) | 986 | 41 (4%) |
| 137 (1.2.0) | 1024 | 40 (4%) |
| 140 (1.2.1) | 387 | 312 (81%), 68 of 96 users |
On build 140, all 14 attachments_sent events had home=cloud. No host-workspace attachment send succeeded.
Change
addAttachmentsno longer seeds upload entries.beginUploadcreates the entry, and only for an attachment the draft still holds. It still ignores removed attachments.- A host draft has no entries: no ring, and Send works. The cloud path is unchanged, because
beginUploadruns synchronously before the firstawaitinupload().
Checks I ran
- New test
composerDraftsStore.test.ts. It fails onmainand passes with this change. settle.test.tshelper now begins an upload explicitly.bun testin apps/mobile: 263 pass. biome is clean on the touched files.tsc: 187 errors before and after, none in the touched files (they look like unbuilt workspace packages).- Not checked in the real app: there is no iOS simulator in this Linux sandbox.
- Ruled out on the server: a presigned PUT for 3.5 MB signs
content-length;content-type;hostwith no checksum parameter, and 3.5 MB is under every limit (200 MB per file, 25 MB inline to a host).
Summary by cubic
Fixes SUPER-3442: attaching a photo to a host workspace draft no longer hangs the composer on "Uploading" with a 0% progress ring and Send disabled.
Bug Fixes
addAttachmentsno longer seeds upload entries; onlybeginUploadcreates one, and only for an attachment the draft still holds.- Host drafts have no upload entries, so Send works as expected; cloud drafts are unaffected.
- Added tests covering the upload-entry lifecycle in
composerDraftsStoreand updated thesettletest helper to begin uploads explicitly.
Summary by CodeRabbit
- Bug Fixes
- Attachment upload progress is now tracked only after an upload begins, rather than when a file is added to a draft.
- Upload tracking now ignores requests for attachments that are not present in the draft.