Repository navigation
fix(mobile): keep a proxied wss host on :443 when editing - #11383
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 0f0cbad54e115be2d1c2bdeee9f6058c1224a2a1 and 6a35f5d. 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughAdds 🚥 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 |
A host paired through a reverse proxy is stored as `wss://desk.example.com` with no explicit port. Editing it — even to only change the display name — rewrote the endpoint to `wss://desk.example.com:6768` and stranded the host, with no warning. `endpointPort` intentionally reports only explicitly written ports, so it returns undefined for that endpoint. The edit screen passed that undefined straight through as `fallbackPort`, where `resolveFallbackPort` substituted the LAN `DEFAULT_PORT`. Add `endpointPortOrSchemeDefault`, which falls back to the scheme's implicit port for wss and leaves bare ws alone so LAN pairings keep landing on DEFAULT_PORT, and use it for the edit screen's fallback. `normalizeHostEndpoint` is untouched — filling a missing port from `fallbackPort` is its documented contract and stays covered by its existing tests.
0f0cbad to
6a35f5d
Compare
…1383) * fix(mobile): keep a proxied wss host on :443 when editing A host paired through a reverse proxy is stored as `wss://desk.example.com` with no explicit port. Editing it — even to only change the display name — rewrote the endpoint to `wss://desk.example.com:6768` and stranded the host, with no warning. `endpointPort` intentionally reports only explicitly written ports, so it returns undefined for that endpoint. The edit screen passed that undefined straight through as `fallbackPort`, where `resolveFallbackPort` substituted the LAN `DEFAULT_PORT`. Add `endpointPortOrSchemeDefault`, which falls back to the scheme's implicit port for wss and leaves bare ws alone so LAN pairings keep landing on DEFAULT_PORT, and use it for the edit screen's fallback. `normalizeHostEndpoint` is untouched — filling a missing port from `fallbackPort` is its documented contract and stays covered by its existing tests. * review(mobile): preserve untouched host endpoints * fix(mobile): preserve routed endpoint edits --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>

Summary
Editing a host that was paired through a reverse proxy silently moved it to a port nothing is listening on.
A host paired with an endpoint like
wss://desk.example.comcarries an implicit:443. Opening Edit host and saving — even when only changing the display name — rewrote the endpoint towss://desk.example.com:6768, after which the host could no longer connect. There was no warning, and the address field never showed a port, so the change was invisible until the next reconnect failed.Root cause:
endpointPortintentionally reports only explicitly written ports (its doc comment calls this out, sincenew URL('wss://host:443').portis empty). Forwss://desk.example.comit correctly returnsundefined.undefinedstraight through asfallbackPort, whereresolveFallbackPortsubstituted the LANDEFAULT_PORT(6768).This adds
endpointPortOrSchemeDefault, which falls back to the scheme's implicit port forwssand deliberately leaves barewsasundefinedso LAN pairings keep landing onDEFAULT_PORT. The edit screen uses it for its fallback.normalizeHostEndpointis not touched: filling a missing port fromfallbackPortis its documented contract and is covered by existing tests (fills missing port on scheme URLs from fallbackPort). Changing it would have broken that contract for every caller.Reproduction
orca serve --pairing-address wss://desk.example.com --mobile-pairingwss://desk.example.com:6768and the host cannot reconnectScreenshots
No visual change.
Testing
pnpm lintpnpm typecheckpnpm test— see the note below on pre-existing failurespnpm buildOn
pnpm test: the root suite reports 43 pre-existing failures (8 files, e.g.src/renderer/src/components/browser-pane/markup/use-markup-draw-hint.test.ts). They are not caused by this PR:upstream/mainis three files, all undermobile/;git diff upstream/main -- src/is empty.includecoverssrc/**,config/scripts/**,tools/**andtests/e2e/**— it does not loadmobile/at all, so nothing changed here is even executed by that suite.My local Node is 26.5.0 while the repo pins 24 (
Unsupported enginewarning), which may well be the cause — worth a sanity check on CI, but it is orthogonal to this change.Six tests added to
mobile/src/transport/host-endpoint.test.ts, including two that exercise the full edit-host round trip (displayHostEndpoint→normalizeHostEndpoint) rather than just the new function in isolation — that round trip is where the port was being lost.I verified the tests actually catch the regression by reverting the fix in place: the two meaningful assertions fail (
expected undefined to be '443', and the round trip yielding:6768instead of:443), and pass again once restored. The remaining assertions pin the behavior that must not change: explicit ports are preserved, barewsstill resolves toDEFAULT_PORT, and non-URL input still reports nothing.mobileis a separate workspace, so its suite was run there as well: 354 files / 2604 tests pass, plusoxlintandtsc --noEmit.AI Review Report
Reviewed with Claude. Main risks checked:
normalizeSchemeUrluse the scheme default — would have silently changednormalizeHostEndpoint('ws://host', { fallbackPort: '9000' }), which an existing test pins. Confirmed the fix stays on the caller side and that no existing assertion changed.ws://hostwithout a port intentionally still returnsundefinedsoDEFAULT_PORTcontinues to apply; asserted explicitly rather than left implicit, since the asymmetry betweenwsandwssis the kind of thing a later refactor would "tidy up" incorrectly.host-endpoint.tssits near themax-linesceiling; the first draft pushed it to 302/300. PerAGENTS.mdthis must never be resolved with amax-linesdisable or a per-file bump, so the comments were tightened instead. Finaloxlintrun is clean.Security Audit
endpointPort/endpointScheme. No new parser, no regex, no additional trust placed in the input.'443'; it never derives a port from user-typed text. Validation of anything the user types still runs throughnormalizeHostEndpoint, unchanged.6768— it narrows, rather than widens, where the client will dial.Notes
displayHostEndpointdrops the scheme when no explicit port is present, sowss://desk.example.comis shown as a baredesk.example.com. That is a large part of why this bug was invisible to the user, but fixing it affects other callers and deserves its own change.normalizeHostEndpoint'sDEFAULT_PORTfallback for scheme URLs is arguably surprising in general (RFC 6455 would imply:80/:443), but it is the documented contract here and changing it is a product decision, not a bug fix.6768, which appears to be outside the shapes the existing tests cover — everyws(s)://case inhost-endpoint.test.tscarries an explicit port.