Skip to content

fix(clipboard): route runtime-owned SSH image paste through the runtime - #19352

Merged
nwparker merged 1 commit into
mainfrom
fix/17679-nested-ssh-clipboard-paste
Sep 8, 2026
Merged

nwparker merged 1 commit into
mainfrom
fix/17679-nested-ssh-clipboard-paste

Conversation

@nwparker

@nwparker nwparker commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​223 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​223
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​20 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​13

Fixes #17679

Note: #17787 (community fork) targets the same issue with the same core routing change plus a shared-protocol refactor across desktop main and the web preload. This PR is the minimal, in-repo version of the routing fix only, with the regression pinned at the IPC seam against the real SSH provider registry. Either can land; if #17787 is preferred, this one should be closed.

ELI5

You have three machines in a row: your laptop, an Ubuntu box running Orca Server, and a Jetson that the Ubuntu box reaches over SSH. You copy a screenshot on the laptop and paste it into a terminal on the Jetson.

The laptop's job is only to hand the image to the Ubuntu box and say "put this on your Jetson connection." Instead, when the laptop saw the word "Jetson" in the request it went looking for a Jetson SSH connection in its own pocket. It never had one (the Ubuntu box dialed that connection, not the laptop), so it gave up with "Remote connection dropped. Click Reconnect" — advice that cannot help, because there is nothing on the laptop to reconnect.

Now the laptop hands the image to the Ubuntu box whenever the Ubuntu box owns the workspace, and tells it which of its SSH targets should receive the file.

Root cause

