Repository navigation
feat(native-chat): upload composer attachments over SSH - #7832
Conversation
The agent GUI composer's three attach surfaces (image paste, file drop, Attach-file picker) always produced client-local paths. On an SSH worktree the agent runs on the remote host, so those paths silently named files the agent could not read. Terminal TUI drops/pastes have been SSH-aware for a long time; the composer was the remaining gap. - resolve the composer's attachment owner at attach time (local / ssh / runtime / not-ready), mirroring the terminal drop resolver's order - SSH file drops and picked attachments upload into the worktree's .orca/drops via the existing fs:resolveDroppedPathsForAgent IPC and attach the returned remote paths - SSH image paste passes connectionId to clipboard:saveImageAsTempFile so the PNG is written to the remote temp dir over SFTP (terminal parity) - not-ready worktrees get an explicit notice instead of silently attaching local paths; runtime-owned panes keep their existing block Co-authored-by: Orca <help@stably.ai>
📝 WalkthroughWalkthroughThis PR adds attachment ownership resolution for native chat composer flows, with local, SSH, runtime, and not-ready cases. SSH-owned attachments are uploaded through IPC before being attached, and the composer now uses 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
…er (STA-1465) A failed clipboard-image save (SSH connection dropped, oversized image) was swallowed by .catch(() => null), so the paste silently did nothing. The terminal surfaces the same failure via setTerminalError; the composer now shows it through its notice, and a menu-driven paste no longer falls through to the text path on a save error. Co-authored-by: Orca <help@stably.ai>
Clean auto-merge, no conflicts. Brought in from main: - daemon boot hardening: fail builds/CI when terminal daemon can't start; plain-node-entry-guard + verify-packaged-daemon-entry (electron require leaked into daemon-entry chunk, #7844/#7849) - perf(windows): relax whole-process-table scans for terminals with no agent evidence (#7607) — foreground-scan-cadence - fix(agents): route WSL OMP hooks to the Windows listener (#7565/#7641) - fix: recover fresh local terminal spawns from a deleted saved cwd (#7847) - native-chat: upload composer attachments over SSH (#7832) - mobile: keyboard dismiss control; agent-tab launch fix - new GitHub issue draft persistence (#7778) Perf-branch structure preserved (clean auto-merge; no restructured terminal files conflicted). Gates: typecheck 0 errors; terminal-pane + ipc/pty + daemon + pane-manager suites 4497 passed / 14 skipped / 0 failed. Co-authored-by: Orca <help@stably.ai>
Conflict resolutions: - store slices (index/types/test-helpers/diffComments): keep BOTH fork bookmarks slice and upstream new-issue-draft slice. - i18n locales (en/es/ja/ko/zh): keep BOTH fork composer keys (addMenu, planMode, model, planPlaceholder…) and upstream SSH-attachment keys (imagePasteFailed, worktreeNotReady, uploadingAttachments). - system-tray: keep upstream attention-image logic + applyTrayImage(), keep fork 'Tobasco' tooltip. - electron-builder: guard BOTH native Swift helpers (computer-use + upstream's new notification-status) behind existsSync for local dev. - composer/paste/attachments: preserve the fork's bespoke composer (send queue, model picker, plan mode, universal slash, element-dump chips) and its own SSH image-paste model; adopt upstream's attachLocalPaths->attachResolvedPaths hook rename (aliased at the one destructure site). Deleted upstream's paste hook test (targets the owner-model API the fork didn't adopt). - web-preload-api: stub discoverCursor/ClaudeSession->null (desktop-local IPC fallback has no runtime RPC bridge). - launch-agent-in-new-tab: merge pushed it over the 300-line lint budget; extracted the prompt-delivery decision into agent-startup-plan-resolution.ts. DEFERRED: upstream's SSH drag/drop attachment upload (useNativeChatExternalAttachments + resolveAttachmentOwner owner model, stablyai#7832) is NOT integrated into the fork's custom composer — feature work, not a mechanical merge. Fork keeps its existing SSH image-paste path. Typecheck (node/cli/web) clean; native-chat (468), store (19), launch-agent (26) tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Orca <help@stably.ai>
Summary
Fixes STA-1465 — "you cannot upload files on SSH." The agent GUI chat composer (native chat) never uploaded attachments to the remote host, so on an SSH worktree every attach path silently named a client-local file the remote agent could not read. Terminal TUI drops/pastes have been SSH-aware for a long time; the composer was the remaining gap.
All three composer attach surfaces are now SSH-aware:
connectionIdtoclipboard:saveImageAsTempFile, so the PNG is written to the remote temp dir over SFTP (matching terminal image paste). Previously it always wrote to the local temp dir with noconnectionId..orca/drops/via the existingfs:resolveDroppedPathsForAgentIPC (the same primitive terminal drops use) and attach the returned remote paths.The composer resolves its worktree owner at attach time (
local/ssh/runtime/not-ready), mirroring the terminal-drop resolver's order:not-ready(store not hydrated / worktree unknown) shows an explicit notice instead of silently attaching a possibly-remote-but-local path (guards against the [Bug]: Remote host attempting to view a file results in error #6648 class of bug).runtime-owned (remote:) panes keep their existing "not available for remote sessions" block — runtime upload support is a separate seam.Changes
native-chat-attachment-upload.ts— owner resolver + SSH upload helper (new).use-native-chat-external-attachments.ts— drop/picker attach hook that routes local vs SSH-upload (new; extracted to keep the composer under the max-lines limit).use-native-chat-composer-paste.ts— resolves the owner and passesconnectionIdto the clipboard save; a failed save (e.g. SSH connection dropped, oversized clipboard image) now surfaces through the composer notice instead of silently doing nothing, and a failed menu-driven paste no longer falls through to the text-paste path.use-native-chat-composer-attachments.ts—attachLocalPaths→attachResolvedPaths(paths may now be remote).Trade-offs
Deliberate scope decisions, kept consistent with the terminal-drop behavior this PR mirrors:
.orca/drops/is gitignored and lives inside the worktree, so it is bounded by worktree lifetime.not-ready. A folder workspace mixing local and SSH child repos (with no focused runtime env) has no single owner, so attach shows the not-ready notice rather than guessing a host and attaching paths the agent might not read. Terminal drops behave identically in that state; resolving from the pane's actual PTY host is a shared follow-up.Validation over real SSH
Exercised end-to-end against a throwaway Linux Docker SSH target (relay deployed,
demo-projectcloned in the container, isolated dev instance driven over CDP):fs:resolveDroppedPathsForAgentuploaded a real file to/work/demo-project/.orca/drops/upload-me.txt— byte-identical content verified on the remote.connectionId(this fix): a valid 16×16 PNG landed on the container at/tmp/orca-paste-*.png(fileconfirmsPNG image data, 16 x 16), readable by the remote agent.connectionId(old behavior): the image stayed at a macOS-local/var/folders/.../T/orca-paste-*.pngpath that does not exist on the remote — reproducing the exact reported failure.Composer wiring (owner routing, disabled-mid-upload guard,
connectionIdpassing) is covered by unit tests.pnpm tcpasses; baseoxlint(incl.max-lines) passes; new tests: 22 innative-chat-attachment-upload.test.ts+use-native-chat-external-attachments.test.tsx, plus 5 inuse-native-chat-composer-paste.test.tsx(failure notice, no text fallthrough on error,connectionIdpass-through, disabled-mid-save suppression).Notes
pnpm lintis currently red onmainfor two pre-existing reasons unrelated to this PR — aswitch-exhaustivenesserror insource-control-manual-review-url.ts:164and a missing localization keyTerminalSshReconnectOverlay.removeWorkspaceButton(from Fix SSH state for paired remote clients + complete target re-adoption sweep (STA-1468) #7767). This PR adds no new lint errors and its own localization keys are complete.Made with Orca 🐋