Skip to content

feat(native-chat): upload composer attachments over SSH - #7832

Merged
brennanb2025 merged 2 commits into
mainfrom
enable-ssh-uploads
Jul 8, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
enable-ssh-uploads

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • Image paste — passes the worktree's connectionId to clipboard: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 no connectionId.
  • File drop and Attach-file picker — upload into the worktree's .orca/drops/ via the existing fs:resolveDroppedPathsForAgent IPC (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.
  • A composer disabled mid-upload (pty drop / presence-lock) drops the result instead of attaching into a guarded composer.

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 passes connectionId to 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).
  • Three new i18n keys across all five locales.

Trade-offs

Deliberate scope decisions, kept consistent with the terminal-drop behavior this PR mirrors:

  • No size cap on uploads. Local attach references files in place with no limit, so capping only the SSH side would make the same file attach locally but error remotely. Uploads stream over SFTP (memory stays bounded); the cost of a huge file is transfer time, not a failure.
  • Sequential uploads over one SFTP session. All files in a batch share one SSH pipe, so parallel writes would mostly interleave on the same bottleneck while making failure/ordering semantics messier. A large first file delays the rest of its batch; same as terminal drops.
  • Indeterminate "Uploading…" toast — no per-file progress or cancel. Deferred on purpose: the upload IPC is a single invoke with no progress channel, so real progress/cancel needs a main→renderer event stream, cancel-token plumbing, and partial-file cleanup. That is a self-contained follow-up worth building whole if payloads grow beyond today's screenshots/small files; a half-version (e.g. cancel with no feedback) adds complexity without the UX.
  • No cleanup daemon for uploaded files. Pasted images rely on the OS reaping the (local or remote) temp dir — the same lifecycle local paste has always had. .orca/drops/ is gitignored and lives inside the worktree, so it is bounded by worktree lifetime.
  • Mixed-ownership folder workspaces resolve to 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-project cloned in the container, isolated dev instance driven over CDP):

  • Upload seam (drop + Attach button): fs:resolveDroppedPathsForAgent uploaded a real file to /work/demo-project/.orca/drops/upload-me.txt — byte-identical content verified on the remote.
  • Image paste, fixed vs. bug (before/after):
    • With connectionId (this fix): a valid 16×16 PNG landed on the container at /tmp/orca-paste-*.png (file confirms PNG image data, 16 x 16), readable by the remote agent.
    • Without connectionId (old behavior): the image stayed at a macOS-local /var/folders/.../T/orca-paste-*.png path that does not exist on the remote — reproducing the exact reported failure.
  • UI: chat composer renders over the SSH agent tab with the Attach button present.

Composer wiring (owner routing, disabled-mid-upload guard, connectionId passing) is covered by unit tests. pnpm tc passes; base oxlint (incl. max-lines) passes; new tests: 22 in native-chat-attachment-upload.test.ts + use-native-chat-external-attachments.test.tsx, plus 5 in use-native-chat-composer-paste.test.tsx (failure notice, no text fallthrough on error, connectionId pass-through, disabled-mid-save suppression).

Notes

Made with Orca 🐋

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>
@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This 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 attachResolvedPaths plus a new useNativeChatExternalAttachments hook for drag-and-drop, file picker, and clipboard paste. Paste handling now resolves owner state at paste time and can show a worktree-not-ready notice. New tests cover owner resolution, upload behavior, hook behavior, and paste edge cases. Localization entries were added for the new composer messages in en, es, ja, ko, and zh.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the change well, but it misses required template sections like Screenshots, AI Review Report, and Security Audit. Add the missing template sections: Screenshots (or 'No visual change'), a testing checklist, an AI Review Report, and a Security Audit summary.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 accurately summarizes the main change: making native-chat composer attachments upload over SSH.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

…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>
@brennanb2025
brennanb2025 merged commit 95f3933 into main Jul 8, 2026
1 check passed
Jinwoo-H added a commit that referenced this pull request Jul 9, 2026
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>
iarrom added a commit to iarrom/tobasco that referenced this pull request Jul 9, 2026
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>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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