Repository navigation
fix(clipboard): route runtime-owned image paste through the runtime for server-owned SSH targets - #17787
fix(clipboard): route runtime-owned image paste through the runtime for server-owned SSH targets#17787cmer wants to merge 3 commits into
Conversation
…or server-owned SSH targets A clipboard image pasted into a runtime-owned pane whose worktree lives on a server-owned SSH target (client -> orca serve -> SSH) was routed to the client's own SSH stack, which has no such connection, failing with 'Remote connection dropped. Click Reconnect on the SSH target'. Route to the runtime whenever a runtime environment id is present and thread the server-owned connection id into the chunked upload start and the small-image single-frame fallback, so the server forwards the file over its own SFTP connection - matching the paired web client, which already passes the connection through. No wire change: the RPCs have accepted the optional connection id since introduction. Fixes stablyai#17679 Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019G22teMcYiNe9RmGQ4dKuK
…nd harden runtime routing Review follow-ups: extract the chunked upload / single-frame fallback / abort protocol into one shared driver used by both the desktop main process and the web preload (their fork is what let connectionId handling diverge), normalize an empty connectionId to null before forwarding, and pin at the IPC seam that a failed runtime upload rejects rather than falling back to a client-reachable host. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019G22teMcYiNe9RmGQ4dKuK
Greptile SummaryThe PR routes runtime-owned clipboard-image pastes through the owning runtime even when a server-owned SSH connection is present.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| src/main/window/clipboard-ipc-handlers.ts | Routes image saves by runtime ownership first and normalizes the forwarded SSH connection identifier. |
| src/main/window/clipboard-runtime-image-upload.ts | Delegates desktop runtime uploads to the shared protocol while preserving byte-limit enforcement. |
| src/shared/clipboard-image-upload-protocol.ts | Centralizes bounded chunking, compatibility fallback, response validation, connection forwarding, and best-effort abort behavior. |
| src/renderer/src/web/preload-api/web-clipboard-api.ts | Replaces the web-specific upload implementation with the shared protocol driver without changing its runtime adapter. |
| src/main/runtime/rpc/methods/clipboard.ts | Re-exports the shared chunk-size constant so runtime validation and clients use the same protocol limit. |
Sequence Diagram
sequenceDiagram
participant UI as Desktop renderer
participant IPC as Main clipboard IPC
participant RT as Remote Orca runtime
participant SSH as Server-owned SSH target
UI->>IPC: save image(runtimeEnvironmentId, connectionId)
IPC->>RT: startImageUpload(connectionId)
loop bounded base64 chunks
IPC->>RT: appendImageUploadChunk
end
IPC->>RT: commitImageUpload
RT->>SSH: save temporary image over SFTP
SSH-->>RT: target path
RT-->>IPC: target path
IPC-->>UI: target path
Reviews (2): Last reviewed commit: "fix(clipboard): normalize blank connecti..." | Re-trigger Greptile
There was a problem hiding this comment.
ℹ️ No critical issues — solid, well-tested fix. One nitpick inline and one follow-up worth tracking.
Reviewed changes
- Runtime routing fix —
saveClipboardImageBufferForTargetnow routes to the runtime whenever a runtime owner is present, threading the server-owned SSHconnectionIdinto the upload start and the single-frame fallback. - Shared protocol driver — extracted the chunk/fallback/abort logic into
src/shared/clipboard-image-upload-protocol.ts, now driven by both the desktop main process and the web preload, removing the two duplicated copies whose divergence caused #17679. - Test coverage — a routing matrix at the IPC seam (including a wrong-host-fallback rejection test) plus a new protocol-mechanics suite; the web preload clipboard tests now exercise the same shared driver.
ℹ️ Known edge is a real behavior change — file a tracking issue
The routing change makes a previously-working (if narrow) path regress: when getRuntimeEnvironmentIdForWorktree resolves a runtime owner while getConnectionId (host-blind, in connection-owner-resolution.ts) returns a client-owned connection id for the same repo, the old !connectionId guard routed to the client's SSH stack — which owns that connection — and worked. The new code forwards that client-owned id to a runtime that has no such connection, failing the paste. The trigger is documented, but it is a silent regression of a path that used to work and should be tracked as an issue rather than left as a PR-body footnote.
Technical details
# Track duplicate-repo-rows routing regression
## Affected sites
- src/main/window/clipboard-ipc-handlers.ts:56 — unconditional runtime routing when `runtimeEnvironmentId` is set (removes the `!connectionId` guard)
- src/renderer/src/lib/connection-owner-resolution.ts:50 — `getConnectionIdFromState` returns `repo.connectionId ?? null` with no host awareness
- src/renderer/src/lib/worktree-runtime-owner.ts:58 — `getRuntimeEnvironmentIdForWorktree` can resolve a runtime owner from a different row than `getConnectionId`
## Required outcome
- A GitHub issue tracking the duplicate-repo-rows case so the regression is not lost.
## Open questions for the human
- Should the renderer resolve `connectionId` host-aware (only forward a connection the runtime actually owns), or should the main process guard against forwarding an unknown connection id?DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…ad driver
A blank connectionId reached the runtime schema ('' fails min(1)) from
callers that pass it through raw — the web preload used '?? null'. Trim
inside the driver so every transport treats blank as 'no connection'.
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_019G22teMcYiNe9RmGQ4dKuK
|
Addressed the bot reviews:
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Blank
connectionIdnormalization centralized —saveClipboardImageBase64ThroughRuntimenow normalizes an empty/whitespace id tonullinside the shared driver (rawConnectionId?.trim() || null), so both the desktop main process and the web preload treat a blank id as "no connection" instead of forwarding it into the runtime'sz.string().min(1)schema. Pinned by a new driver test.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
thanks for reporting. looking into it |
|
Closing since the minimal in-repo version of this routing fix landed via #19352, which notes: "#17787 (community fork) targets the same issue with the same core routing change… This PR is the minimal, in-repo version of the routing fix only… Either can land; if #17787 is preferred, this one should be closed." Thanks for the community contribution — please reopen if your branch carries anything beyond #19352. |

