Skip to content

fix(mobile): accept WebSocket pairing addresses - #9912

Merged
OrcaWin merged 7 commits into
stablyai:mainfrom
OnlyYu1996:codex/issue-9746-pairing-address-url
Jul 29, 2026
Merged

OrcaWin merged 7 commits into
stablyai:mainfrom
OnlyYu1996:codex/issue-9746-pairing-address-url

Conversation

@OnlyYu1996

@OnlyYu1996 OnlyYu1996 commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Accept complete ws:// and wss:// URLs in the custom Mobile pairing address picker, including explicit ports and reverse-proxy paths.
  • Keep the existing IPv4 and hostname validation while matching the runtime's rejection of credentials, fragments, port zero, and wildcard endpoints.
  • Update the custom-address copy and add regression coverage for the formats reported in [Bug]: Desktop UI rejects pairing addresses containing a WebSocket scheme and port #9746.

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 in src/renderer/src/components/skills/skill-freshness-group.tsx:101)
  • pnpm typecheck
  • pnpm test (28 related tests passed)
  • pnpm build (pnpm build:electron-vite passed)
  • Added or updated high-quality tests that would catch regressions

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 resolveAdvertisedPairingEndpoint contract. 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-check failure in skill-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.

  • X handle: N/A

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.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Manual network address parsing now accepts validated ws:// and wss:// URLs, including optional ports, paths, and query strings while rejecting unsupported URL forms. Error messages and tests were updated accordingly. The pairing address dialog now documents hostnames, static addresses, and full WebSocket reverse-proxy URLs.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy #9746 by accepting ws:// and wss:// pairing addresses, including explicit ports, as requested.
Out of Scope Changes check ✅ Passed The edits stay focused on pairing-address validation, regression tests, and related UI copy/localization.
Title check ✅ Passed The title matches the main change: accepting WebSocket pairing addresses for mobile.
Description check ✅ Passed The description includes all required sections and covers testing, screenshots, AI review, security, and notes.

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.

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

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.tsx
  • src/shared/network/manual-address.test.ts
  • src/shared/network/manual-address.ts

@AmethystLiang
AmethystLiang requested a review from OrcaWin July 22, 2026 17:03
@nwparker nwparker added the bug Something isn't working label Jul 27, 2026
@OrcaWin
OrcaWin merged commit 3f53287 into stablyai:main Jul 29, 2026
29 checks passed
@OnlyYu1996
OnlyYu1996 deleted the codex/issue-9746-pairing-address-url branch July 29, 2026 03:39
Comment on lines +32 to +36
if (trimmed.includes('://')) {
return normalizePairingUrl(trimmed)
? { ok: true, address: trimmed }
: { ok: false, error: ERROR_MESSAGE }
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Comment on lines +185 to 195
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 () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Comment on lines +79 to +85
const handleCustomConfirm = async (next: string): Promise<boolean> => {
if (beforeCustomConfirm && !(await beforeCustomConfirm(next))) {
return false
}
onValueChange(next)
return true
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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-apps

greptile-apps Bot commented Jul 29, 2026

Copy link
Copy Markdown

Greptile Summary

This PR extends mobile pairing to accept complete ws://, wss://, http://, and https:// URLs (including explicit ports and reverse-proxy paths) in the custom address picker, fixing #9746 where only bare hostnames were accepted. It also adds IPv6 support, centralises wildcard-host and protocol-limit constants, upgrades CustomAddressDialog to support async confirmation with a loading state, and fixes a log-redaction gap in the mobile RPC client that previously emitted the full endpoint URL.

  • New pairing-url.ts + mobile-pairing-protocol-limits.ts: shared normalizePairingUrl / isPairingWildcardHostname helpers used by both the renderer validator and the main-process endpoint resolver, with a new constants file that avoids pulling the Zod schema into the renderer bundle.
  • CustomAddressDialog async onConfirm: the dialog now locks during submission, shows a spinner, and surfaces a confirmationError message; AddressPicker threads a beforeCustomConfirm hook that calls getPairingQR to validate custom addresses live before closing.
  • Nullable qrDataUrl in getPairingQR: QR-encoding is extracted into encodeMobilePairingQr, the IPC response now carries qrDataUrl: null | string and an optional qrError, and the pairing section surfaces a fallback "copy instead" message when encoding fails.

Confidence Score: 4/5

The 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 (normalizePairingUrl, isPairingWildcardHostname, resolveAdvertisedPairingEndpoint) is correct and the wildcard/credential/port-zero rejections are aligned between renderer and main process. The three findings are all non-blocking: the address picker stores the raw HTTP/HTTPS form instead of the canonical ws/wss form (display inconsistency only, main process re-normalizes on every use), a transient runtime outage produces a misleading 'check the address' error in the confirmation dialog, and the preemptive validation call discards its QR result causing a double token rotation. None of these affect pairing correctness for the typical flow.

Files Needing Attention: src/shared/network/manual-address.ts (URL branch returns raw input instead of normalized form) and src/renderer/src/components/mobile/MobilePage.tsx (beforeCustomAddressChange error-path ambiguity).

Important Files Changed

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
Loading

Reviews (1): Last reviewed commit: "fix(mobile): reset custom address dialog..." | Re-trigger Greptile

@AmethystLiang

Copy link
Copy Markdown
Contributor

thanks for reporting. looking into it

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Desktop UI rejects pairing addresses containing a WebSocket scheme and port

5 participants