Repository navigation
fix: make remote server pairing failures actionable - #11510
Conversation
|
@coderabbitai review |
✅ Action performedReview finished.
|
Greptile SummaryThis PR makes remote server pairing failures actionable by validating access links before saving, classifying connection failures at five distinct stages (host-unreachable, host-identity-mismatch, access-link-invalid, protocol-incompatible, connection-interrupted), and surfacing endpoint-type-aware recovery guidance for LAN, Tailscale, public, custom, and SSH-tunnel-loopback scenarios.
Confidence Score: 5/5Safe to merge; the verification and classification logic is well-tested end-to-end on both the Electron and browser paths with no correctness defects in the changed code. The Electron and browser pairing flows both verify host identity, access grant, protocol compatibility, and runtime-status shape before persisting a host. The pairingStage annotations on every RemoteRuntimeClientError throw site are accurate and covered by integration tests. The one noted gap — that the browser path cannot surface host-identity-mismatch as a distinct failure kind because WebRuntimeClient does not expose pairingStage — produces actionable feedback via a different kind rather than silent failure or data corruption. Files Needing Attention: src/renderer/src/web/web-preload-api.ts — the verifyAndAddFromPairingCode error catch block cannot distinguish host-identity-mismatch from access-link-invalid or host-unreachable because WebRuntimeClient does not expose pairingStage.
|
| Filename | Overview |
|---|---|
| src/shared/remote-pairing-address.ts | New file: parses and classifies host access links; port-0 and wildcard-bind-address non-connectable checks are present. |
| src/shared/remote-pairing-verification.ts | New file: validates runtime status shape, mobile-only scope, protocol version range, and capability format before persisting a verified host. |
| src/main/ipc/runtime-environment-pairing-verification.ts | New file: Electron pairing flow classifies errors by pairingStage into all five failure kinds. |
| src/renderer/src/web/web-preload-api.ts | Adds verifyAndAddFromPairingCode to the browser API path; error classification lacks pairingStage tracking so host-identity-mismatch collapses into access-link-invalid or host-unreachable. |
| src/renderer/src/web/web-runtime-client.ts | Replaces string-based rejection with structured WebRuntimeClientError; clean mechanical change. |
| src/renderer/src/web/web-runtime-client-error.ts | New file: WebRuntimeClientError with code:'unauthorized' and isWebRuntimeUnauthorizedError type guard. |
| src/shared/runtime-environment-store.ts | Adds connectionDependency:'ssh-tunnel'; getPairingConnectionDependency correctly strips the dependency for non-loopback endpoints. |
| src/renderer/src/components/settings/RuntimeHostAccessForm.tsx | New settings-pane form with correct aria-invalid/aria-describedby handling for all error and clean states. |
| src/renderer/src/lib/remote-pairing-copy.ts | New file: localised copy helpers for all error and endpoint kind enums. |
| src/shared/remote-runtime-client.ts | Adds pairingStage and closeCode to every RemoteRuntimeClientError throw site. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[User pastes access link] --> B[parseHostAccessLink]
B -->|invalid format| C[access-link-invalid]
B -->|mobile-only scope| C
B -->|unsupported dest| D[unsupported-destination]
B -->|loopback + no SSH override| E[host-unreachable]
B -->|ok| F[status.get over WebSocket]
F -->|pairingStage:connect| G[host-unreachable]
F -->|pairingStage:host-identity| H[host-identity-mismatch]
F -->|pairingStage:access-grant| C
F -->|pairingStage:runtime| I[connection-interrupted]
F -->|status received| J[verifyRemotePairingRuntimeStatus]
J -->|malformed| I
J -->|mobile scope| C
J -->|protocol blocked| K[protocol-incompatible]
J -->|ok| L[persist environment]
L -->|write error| M[environment-save-failed]
L -->|ok| N[success]
Reviews (2): Last reviewed commit: "fix: address final remote pairing review..." | Re-trigger Greptile
📝 WalkthroughWalkthroughThis change adds remote pairing-link parsing, endpoint classification, runtime-status verification, structured failure handling, and SSH-tunnel dependency tracking. It exposes verification through desktop IPC, preload, and web APIs. Renderer settings now include workflow-based runtime management, host-access validation, pairing-link intent selection, stale-link handling, troubleshooting guidance, and Cloud VM terminology. Tests cover parsing, compatibility, transport failures, persistence, UI forms, API behavior, and localization updates. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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 |
There was a problem hiding this comment.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/renderer/src/components/sidebar/AddRemoteHostFields.tsx (1)
177-202: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winAssociate the error text with the input.
aria-invalidis set on the input, butaria-describedbyonly points at the static help paragraph. Therole="alert"error at Line 199 has no id and is never referenced, so assistive tech announces "invalid" without the reason on focus.♿ Proposed fix
<Input id="add-server-pairing-code" aria-invalid={inputError} - aria-describedby="add-server-pairing-code-help" + aria-describedby={ + inputError + ? 'add-server-pairing-code-error add-server-pairing-code-help' + : 'add-server-pairing-code-help' + } @@ {inputError ? ( - <p role="alert" className="text-xs text-destructive"> + <p id="add-server-pairing-code-error" role="alert" className="text-xs text-destructive"> {parsedLink.ok ? null : translateHostAccessLinkError(parsedLink.kind)} </p> ) : null}src/shared/remote-runtime-client.ts (1)
266-277: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winUndecryptable-frame error mislabels
pairingStageduring the runtime/RPC phase.This branch runs for both
awaiting_authenticatedandreadystates, but hardcodespairingStage: 'host-identity'. Whenstate === 'ready'(post-handshake, mid-RPC), a decrypt failure is a runtime-stage issue, not a host-identity mismatch —classifyPairingVerificationErrorinruntime-environment-pairing-verification.tswill surface the misleading "host does not match this access link" message instead of "connection was interrupted during verification."🐛 Proposed fix
if (plaintext === null) { finish({ ok: false, error: new RemoteRuntimeClientError( 'invalid_runtime_response', 'Remote Orca runtime returned an undecryptable frame.', - { pairingStage: 'host-identity' } + { pairingStage: state === 'awaiting_authenticated' ? 'host-identity' : getPairingStage() } ) }) return }
🧹 Nitpick comments (5)
src/renderer/src/components/settings/RuntimePairingGeneratorForm.test.tsx (1)
9-48: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for the stale-generated-link gating.
renderFormhardcodesgeneratedAddress={null}, so the newgeneratedIsCurrent/staleGeneratedLinkbehavior (Lines 53-54, 299-307, 325-352 ofRuntimePairingGeneratorForm.tsx) is never exercised. That gate is what prevents showing a pairing/browser URL that belongs to a different address — worth a regression test.💚 Proposed test additions
-function renderForm(intent: RuntimePairingIntent, selectedAddress: string): string { +function renderForm( + intent: RuntimePairingIntent, + selectedAddress: string, + overrides: { + generatedAddress?: string | null + runtimePairingUrl?: string | null + webClientUrl?: string | null + } = {} +): string { return renderToStaticMarkup( <TooltipProvider> <RuntimePairingGeneratorForm intent={intent} loopbackAddress="127.0.0.1" networkInterfaces={[{ name: 'tailscale0', address: '100.76.32.125' }]} selectedAddress={selectedAddress} refreshingNetworkInterfaces={false} isGeneratingPairing={false} - webClientUrl={null} - runtimePairingUrl={null} + webClientUrl={overrides.webClientUrl ?? null} + runtimePairingUrl={overrides.runtimePairingUrl ?? null} copiedTarget={null} - generatedAddress={null} + generatedAddress={overrides.generatedAddress ?? null} onIntentChange={vi.fn()} onSelectedAddressChange={vi.fn()} onRefreshNetworkInterfaces={vi.fn()} onGenerate={vi.fn()} onCopy={vi.fn()} /> </TooltipProvider> ) }+ it('hides generated links once the selected address changes', () => { + const stale = renderForm('another', '100.76.32.125', { + generatedAddress: '192.168.1.10', + runtimePairingUrl: 'orca://pair?code=stale', + webClientUrl: 'https://192.168.1.10/web' + }) + expect(stale).not.toContain('orca://pair?code=stale') + expect(stale).not.toContain('https://192.168.1.10/web') + + const current = renderForm('another', '100.76.32.125', { + generatedAddress: '100.76.32.125', + runtimePairingUrl: 'orca://pair?code=current' + }) + expect(current).toContain('orca://pair?code=current') + })src/renderer/src/lib/remote-pairing-copy.ts (1)
53-86: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueKey namespace is inconsistent with the rest of this module.
The two helpers above use
auto.lib.remotePairingCopy.*, but these failure strings keepauto.components.settings.RuntimeHostAccessForm.*even though the copy now lives in a shared lib and is consumed beyond that form. Consider moving them underauto.lib.remotePairingCopy.*and re-running the catalog sync.Based on learnings, prefer semantic locale keys matching the owning namespace and validate with
pnpm sync:localization-catalog/pnpm verify:localization-catalog.Source: Learnings
src/renderer/src/components/settings/RuntimeHostAccessForm.test.tsx (1)
1-64: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winNo interactive coverage for the SSH-tunnel checkbox or submit wiring.
renderToStaticMarkuponly validates static markup; the checkbox toggle →tunnelOverrideEnabled→onSubmit(allowLoopback)flow andcanSubmitgating (empty name, busy state) are the most behaviorally significant parts of this component and remain untested.Consider adding tests using an interactive renderer (e.g.
@testing-library/react+userEvent) to click the checkbox and submit the form, assertingonSubmitis called with the expectedallowLoopbackvalue.src/renderer/src/web/web-preload-api.test.ts (1)
536-633: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider covering the loopback gate.
These three cases cover the rejection paths well. The
allowLoopbackbranch inverifyAndAddFromPairingCode(block without the flag; persistconnectionDependency: 'ssh-tunnel'with it) is the security-relevant gate and currently has no browser-side test.src/shared/pairing.test.ts (1)
25-37: 🎯 Functional Correctness | 🔵 TrivialTest only covers one payload length; won't reliably catch base64 padding edge cases.
This test uses a single fixed
offer, so it may pass only because this particular payload's encoded length happens to be padding-safe. Consider parameterizing across payloads of varying JSON byte lengths (mod 3 = 0, 1, 2) to exercise all base64 padding remainders for the Buffer-less path.
[recommended_refactor_low_effort_and_high_reward]
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: dde5c8b7-2f9f-4043-87a7-b74fc98aeb26
📒 Files selected for processing (42)
src/main/ipc/runtime-environment-connectivity-handlers.tssrc/main/ipc/runtime-environment-handler-channels.tssrc/main/ipc/runtime-environment-pairing-verification.tssrc/main/ipc/runtime-environments.test.tssrc/main/ipc/runtime-environments.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/settings/EphemeralVmRuntimesSection.test.tsxsrc/renderer/src/components/settings/EphemeralVmRuntimesSection.tsxsrc/renderer/src/components/settings/RuntimeEnvironmentsPane.tsxsrc/renderer/src/components/settings/RuntimeHostAccessForm.test.tsxsrc/renderer/src/components/settings/RuntimeHostAccessForm.tsxsrc/renderer/src/components/settings/RuntimePairingGeneratorForm.test.tsxsrc/renderer/src/components/settings/RuntimePairingGeneratorForm.tsxsrc/renderer/src/components/settings/RuntimePairingUrlGenerator.tsxsrc/renderer/src/components/settings/runtime-pairing-link-state.tssrc/renderer/src/components/sidebar/AddRemoteHostDialog.tsxsrc/renderer/src/components/sidebar/AddRemoteHostFields.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/i18n-jsx-spacing-guard.test.tssrc/renderer/src/lib/remote-pairing-copy.tssrc/renderer/src/web/web-preload-api.test.tssrc/renderer/src/web/web-preload-api.tssrc/renderer/src/web/web-runtime-environment.tssrc/shared/network/server-share-address.test.tssrc/shared/network/server-share-address.tssrc/shared/pairing.test.tssrc/shared/pairing.tssrc/shared/remote-pairing-address.test.tssrc/shared/remote-pairing-address.tssrc/shared/remote-pairing-verification.test.tssrc/shared/remote-pairing-verification.tssrc/shared/remote-runtime-client-error.tssrc/shared/remote-runtime-client.test.tssrc/shared/remote-runtime-client.tssrc/shared/runtime-environment-store.test.tssrc/shared/runtime-environment-store.tssrc/shared/runtime-environments.ts
💤 Files with no reviewable changes (1)
- src/renderer/src/lib/i18n-jsx-spacing-guard.test.ts
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/components/settings/RuntimePairingUrlGenerator.tsx (1)
356-365: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
updateIntentdoesn't persist the new intent toruntimePairingLinkCache.
updateSelectedAddresswrites through toruntimePairingLinkCache.selectedAddress/.customAddress/.intent, butupdateIntentonly updates local React state (setIntent,setSelectedAddress). Since the component initializes state fromruntimePairingLinkCache.intenton mount, a remount (e.g., switching workflow tabs inRuntimeEnvironmentsPaneand back) will revert the displayed intent to the stale cached value, discarding the user's last selection.🐛 Proposed fix
const updateIntent = (nextIntent: RuntimePairingIntent): void => { + runtimePairingLinkCache.intent = nextIntent setIntent(nextIntent) setSelectedAddress( selectRuntimePairingIntent( nextIntent, networkInterfaces, runtimePairingLinkCache.customAddress ) ) }
🧹 Nitpick comments (1)
src/shared/remote-runtime-client.ts (1)
269-279: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRedundant ternary —
getPairingStage()already covers this branch.By the time
decrypt()runs,statecan only be'awaiting_authenticated'or'ready'(thestate === 'awaiting_ready'case already returned earlier inonMessage).getPairingStage()returns'host-identity'for'awaiting_authenticated'and'runtime'for'ready', sostate === 'awaiting_authenticated' ? 'host-identity' : getPairingStage()is equivalent to justgetPairingStage().♻️ Proposed simplification
- { - pairingStage: state === 'awaiting_authenticated' ? 'host-identity' : getPairingStage() - } + { pairingStage: getPairingStage() }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8580dda1-4c9b-465f-afa0-4050be7c0e5b
📒 Files selected for processing (17)
src/main/ipc/runtime-environment-pairing-verification.tssrc/main/ipc/runtime-environments.test.tssrc/renderer/src/components/settings/RuntimeHostAccessForm.test.tsxsrc/renderer/src/components/settings/RuntimeHostAccessForm.tsxsrc/renderer/src/components/settings/RuntimePairingGeneratorForm.test.tsxsrc/renderer/src/components/settings/RuntimePairingUrlGenerator.test.tsxsrc/renderer/src/components/settings/RuntimePairingUrlGenerator.tsxsrc/renderer/src/components/sidebar/AddRemoteHostDialog.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/lib/remote-pairing-copy.tssrc/renderer/src/web/web-preload-api.test.tssrc/renderer/src/web/web-preload-api.tssrc/shared/remote-pairing-verification.tssrc/shared/remote-runtime-client.test.tssrc/shared/remote-runtime-client.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- src/renderer/src/components/sidebar/AddRemoteHostDialog.tsx
- src/renderer/src/i18n/locales/ko.json
- src/shared/remote-pairing-verification.ts
* fix: make remote server pairing failures actionable * refactor: extract daemon router event types * fix: address remote pairing review findings * fix: address final remote pairing review feedback



Summary
Screenshots
Representative localized share, SSH-tunnel, and verification-error states are attached in a PR comment.
Testing
pnpm lintpnpm typecheckpnpm test— 3,916 files / 41,387 tests passed; 10 files / 73 tests skippedpnpm build:electron-vitepnpm build:webAdditional checks:
pnpm check:code-quality:changedAI Review Report
Completed three review/fix rounds, rebased onto current
main, then completed another review/fix pass.The review explicitly checked functionality regressions, performance regressions, unclear UI, accessibility, localization, SSH tunnels, folder workspaces, browser storage behavior, and malformed or hostile endpoint input. It flagged and fixed:
0, credentials, oversized input, and malformed IPv4.Live UI QA covered connect/share/cloud flows, invalid custom addresses, blocked loopback links, the SSH tunnel override, identity mismatch feedback, and translated Chinese copy. A workflow-switch performance trace showed a largest non-profiler task of about 70 ms, with no feature-related console errors.
Cross-platform review covered macOS, Linux, and Windows. This change adds no shortcuts, shell commands, hardcoded path separators, native modules, or Git behavior. Electron and web preload behavior were both built and tested. SSH and folder-workspace flows remain explicit and do not assume a local git worktree.
Security Audit
Notes
::highlightwarnings.