You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(pairing): pair a phone with a loopback-only server through Relay - #51211
An Orca server that only listens on its own machine (127.0.0.1), such as the one Orca installs on an SSH host, refused every orca pair with network_exposure_failed. That included --relay, which doesn't need a network address at all. Now such a server pairs a phone through Orca Relay. When Relay isn't available, it says what's missing.
Files
Added
Deleted
Net
Test
1
$\color{#1a7f37}{\Huge{\mathbf{+}}}$83
0
$\color{#1a7f37}{\Huge{\mathbf{+}}}$83
Prod
6
$\color{#1a7f37}{\Huge{\mathbf{+}}}$101
$\color{#cf222e}{\Huge{\mathbf{−}}}$23
$\color{#1a7f37}{\Huge{\mathbf{+}}}$78
What Changed
Before, on a server bound to 127.0.0.1 (SSH-managed orcad, or orca serve --bind 127.0.0.1):
orca pair --mobile, orca pair --mobile --relay and orca pair all printed Pairing is unavailable (network_exposure_failed). Could not expose the runtime to the network for pairing….
After:
orca pair --mobile --relay mints a Relay-only offer. It has no direct endpoint, and the listener stays on 127.0.0.1.
orca pair --mobile --relay on a host that isn't signed in prints: Orca Relay needs this host signed in to Orca. Run orca auth login here, then retry.
orca pair --mobile (LAN only) prints: This Orca listens only on loopback, so nothing can dial it directly. Give an address that forwards to it, such as a tunnel or SSH port-forward. Or pair the phone through Orca Relay.
orca pair --mobile --address 127.0.0.1 (an SSH port-forward) now mints a working offer.
A server bound to one network address (--bind 100.64.1.20) now pairs on that address instead of refusing.
Mechanism:
ensureNetworkExposure() returns without widening for any pinned bind. Before, it threw for every pinned bind except 0.0.0.0.
Which addresses a pinned listener answers on is now decided in one place, pinnedListenerAddress(): none for loopback, and only its own address for a network bind.
getPairingNetworkInterfaces(), getDefaultPairingAddress() and the phone's pairing.getDirectEndpoints list all use it.
So automatic selection, the pairing window's address picker and the endpoints phones follow all agree.
IPv6 spellings are canonicalized first, so ::ffff:127.0.0.1 and 0:0:0:0:0:0:0:1 count as loopback, and an IPv4-mapped wildcard offers IPv4 only.
The owner orca pair path turns relay_signed_out, relay_not_entitled and a missing provider into guidance that names the fix. It never suggests LAN to a loopback-only host.
Why
ensureNetworkExposure() threw for any pinned bind because, when orcad gained --bind (#16398), every caller widened the bind so it could advertise a LAN address. Refusing kept unreachable addresses out of QR codes. Relay-only mobile offers came later, and they need no direct route, so that premise stopped holding. Since managed orcad always pins 127.0.0.1, the hand-pairing workaround in #27988 and #40079 couldn't work on it.
The rule against widening a bind the operator chose (STA-2370) still holds: a pinned bind is never rebound. The throw was also doing a second job, keeping unreachable addresses out of offers. That job now sits in address selection, which only offers addresses the pinned listener actually answers. The alternative was to keep the throw and bypass it for Relay offers. That would leave --address port-forwards and network-pinned binds broken, and it would add a second exception path later Relay offers would have to copy.
Linked Issue
#27988, #40079: SSH-managed orcad can now be hand-paired with a phone through Relay. A phone reaching the server with no desktop step at all is still to come.
Visual Proof
N/A: no UI change. The CLI output before and after is in What Changed.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
On macOS, against a real orcad built from this branch, bound to 127.0.0.1 with its own profile:
On main, all of orca pair --mobile, --mobile --relay and plain orca pair returned network_exposure_failed.
On this branch, signed out, they print the guidance above. lsof shows the listener still on 127.0.0.1 only.
An offer from orca pair --mobile --address 127.0.0.1 was paired by a client speaking the phone's direct E2EE protocol. It authenticated as a mobile device, and status.get answered.
A live phone pairing through Relay wasn't run: the scratch server wasn't signed in to an Orca account. The Relay mint path itself is unchanged; the test below drives it with a stubbed provider.
Address selection was checked for 127.0.0.1, ::1, ::ffff:127.0.0.1, 0:0:0:0:0:0:0:1, 0.0.0.0, ::, ::ffff:0.0.0.0 and a Tailscale address.
loopback-pinned-pairing-offer.test.ts runs a real OrcaRuntimeRpcServer pinned to 127.0.0.1 with only the Relay provider stubbed. It checks three things: a Relay offer comes back with a null endpoint, a LAN-only offer is refused, and the listener never leaves 127.0.0.1. It fails on main with network_exposure_failed.
Performance
None. Pinned binds now skip the interface scan and route lookup entirely. Unpinned listeners add one string normalization per pairing request or phone endpoint read, and nothing here polls, writes or retries.
Risk
The riskiest part is that a pinned bind no longer refuses pairing. If address selection were wrong, an offer could carry an address the listener doesn't answer, and the phone would fail to connect. Selection now only returns addresses the pinned listener answers, and every loopback spelling was checked. An explicit --address is still advertised as given, as serve --pairing-address already is, because a tunnel or proxy can make any address reach the listener.
The desktop app is never pinned, so its pairing is unchanged. An older host still returns network_exposure_failed to a newer CLI. Nothing changes on the wire or in saved data. A plain revert backs it out.
Level: Low
AI Disclosure
Review
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Security: no path widens a pinned bind.
Remote SSH: this is the SSH-managed path.
Mobile: the phone app is unchanged, and Relay-only offers have the same shape the desktop already mints when it has no LAN address. No store build is needed.
Cross-platform: address selection is shared code, and the Windows Hyper-V route lookup is skipped for pinned binds.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
A server started on a fixed address (SSH-managed orcad, orca serve --bind)
refused every orca pair with network_exposure_failed, even with --relay:
pairing always tried to widen the listener first, and a pinned bind threw.
A pinned bind is now never widened and never an error; offers advertise
only the address it answers, so a loopback pin mints a Relay-only offer.
Pairing address selection now distinguishes wildcard, loopback, and other pinned listener addresses. Pairing offers provide listener-specific guidance, including Relay guidance for loopback-bound servers. Network exposure now returns for any pinned bind host. The pull request adds an integration test and updates CLI and remote-server documentation.
Merge Risk: Moderate · up to 045d1
Pairing a loopback-bound server through Relay may produce a link that also carries a loopback direct address. A phone could try that address first, which would make Relay pairing slower or fail. This should be confirmed or fixed before merge; the rest of the change appears sound.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the primary change: pairing a phone with a loopback-only server through Relay. It is specific and matches the changeset, which adds Relay-only offers for 127.0.0.1-pinned binds and rem…
Description check
The description follows the template closely. It has ELI5, What Changed (before and after, with mechanism), Why (with alternatives considered), Linked Issue, Visual Proof marked N/A with a reason, Tes…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the primary change: pairing a phone with a loopback-only server through Relay. It is specific and matches the changeset, which adds Relay-only offers for 127.0.0.1-pinned binds and removes the network_exposure_failed refusal. The 'fix(pairing)' prefix follows a conventional-commit style and is clear.
Full details: Description check
Explanation
The description follows the template closely. It has ELI5, What Changed (before and after, with mechanism), Why (with alternatives considered), Linked Issue, Visual Proof marked N/A with a reason, Testing with manual and automated test details, Performance, Risk with level and revert path, and Notes and Checklist. The AI Disclosure and Review sections are empty, but the template says to skip AI Disclosure for team members, and Review has no required content. The Linked Issue section cites #27988 and #40079 rather than a 'Fixes #' issue, which is a minor template deviation for a maintainer PR.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
LanguageTool
docs/site/content/docs/remote-servers.mdx
LanguageTool could not check every text chunk; analysis is incomplete
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
An Orca server that only listens on its own machine (127.0.0.1), such as the one Orca installs on an SSH host, refused every
orca pairwithnetwork_exposure_failed. That included--relay, which doesn't need a network address at all. Now such a server pairs a phone through Orca Relay. When Relay isn't available, it says what's missing.What Changed
Before, on a server bound to 127.0.0.1 (SSH-managed orcad, or
orca serve --bind 127.0.0.1):orca pair --mobile,orca pair --mobile --relayandorca pairall printedPairing is unavailable (network_exposure_failed). Could not expose the runtime to the network for pairing….After:
orca pair --mobile --relaymints a Relay-only offer. It has no direct endpoint, and the listener stays on 127.0.0.1.orca pair --mobile --relayon a host that isn't signed in prints:Orca Relay needs this host signed in to Orca. Run orca auth login here, then retry.orca pair --mobile(LAN only) prints:This Orca listens only on loopback, so nothing can dial it directly. Give an address that forwards to it, such as a tunnel or SSH port-forward. Or pair the phone through Orca Relay.orca pair --mobile --address 127.0.0.1(an SSH port-forward) now mints a working offer.--bind 100.64.1.20) now pairs on that address instead of refusing.Mechanism:
ensureNetworkExposure()returns without widening for any pinned bind. Before, it threw for every pinned bind except0.0.0.0.pinnedListenerAddress(): none for loopback, and only its own address for a network bind.getPairingNetworkInterfaces(),getDefaultPairingAddress()and the phone'spairing.getDirectEndpointslist all use it.::ffff:127.0.0.1and0:0:0:0:0:0:0:1count as loopback, and an IPv4-mapped wildcard offers IPv4 only.orca pairpath turnsrelay_signed_out,relay_not_entitledand a missing provider into guidance that names the fix. It never suggests LAN to a loopback-only host.Why
ensureNetworkExposure()threw for any pinned bind because, when orcad gained--bind(#16398), every caller widened the bind so it could advertise a LAN address. Refusing kept unreachable addresses out of QR codes. Relay-only mobile offers came later, and they need no direct route, so that premise stopped holding. Since managed orcad always pins 127.0.0.1, the hand-pairing workaround in #27988 and #40079 couldn't work on it.The rule against widening a bind the operator chose (STA-2370) still holds: a pinned bind is never rebound. The throw was also doing a second job, keeping unreachable addresses out of offers. That job now sits in address selection, which only offers addresses the pinned listener actually answers. The alternative was to keep the throw and bypass it for Relay offers. That would leave
--addressport-forwards and network-pinned binds broken, and it would add a second exception path later Relay offers would have to copy.Linked Issue
#27988, #40079: SSH-managed orcad can now be hand-paired with a phone through Relay. A phone reaching the server with no desktop step at all is still to come.
Visual Proof
N/A: no UI change. The CLI output before and after is in What Changed.
Testing
On macOS, against a real orcad built from this branch, bound to 127.0.0.1 with its own profile:
orca pair --mobile,--mobile --relayand plainorca pairreturnednetwork_exposure_failed.lsofshows the listener still on127.0.0.1only.orca pair --mobile --address 127.0.0.1was paired by a client speaking the phone's direct E2EE protocol. It authenticated as a mobile device, andstatus.getanswered.127.0.0.1,::1,::ffff:127.0.0.1,0:0:0:0:0:0:0:1,0.0.0.0,::,::ffff:0.0.0.0and a Tailscale address.loopback-pinned-pairing-offer.test.tsruns a realOrcaRuntimeRpcServerpinned to 127.0.0.1 with only the Relay provider stubbed. It checks three things: a Relay offer comes back with a null endpoint, a LAN-only offer is refused, and the listener never leaves 127.0.0.1. It fails on main withnetwork_exposure_failed.Performance
None. Pinned binds now skip the interface scan and route lookup entirely. Unpinned listeners add one string normalization per pairing request or phone endpoint read, and nothing here polls, writes or retries.
Risk
The riskiest part is that a pinned bind no longer refuses pairing. If address selection were wrong, an offer could carry an address the listener doesn't answer, and the phone would fail to connect. Selection now only returns addresses the pinned listener answers, and every loopback spelling was checked. An explicit
--addressis still advertised as given, asserve --pairing-addressalready is, because a tunnel or proxy can make any address reach the listener.The desktop app is never pinned, so its pairing is unchanged. An older host still returns
network_exposure_failedto a newer CLI. Nothing changes on the wire or in saved data. A plain revert backs it out.Level: Low
AI Disclosure
Review
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)