Repository navigation
fix(mobile): accept WebSocket pairing addresses - #9912
Conversation
📝 WalkthroughWalkthroughManual network address parsing now accepts validated 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 71e58707-c707-402e-8f0f-00fda625541b
📥 Commits
Reviewing files that changed from the base of the PR and between 300ee19 and ccef2066e24ad18cc7dbf18e874f6ed5b454b0c6.
📒 Files selected for processing (3)
src/renderer/src/components/mobile/NetworkInterfacePicker.tsxsrc/shared/network/manual-address.test.tssrc/shared/network/manual-address.ts
| if (trimmed.includes('://')) { | ||
| return normalizePairingUrl(trimmed) | ||
| ? { ok: true, address: trimmed } | ||
| : { ok: false, error: ERROR_MESSAGE } | ||
| } |
There was a problem hiding this comment.
URL validation stores raw input instead of normalized form
The URL branch validates through normalizePairingUrl (which normalizes http:// → ws://, https:// → wss://, and strips trailing slashes) but discards the normalized result and stores trimmed (the raw input). This means entering https://proxy.example.com/orca persists as https://proxy.example.com/orca (custom) in the address picker while the actual pairing endpoint used is wss://proxy.example.com/orca. Using the return value of normalizePairingUrl directly as address would keep the stored value canonical and consistent with what the QR section displays as the endpoint.
| try { | ||
| const result = await window.api.mobile.getPairingQR({ address, connectionMode }) | ||
| return result.available && result.qrDataUrl !== null | ||
| } catch { | ||
| return false | ||
| } | ||
| }, | ||
| [connectionMode, signedIn] | ||
| ) | ||
|
|
||
| const copyPairingCode = useCallback(async () => { |
There was a problem hiding this comment.
Misleading confirmation error when the pairing runtime is temporarily unavailable
beforeCustomAddressChange returns false for any case where result.available is false, which includes both address-format rejections by resolveAdvertisedPairingEndpoint and transient runtime-unavailability (e.g., the Orca runtime not yet started, a brief outage, or an IPC error triggering the catch branch). In either case the dialog displays "This address could not produce a scannable pairing code. Check the address and try again." — which tells the user to re-check an address that may be perfectly valid. Distinguishing the two failure modes (e.g., inspecting result.available vs. a thrown exception, or bubbling a reason field) would allow a more accurate error message for the transient-unavailability case.
| const handleCustomConfirm = async (next: string): Promise<boolean> => { | ||
| if (beforeCustomConfirm && !(await beforeCustomConfirm(next))) { | ||
| return false | ||
| } | ||
| onValueChange(next) | ||
| return true | ||
| } |
There was a problem hiding this comment.
Preemptive QR call result is discarded, causing double token rotation
handleCustomConfirm calls beforeCustomConfirm(next) (which invokes getPairingQR and rotates a pairing token), then immediately calls onValueChange(next), which triggers generatePairing and rotates a second token. The first token is never shown to the user and is wasted. For high-frequency address changes (e.g., a user retrying different addresses) this also doubles the IPC load. Consider threading the pre-flight result into the address state so generatePairing can reuse it, or accept the efficiency loss with a comment explaining the intentional redundancy.
Greptile SummaryThis PR extends mobile pairing to accept complete
Confidence Score: 4/5The core validation and normalization logic is correct and well-tested; the main concerns are UX consistency in edge cases rather than broken functionality. The URL normalization logic ( Files Needing Attention:
|
| Filename | Overview |
|---|---|
| src/shared/network/pairing-url.ts | New shared helper: normalizePairingUrl validates and canonicalizes ws/wss/http/https URLs, and isPairingWildcardHostname centralizes wildcard-host detection. Logic is correct and well-bounded. |
| src/shared/network/manual-address.ts | Adds URL and IPv6 support to the renderer-side address validator. The URL branch stores the raw input rather than the normalized ws/wss form, causing a display mismatch in the address picker. IPv6 and wildcard checks are otherwise correct. |
| src/main/runtime/pairing-endpoint.ts | Refactored to delegate URL normalization to normalizePairingUrl; adds a character-length guard on the resolved endpoint. Logic unchanged and correct. |
| src/renderer/src/components/mobile/MobilePage.tsx | Introduces beforeCustomAddressChange which makes a preemptive getPairingQR call to validate custom addresses; misleading error shown when the runtime is transiently unavailable vs. when the address is genuinely bad. |
| src/renderer/src/components/network/AddressPicker.tsx | Threads async beforeCustomConfirm through handleCustomConfirm; the preemptive QR call result is discarded, causing a second token rotation when onValueChange triggers generatePairing. |
| src/renderer/src/components/network/CustomAddressDialog.tsx | Upgraded to support async onConfirm with loading spinner, submission lock, and confirmationError display. Implementation is clean and correct. |
| src/main/ipc/mobile.ts | Extracts QR encoding into encodeMobilePairingQr and propagates the nullable qrDataUrl / qrError to callers. Correctly handles the failure case. |
| src/shared/mobile-pairing-protocol-limits.ts | New file consolidating protocol limit constants extracted from mobile-relay-pairing-offer.ts to avoid pulling the Zod schema into the renderer bundle. |
| mobile/src/transport/rpc-client.ts | Fixes a log-redaction gap: previously the full endpoint URL (potentially containing path/query) was logged; now only new URL(ep).host is emitted, correctly redacting credentials and paths. |
| src/shared/network/manual-address.test.ts | Comprehensive regression tests added for IPv6 (bare, bracketed, wildcard rejection), full URL forms (ws/wss/http/https), reverse-proxy paths, and the shared endpoint length boundary. |
Sequence Diagram
sequenceDiagram
participant User
participant NetworkInterfacePicker
participant CustomAddressDialog
participant AddressPicker
participant MobilePage
participant MainIPC as Main Process (mobile IPC)
User->>NetworkInterfacePicker: Opens "Add custom address…"
NetworkInterfacePicker->>CustomAddressDialog: "open=true"
User->>CustomAddressDialog: Types URL / hostname / IPv6
CustomAddressDialog->>NetworkInterfacePicker: validateCustom(input)
NetworkInterfacePicker-->>CustomAddressDialog: "{ok, value} via parseManualNetworkAddress"
User->>CustomAddressDialog: Clicks "Use address"
CustomAddressDialog->>AddressPicker: onConfirm(parsed.value)
AddressPicker->>MobilePage: beforeCustomConfirm(address) [pre-flight]
MobilePage->>MainIPC: "getPairingQR({address, connectionMode})"
MainIPC->>MainIPC: resolveAdvertisedPairingEndpoint → normalizePairingUrl
MainIPC->>MainIPC: encodeMobilePairingQr(pairingUrl)
MainIPC-->>MobilePage: "{available, qrDataUrl, pairingUrl, endpoint}"
alt "available && qrDataUrl !== null"
MobilePage-->>AddressPicker: true
AddressPicker->>MobilePage: onValueChange(address)
MobilePage->>MainIPC: generatePairing [second QR call]
MainIPC-->>MobilePage: "{qrDataUrl, pairingUrl, endpoint}"
CustomAddressDialog-->>User: Dialog closes, QR shown
else
MobilePage-->>AddressPicker: false
AddressPicker-->>CustomAddressDialog: false
CustomAddressDialog-->>User: confirmationError displayed
end
Reviews (1): Last reviewed commit: "fix(mobile): reset custom address dialog..." | Re-trigger Greptile
|
thanks for reporting. looking into it |
* fix(mobile): accept websocket pairing addresses * fix(mobile): align manual pairing address validation * docs(mobile): correct custom address grammar comment * fix(mobile): enforce pairing endpoint size limit * fix(mobile): reject canonical IPv6 wildcard addresses * fix(mobile): handle unscannable pairing offers * fix(mobile): reset custom address dialog on close --------- Co-authored-by: OrcaWin <[email protected]>
Summary
ws://andwss://URLs in the custom Mobile pairing address picker, including explicit ports and reverse-proxy paths.Closes #9746
Screenshots
No layout or styling change; this updates validation behavior and the custom-address dialog copy.
Testing
pnpm lint(blocked by the existing non-exhaustive switch insrc/renderer/src/components/skills/skill-freshness-group.tsx:101)pnpm typecheckpnpm test(28 related tests passed)pnpm build(pnpm build:electron-vitepassed)The regression tests cover the three requested WebSocket URL forms, reverse-proxy paths and query strings, and invalid endpoint forms that the main process refuses.
AI Review Report
Reviewed the renderer-to-main pairing-address flow, URL parsing behavior, and the existing
resolveAdvertisedPairingEndpointcontract. The review checked macOS, Linux, and Windows compatibility and found no platform-specific shortcuts, labels, paths, shell behavior, or Electron APIs in the change. It also checked local and SSH/remote assumptions, supported integrations and providers, performance, and the dialog copy; the address continues through the existing provider-neutral IPC path without host-specific behavior.Security Audit
The custom input is parsed locally with the platform URL implementation before it reaches the existing pairing IPC. WebSocket URLs containing credentials, fragments, port zero, malformed ports, or wildcard hosts are rejected. No command execution, filesystem paths, auth storage, secrets, dependencies, IPC contracts, or network requests were added.
Notes
The full lint pipeline reaches the existing
switch-exhaustiveness-checkfailure inskill-freshness-group.tsx; targeted oxlint for all changed files passes. The behavior is platform-neutral and does not change SSH, git-provider, or agent-specific code.ELI5
Mobile pairing only accepted bare hosts, not full ws:// or wss:// URLs with ports or paths. Custom pairing addresses now accept complete WebSocket URLs that reverse proxies need.