src/main/window/clipboard-ipc-handlers.ts saveClipboardImageBufferForTarget routed to the paired runtime only when runtimeEnvironmentId && !connectionId. It read "has an SSH connectionId" as "is a client-local SSH target". In the nested topology the renderer legitimately supplies both ids (terminal-clipboard-paste.ts forwards them verbatim; getRepoSshConnectionId documents that a connectionId beside a runtime: host names the runtime's nested target). So the runtime was skipped and control fell to clipboard-image-temp-file.ts, which called requireSshFilesystemProvider on a registry (src/main/providers/ssh-filesystem-dispatch.ts) that only holds connections this process established. The nested connection lives in the Ubuntu server's process; the lookup missed and threw SSH_FILESYSTEM_PROVIDER_UNAVAILABLE_MESSAGE — the reported string verbatim.

Second arm of the same defect: clipboard-runtime-image-upload.ts hardcoded connectionId: null on both the chunked startImageUpload and the single-frame saveImageAsTempFile fallback, so even after relaxing the guard the runtime would have saved the file on the Ubuntu host rather than the Jetson. Relaxing the guard alone would move the failure, not remove it.

Fix (one change, both arms)

  • clipboard-ipc-handlers.ts: route to the runtime whenever a runtimeEnvironmentId is present, forwarding the connectionId (or null).
  • clipboard-runtime-image-upload.ts: thread connectionId through startImageUpload and the single-frame fallback.

Unchanged and pinned: plain client-local SSH (connectionId only) still uses this process's provider registry; plain local paste (no args) still writes to the OS temp dir; a client-dialed target that really is gone still reports the dropped-connection verdict.

Boundaries

  • Wire compatibility — Rule 1 (safe). No new field, opcode, or method. clipboard.startImageUpload / clipboard.saveImageAsTempFile have accepted connectionId: string | null since they were introduced, and the server already honours it on commit (src/main/runtime/rpc/methods/clipboard.ts). The web client has forwarded it all along (web-clipboard-api.ts). This PR only makes the desktop client send a value the server already understands.
  • SSH execution boundary. The execution host (the runtime) now performs the save on its own SSH connection; the client no longer treats "not in my registry" as evidence about the remote connection's state.
  • Not a git-worktree-only path: getRuntimeEnvironmentIdForWorktree / getConnectionId resolve folder workspaces too, and the main-process change is shape-only.
  • Cross-platform: the reporter hit this on Windows and macOS clients; the change is in host-neutral routing.

Reproduction

  1. Orca Server on an Ubuntu box; desktop client paired to it as a Remote Orca Server.
  2. From the Ubuntu server, add an SSH target (the reporter used a Jetson) and open a project on it.
  3. Open a terminal in that project, copy an image on the client, paste.
  4. Before: Image paste failed: ... Remote connection dropped. Click Reconnect on the SSH target before retrying.

Before / after proof (#17679)

Probe at the IPC seam, clipboard:saveImageAsTempFile, with only electron and the runtime transport mocked; the real ssh-filesystem-dispatch registry is used, with one client-dialed connection registered and the nested target deliberately absent (as in the real client process). Same instrument that reproduced the reported string.

arg shape (built the way the renderer builds it) origin/main this PR
A nested: {connectionId:'jetson', runtimeEnvironmentId:'ubuntu-server'} ERR Remote connection dropped. Click Reconnect on the SSH target before retrying. — runtime calls=0 OK /tmp/on-runtime-target.png — runtime calls=3, startImageUpload {connectionId:'jetson'}
B runtime only: {runtimeEnvironmentId:'ubuntu-server'} OK, startImageUpload {connectionId:null} OK, startImageUpload {connectionId:null} (unchanged)
C both ids, unknown env ERR Remote connection dropped ... (runtime never consulted) ERR Unknown environment (runtime's own verdict, runtime calls=1)
D client-local SSH: {connectionId:'client-dialed'} OK /var/tmp/orca-paste-...png, runtime calls=0 OK, runtime calls=0 (unchanged)
E plain local: undefined OK /tmp/orca-paste-...png OK (unchanged)

Symptom map: (a) the paste failure — row A; (b) the misleading Reconnect advice — row A/C now surface the runtime's own verdict; (c) hardcoded connectionId:null — row A's startImageUpload params now name the target; (d) client-local SSH and plain local keep working — rows D/E.

Not yet measured on a real three-machine stack; the nested arg shape is established from the renderer selectors against the repo's own fixtures (connection-context.test.ts "keeps a runtime host nested SSH target"). An end-to-end confirmation on real nested hardware is worth doing once this lands.

Verification bar

New src/main/window/clipboard-runtime-owned-ssh-paste.test.ts (7 tests, real SSH registry, nested args passed as one object and asserted from the same object the handler received). Per-regression mutation results — each mutation re-introduces exactly one defect:

mutation failing tests
M0 origin/main production files 3 (nested chunked, nested fallback, runtime verdict)
M1 restore && !args?.connectionId guard only 3
M2 startImageUpload hardcodes connectionId: null 1 (nested chunked only)
M3 single-frame fallback hardcodes connectionId: null 1 (nested fallback only)
M4 handler drops the 4th arg 2 (both nested)
M5 over-correction: any connectionId goes to the runtime 2 (client-dialed SSH, dropped client target)
restored 0

Also green: clipboard-ipc-handlers.test.ts (23), runtime/rpc/methods/clipboard.test.ts, web-preload-api-clipboard.test.ts, terminal-clipboard-paste.test.ts, clipboard-dashboard-popout-access.test.ts; pnpm tc:node; pnpm run check:code-quality:changed; oxfmt.

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: c7bc8407-2b68-4e4c-a8f6-f03e65c0b63f

📥 Commits

Reviewing files that changed from the base of the PR and between d0506bf and 34f5e55.

📒 Files selected for processing (3)
  • src/main/window/clipboard-ipc-handlers.ts
  • src/main/window/clipboard-runtime-image-upload.ts
  • src/main/window/clipboard-runtime-owned-ssh-paste.test.ts

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


📝 Walkthrough

Walkthrough

Clipboard image saves now route through the runtime whenever runtimeEnvironmentId is present. The SSH connectionId flows through direct runtime uploads and the single-frame fallback. New tests cover runtime-owned SSH pastes, runtime errors, local SSH targets, unavailable providers, and local clipboard saves.

Merge Risk: ⚪ Minimal · up to 34f5e

Clipboard image pastes for runtime-owned SSH targets now save through the owning runtime while preserving existing local SSH and local paste behavior. The covered routing and fallback paths indicate no remaining merge-blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 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 and concisely describes the primary change: routing runtime-owned SSH image pastes through the runtime.
Description check ✅ Passed The description is detailed and covers the problem, root cause, fix, scope, linked issue, reproduction, before-and-after behavior, and automated verification. It does not use every template heading or…
Linked Issues check ✅ Passed The changes address issue #17679 by routing runtime-owned SSH clipboard uploads through the runtime, forwarding the nested connectionId for both upload paths, preserving local behavior, and adding reg…
Out of Scope Changes check ✅ Passed The production changes and regression tests are directly related to the nested SSH clipboard paste failure. No unrelated code changes are identified.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 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.

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

✅ No new issues found.

Reviewed changes

  • Runtime-owned SSH image paste routing — saveClipboardImageBufferForTarget now routes to the paired runtime whenever a runtimeEnvironmentId is present, forwarding args?.connectionId ?? null instead of gating on !connectionId.
  • connectionId threading — clipboard-runtime-image-upload.ts threads the target id through clipboard.startImageUpload and the single-frame clipboard.saveImageAsTempFile fallback, replacing the hardcoded connectionId: null.
  • Integration regression test — a new 7-test file pins the nested Remote Server → SSH case at the IPC seam against the real ssh-filesystem-dispatch registry, with per-regression mutation coverage documented in the PR body.

The root-cause analysis holds up against the surrounding code: getRepoSshConnectionId returns the runtime's nested target for a runtime: host (src/shared/execution-host.ts:204), and both terminal paste entry points (terminal-pane-paste-execution.ts, terminal-pane-menu-paste.ts) forward both ids verbatim, so the two id fields can never cross-route through the renderer. Wire compatibility is genuinely safe — connectionId is optional().nullable() on a non-strict zod schema and was already sent as null — and the client-local SSH, plain local, and runtime-only cases are all pinned as unchanged. The new assertions are exact (forwarded params and runtime call counts), not truthiness checks, so they will fail on regression.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

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.

[Bug]: Clipboard image paste fails in nested Remote Server → SSH session with "Remote connection dropped"

1 participant