Skip to content

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

Merged
harshithmullapudi merged 1 commit into
mainfrom
superset/super-3442-photo-upload-hang-debug-e9018579
Nov 13, 2026
Merged

harshithmullapudi merged 1 commit into
mainfrom
superset/super-3442-photo-upload-hang-debug-e9018579

Conversation

@harshithmullapudi

@harshithmullapudi harshithmullapudi commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

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.

View guided diff Turn on auto-fix

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.

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

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.

Changes: Composer draft upload tracking

Layer / File(s) Summary
Upload entry lifecycle
apps/mobile/screens/(authenticated)/stores/composerDraftsStore/composerDraftsStore.ts, apps/mobile/screens/(authenticated)/stores/composerDraftsStore/composerDraftsStore.test.ts, apps/mobile/lib/attachments/settle.test.ts
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.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: saddlepaddle

Merge Risk: Minimal · previous review b2d50

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: Passed 4

Check name Status Explanation
Title check Passed 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 Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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.

Share

Recent review info

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: 1b55f4aa-fce0-4a32-bca5-b787ac9820af
Commits

Reviewing files that changed from the base of the PR and between 8cd5f15 and b2d5013.

Files selected for processing: 3

  • apps/mobile/lib/attachments/settle.test.ts
  • apps/mobile/screens/(authenticated)/stores/composerDraftsStore/composerDraftsStore.test.ts
  • apps/mobile/screens/(authenticated)/stores/composerDraftsStore/composerDraftsStore.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

@expo

expo Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Preview update published for development build e4df89ca (fingerprint 315789730588). Open the build on your phone and scan:

Update group 5cd13b7d

@expo

expo Bot commented Nov 12, 2026

Copy link
Copy Markdown

🎉 Your workflow run has finished!

Check out the details below.


Builds

ID Platform Status Actions
e008fa7 iOS ✅ Success (logs) Install Download
Open QR Code Install QR code for build e008fa7d-c681-490a-9147-26e2bdb8b175

Copy link
Copy Markdown
Contributor

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.

Full report: https://app.superset.sh/page/pr-9675-review-host-attachments-hang-ri6enr

harshithmullapudi commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator Author

Verification

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/mobile bun 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 branch was previously deployed

1 inactive deployment
preview — 859c9a23 Deployed Nov 13, 2026 by harshithmullapudi via Cleanup Preview Resources #5565
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github GitHub-sourced work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants