fix(mobile): attachments in a host workspace no longer hang the composer (SUPER-3442)

Merged
HA
5d ago
+52-14

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:

  • TerminalComposer passes progress: 0, and the native composer draws a 0% ring.
  • ComposerModel.isUploading is 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)

buildattachment_addedattachment_removed
113 (1.1.3)98641 (4%)
137 (1.2.0)102440 (4%)
140 (1.2.1)387312 (81%), 68 of 96 users

On build 140, all 14 attachments_sent events had home=cloud. No host-workspace attachment send succeeded.

Change

  • addAttachments no longer seeds upload entries.
  • beginUpload creates 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 beginUpload runs synchronously before the first await in upload().

Checks I ran

  • New test composerDraftsStore.test.ts. It fails on main and passes with this change.
  • settle.test.ts helper now begins an upload explicitly.
  • bun test in 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;host with 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

  • addAttachments no longer seeds upload entries; only beginUpload creates 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 composerDraftsStore and updated the settle test 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.