Fixes #17679
Problem
In a nested topology — desktop client → Remote Orca Server → server-owned SSH target — pasting a clipboard image fails with
Remote connection dropped. Click Reconnect on the SSH target before retrying, and reconnecting never helps.The routing in
saveClipboardImageBufferForTargetonly chose the runtime transport when noconnectionIdwas present. A nested worktree carries both aruntimeEnvironmentIdand the server's SSHconnectionId, so the client fell into its own SSH SFTP path with a connection id it has no connection for — the exact error reported, on both Windows and macOS clients.Fix
connectionIdalongside a runtime owner names a server-owned connection: the runtime forwards the file over its own SFTP, exactly as the paired web client already does.null, which would have landed the file on the server instead of the SSH target).clipboard.startImageUpload/clipboard.saveImageAsTempFilehave accepted the optional nullableconnectionIdsince they were introduced, so older servers honor it (perdocs/reference/remote-wire-compatibility.md, no capability negotiation needed).Review follow-ups included
src/shared/clipboard-image-upload-protocol.ts, now driven by both the desktop main process and the web preload. The two hand-rolled copies are how theconnectionIddivergence happened in the first place. (The mobile client still has its own copy — possible follow-up, it's a separate package.)connectionIdtonullbefore forwarding (the old guard treated''as absent; the RPC schema rejects it).Known narrow edge (not addressed here)
getConnectionIdresolution is host-blind over duplicate repo rows (one runtime-stamped, one client-SSH): in that state a client-owned connection id could be forwarded to a runtime that doesn't know it, failing the paste. The trigger requires duplicate repo ids with only the runtime row's worktree hydrated; fixing it means host-aware connection resolution in the renderer and is left as a follow-up.Testing
clipboard-ipc-handlers.test.ts: routing matrix at the IPC seam — runtime-only, runtime+server-owned-connection (asserts the client SSH stack is never consulted), failure rejection, plus the untouched SSH-only/local cases.clipboard-runtime-image-upload.test.ts(new): protocol mechanics through the shared driver — connection threading in start and fallback, chunking, abort-on-chunk-failure.🤖 Generated with Claude Code
https://claude.ai/code/session_019G22teMcYiNe9RmGQ4dKuK