Skip to content

Fix ownership for terminal and chat file drops (STA-6940, PR 1/6) - #25749

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/sta-6940-pr1-drop-ownership
Oct 6, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
brennanb2025/sta-6940-pr1-drop-ownership

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1106 $\color{#cf222e}{\Huge{\mathbf{−}}}$​161 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​945
Prod 10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​190 $\color{#cf222e}{\Huge{\mathbf{−}}}$​78 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​112

ELI5

Dropping a file on one terminal split could paste it into the active split, and hovering a title changed which split was active. A file queued during input-method composition in native chat could also attach after the chat moved to another workspace or host. These paths trusted focus or checked the destination before the queued attachment was finally applied.

The independent review found two remaining failures: terminals on a connected runtime server used that server's own “local” host label to search the client's workspace list, so drops could be refused or select a same-ID local workspace; and one stale chat drop could discard a later valid retry queued during the same composition after an SSH reconnect.

This is PR 1 of 6 for STA-6940. Drops now stay with the identified terminal leaf and its captured runtime workspace. Each queued chat drop is checked separately: obsolete drops are refused, and current retries attach once.

What Changed

  • Terminal title bars publish their stable layout leaf identity for OS drops and pass the same identity for internal file drags. Neither dragover nor drop activates a different pane.
  • Missing or stale terminal leaves, outside internal drop targets, and OS payloads without a terminal tab are ignored instead of falling back to the active pane.
  • One workspace-root resolver serves OS and internal terminal drops, including folder workspaces. It derives the client's catalog host from the receiving terminal's captured runtime environment, without consulting the focused runtime. SSH through a runtime also matches the environment and SSH target using the existing recorded-owner routing. A same-ID client-local record, direct SSH record, or another runtime's record cannot supply the root. The dropped file can no longer become its own workspace root; local floating terminals retain their own working directory.
  • The transport's actual local or SSH execution host is retained for upload checks on the server and for destination rechecks, including the captured SSH connection generation. Runtime fixtures now report the real combination of physical host local and a separate runtime environment; creating a transport no longer rewrites workspace rows to match it.
  • Native chat keeps each drop's batch boundary during input-method composition. It refuses obsolete batches individually, attaches current batches once in their original order, retains the existing refusal notice, and preserves the attachment cap. Its destination check stays separate from the source-workspace check, so OS drops receive no workspace-file exemption.

The existing preload → main → window subscriber delivery remains in place. PR 2 adds the path bridge, preparation request, owner hook, and reader guards; PRs 3–5 migrate chat/composers/feedback, terminals, and file/editor/sidebar surfaces; PR 6 removes the broadcast and legacy markers.

Why

Stable leaf identity and the receiving transport identify the destination without changing focus. The server's physical host and the client's workspace-list host name different things; deriving the latter from the captured runtime fixes lookup without changing the upload's execution-host checks. Reusing the existing workspace lookup and recorded-owner routing avoids choosing another host's same-ID workspace.

Keeping gesture boundaries lets a valid retry survive an earlier stale drop while rejecting each obsolete drop as a whole. Flattening only accepted batches preserves insertion order and applies them together, without moving the caret between gestures. A separate chat destination check preserves the distinction between where an attachment may land and whether its paths came from a verified workspace drag.

Differences from the common pattern:

  • Temporary: broadcast delivery and legacy markers remain until PR 6, keeping every surface on its current delivery path during this first ownership repair.
  • Intended: desktop file-path references and guarded SSH/runtime uploads remain. This preserves existing terminal behavior, including local floating-terminal drops.
  • Temporary: web path attachments and native-chat runtime attachments retain their existing refusal until the separately scoped file-byte attachment follow-up.

Linked Issue

STA-6940

Visual Proof

A separate QA agent ran this branch (head a0a5923c29a) as a hidden Orca dev window with an isolated profile and simulated OS file drops through the Chrome DevTools Protocol (Input.dispatchDragEvent). Terminal text was read from each pane's screen buffer and the active pane from app state. Screenshots are uncropped captures of that window. All five checks passed.

1. File dropped on the left pane's title bar while the right pane is active. The path lands in the left pane only; app state shows the right pane is still the active pane (before this PR the title bar delivered to whichever pane was active).

Title-bar drop lands in the left pane

2. Same file dropped on the left pane's body. A second copy of the path lands in the left pane; the right pane is unchanged and still active.

Body drop lands in the left pane

3. File dropped on the divider between the panes. Nothing is pasted anywhere and no error appears: a drop Orca cannot place now does nothing instead of going to the active pane.

Divider drop does nothing

4. A file name with a space. Pasted as one single-quoted shell argument.

Path with a space is quoted

5. File dropped on the floating terminal (a terminal with no project behind it). The path is pasted there, and the main panes are unchanged.

Floating terminal drop

Restructured native chat (macOS, Claude)

A second hidden-window run on this head (a0a5923c29a) with native chat and structured native chat on, and agent tabs opening in chat view. Both chats were proven to be the restructured kind before testing: their tabs are structured agent sessions, the app had zero terminal sessions, and Claude ran through the agent SDK under Orca's provider supervisor, not as a command-line session in a terminal. Chat A is the visible tab; chat B is open in the second tab.

1. File dropped from the OS on chat A's composer. It attaches to A as a file reference, once. Chat B and the (non-existent) terminal get nothing.

OS file drop on the restructured chat composer

2. Image dropped on chat A's transcript area, outside the composer. It attaches to A as one image.

OS image drop on the chat transcript area

3. Hidden chat isolation. A file dropped on chat B attached to B only; back on A, nothing from B appears.

Chat A unchanged after a drop on chat B

4. Image pasted into chat B's composer (a real PNG on the system clipboard, pasted through the composer's paste handler). Exactly one image attaches to B, next to B's own dropped file; chat A gains nothing.

Image paste into the restructured chat

5. File dragged from Orca's file explorer into chat A. It attaches as a workspace file reference, once.

File explorer drag into the restructured chat

6. File dropped while an input method was mid-composition (this PR's new destination re-check). The file attached exactly once after composition ended; the composed text survived.

Drop during input-method composition

7. The attachment reaches the agent. With only the dropped image attached, a message was sent; Orca's session journal records the submission with exactly that image. Claude's reply never arrived in this isolated test profile (the turn stayed "Working…"), so the reply itself is not verified.

Message with the dropped image, before sending

Not covered by this run: SSH, WSL and remote-runtime workspaces (covered by the unit fixtures listed below), Linux and Windows. There is no "before" capture; the before behaviour is pinned by the regression tests below, which fail against main's code.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated

On macOS, the following explicit 24-file Vitest command passed 215/215 tests:

ORCA_BACKGROUND_LAUNCH=1 pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/terminal-drop-handler.test.ts src/renderer/src/components/terminal-pane/terminal-drop-internal-handler.test.ts src/renderer/src/components/terminal-pane/TerminalPaneHeaderOverlay.test.tsx src/renderer/src/components/terminal-pane/terminal-drop-pane-resolution.test.ts src/renderer/src/components/terminal-pane/terminal-drop-worktree-path.test.ts src/renderer/src/components/terminal-pane/terminal-drop-transport-owner.test.ts src/renderer/src/components/terminal-pane/terminal-drop-local-workspace.test.ts src/renderer/src/components/terminal-pane/use-terminal-pane-global-effects-file-drop.test.ts src/renderer/src/components/native-chat/use-native-chat-external-attachments.test.tsx src/renderer/src/components/native-chat/native-chat-external-attachments-destination.test.tsx src/renderer/src/components/native-chat/use-native-chat-composer-attachments.test.tsx src/renderer/src/components/native-chat/native-chat-composer-drop-scope.test.tsx src/renderer/src/components/native-chat/native-chat-composer-workspace-file-drop.test.tsx src/renderer/src/components/native-chat/native-chat-pane-file-drop.test.tsx src/renderer/src/components/native-chat/native-chat-view-file-drop.test.tsx src/shared/native-file-drop.test.ts src/renderer/src/hooks/composer-native-file-drop.test.ts src/renderer/src/components/terminal-pane/terminal-drop-path-writer.test.ts src/renderer/src/components/terminal-pane/terminal-drop-runtime-owner.test.ts src/renderer/src/components/terminal-pane/terminal-drop-shell.test.ts src/renderer/src/components/terminal-pane/terminal-drop-upload-report.test.ts src/renderer/src/components/terminal-pane/terminal-drop-image-path.test.ts src/renderer/src/components/terminal-pane/terminal-drop-write-failure.test.ts src/renderer/src/components/terminal-pane/terminal-drop-runtime-catalog-owner.test.ts

Both follow-up regressions fail on the reviewed PR head 2dcc2a94273260d6b3aec5371c2934634ae7c553 and pass after these fixes. With the final tests retained, I temporarily replaced the four changed production modules with that head's sources and ran:

ORCA_BACKGROUND_LAUNCH=1 pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/terminal-drop-runtime-catalog-owner.test.ts src/renderer/src/components/native-chat/native-chat-external-attachments-destination.test.tsx

The reviewed head produced 11 behavioral assertion failures and 9 passes: 10 runtime ownership cases failed across OS and internal drops, and the stale-then-current SSH composition retry failed. After restoring the fixed sources, the identical command passed 20/20 tests. Runtime worktree, folder, and SSH fixtures keep a different runtime focused and include same-ID local records; the SSH fixture also includes a direct-client record and another runtime's same target. The chat test queues files and images on SSH generation 1, reconnects to generation 2, queues the retry, then flushes twice: only the retry attaches, exactly once, and the existing owner-change notice remains.

Initial PR validation temporarily replaced the nine changed existing source modules with origin/main at 9756daeced4e, retaining the regression tests, then ran the title, pane resolution, workspace path, internal handler, global terminal subscriber, local-workspace, and external-attachment destination test files. 16 tests failed and 28 passed, covering all four title drag/drop combinations, missing/stale destinations, folder/host lookup, the dropped-path root fallback, missing terminal tab, and queued workspace/host/SSH-generation changes. Both native and internal floating-terminal tests passed against main and this branch. All source files were restored afterward.

The two OS workspace-exemption guards already pass on main. Initial PR validation proved they catch the rejected implementation by temporarily changing the OS lane to pass its destination check as targetOwnerIsCurrent: both immediate and queued guards failed. Restoring the separate destinationIsCurrent check returned the entire suite to green.

Also passed: pnpm tc:web; pnpm run check:code-quality:changed; full-file pnpm exec oxlint on all 22 changed TypeScript files; pnpm run check:react-doctor:changed (no issues); pnpm run verify:localization-catalogs; formatting and git diff --check.

SSH, runtime, Windows/WSL, and folder cases were exercised through unit fixtures. No real SSH/WSL host, Linux/Windows machine, or packaged build was verified; the Electron check is under Visual Proof.

Review

Self-reviewed destination identity, source provenance, server host identity, workspace-list qualification, and queued drop settlement, and line budgets. The title overlay is net −1 effective line and the global-effects hook is net negative; full-file lint enforces their limits. No preload, main-process relay, editor options, sidebar readers, web entry files, or documentation changed.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

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 (after screenshots above; the before behaviour is pinned by tests failing on main)
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (focused checks passed above; full build and full lint left to CI)

@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6bc4423f-d017-4921-9fb0-e485c8581366
📥 Commits

Reviewing files that changed from the base of the PR and between 610f95e and de2e0e0.

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

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 74034621-f8c0-4650-ad8f-93cbf7251258
📥 Commits

Reviewing files that changed from the base of the PR and between a0a5923 and 610f95e.

📒 Files selected for processing (2)
  • src/renderer/src/components/native-chat/use-native-chat-external-attachments.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-external-attachments.ts

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


📝 Walkthrough

Walkthrough

Native chat attachments now revalidate their destination before attachment and when queued paths are flushed after input-method composition. Terminal file drops now require pane or tab identity, resolve workspace paths using the receiving transport’s host and runtime environment, and check captured ownership before delivery. Tests cover destination changes, pane routing, host-specific path resolution, and drop behavior across local, runtime, and SSH contexts.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 610f9

No actionable issue remains in the reviewed context; the change is ready to proceed through normal CI.

Security Architecture Review

Security architecture risk: 🔵 Low · up to a0a59

The changes strengthen destination isolation and reject obsolete drops instead of redirecting them. No introduced or worsened security issue was established in the inspected flows. Some reconnect, teardown and partial-upload behavior remains incompletely verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The inspected authority is scoped to dropped file paths, the receiving terminal or chat attachment scope, and uploads into the selected workspace's .orca/drops directory. A misrouting failure could expose paths or copied files to the wrong shell or agent. The inspected changes narrow destination selection; broader account or environment exposure was not established.

Trust Boundaries and Controls

  • observed — Drag payloads remain input data rather than authority to select another destination. Terminal delivery uses the resolved leaf and transport snapshot; chat application distinguishes destination validity from source-workspace ownership. SSH upload authority is checked again outside the renderer.

Resilience and Maintainability Implications

  • inferred — Residual lifecycle uncertainty is not an established PR regression. Chat hooks still lack explicit unmount invalidation, as at the base, so delayed same-scope cache updates require further verification. The unchanged terminal writer checks target identity between paths but not execution-host metadata; whether recovery can change that owner while retaining the same accepted PTY identity remains unresolved.

Hardening Proposals

  • proposed — Consider explicit lifetime invalidation for delayed chat work and a common owner-currentness guard at each terminal write boundary. These would make teardown and same-handle recovery guarantees explicit; they are hardening proposals, not verified vulnerabilities introduced by this PR.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 22 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: fixing ownership for terminal and chat file drops. The issue and PR sequence identifiers do not obscure the purpose.
Description check ✅ Passed The description is detailed and covers the change, rationale, linked issue, testing, review, and cross-platform limitations. It includes after screenshots and explains that before behavior is covered …
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · 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

Copy link
Copy Markdown
Contributor Author

Review summary

This PR went through an independent code review, a fix round, a second review of the fixes, and a rendered check in a real Orca window. The reviews were done by separate agents that did not write the code. Their reports are summarized here because they were kept off GitHub while the work was in progress.

First review (head 2dcc2a94273): two bugs found

  1. Drops failed on terminals running on a connected remote Orca server (serious). Such a terminal reports its own machine as local, but Orca lists that server's worktrees and folders under the server's runtime host. Looking the workspace up by local missed them, so an OS file drop showed "Worktree path not available." and a drag from the file explorer silently did nothing. The original tests did not catch it because a test fixture rewrote the workspace rows to match the terminal's host.
  2. A valid retry could be lost while typing with an input method (IME). Drops made during composition are queued until it ends. If one queued drop's destination had changed (for example the SSH connection reconnected), the whole queue was refused, including a later valid retry.

The reviewer also confirmed by re-running the new tests against main's code that the title-bar, missing-pane, folder-lookup and queued-attachment tests fail there for the intended reasons.

Fixes (head a0a5923c29a)

  1. Terminal drops now look up their workspace under the runtime's own host while keeping the terminal's physical host for the safety re-checks. SSH reached through a runtime must match both the runtime and the SSH target. There is no fallback to the focused runtime. The tests now use the real combination (local plus a runtime) with a different runtime focused.
  2. Each drop in the queue is kept as its own batch: a stale batch is refused on its own, and current ones are applied once.

Second review of the fixes: approved

Both findings are closed for OS drops and file-explorer drags across local, direct SSH, runtime, SSH through a runtime, runtime folders and the floating terminal. Restoring the pre-fix code made the new tests fail (10 and 1 failures), and the full 24-file drop suite passed (215 tests). No new issues, scope creep or rule problems were found.

Rendered check

All five scenarios passed in a hidden Orca dev window with simulated OS file drops; screenshots are in the PR description under Visual Proof.

Not verified

Real SSH, WSL and remote-runtime hosts, Linux and Windows. Those paths are covered by unit fixtures only.

@brennanb2025

brennanb2025 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

Restructured native chat check

The restructured native chat (native chat + structured native chat on, agent tabs opening in chat view) was exercised on this head (a0a5923c29a) in a hidden Orca window on macOS with Claude. Both chats were confirmed to be structured agent sessions before testing, with no terminal sessions in the app. Screenshots are in the description under "Restructured native chat".

Check Result
OS file drop on chat A's composer Attached to A once; chat B unchanged
OS image drop on chat A's transcript area One image attached to A
Drop on chat B, then back to A B got its file; A gained nothing
Image paste from the real clipboard into chat B One image attached to B; A unchanged
Drag from Orca's file explorer into chat A One workspace file reference
File dropped during input-method composition Attached once after composition ended
Sending the dropped image to Claude Orca's session journal shows the message with exactly that image; Claude's reply did not arrive in the isolated test profile, so the reply is unverified

The test machine's real ~/.codex and ~/.claude/settings.json files and Orca's hook files were byte-identical before, during and after the run.

Oddities seen, outside what this PR changes (not yet checked against main)

  1. The chat's right-click Paste menu item did nothing with a PNG on the clipboard, while a normal paste into the composer worked.
  2. A paste that landed on the chat page but not the composer left an extra image preview chip in the composer.
  3. A file dropped right after composed text is inserted with no space before the @ reference (ni@/path/notes.txt), which may stop it reading as a file reference.
  4. The one Claude turn stayed on "Working…" for about 16 minutes with no error shown. This is likely specific to the isolated test profile.

These will be checked against main separately rather than folded into this PR.

…-pr1-drop-ownership

# Conflicts:
#	src/renderer/src/components/native-chat/use-native-chat-external-attachments.ts
@brennanb2025
brennanb2025 merged commit 5345ba3 into main Oct 6, 2026
51 of 53 checks passed
brennanb2025 added a commit that referenced this pull request Oct 6, 2026
brennanb2025 added a commit that referenced this pull request Oct 7, 2026
…er (#25146)

* feat(native-chat): a paired server keeps a store for chat attachments

A structured chat on a paired Orca server had nowhere to put a file the client
attached. The server now keeps a per-chat attachment store under its userData,
filled through agentSessionAttachment.uploadStart/Append/Commit/Abort and read
back for previews through agentSessionAttachment.read, behind the structured
session gate and advertised as agent-session.attachments.v1.

Nothing records cleanup as owed: a sweep re-derives what may go from the host's
chat records and journal (unfinished uploads after an hour, uploads for a chat
that never existed or that its journal never mentions after a day). The clipboard
RPC's in-flight bookkeeping moves into a shared ChunkedUploadRegistry both use.

* feat(native-chat): upload attached files into a paired server's chat store

Main streams dropped or picked files (fs:uploadPathsToAgentSessionAttachments)
and pasted images (clipboard:saveImageAsTempFile with agentSessionAttachment)
into the chat's store on its paired server, reusing the file-import slice
streamer and pinning every call to the pairing revision and server process.
The browser client's paste takes the same route.

* feat(native-chat): attach files to a structured chat on a paired server

Pasted images, files dropped from Finder/Explorer and the file picker no longer
refuse with "Local attachments are not available for remote sessions." in a
structured chat on a paired server: they upload into that server's chat store and
the chat gets only the stored path. Dropped files show as pending chips at once
so Send waits for them; every attached item carries the server, pairing and chat
it was stored for, and a send to anywhere else drops it with the existing
"changed hosts" notice. Chips and transcript images read stored files back
through the server, never from this machine's disk. An older server gets an
update notice instead of an upload. The terminal-backed chat keeps refusing.

* test(native-chat): type the attachment test doubles without bare casts

* refactor(native-chat): keep the clipboard RPC on its own upload bookkeeping

The chunked upload registry stays for the chat attachment store only, beside it.

* feat(native-chat): claim chat attachments when the host admits a message

A message's references into the host's attachment store are claimed in the same
journal transaction that makes it durable (a direct send, a queued draft, a /clear
carry). The sweep deletes an upload only after marking it in that database while
no claim exists, so a send and a sweep can never both win: a client's send that
names an expired or foreign upload is refused whole with the new attachmentExpired
reason, before anything is recorded. This replaces scanning chat transcripts for
paths.

The store is now <root>/<upload id>/<name>, refuses uploads for chats the host
does not hold, caps stored names in UTF-8 bytes and avoids Windows device names.
The preview read goes through the protected bounded read and the request's reply
budget, so an image too large for one reply is refused instead of closing the
connection.

* feat(native-chat): let structured Claude read the host's chat attachment store

Attached non-image files live outside the workspace; the store root is passed as an
added directory so the agent reads them without asking, the common pattern.

* fix(native-chat): skip a dropped folder before staging walks into it

* fix(native-chat): pin the browser client's chat paste to its server

Every upload call goes to the environment the paste was meant for and checks its
pairing and server process, as the desktop upload does; a re-pair ends the upload
instead of storing the image on another server.

* refactor(native-chat): let the host's claim be the only attachment check

The composer no longer records which server and pairing each attachment came from,
and Send no longer strips attachments it judges foreign: the host refuses an
expired or unknown stored path when it admits the message, which also covers
retries, Stop-restores and queued edits the client check missed. Previews of
stored files route through the chat's own server by path.

Removing a file's chip while it uploads now keeps its @path out of the draft. A
dropped or picked file shows its name and kind on its chip while it uploads, with
no separate progress toast, and files that did not attach are named in one notice.
A rich-text paste into a chat on an older server no longer shows the update notice
beside the pasted text.

* chore(native-chat): keep the claim hook beside the draft consume and fit the line budgets

The submission's claim runs in the same append hook as a draft's consume, owned by
the queued-message collaborator, so the journal store stays within its size limit.
Formats the new files and regenerates the runtime-required English catalog.

* test(native-chat): pin the attachment store grant in the Claude launch, restore upload result types

* fix(native-chat): create the attachment store at install and claim only exact store paths

Claude drops an added directory that does not exist when it starts, so the store
root is created when the host installs it, best effort. A commit keeps its upload
in flight until the rename lands, so a sweep never takes a slow upload's part file.
Only a path under this host's exact store root is claimed and required; any other
mention of a store path is plain text and never refuses the message.

* refactor(native-chat): reuse the newer-Orca notice and drop leftover attach options

An older server's refusal to store attachments uses the notice every other write
it refuses already shows, so one string fewer in every catalog; the attach
callbacks lose an options parameter no caller passes since the provenance check
went.

* fix(native-chat): give a message refused for an expired attachment back to the composer

Sending the same message again can never bring the attachment back, so instead of
a Retry that always fails the message's text and images return to the composer,
as a Stop's withdrawn message does, and the notice says what to remove.

* fix(native-chat): keep uploads across a prompt, say why a file did not attach

An upload that finishes while a prompt card has replaced the composer lands in the
scope's attachment and draft caches, which the composer reads back when it
returns, instead of the unmounted composer. The single failure notice names the
cause the files share, such as the size limit. Rich text pasted into a chat on an
older server no longer flashes an image chip: the chip waits for the server to
take the image. A picked command waits, as Send does, while an attachment is still
uploading.

* fix(native-chat): keep a paste's upload across a prompt; pin the Claude grant hand-off

A paste uploading into a paired server's store keeps its chip live when a prompt
card unmounts the composer, and its result is filed for the composer's return,
as a drop's is. A failure cause ending in full-width punctuation gets no extra
full stop. A runtime test pins that the store root reaches Claude's launch
resolver through the adapter.

* test(native-chat): type the grant hand-off captures without casts

* test(native-chat): pin that the composer files a paste's upload across a prompt

* fix(native-chat): retry a held rename at commit and keep cut names Windows-safe

A commit renames the part file with the Windows retry the app uses elsewhere, so
an antivirus or indexer holding it briefly no longer loses the upload. A name cut
to the byte limit is stripped of trailing dots and spaces again. The upload
pump's result cast states why it holds.

* fix(native-chat): keep attachments still on their way in the pane's attachment cache

A prompt card unmounts the composer, and an attachment still saving or uploading
lived only in that composer: one that came back showed no pending chip, so Send
went out without the file and the file then landed in the next draft. Pending
chips now live in the pane's attachment cache beside settled ones and settle
there whichever composer is showing, so Send waits for them after a remount too.
A stored file's @path goes into the pane's draft cache, which keeps it through an
input-method composition and a remount. A rich-text paste's image is registered
as a hidden pending chip before the server is asked, so Send waits for it from
the start, and it shows only once the server takes it.

* test(native-chat): a dropped file still uploading stays pending across a remount

* fix(native-chat): reveal a rich-text image in a composer that came back; keep caret inserts

A rich-text paste's held image is revealed through the pane's attachment cache,
so a composer a prompt card remounted during the server's answer shows it rather
than holding Send on an invisible chip. A stored file's @path goes in at the
caret while the composer is showing and not composing, as every other attach
does; only mid-composition or after a remount does it go to the pane's draft.

* fix(native-chat): never evict a pane's attachments while a composer shows them or one is on its way

The pane attachment cache is now where chips live, so its 128-scope bound passes
over a scope a mounted composer subscribes to or that still holds a pending
attachment, and evicts the oldest scope nobody uses instead. Protected scopes are
bounded by mounted composers and attachments in flight.

* fix(native-chat): never evict the scope just written when every older one is in use

* fix(native-chat): keep the attachment store out of the RPC method table's imports

The method table is imported far and wide (the SSH relay's CLI included), and the
attachment RPCs pulled in the store, whose preview read loads modules that read
fs constants at load: any test that mocks fs/promises without them failed to
import. The installed store now lives in a small registry module; only the host
wiring loads the store itself.

* refactor(native-chat): the submission hook gets its own module

Merging main added the operation receipt to the queued-message insert, which
put journal-queued-messages.ts over the 300-line limit. The submission hook
only uses the queued-messages object's public methods, so it moves out.

* refactor(native-chat): fit the attachment sweep and paste upload into main's line budgets

After merging main, the record store and the clipboard handlers each ran
a few lines over the 300-line budget. The sweep now asks the record store
whether a chat is recorded through the two lookups it already has
(readable or unreadable) instead of a new id-listing method, and the
paired-server paste upload lives beside the other attachment uploads.
No behavior changes.

* fix(native-chat): pending chips sit beside main's saved draft, which keeps server-stored images

Main now saves a composer's draft (text and settled images) in one store
that survives a reload or quit. This branch kept every chip, settled or
not, in its own pane cache. After the merge the saved draft owns settled
images and the pane cache holds only chips still on their way: they come
back pending in a composer a prompt card remounted, hold Send, settle into
the saved draft whichever composer is showing, and are never saved
themselves, so a restored draft cannot bring back an upload as if it were
attached.

An image a paired server stored for the chat is saved with the draft as
the real image (a pasted one is no longer turned into a "Not kept"
placeholder), and the restore check leaves it to that server, whose claim
at Send refuses one it no longer holds, instead of asking this machine's
disk for a path that only exists on the server.

Also: previews and the pending subscription move into their own small
hooks to fit the line budget, the "local attachments" notice moves to the
composer-target module so the attachments hook no longer pulls in the
upload module's imports, and tests follow main's new mocks.

* test(native-chat): give the claims test main's provider handle and message source

* fix(native-chat): a paste still uploading dies with its tab or workspace

A pasted image still uploading to a paired server sits in the pending
chip cache, which by design outlives the composer and its tab. Removing
the workspace deleted its saved drafts but left those chips, so the
upload finishing afterwards recreated and saved the deleted draft. With
the workspace's tabs gone it had no owner either, so no later workspace
cleanup could ever remove it.

A pending chip now records the owner its draft would have, resolved the
way the draft store resolves one when the chip is added. Workspace
removal and a user's tab close drop pending chips by the same owner,
conversation and tab matches they delete drafts by, and a chip that
settles after its chat's tab closed writes its draft under the owner it
was begun in.

* fix(native-chat): the claim type uses the journal's own SQLite type

* refactor(native-chat): read the pending-image handlers off the composer's attachments

Main's multi-file picker (#23956) and this branch together took NativeChatComposer over the 400-line limit; reading the two pending-image handlers the way the neighbouring ones already are keeps it at the limit.

* test(native-chat): pass the launch-args resolver main now requires in the attachment grant test

* fix(native-chat): grant the attachment store beside folders the saved Claude Arguments add

Main (#25721) now builds additionalDirectories from the user's --add-dir arguments; this branch's attachment-store grant replaced that list instead of adding to it. Both are granted now. Moves the Claude session-id derivation to its own module to keep the resolver under the line limit.

* test(native-chat): run the attachment store's SQLite tests in the Node runtime project

* test(native-chat): follow main's attach ownership recheck (#25749) in the attachment tests

* test(native-chat): a named upload chip still shows when the agent takes no images

* fix(native-chat): a paired-server image paste failure keeps its error apart, as main's notice card does

* fix(native-chat): the attachment sweep reads the chat list directly now that records have no import still owed
@brennanb2025
brennanb2025 deleted the brennanb2025/sta-6940-pr1-drop-ownership branch October 8, 2026 02:03
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