You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(mobile): attachments in a host workspace no longer hang the composer (SUPER-3442) - #9675
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)
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
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.
Written for commit 859c9a2. Summary will update on new commits.
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.
Review was skipped as selected files did not have any reviewable changes.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: eadec7b7-5efd-418f-9018-a344f33dc78d
Commits
Reviewing files that changed from the base of the PR and between b2d5013 and 859c9a2.
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
No actionable comments were generated in the recent review.
Walkthrough
The composer draft store now creates upload-state entries when an upload begins for an attachment in the draft. Adding attachments alone leaves the uploads map empty. Tests cover these behaviors and update the attachment helper to begin uploads.
addAttachments now only appends attachments. beginUpload creates upload state when the draft contains the attachment and otherwise leaves the store unchanged. Tests verify the upload state, and the attachment test helper begins uploads for added attachments.
This change stops host-workspace attachments from leaving the composer stuck on a progress ring with Send disabled. The cloud upload path is reported unchanged. No actionable merge-blocking risk remains. Real-app behavior was not checked on a device.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title uses conventional commit format and names the main change: attachments in a host workspace no longer leave the composer hanging. It matches the diff, which stops seeding upload entries in ad…
Description check
The description follows the template's main sections: What & why, How I tested it, and the checklist items. The What & why section names the root cause, the fix, and links SUPER-3442. The testing sect…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title uses conventional commit format and names the main change: attachments in a host workspace no longer leave the composer hanging. It matches the diff, which stops seeding upload entries in addAttachments and creates them only in beginUpload. The title is specific to the bug and the affected scope.
Full details: Description check
Explanation
The description follows the template's main sections: What & why, How I tested it, and the checklist items. The What & why section names the root cause, the fix, and links SUPER-3442. The testing section lists the test added, the commands run, and what was not checked in the real app. Gaps: no screenshots, although the template strongly prefers before/after screenshots for user-visible bug fixes. The checklist is not marked, and the description does not confirm the title follows conventional commits (it does), lint and typecheck status (the author reports biome clean and tsc errors unchanged, but not a passing lint/typecheck run), or fork maintainer-edit and CLA status. The description also includes auto-generated cubic text, which is acceptable.
Resolution
Consider adding before/after screenshots or a recording of the composer on a host workspace draft, as the template recommends for user-visible bug fixes. Tick the checklist items after confirming them, especially that bun run lint and bun run typecheck pass, since the author reports only biome on touched files and tsc with 187 pre-existing errors.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Review: looks good. The root cause is right (a seeded {progress: 0} entry that a host draft never settles), and removing the seed fixes it with the least change. Every consumer already treats a missing entry as "not uploading".
Nits (none block merge):
apps/mobile/lib/attachments/settle.test.ts:99: the beginUpload store tests live here and overlap the new composerDraftsStore.test.ts:24. Move them next to the store and drop the duplicate.
apps/mobile/screens/(authenticated)/stores/composerDraftsStore/composerDraftsStore.test.ts:14: the SUPER-3442 rationale comment belongs in the commit or PR, per AGENTS.md.
Optional: no test goes through the host path end to end (setDraftAttachmentHome("host") → startAttachmentUploads → no entries).
Verified: bun test in apps/mobile gives 263 pass. The new test fails when run against base 8cd5f154. On the EAS simulator, the cloud attach path is unchanged: a spinner shows, then Send is enabled. Not verified in the app: the host-workspace composer. The sandbox has no relay or host-service, so the host showed as offline.
Root cause reproduced on main. With main's store, the new composerDraftsStore.test.ts fails: after addAttachments the draft holds { a: { progress: 0 } }, and nothing on the host path ever settles that entry.
Host attach flow, run end to end through lib/attachments/upload.ts. This was a throwaway test: only expo-file-system and the tRPC client were stubbed, and it was not committed because it needs mock.module. "Send blocked" uses TerminalComposer's progress mapping and the Swift check isUploading = progress != nil && !failed.
Scenario
main
this PR
Host workspace: attach a photo
entry {"progress":0}, no upload, Send blocked
no entry, no upload, Send enabled
Cloud workspace: attach a photo
entry right away, upload starts, ring shows
same (no regression)
Read in the code:
Both host send paths read the bytes at send time and never wait on upload entries: terminal sends via writeAttachmentsToWorktree(toAttachmentFiles(...)), chat sends via chatAttachmentParts with home === "host".
The drafts store is not persisted, so stuck entries from 1.2.1 do not come back after an update.
An attachment added before the workspace's home is known still uploads to cloud storage, as it does on main. The upload settles, so it cannot get stuck.
Suite: full apps/mobilebun test with this PR's two changed files applied on current main (ef07711): 264 pass, 0 fail.
Not checked: the real iOS app. The SwiftUI side was traced in the code only.
…ser (SUPER-3442)
Adding an attachment seeded an upload entry at 0% for every draft. Since
#9064, a draft for a workspace on a machine someone owns starts no upload at
attach time: its bytes go to the host at send. Nothing ever settled the
seeded entry, so the composer drew a 0% ring and kept Send disabled
("Uploading") for any photo, on any network, at any size.
Only beginUpload now creates an entry, and only for an attachment the draft
holds. A host draft has no entries, so its tray shows no ring and sends.
PostHog, mobile build 140, last 14 days: 312 of 387 attachments added were
removed again (about 4% on builds 113 and 137), and every attachments_sent
had home=cloud. No host-workspace attachment send succeeded.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.addAttachmentsseededuploads[id] = { progress: 0 }for every attachment. Since #9064,startAttachmentUploadsreturns 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 afileIdor 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)
On build 140, all 14
attachments_sentevents hadhome=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.beginUploadruns synchronously before the firstawaitinupload().Checks I ran
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).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.composerDraftsStoreand updated thesettletest helper to begin uploads explicitly.Written for commit 859c9a2. Summary will update on new commits.
Summary by CodeRabbit