Skip to content

Chat: dropped files hold Send until they're attached - #29173

Merged
brennanb2025 merged 6 commits into
mainfrom
brennanb2025/chat-drop-reserves-pending
Oct 17, 2026
Merged

brennanb2025 merged 6 commits into
mainfrom
brennanb2025/chat-drop-reserves-pending

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​150 $\color{#cf222e}{\Huge{\mathbf{−}}}$​28 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​122
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​347 $\color{#cf222e}{\Huge{\mathbf{−}}}$​194 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​153

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:

  • Send during the check: if you've typed text and press Send before the check finishes, the message goes without the file. When the check finishes, the file is added to the now-empty composer and goes out with your next message.
  • Leaving mid-check: if the composer goes away while the check runs (switching chats, closing the pane), the file is silently dropped.
  • During an input-method composition (typing Japanese/Chinese/Korean with an IME): a dropped file waits until the composition ends; if the composer goes away first, the file is lost.

Before / after, as the user sees it

You drop a local file onto Chat, then... Before After
...press Send during the readability check Message sent without the file; the file lands in the next draft After native drop preparation, a pending chip appears before the readability check; Send is disabled until it resolves or is removed, then you press Send again
...switch away before the check finishes File lost File is kept in that chat's draft and is there when you come back
...are mid-composition (IME) and the composer goes away File lost File is kept in that chat's draft
...remove the pending chip before the check finishes n/a The file is not attached
...drop a file that can't be read Skipped, notice shown Its chip is removed, same notice
...the chat is disabled meanwhile Dropped Chips released, nothing attached

The mechanism. The local drop route (captureExternalDrop in use-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.

  • After the check, the prepared files travel as one operation through the composer's existing composition queue (use-native-chat-resolved-path-attachments.ts). Applying it resolves each chip (images become image chips, other files become @path references); cancelling it releases the chips.
  • If the composer unmounts while the operation is queued or the check is running, the operation settles into that chat's saved draft (the per-chat pending-attachment cache) instead of being thrown away. It still re-checks that the destination is the same chat and workspace first.
  • A disabled composer releases its pending chips.
  • When the operation applies, it reads the chat's current "takes images" setting, not the one captured at drop time, so an image queued while the agent's image support changed is attached as an image or as a file reference to match.
  • How a pending chip looks. It shows a spinner above the file's name, nothing else. Before, it stacked a picture or document icon, the spinner and the cut-off name in one small square, which read as three unrelated things. A pending chip that already has its picture shows the picture dimmed with a small spinner strip along the bottom.
  • settleNativeChatPendingAttachmentReferences and the chip resolve/attachReferences calls 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

  • Intended: the reservation is a pending chip in the composer rather than a separate counter. It enforces the same rule (Send is unavailable while files are being prepared), and it is the mechanism Orca's server-upload drop already uses.

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.

  • Intended: accepted attachments remain owned by their chat draft across composer teardown; existing path references, caret insertion, and input-method composition handling remain in place.
  • Intended: a pending file is a square tile (spinner above the name) and becomes a file pill once it settles; the common pattern shows a pill with a spinner from the start. The tile is the shape every pending chip in Orca's composer already has, including server uploads; changing it is a separate look change.
  • Temporary: local file checks inherit the shared pending chip’s “Uploading” accessible/preview label, although no upload occurs. The review panel deferred this P3; the follow-up is precise per-file preparation wording on the existing shared surface.

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:

main this PR
main: no chip, Send enabled PR: pending chip, Send disabled

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:

  • Plain drop, then Send: image and text go together on both builds (unchanged).
  • Drop, then press Enter immediately with the CPU slowed 8x: on both builds the text went alone and the files followed in the next message. That Enter landed before Chat received the dropped paths (the operating system's drop preparation runs first), which is the earlier window this PR does not cover; at normal speed the chip appears within about 150 ms.
  • Drop, then close the chat: the files stay in that chat's saved draft on both builds.
  • The local pending chip's screen-reader label says "Uploading sta-copy.png…" though nothing is uploaded; recorded as a follow-up wording fix. (The visible chip now shows only the spinner and the name.)

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.

Pending Settled
pending: spinner above each name, Send disabled settled: thumbnail and PDF pill, Send enabled

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.tsx and native-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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Remote / SSH: paired-server chats already used the server-upload drop, which reserved chips; unchanged apart from reporting whether a chip attached.
  • Cross-platform: renderer-only; no platform-specific code.
  • Mobile, wire, saved data: no change. The pending chips use the existing per-chat pending-attachment cache.
  • Performance: one chip per dropped file, created up front instead of after the check; the drop limit is unchanged.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

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.
@brennanb2025

brennanb2025 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor Author

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 0cc796df1be with no confirmed P0, P1, or P2 finding. The change reuses existing draft ownership and submission blocking, consistent with the common pattern; no new saved field, wire operation, or separate Send flag is introduced. The PR description was corrected to match the actual submission behavior and reservation boundary.

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 f506ddc6715 (main merged in). The only conflict was with main's server-owned image paste (#29278) in use-native-chat-composer-attachments.ts; the resolution keeps both behaviors. An independent review of the merge found no defects: the server-owned flag still reaches every pending-image settle path, and no test mocks went stale.

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 76511230d90. The full CI run on the merged head failed only the file-length limit on use-native-chat-composer-attachments.ts (307 of 300 lines). That commit moves the composer's image-chip list (draft images, pending chips and their previews) unchanged into use-native-chat-composer-image-chips.ts; no behavior changed. The full PR workflow is green on this head: static analysis and typecheck, all five unit-test shards, relay integration, Linux and Windows packaging, and the "PR checks passed" aggregate. No tests, static checks, install, build, or app launch ran on this Mac.

Update for head 03472b3536d. Brennan found the pending chip confusing: a picture or document icon, a spinner and a cut-off file name stacked in one small square. These commits redraw it. A pending chip with no picture yet shows only a spinner above the file name. A pending chip that has its picture shows it dimmed, with a spinner strip along the bottom. The screen-reader label and Send blocking are unchanged. A test now checks that a pending file chip shows its name and no kind icon.

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 settled chip's file-type icon choice is now dead code: settled chips only ever show the image icon.
  • The spinner strip covers the chip's 1px bottom border.
  • One test title mentions a spinner the test doesn't check.

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.

@brennanb2025
brennanb2025 marked this pull request as ready for review October 15, 2026 19:00
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

External uploads now create pending chips before checking path readability. Resolved paths can carry operations through deferred attachment batches. The composer settles those operations according to its current image support and scope state, while cancellation removes prepared chips. Tests cover validation, composition, unmounting, disabling, and destination changes.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 03472

Pending attachments still show a loading indicator; the changed test leaves a narrow gap in protecting that behavior. No current user-facing failure is established, so the remaining merge risk is minimal.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 12 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check Warning The description is detailed and covers the user impact, implementation, rationale, testing, visual proof, and compatibility considerations. However, the required Linked Issue section does not contain … Add the actual Linear issue link to the Linked Issue section and complete the Fixes # reference. Also check the visual-proof and validation checklist items if the documented evidence and CI results satisfy them, or explain why they remain…
Passed Passed checks: 3 passed
Check name Status Explanation
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.
Title check Passed The title clearly and concisely describes the main change: dropped files keep Send disabled until attachment processing completes.
Full details: Description check

Explanation

The description is detailed and covers the user impact, implementation, rationale, testing, visual proof, and compatibility considerations. However, the required Linked Issue section does not contain an actual issue link or completed Fixes # reference.

Resolution

Add the actual Linear issue link to the Linked Issue section and complete the Fixes # reference. Also check the visual-proof and validation checklist items if the documented evidence and CI results satisfy them, or explain why they remain unchecked.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • 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

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

@brennanb2025
brennanb2025 marked this pull request as ready for review October 17, 2026 00:01
…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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments: 1
src/renderer/src/components/native-chat/NativeChatImageAttachmentPreview.test.tsx: 1

120-126: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert the pending loading indicator.

The replacement reaches the same pending render branch, but it does not assert that LoadingSpinner renders. 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
📥 Commits

Reviewing files that changed from the base of the PR and between 847bd36 and 03472b3.

📒 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.

@brennanb2025
brennanb2025 merged commit ed3c3cc into main Oct 17, 2026
31 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/chat-drop-reserves-pending branch October 17, 2026 07:21
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