Repository navigation
Chat: dropped files hold Send until they're attached - #29173
Conversation
A local file drop checked each file before adding it, with nothing in the composer meanwhile: Send during the check went without the file, which then landed in the next draft; unmounting mid-check lost it; and files queued behind an input-method composition were lost on unmount. Drops now reserve a pending chip per file before the check, so Send waits as it already does for server-upload drops. The prepared attachment travels through the existing composition queue as one operation, settles into its draft scope after unmount, releases its chips when refused or disabled, and reads the scope's current image capability when it applies.
|
Dropping a local file into Chat and pressing Send during its readability check could send the message without the file, then add it to the next draft. Closing the composer during that check or an input-method composition could also lose the accepted attachment. This PR reserves the existing pending chip before the readability check and keeps accepted work with its owning draft. Send stays disabled until pending chips resolve or are removed; afterward, the user presses Send again. There is no automatic delayed send. Independent correctness, architecture, and final readiness/performance reviews completed on The three-model design panel ruled to keep the current ownership mechanism. Deferred: the minor “Uploading” label inherited by local checks (in the chip’s accessible name and opened preview), and the unmeasured cost of one saved-draft update per image. A gesture accepts at most 256 files and saves path metadata, but source counts do not establish responsiveness; batching remains a follow-up only if measurement justifies it. The wording follow-up is precise per-file preparation text on the existing shared surface; no new notice or state was added here. QA should also observe the unproven possibility of a document chip flashing or changing composer height before it becomes a file reference. The pre-existing operating-system drop preparation happens before Chat receives the paths and reserves a chip. This PR covers the later readability check and composition handoff; it does not close that earlier interval. The concern that removing an attachment during input-method composition does not immediately release its queued-file capacity remains deferred after a bounded source trace; no new confirmed user-visible failure was reproduced. Update for head Real Electron before/after QA ran on macOS and the screenshots and results are in the PR description: during input-method composition, main shows no chip and leaves Send enabled, while this PR shows the pending chip and disables Send. The earlier interval (operating-system drop preparation before Chat receives the paths) behaves the same on main and this PR and stays out of scope. Update for head Update for head An independent review of the redraw found no P0, P1 or P2. It checked every pending and settled state, the screen-reader label, that the strip doesn't cover the remove button, the colour tokens against the style guide, and the common pattern for pending attachments. Three P3 cleanups are deferred:
The PR description records one intended difference: a pending file is a square tile that becomes a file pill once it settles. Real Electron QA ran on this exact head, on macOS in a hidden test copy with a throwaway home: dropping a PNG and a PDF during Japanese input-method composition. While waiting, each chip shows a spinner above its name with no kind icon, and Send is disabled. Once settled, the PNG is a thumbnail, the PDF is a file pill, the text is kept and Send is enabled. Screenshots are in the PR description. The full PR workflow is green on this head. |
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
…wn hook Main's server-owned paste pushed the attachments hook past the file length limit.
…ame, not a stacked icon A local drop now waits as a pending chip, which drew the kind icon, the file name and a centered spinner on top of each other. Without a thumbnail the chip shows the spinner above the name; with one, the dimmed picture keeps a spinner strip along its bottom.
There was a problem hiding this comment.
🧹 Nitpick comments: 1
src/renderer/src/components/native-chat/NativeChatImageAttachmentPreview.test.tsx: 1
120-126: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert the pending loading indicator.
The replacement reaches the same pending render branch, but it does not assert that
LoadingSpinnerrenders. Removing the spinner would leave the button label, filename, and icon assertions passing. Add the spinner assertion. The removed kind-icon assertion is intentionally covered by the existing absence check.Suggested fix
expect(screen.getByRole('button', { name: 'Uploading report.pdf…' })).toBeTruthy() expect(screen.getByText('report.pdf')).toBeTruthy() + expect(document.querySelector('.animate-spin')).toBeTruthy() expect(document.querySelector('.lucide-file-text, .lucide-image')).toBeFalsy()
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
01b13b6a-1cb5-4c95-9792-035d079cb569
📒 Files selected for processing: 1
src/renderer/src/components/native-chat/NativeChatImageAttachmentPreview.test.tsx
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
ELI5
If you dropped a file onto Chat and pressed Send before Chat finished checking the file, the message went without it, and the file showed up later in your next message instead. Now, once the file reaches Chat’s attachment handler, it shows a pending chip before the readability check. Send is disabled until the files are attached or removed; press Send afterward to send the complete message, as with files uploaded to a paired server.
What Changed
The problem (on main today). When you drop a local file onto Chat (or pick one with the file picker), Chat first checks each file can be read, one by one, and only then adds it to the message. Nothing appears in the composer while that check runs. So:
Before / after, as the user sees it
The mechanism. The local drop route (
captureExternalDropinuse-native-chat-external-attachments.ts) now reserves one pending chip per file before its first file check, instead of adding files only after checking them. A pending chip already disables Send (nativeChatImagesHoldSend), so submission during the readability check is refused by the composer’s existing rule; it is not queued to send automatically.use-native-chat-resolved-path-attachments.ts). Applying it resolves each chip (images become image chips, other files become@pathreferences); cancelling it releases the chips.settleNativeChatPendingAttachmentReferencesand the chipresolve/attachReferencescalls now report whether anything was attached, so a removed chip is not counted as an attachment.Why
Orca's server-upload drop (
native-chat-session-attachment-drop.ts) already reserves a pending chip before its async upload; the local drop was the one intake that didn't. Reserving before attachment checks and refusing submission while preparation is pending is also the common pattern. The alternative, a separate "drop in progress" flag that blocks Send, would add a second Send guard beside the existing chip rule and still lose the file on unmount; reserving a chip uses the state the composer already has.Differences from the common pattern
Scope limit: the operating system’s existing dropped-file preparation runs before Chat receives the paths. This PR reserves chips before Chat’s readability checks; it does not close the earlier preparation interval or promise a chip at the native drop instant.
Linked Issue
Linear STA-10652. This is the drop half of that fix: review of the paste change (#29089, stacked on this PR) found that the drop route never reserved before its file check, so the send race exists for drops on main too. #29089 routes pasted files through this same intake.
Visual Proof
Live QA on macOS (M4Air), main 6ade7a5 against this PR at 0cc796d, hidden test copies with throwaway homes, driven over the Chrome DevTools Protocol.
Dropping a file while typing Japanese with an input method, before the composition is committed:
On main nothing shows until the composition ends and Send stays enabled. With this PR the pending chip appears at once and Send is disabled until it settles; after the commit the file is attached and the text kept.
Other cases, same builds:
Real ~/.claude/settings.json and ~/.codex/hooks.json on the QA machine were unchanged before and after.
Pending chip redraw, at
03472b3536d(hidden test copy on macOS with a throwaway home, driven over the Chrome DevTools Protocol). A PNG and a PDF were dropped through the composer's drop handler while Japanese text was mid-composition. While waiting, each chip shows one spinner above its name, with no kind icon, and Send is disabled. Once settled, the PNG is a thumbnail, the PDF is a file pill, the Japanese text is kept and Send is enabled. This round drives the composer's drop handler; it doesn't cover the operating system's own drag.Testing
native-chat-external-attachments-destination.test.tsx: chips are reserved before the file check and settle into the chat's draft across chip removal, an unreadable file and a remount; prepared work settles quietly when composition loses its composer; refused and disabled work releases its chips, including a check that spans disable and re-enable; an image queued during composition attaches by the chat's image support when it applies, in both directions.NativeChatImageAttachmentPreview.test.tsx: a pending file chip shows its name and no kind icon.use-native-chat-external-attachments.test.tsxandnative-chat-floating-file-drop.test.tsx: updated for reserve-first chips and the attached/not-attached result.Unit tests, lint and typecheck: CI.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)