Skip to content

refactor(remote): clients connect through a paired-connection handle, not a pairing offer - #27533

Merged
OrcaWin merged 1 commit into
mainfrom
np/d2b-connection-handle
Oct 11, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
np/d2b-connection-handle

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 50 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​634 $\color{#cf222e}{\Huge{\mathbf{−}}}$​319 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​315
Prod 48 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​381 $\color{#cf222e}{\Huge{\mathbf{−}}}$​271 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​110

ELI5

To talk to a paired Orca host, every client used to carry around the whole "pairing offer", the thing you scan or paste once when you pair. This PR gives clients a small "connection" object instead: where the host is, which host key to expect, and the credential to prove who you are. Pairing offers are still read when you pair; after that, everything connects with the connection object. Nothing changes for users, and nothing changes on the wire.

What Changed

  • New: src/shared/paired-runtime-connection.ts with PairedRuntimeConnection = { endpoint, hostPublicKeyB64, credential, pairedDeviceId? }. The credential is the shared handshake's PairedE2EEAuthCredential, which is { kind: 'token', deviceToken } today. pairedRuntimeConnectionFromOffer(offer) converts at the pairing boundary.
  • New: getPreferredPairedRuntimeConnection(environment) next to getPreferredPairingOffer. The web client has getPreferredWebRuntimeConnection.
  • Before: the request socket, cached request connection, subscription socket, shared control connection, relay passthrough socket, the CLI's remote client, desktop IPC routing, browser network/lease routes, managed-server (SSH) probes and the web client all took a PairingOffer.
  • After: they all take a PairedRuntimeConnection. Every place that sends the token reads connection.credential.deviceToken, so request envelopes and the auth frame carry the same bytes as before.
  • Still on PairingOffer (by design):
    • parsing codes, QR and links, and the pairing dialog;
    • orca environment add and the environment stores, which persist what was paired;
    • host-side minting and readiness output;
    • re-encoding into a pairing code where a code string is genuinely handed on: managed-server conversion wiring and the tunneled managed-server pairing code;
    • the relay host catalog, which carries the desktop's own runtime offer. The relay converts it when it opens the passthrough socket and swaps in the phone's delegated token there.
  • The SSH verification result field verifiedPairing is now verifiedConnection.

Why

The next pairing steps replace the token with a per-device key (browser first, then desktop and CLI) and add single-use tickets. If every connect call site still took a pairing offer, each of those steps would edit about 50 files and mix a mechanical change with a security change. Moving to a handle first keeps those later PRs small: they change what goes in credential, not every caller.

The alternative was to add optional credential fields to PairingOffer. That type is also the pairing wire format and the stored record, so widening it would leak client-only state into what hosts and old clients parse.

Linked Issue

Part of #17394 / #17399 (preparation). No user-visible fix on its own.

Visual Proof

N/A: a type-level refactor with no UI or behaviour change.

Testing

  • src/shared/paired-runtime-connection.test.ts (written first): offer to handle, the token accessor, and the environment's preferred endpoint.

  • Updated every transport, IPC, SSH, browser and web test that passed an offer to a connect path; test servers now hand out a connection (and the offer where a test re-encodes a code).

  • pnpm tc, focused vitest over src/shared, src/cli, src/main/{ipc,ssh,browser,runtime}, src/renderer/src/{web,runtime}, oxlint, pnpm run check:code-quality:changed, pnpm lint.

  • No cross-version test added: nothing on the wire changes. The B2 cross-version suite (stacked below) still covers the handshake bytes.

  • Automated tests added/updated

Agent skill upstream boundary

  • Not applicable.

Notes

Stacked on #27523. SSH: managed-server probes and tunnel identity checks connect through the handle; the tunnel endpoint override is applied to the handle exactly as it was to the offer. Windows/Linux/macOS: no platform code.

Checklist

  • This PR is small and focused (mechanical)
  • I explained what changed and why
  • N/A for visuals, with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered

@OrcaWin
OrcaWin force-pushed the np/d2b-handshake-core branch 2 times, most recently from de51381 to 1eb704a Compare October 11, 2026 18:56
@OrcaWin
OrcaWin marked this pull request as ready for review October 11, 2026 18:57
@OrcaWin
OrcaWin force-pushed the np/d2b-connection-handle branch from 8766bff to 6c02776 Compare October 11, 2026 18:57
@OrcaWin
OrcaWin changed the base branch from np/d2b-handshake-core to main October 11, 2026 19:15
@OrcaWin
OrcaWin force-pushed the np/d2b-connection-handle branch from 6c02776 to 69eb366 Compare October 11, 2026 19:15
@coderabbitai

coderabbitai Bot commented Oct 11, 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: a948b534-0397-4e95-95d7-a7a6d29d2319

📥 Commits

Reviewing files that changed from the base of the PR and between bb54fd8 and 1e289ba.


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: a0b06dcc-897d-40bd-b464-490a88a0141d



📥 Commits

Reviewing files that changed from the base of the PR and between f9794d8 and 69eb366afdaebb926a8920498e5e1a6f7ce0acfa.




📒 Files selected for processing (98)
  • src/cli/runtime/client.ts
  • src/cli/runtime/remote-runtime-compat-gate.ts
  • src/cli/runtime/runtime-access-denied.test.ts
  • src/cli/runtime/runtime-remote-pairing.ts
  • src/cli/runtime/websocket-transport.ts
  • src/main/browser/browser-client-file-channel-negotiation.test.ts
  • src/main/browser/browser-client-file-channel-reconnect.test.ts
  • src/main/browser/browser-client-host-attach-request.test.ts
  • src/main/browser/paired-runtime-browser-client-host-reconnect.test.ts
  • src/main/browser/paired-runtime-browser-client-host-runtime.ts
  • src/main/browser/paired-runtime-browser-client-host.test.ts
  • src/main/browser/paired-runtime-browser-client-host.ts
  • src/main/browser/paired-runtime-browser-host-command-admission.test.ts
  • src/main/browser/paired-runtime-browser-host-lease-connection.ts
  • src/main/browser/paired-runtime-browser-host-lease-options.ts
  • src/main/browser/paired-runtime-browser-host-lease-reconnect.test.ts
  • src/main/browser/paired-runtime-browser-host-lease.test.ts
  • src/main/browser/paired-runtime-browser-host-reconciliation-negotiation.test.ts
  • src/main/browser/paired-runtime-browser-network-route.test.ts
  • src/main/browser/paired-runtime-browser-network-route.ts
  • src/main/browser/paired-runtime-browser-network-transport.ts
  • src/main/ipc/runtime-environment-abortable-requests.ts
  • src/main/ipc/runtime-environment-capability-evidence.test.ts
  • src/main/ipc/runtime-environment-capability-evidence.ts
  • src/main/ipc/runtime-environment-cli-removal-routing.test.ts
  • src/main/ipc/runtime-environment-federated-read-transport.bench.test.ts
  • src/main/ipc/runtime-environment-host-key.ts
  • src/main/ipc/runtime-environment-pairing-verification.ts
  • src/main/ipc/runtime-environment-request-connections.ts
  • src/main/ipc/runtime-environment-shared-control-support.ts
  • src/main/ipc/runtime-environment-status-connection.test.ts
  • src/main/ipc/runtime-environment-status-owner.ts
  • src/main/ipc/runtime-environment-status-probe.ts
  • src/main/ipc/runtime-environment-support-routing.test.ts
  • src/main/ipc/runtime-environment-support-routing.ts
  • src/main/ipc/runtime-environment-transport-routing.ts
  • src/main/ipc/runtime-environments-ipc-test-harness.ts
  • src/main/ipc/runtime-environments-status-diagnostics.test.ts
  • src/main/runtime/browser-network-tunnel-paired-runtime.integration.test.ts
  • src/main/runtime/delegated-mobile-device.integration.test.ts
  • src/main/runtime/mobile-desktop-relay/mobile-desktop-relay.integration.test.ts
  • src/main/runtime/mobile-desktop-relay/mobile-desktop-relay.ts
  • src/main/runtime/mobile-desktop-relay/mobile-relay-host-catalog.integration.test.ts
  • src/main/runtime/remote-agent-session-host-authority.integration.test.ts
  • src/main/runtime/remote-runtime-close-intent.integration.test.ts
  • src/main/runtime/remote-runtime-request-connection.integration.test.ts
  • src/main/runtime/runtime-environment-identity-verification.ts
  • src/main/runtime/runtime-rpc-mobile-terminal-streaming.test.ts
  • src/main/ssh/orcad-managed-tunnel-identity-restart.test.ts
  • src/main/ssh/orcad-managed-tunnel-identity.test.ts
  • src/main/ssh/orcad-managed-tunnel-identity.ts
  • src/main/ssh/orcad-managed-tunnel-resume.ts
  • src/main/ssh/orcad-migration-catalog-client.ts
  • src/main/ssh/orcad-terminal-census-client.ts
  • src/main/ssh/runtime-ssh-access-verification.test.ts
  • src/main/ssh/runtime-ssh-access-verification.ts
  • src/main/ssh/runtime-ssh-access.test.ts
  • src/main/startup/main-process-runtime-service.ts
  • src/renderer/src/runtime/paired-host-client-capabilities.test.ts
  • src/renderer/src/web/WebConnect.tsx
  • src/renderer/src/web/preload-api/web-runtime-environments-api.ts
  • src/renderer/src/web/preload-api/web-runtime-session.ts
  • src/renderer/src/web/web-preload-api-workspace-catalog.test.ts
  • src/renderer/src/web/web-runtime-client-file-watch-replay.test.ts
  • src/renderer/src/web/web-runtime-client-heartbeat.test.ts
  • src/renderer/src/web/web-runtime-client-timeout-budget.test.ts
  • src/renderer/src/web/web-runtime-client.test.ts
  • src/renderer/src/web/web-runtime-client.ts
  • src/renderer/src/web/web-runtime-connection-transport.ts
  • src/renderer/src/web/web-runtime-direct-proxy-live.integration.test.ts
  • src/renderer/src/web/web-runtime-environment-repair.test.ts
  • src/renderer/src/web/web-runtime-environment.ts
  • src/shared/paired-runtime-connection.test.ts
  • src/shared/paired-runtime-connection.ts
  • src/shared/remote-runtime-client.test.ts
  • src/shared/remote-runtime-client.ts
  • src/shared/remote-runtime-connect-bound.test.ts
  • src/shared/remote-runtime-outbound-admission.test.ts
  • src/shared/remote-runtime-passthrough-socket.ts
  • src/shared/remote-runtime-request-connection-stale.test.ts
  • src/shared/remote-runtime-request-connection.test.ts
  • src/shared/remote-runtime-request-connection.ts
  • src/shared/remote-runtime-request-socket.ts
  • src/shared/remote-runtime-request-websocket.test.ts
  • src/shared/remote-runtime-request-websocket.ts
  • src/shared/remote-runtime-shared-control-connection.test.ts
  • src/shared/remote-runtime-shared-control-connection.ts
  • src/shared/remote-runtime-shared-control-open.ts
  • src/shared/remote-runtime-shared-control-standing-intent.test.ts
  • src/shared/remote-runtime-shared-control-test-server.ts
  • src/shared/remote-runtime-subscription-connect-bound.test.ts
  • src/shared/remote-runtime-subscription-request-channel.ts
  • src/shared/remote-runtime-subscription-request.test.ts
  • src/shared/remote-runtime-subscription-transport.ts
  • src/shared/runtime-environment-sidecar.test.ts
  • src/shared/runtime-environment-ssh-access-store.test.ts
  • src/shared/runtime-environment-ssh-access-store.ts
  • src/shared/runtime-environments.ts



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





📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The change introduces PairedRuntimeConnection, which carries the endpoint, host public key, token credential, and optional paired device ID. Remote request and subscription transports, browser hosts, CLI and IPC routing, runtime and SSH callers, and web clients now accept or select this connection type. Tests and fixtures are updated to construct and pass connections. Existing routing, status, verification, and error-handling flows are otherwise described as unchanged.





Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 69eb3

This refactor changes how remote connection call sites receive their connection data, and the reported behavior is unchanged. No concrete merge-blocking risk was found in the supplied context.

Pre-merge checks | Passed 4 | Inconclusive 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 11.54% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 52 functions across 50 files. (48 skipped… 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: replacing pairing offers with paired-connection handles for remote clients.
Description check Passed The description is complete and aligned with the template. It explains the change, motivation, scope, linked issues, visual impact, testing, platform considerations, and checklist status. The missing …
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.



Full details: Docstring Coverage

Explanation

Docstring coverage is 11.54% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 52 functions across 50 files. (48 skipped: 48 over the file limit.)






✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR



🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR





  • Autofix · 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.

@OrcaWin
OrcaWin force-pushed the np/d2b-connection-handle branch from 69eb366 to bb54fd8 Compare October 11, 2026 19:42
… not a pairing offer

Desktop, CLI, web and runtime transports now take a PairedRuntimeConnection
(endpoint, pinned host key, credential) instead of a PairingOffer. Offers stay on
the pairing input path (codes, QR, links, environment add) and are converted with
pairedRuntimeConnectionFromOffer. The credential is token-only today; request
envelopes still carry the same deviceToken, so the wire is unchanged.

This lets device-key and ticket credentials replace the token later without
touching every connect call site again.
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