Skip to content

fix(files): attach uploads that finish after a retry or resume - #467

Draft
nossila wants to merge 1 commit into
masterfrom
feature/files-retry-autoattach
Draft

nossila wants to merge 1 commit into
masterfrom
feature/files-retry-autoattach

Conversation

@nossila

@nossila nossila commented Oct 10, 2026

Copy link
Copy Markdown
Member

Summary

Fixes an existing web bug: with autoAttach on, a file that finishes uploading after a retry or resume is never attached to its target. On web this hits comment editing (CommentUpdate → FileUploadTrigger autoAttach). Pause an upload and resume it, or retry a failed one. The chip reaches "completed", but the file is not attached and is gone after a reload.

Backend: N/A, frontend-only.
Template PR: none yet. The template picks this up when its submodule pointer next moves past this commit.

Cause

useFileUploadLogic attached late completions through useChunkedUpload({ onUploadComplete }). That callback belongs to the hook instance. The Retry and Resume buttons live in UploadingFileItem, which calls its own useChunkedUpload() with no options. So when a retried or resumed upload completed, nothing attached it.

What changed

files/common/hooks/useFileUploadLogic:

  • Watches the upload store, through a useShallow selector, for COMPLETED uploads in its target's scope that have a relay id, and attaches them. This doesn't depend on which component started the retry or resume.
  • While a batch from handleFilesSelected is running, the batch attaches its own files and the watcher waits. When the batch ends, anything that completed in the meantime is attached. Ids already sent are still deduped through attachedRef, so nothing is attached twice.
  • A late-attached file is now removed from the store once the mutation lands, like batch files. Otherwise it kept showing as a completed upload chip next to its attached chip. resetKey still bumps only for batches.

Test plan

Q: Is the bug covered by a test?
A: Yes, the new useFileUploadLogic.test.ts. Three of its four cases fail on master and pass here: late completion attaches; the late file leaves the store once attached; completion during a running batch is attached after it. The fourth (other scopes / autoAttach: false are ignored) passes on both.

Q: How do I check it by hand?
A: On web, edit a comment and attach a large file.

  1. Pause it, then resume. After it completes, the file should show as attached, and still be there after a reload.
  2. Repeat with a failed upload, e.g. drop the network mid-upload, then click retry.

Q: Does it change the normal path?
A: No. A file that finishes inside its original batch is attached by the batch, exactly as before.

Tradeoffs

  • The watcher attaches any completed, unattached upload in the target's scope, including leftovers already in the store when the trigger mounts. In practice those are exactly the files this bug left unattached. No other code writes to a target-id scope with autoAttach.
  • attachedRef is per hook instance. Two auto-attach triggers mounted for the same target at once could each attach the same late file. No screen does that today.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Dq2w352FXrTDKwmGC9eyxH

With autoAttach on, a file that failed or was paused and then retried or
resumed uploaded fine but was never attached: the list item's retry/resume
runs its own useChunkedUpload, so useFileUploadLogic's onUploadComplete never
fired. Pick completed uploads in the target's scope up from the store instead,
and drop them from the store once attached.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Dq2w352FXrTDKwmGC9eyxH
@changeset-bot

changeset-bot Bot commented Oct 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b3c2766

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@baseapp-frontend/components Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Oct 10, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • 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

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant