Skip to content

feat(ports): open a remote workspace's port in the system browser - #21807

Open
mmarabel wants to merge 11 commits into
stablyai:mainfrom
mmarabel:feat/remote-workspace-port-system-browser
Open

mmarabel wants to merge 11 commits into
stablyai:mainfrom
mmarabel:feat/remote-workspace-port-system-browser

Conversation

@mmarabel

@mmarabel mmarabel commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When your code runs on another computer, its dev server prints http://localhost:5173. "localhost" means "the machine I am on", so on your own laptop that address points at nothing — or worse, at something completely unrelated that you happen to be running on the same port. Orca's Ports list showed you that address anyway.

Now, when your laptop is talking to that other machine over an address like 100.64.1.20, and the dev server was started so that other machines are allowed to connect, the Ports list shows 100.64.1.20:5173 instead — the address that actually points at the right server. Copying the row copies that.

Clicking a remote port still opens Orca's own browser, exactly as before, because Orca's browser tunnels through the connection and always works. If you specifically want the page in your own browser — real profile, extensions, second monitor — hold ⇧⌘ (⇧Ctrl on Windows and Linux) and click. That works whichever way your link-routing settings are set. If there is no address that could reach the server, Orca stops advertising that shortcut instead of promising something it cannot do.

What Changed

Before. On a workspace hosted by a paired Remote Orca Server, every ports surface displayed and copied localhost:<port> — an address naming the client machine. The tooltip offered ⇧⌘+click for system browser on every row, but the code behind it was gated on runtimeTarget.kind === 'local', so on a remote port the shortcut silently did nothing different.

After. A remote port whose listener accepts off-host connections displays and copies the address this client is already reaching that host on. ⇧⌘+click opens it in your own browser. A remote port that nothing can reach is left exactly as it was, and its tooltip no longer offers the shortcut. A plain click is unchanged everywhere: local ports route by your Link Routing setting, remote ports go to the embedded browser.

Mechanism. Two facts Orca already had in the renderer, joined for the first time:

  1. WorkspacePort.bindHost — the unmodified address the OS listener reported, kept alongside the normalized connectHost. A wildcard bind (0.0.0.0, ::, *) means the kernel accepts connections on every interface. A loopback bind never leaves its own host at any address.
  2. The address this client is dialing the runtime on, read from the environment catalog already present in the renderer (PublicKnownRuntimeEnvironment.endpoints, tokens already redacted).

clientReachableBrowserUrlForPort combines them, and usePortClientReachability is the one hook every ports surface destructures for the address to show, the address to copy, the URL to offer, and the host that owns the row — so those four cannot drift apart.

Three things this deliberately does not do, each of which an earlier revision of this branch got wrong:

  • It does not move the default click. openLinksInApp defaults to false, so openInOrcaBrowser === false is not the modifier — it is the ordinary click. Routing on that alone would have sent every stock-settings click on a remote port out of the app. The modifier is now reported separately from the saved setting, and only an explicit gesture trades the embedded browser away.
  • It does not claim the URL will load. The connection proves the client reaches the pairing port; a wildcard bind proves the kernel will accept locally. Neither proves a packet to port 5173 survives a security group, ufw, Windows Firewall, or a port-scoped Tailscale ACL. window.api.shell.openUrl reports success either way. So the reachable URL is an offer behind a gesture, and the path that always works — the embedded browser, which tunnels — stays the default.
  • It does not rewrite a DNS origin. If a dev server advertised https://local.example.com:3001, that name is what its certificate is for and what any reverse proxy keys on. Substituting an IP there is strictly worse whenever the name resolves, so the advertised origin is offered unchanged. Loopback, wildcard and IP-literal advertised hosts are substituted — and so is a loopback alias such as http://feature.localhost:5173, which looks like a DNS name but resolves to the client's own machine.

Three adjacent correctness fixes fell out of the same work:

  • Which machine a row belongs to. The status-bar popover renders the merged all-hosts scan, so rows from different machines sit side by side, and every consumer resolved a row's host from the active workspace. A local 0.0.0.0:7000 listener next to remote rows was therefore attributed to the remote machine — for its address, and for its stop button. The merge already knew the answer and threw it away into a prefixed row id; it now carries the scan key as a field, on the single-host projection as well as the multi-host one.
  • What the modifier means. The ports surfaces never honoured Invert link-routing modifier. Gating the hint on settings alone was not enough either: inverting means "the other destination", and on a remote port the other destination is never Orca, because a plain click already lands in the embedded browser whatever Link Routing says. Users with that setting on could therefore never reach the system browser at all, while being told ⇧⌘+click to open in Orca. The resolver now takes where a plain click on this row goes and names the destination a plain click does not reach — mirroring what ChecksPanel already does for review links — or names nothing, when both meanings coincide.
  • Where a row ends its address. A reachable address was built from URL.host, which omits a default port, so a remote listener on :80 or :443 rendered as a bare hostname while every other row rendered host:port.
  • The SSH forwarded-port row. It printed ⇧⌘+click for system browser unconditionally, which repeats the plain click under stock settings and names the wrong end for an inverting user. A forward listens on this machine's loopback, so the same resolver answers it and the panel now passes the destination down.

Why

The execution host owns the dev server, but the person is sitting at the client. Orca's embedded browser bridges that with a network tunnel; the system browser cannot inherit a per-session proxy, so it needs a URL that stands on its own.

Why the connection address rather than detecting a VPN or tunnel provider. A provider integration means a dependency, a detection path, and a list to maintain. The address the client already holds needs none of that and works over a LAN, a VPN, a tailnet or a public address without knowing which. classifyRemotePairingHostname already distinguishes those and is reused both to decline loopback endpoints and to decline loopback-alias advertised origins.

Why bindHost rather than probing. Whether another machine may connect at all was decided when the server bound its socket. Reading it is exact and free; probing would be slow, racy, and still wrong behind a firewall.

Why show the address even though the open path is gated. localhost:5173 on a remote row is not merely useless — a developer laptop very often does have something on 5173, so the old row could send a copied address to the wrong server and look like it worked. The reachable address either works or refuses the connection; it cannot silently show the wrong page. That is why display and copy follow the reachable address even though the system-browser route is opt-in.

Why derive the modifier from the plain click rather than from the settings. A tooltip that names a destination the gesture does not reach is worse than no tooltip, and a gesture with no destination is worse still. Taking the plain-click landing spot as the input makes both fall out of one answer, and it is the same shape resolveChecksPanelHostedReviewModifierDestination already uses, so the two surfaces cannot diverge.

Why the renderer. It is the only place that holds both facts. No wire change, no new IPC, no new store, no probe.

Linked Issue

Part of #21806

This PR covers Branch A of that issue only — a wildcard-bound port on a paired Remote Orca Server — so it closes the second of the two gaps the issue lists (the Ports panel offering no system-browser option on a remote workspace) and not the first. It therefore does not close the issue, and the label is deliberate rather than an oversight.

The remaining branches, all tracked separately:

Visual Proof

The modifier on a remote port, for a user with "Invert link-routing modifier" on

This is the defect the latest round of review found, and it is the one that made the headline feature unreachable for that cohort. Both captures are the real PortRow component rendered with the same store — a remote workspace reached at 100.64.1.20, one dev server bound 0.0.0.0:5173 and one control server bound 127.0.0.1:4322 — with Link Routing off and the modifier inverted. Hover states are forced on so both tooltips are visible at once.

BEFORE — both rows advertise ⇧⌘+click to open in Orca, which is where a plain click already goes. The gesture does nothing on either row, and the unreachable 4322 advertises it too:

before: both remote rows advertise a modifier that opens in Orca, which a plain click already does

AFTER — 5173 advertises ⇧⌘+click for system browser and the gesture opens http://100.64.1.20:5173 there. 4322 has no reachable address, so it advertises nothing:

after: the reachable remote row offers the system browser, the unreachable one offers nothing

The address a remote row shows and copies

The status-bar port row, rendered from the real PortRow component against origin/main and against this branch, with the same three ports and the same store: a remote dev server bound 0.0.0.0:5173, a remote control server bound 127.0.0.1:4322, and — in the merged all-hosts view — a listener on this laptop on 0.0.0.0:7000. The client reaches the runtime at 100.64.1.20.

BEFORE (origin/main) — the remote dev server reads localhost:5173, which names this laptop:

before: remote port row shows localhost:5173

AFTER — it reads 100.64.1.20:5173. The loopback-bound remote port is untouched, and the local row in the merged view still correctly reads localhost:7000:

after: remote port row shows 100.64.1.20:5173

The tooltip on the remote port that cannot be reached — BEFORE, offering a shortcut that did nothing:

before: unreachable remote port still advertises the system-browser modifier

AFTER — the offer is withdrawn:

after: unreachable remote port no longer advertises the modifier

AFTER, on the port that can be reached, the shortcut is still advertised:

after: reachable remote port keeps the system-browser hint

What these captures do not show, stated plainly: the external browser window actually loading the page. That needs two machines, and the takeover was done on one. The original author captured the display change on a real two-machine setup (macOS client paired to a Linux remote Orca server, 0.0.0.0:4321 against a 127.0.0.1:4322 control) and confirmed there that ⇧⌘+click opened the default browser; that evidence stands and matches the row behaviour above. Which URL reaches shell.openUrl on each click path is pinned by workspace-port-actions.test.ts and ports-status-popover-rows.test.tsx rather than by a screenshot.

Testing

Automated, on macOS:

  • pnpm tc — clean.
  • pnpm test — full suite, 9228 files, 85824 passing. 8 files fail, none of them in or near ports: native-build parallelism, the AI-vault session scanner, browser-manager viewport ownership, a real-CLI Claude test, terminal-history tombstone retries, and three e2e harness files (cross-version wire, release checkout, worker env isolation). They are environment-sensitive on this machine and none touch a file this PR changes; the ports suites are green.
  • pnpm run check:code-quality:changed — 0 new findings across all 7 gate configs.

Honest account of what the tests actually cover, because an earlier revision of this section overstated it. The behaviour-bearing files are:

  • workspace-port-actions.test.ts — the open path itself, with window.api.shell.openUrl stubbed: a local port still opens on the stock plain click; a local port with a worktree label still opens the registered label URL; a remote port on a stock plain click stays in the embedded browser and never calls openUrl; a remote port opens the reachable URL only when the modifier is set; and with the modifier but no reachable URL it falls back to the embedded browser. Plus the scan-key ↔ runtime-target round trip and the single-host hostScanKey stamp.
  • workspace-port-open-routing.test.ts — the full destination matrix: remote port with and without inverting, remote port with no reachable address, local port under all three settings combinations, and the tooltip string each one produces.
  • ports-status-popover-rows.test.tsx — five rendered-row cases: a remote wildcard port shows and writes to the clipboard the reachable address; a remote loopback port keeps the OS-derived address and drops the hint; a local row in the merged view is not stamped with the remote host; an inverting user on a remote port sees the system-browser hint and a ⇧⌘+click calls openUrl with the reachable URL; and an inverting user on an unreachable remote port sees no hint at all.
  • WorktreeCardPorts.test.tsx — the hint is absent on a local port with Link Routing off (where the plain click already opens the system browser) and present once Link Routing is on.
  • ssh-forwarded-port-row.test.tsx — the same three hint outcomes on an SSH forward, so the two ports panels cannot drift apart.
  • workspace-port-urls.test.ts / workspace-port-client-reachability.test.ts — the pure resolvers, including the DNS-origin passthrough, the *.localhost refusal, the path-bearing-endpoint refusal, the IPv6 bracketing and the default-port address.

Each production change was reverted one at a time and the corresponding tests confirmed to fail, then restored: the modifier resolver (8 failures), the *.localhost guard (1), the single-host stamp (2), the default-port address (1), and the SSH row's destination threading (2).

Manual, by the original author, on a real two-machine setup — a macOS desktop client paired to a Linux remote Orca server, two servers in one workspace, one bound 0.0.0.0:4321 and one bound 127.0.0.1:4322: 4321 displayed and copied the reachable address and the modifier opened it in the default browser; 4322 was unchanged. From the host, 127.0.0.1:4322 answered 200; from the client the same address refused the connection, confirming the split is real and not cosmetic.

Not exercised on hardware by the takeover: Windows and Linux clients. Nothing platform-dependent is touched — no paths, shells, processes — and the one shortcut string already branches on navigator.userAgent.includes('Mac'), which both platforms are covered for in tests.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Claude Opus 5, for investigation, implementation and tests, by both the original author and the maintainer who took the PR over. Every claim about existing behaviour here was read from the source.

Review

Taken over by @nwparker. The author's design — join bindHost with the connection endpoint, in the renderer, and let null mean "do not offer" — was kept as-is; it is the right shape and costs no wire change. What changed is the packaging: the default click no longer moves, the reachable URL is an offer rather than a silent replacement, four duplicated derivations collapsed into one hook, the modifier now resolves from where a plain click lands rather than from settings alone, and the prose above no longer claims coverage or refusals that the code did not have.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security. Nothing new is exposed. A wildcard-bound listener is already reachable from any machine that can route to it; this surfaces an address the user could have typed. No new listener, no new grant, and no credential leaves the client — the endpoint list already reaching the renderer is redacted of deviceToken and publicKeyB64. The advertisedUrl that can now be offered to shell.openUrl is scraped only by a matcher anchored on /\bhttps?:\/\//i, so no javascript: or file: origin can reach it.
  • Exposure the user should know about. This surfaces an address; it does not create one. If a dev server is bound 0.0.0.0 on a host with a routable address, everything that can route there could already reach it. That is a property of how the server was started, and the raw Bind: value sits next to the address in the port details dialog so the two can be read together.
  • Backwards compatibility. Renderer-only. No wire change, no schema change, no new IPC or RPC. hostScanKey is an optional field the renderer's own merge sets and nothing sends. clientReachableUrl and systemBrowserRequested are optional, so a caller that omits them gets today's behaviour.
  • Cross-platform. No paths, shells or processes. The shortcut string already branches on platform; IPv4 and IPv6 are both covered by tests.
  • Remote SSH. SSH-backed repos route to SshPortsPanel. Its routing is unchanged — the new remoteHost input defaults to false, which reproduces the old answer on every settings combination — while its forwarded-row tooltip now names the same destination as the workspace-port rows. An ssh-tunnelled pairing is explicitly refused, because its endpoint terminates on the client's own loopback.
  • Mobile / web clients. Untouched; they do not use these actions.
  • Performance. One array lookup and one URL parse per row, memoised. The new hook replaces two duplicate store subscriptions per row with one.
  • Known gap, deliberately excluded. A server bound to a concrete non-loopback address (100.64.1.20:4321 rather than 0.0.0.0) is reachable but returns null today. Treating every non-loopback bind as reachable would be wrong — a host commonly has 172.17.0.1 and other bridge addresses that are non-loopback and unroutable from the client. The safe narrow extension is bindHost equal to the connected address; it is not in this PR.
  • Refactors carried along. isUnspecifiedHost and isWildcardBindHost were the same predicate and are now one; preferredEndpointId ?? endpoints[0] had three copies and is now preferredRuntimeEndpoint, which matters here because this feature's correctness argument is "we name the endpoint the transport actually dials"; the two modifier-hint strings are now the shared getTerminalUrlSystemBrowserHint / getTerminalUrlOrcaBrowserHint that ChecksPanel already imports, with an optional isMac for tests, rather than private copies. workspace-port-actions.ts crossed the 300-line cap, so the click-routing concern moved to workspace-port-open-routing.ts rather than suppressing the rule.

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)
  • 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 paired runtime's dev server URL is "localhost:<port>" on the runtime, so the
system-browser action was gated to local workspaces; a remote port could only open
in Orca's own browser.

When a remote listener is bound to a wildcard address, substitute the address this
client already uses to reach that runtime, which is reachable by definition. This
stays transport-agnostic: LAN, VPN, tailnet and public endpoints all work without
detecting which is which.

Loopback-bound listeners, ssh-tunnelled pairings and relay-only connections resolve
to null and keep today's in-app behavior rather than emitting an unreachable URL.
The row rendered addressForPort(), which on a remote workspace is
"localhost:<port>" — an address naming the client machine, where nothing is
listening. The copy button handed over the same unusable string, so the panel
was actively misleading rather than merely unhelpful.

Display and copy the reachable address when one exists, so what is shown,
copied and opened all agree and a remote port reads like a local one. Rows with
no reachable address keep the OS-derived value unchanged.
The sidebar worktree card and the status-bar popover open ports through the
same action as the right-sidebar panel, but neither passed the reachable URL
and both still rendered the OS-derived address. A remote port therefore kept
its old behavior on the two surfaces users reach first.
@mmarabel
mmarabel marked this pull request as ready for review September 20, 2026 18:36
@coderabbitai

coderabbitai Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 0be5bbde-3256-49bc-a3d1-fe85069e9022

📥 Commits

Reviewing files that changed from the base of the PR and between b131ac1 and ee1eb5f.

📒 Files selected for processing (3)
  • src/renderer/src/components/right-sidebar/ssh-forwarded-port-row.test.tsx
  • src/renderer/src/components/right-sidebar/ssh-forwarded-port-row.tsx
  • src/renderer/src/components/right-sidebar/ssh-ports-panel.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

The changes add shared runtime-endpoint selection and client-reachable workspace-port address resolution. Merged port rows retain their source scan key, which reachability resolution uses to identify the runtime target. Port rows use resolved addresses for display and copying, and pass reachability and routing results to browser-opening actions. Remote ports open in the embedded browser by default; an explicit system-browser request uses the reachable URL when available. Tests cover endpoint selection, address attribution, URL construction, and browser-routing decisions.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to ee1eb

The reviewed changes have no identified issue requiring a fix before merge.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to ee1eb

A deliberate shortcut can now open a remote workspace port in the user’s regular browser. That is useful, but a URL advertised by a remote process can supply the destination’s hostname. The shortcut requires a user gesture, and no automatic browser opening was found.

Retained concerns

  • Medium · security · inferred: A remote process’s terminal-advertised hostname can become the destination of an explicit system-browser open for a reachable remote port. The reachability checks establish a usable paired-host endpoint, but do not bind a preserved advertised DNS hostname to that host. A hostile or mistaken advertisement could therefore direct the client’s regular browser somewhere other than the scanned service.
Security review details

Security Blast Radius

  • inferred — The new exposure is bounded to a user who invokes the system-browser shortcut on an eligible remote port, but that action runs in the client’s regular browser rather than the remote in-app browser. The evidence does not establish a broader automatic-opening path.

Security Findings and Attack Paths

  • inferred — If a remote process can advertise a matching-port origin with an unrelated DNS hostname, an eligible modified click can open that origin in the client’s browser. No exploit, credential disclosure, or automatic navigation was verified.

Trust Boundaries and Controls

  • observed — The resolver excludes loopback-bound listeners, unusable paired endpoints, and SSH-tunnelled environments. Routing also requires an explicit modifier-derived system-browser request; these controls do not verify that a preserved advertised DNS name belongs to the paired host.

Hardening Proposals

  • proposed — For a preserved advertised hostname that differs from the paired endpoint, consider making that destination explicit at the system-browser action or requiring confirmation. Legitimate virtual hosts mean silently replacing every advertised hostname would not be equivalent behavior.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.35% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 57 functions across 28 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately describes the main change: opening remote workspace ports in the system browser.
Description check ✅ Passed The description is comprehensive and covers the required sections, user-visible behavior, implementation, rationale, linked issue, visual proof, testing, AI disclosure, compatibility considerations, a…
  • Fix all pre-merge checks with AI

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.

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

ℹ️ No critical issues — minor suggestions inline.

Reviewed changes

  • Remote reachable-address resolver — new clientReachableBrowserUrlForPort rewrites only the host of an advertised origin (scheme/path preserved) or synthesizes scheme://host:port, gated on a wildcard bind plus a non-loopback paired endpoint, with IPv6 kept bracketed exactly once.
  • Reactive row wiring — useClientReachableUrlForPort / clientReachableAddress drive display and copy on the right-sidebar Ports panel, the worktree card, and the status-bar popover; openWorkspacePortInBrowser routes the system-browser branch through the resolved URL and falls through to the in-app browser when there is none.
  • Tests — new exact-assertion unit tests for the resolver and URL builder, including the IPv6 [[…]] regression and the refusal set (loopback bind, ssh-tunnel, unparseable endpoint, missing environment, stale preferredEndpointId).

I traced the load-bearing claims: advertisedUrl is keyed by (worktreeId, port, pid) in local-workspace-port-attribution.ts:89 so its port always matches the listener; the transport dials getPreferredPairingOffer (i.e. preferredEndpointId), so "the address this client already uses" is accurate; and desktop runtime pairing offers cannot carry a relay, so the JSDoc's relay-only refusal has no desktop producer. Existing PortsPanel / WorktreeCardPorts tests still pass (42 tests).

Technical details
# Remote-reachable port address

## Verified contracts
- `src/main/ports/local-workspace-port-attribution.ts:89` — `advertisedUrl` only attached when the watcher lookup matches `(worktreeId, port, pid)`, so its port equals the listener port.
- `src/main/ipc/runtime-environment-transport-routing.ts:106` — every RPC dials `getPreferredPairingOffer(currentEnvironment)`, so `preferredEndpointId` is the live endpoint, not a stale preference.
- `src/shared/mobile-relay-pairing-offer.ts:82-91` — relay is rejected for `scope: 'runtime'`; no desktop environment endpoint is a relay URL.

## No new issues found in
- `openWorkspacePortInBrowser` system-browser branch: `local ? url : (clientReachableUrl ?? null)` is behavior-preserving for local and never forwards a remote `localhost:<port>` to the OS.
- Host attribution across all three surfaces: per-port owner target (workspace) and `activeWorktreeId` (container/external) are consistent between display and the open/stop action.

ℹ️ Nitpicks

  • getPortOpenBrowserTooltipLabel still advertises ⇧⌘+click for system browser on a remote port whose clientReachableUrl is null (loopback-bound). There the modifier falls through to the in-app browser, so the tooltip promises an action that does nothing — the same class of mismatch this PR fixes for wildcard binds. Conditioning the hint on clientReachableUrl != null would close it.
  • isWildcardBindHost in workspace-port-urls.ts duplicates the private helper of the same name in src/shared/browser-url.ts:90 (which additionally normalizes brackets and trailing dots). Exporting and reusing it would keep the two predicates from drifting.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

…er hint

Review follow-ups on stablyai#21807.

The details dialog was a fourth surface still rendering addressForPort(), so a
remote wildcard-bound port read localhost:<port> there while the row it was
opened from read the reachable host. Its Bind field keeps the raw value, which
is what makes the two fields useful together on a remote workspace.

The open-in-browser tooltip advertised the system-browser modifier on every
port, including a remote loopback-bound one where it falls through to the
in-app browser and does nothing. The hint is now conditional; omitting it needs
no new string.

isWildcardBindHost moves next to the bindHost field it interprets. It is
deliberately NOT the same-named helper in browser-url.ts: that one answers a
certificate question about a URL hostname and accepts only 0.0.0.0 and ::,
while a scanner-reported bind can also be '*' from lsof, so reusing it would
silently stop recognising wildcard binds on macOS.
@mmarabel

Copy link
Copy Markdown
Contributor Author

Thanks — all three addressed in 60d8855.

Details dialog. Correct, and it was the same mistake I'd already made once in this PR: openWorkspacePortInBrowser has three call sites and I originally wired one. The dialog was a fourth surface showing an address. It now uses the resolved address for both the header and the Address field, while Bind keeps the raw value — on a remote workspace those two fields are more useful together, since Bind: 0.0.0.0:4321 is exactly why Address: 100.64.1.20:4321 is reachable.

Tooltip hint. Agreed, and it's the same mismatch the PR fixes, one level up: the UI was advertising ⇧⌘+click for system browser on every port including remote loopback-bound ones, where the modifier silently falls through to the in-app browser. getPortOpenBrowserTooltipLabel now takes systemBrowserAvailable, and the rule lives in one hook (usePortSystemBrowserAvailable) rather than being re-derived per surface. Omitting the hint needs no new string, so there's no localization debt.

Duplicate isWildcardBindHost — I've moved it, but deliberately not reused the one in browser-url.ts, because they are not the same predicate and merging them would be a regression:

// browser-url.ts:90 — a certificate question about a URL hostname
return normalized === '0.0.0.0' || normalized === '::'

A scanner-reported bindHost can also be '*', which is what lsof prints on macOS — see local-workspace-port-address.ts:4, advertised-url-parsing.ts:185, and the host: '*' case in local-workspace-port-scanner.test.ts. Adopting the stricter predicate would silently stop recognising wildcard binds on exactly one platform, which is the worst shape of bug this feature could have.

The drift concern is fair though, so isWildcardBindHost now lives in shared/workspace-ports.ts directly beside the bindHost field it interprets, with a comment naming the distinction so the two aren't mistaken for each other later.

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

✅ No new issues found.

Reviewed changes

  • Threaded the client-reachable address into LocalPortDetailsDialog's header and Address field, falling back to the OS-derived address only when none exists — so the details pane agrees with the row it was opened from.
  • Gated the system-browser modifier hint in getPortOpenBrowserTooltipLabel on a new usePortSystemBrowserAvailable hook, dropping it when a remote loopback-bound port has no reachable URL instead of advertising a no-op.
  • Moved isWildcardBindHost beside the bindHost field in src/shared/workspace-ports.ts, with a comment on why it stays separate from browser-url.ts's certificate-hostname predicate.
  • Added a test pinning the hint's omission when the system browser cannot serve the port.

Both prior nitpicks and the one inline thread from the last review are addressed. I re-ran the affected suites (workspace-port-urls, workspace-port-client-reachable-url, PortsPanel) — 43 tests, all passing.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

…inition each

`isWildcardBindHost` and `isUnspecifiedHost` were the same predicate, and the
comment defending the duplicate named the wrong twin: it argued against reusing
`browser-url.ts`'s certificate predicate, while the real twin was the main-process
one, which is strictly stronger (it lowercases and strips brackets). Keep the
shared one, give it that normalization, and delete the main-process copy.

`preferredEndpointId ?? endpoints[0]` had three copies. Since a surface that names
a runtime endpoint must name the one the transport actually dials, that pick must
not be able to diverge; extract `preferredRuntimeEndpoint` and call it everywhere.
…ed endpoint

Two ways the reachable URL could be confidently wrong.

An advertised origin with a DNS name (the real case in the code is
`local.getmontecarlo.com:3001`) is the name the certificate is issued for and the
name any vhost or reverse proxy keys on. Substituting the connection's IP there
broke TLS and Host-header routing in the one case where the original may well have
worked, and it regressed display and copy versus main. Only loopback, wildcard and
IP-literal advertised hosts are substituted now.

`PairingOffer.endpoint` is allowed to carry a path, and `parseHostAccessLink`
explicitly permits one. For a pairing routed through a gateway at
`wss://gw.example.com/orca/ws` the bare hostname names the proxy and says nothing
about reaching a dev-server port behind it, so that endpoint is refused.

Also drops the `isWildcardBindHost` pass-through re-export, rebuilds the origin
instead of `URL.toString()` (advertisedUrl is origin-only by construction, so the
old path always appended a trailing slash), and rewrites the JSDoc to say what the
function actually proves: an offer, not a guarantee.
…ult route

Three problems, one shape: the branch treated "an address that reaches this host"
as "a URL that will load", and then wired the unverified answer into the path a
stock install takes on every click.

Default click. `openLinksInApp` defaults to false, so `openInOrcaBrowser === false`
is not the modifier — it is the ordinary pointer click. On main the second conjunct
`runtimeTarget.kind === 'local'` absorbed that and a remote port always landed in
the embedded browser. Routing on the reachable URL alone sent every click on a
remote wildcard-bound port out of the app to a URL that a security group, ufw,
Windows Firewall or a port-scoped ACL can refuse — with `shell.openUrl` reporting
success either way and no fallback. `resolvePortOpenRouting` now reports the
modifier separately from the saved setting, and only an explicit modifier trades
the embedded browser (which always works, because it tunnels) for the direct URL.
A local port's routing is unchanged.

Modifier inversion. The ports surfaces never read `openLinksInAppModifierInverts`,
so for users who opted into inversion the modifier and its hint were backwards,
unlike every other link surface. They now go through one destination resolver that
also drives the tooltip, so the hint names where the gesture actually lands.

Owning host. The status-bar popover renders the merged all-hosts scan, and every
row resolved its host from the *active* workspace. A local `0.0.0.0:7000` listener
sitting next to remote rows was therefore stamped with the remote machine's
address, pointing at whatever that host runs on 7000. The merge already knew the
answer and discarded it into a prefixed row id; it now carries the scan key as a
field, and one hook resolves the host, the address, the reachable URL and whether
the system browser has anywhere to go. Four hand-copied derivations become one
`usePortClientReachability`, which is what keeps display, copy and open from
drifting — the dialog had already been missed once on this branch.

`workspace-port-actions.ts` crossed the 300-line cap, so the click-routing
concern moved to `workspace-port-open-routing.ts` rather than suppressing it.

Tests: adds `workspace-port-actions.test.ts` (the open path, including the plain
click that must stay in Orca), `workspace-port-open-routing.test.ts` (the
modifier and the tooltip), and rendered-row cases in the popover test for the
address a remote row shows and copies and for the local row in the merged view.
Each was confirmed to fail with its production change reverted.

@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: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 66feac15-d324-48e7-b942-060f2bf09d1f

📥 Commits

Reviewing files that changed from the base of the PR and between 60d8855 and 470415b.

📒 Files selected for processing (22)
  • src/main/ports/advertised-url-cache-update.ts
  • src/main/ports/advertised-url-parsing.ts
  • src/renderer/src/components/right-sidebar/PortsPanel.test.tsx
  • src/renderer/src/components/right-sidebar/local-port-details-dialog.tsx
  • src/renderer/src/components/right-sidebar/local-port-row.tsx
  • src/renderer/src/components/right-sidebar/local-workspace-ports-panel.tsx
  • src/renderer/src/components/right-sidebar/ssh-forwarded-port-row.tsx
  • src/renderer/src/components/right-sidebar/ssh-ports-panel.tsx
  • src/renderer/src/components/sidebar/WorktreeCardPorts.tsx
  • src/renderer/src/components/status-bar/ports-status-popover-rows.test.tsx
  • src/renderer/src/components/status-bar/ports-status-popover-rows.tsx
  • src/renderer/src/lib/workspace-port-actions.test.ts
  • src/renderer/src/lib/workspace-port-actions.ts
  • src/renderer/src/lib/workspace-port-client-reachability.test.ts
  • src/renderer/src/lib/workspace-port-client-reachability.ts
  • src/renderer/src/lib/workspace-port-open-routing.test.ts
  • src/renderer/src/lib/workspace-port-open-routing.ts
  • src/renderer/src/lib/workspace-port-urls.test.ts
  • src/renderer/src/lib/workspace-port-urls.ts
  • src/renderer/src/web/web-runtime-environment.ts
  • src/shared/runtime-environments.ts
  • src/shared/workspace-ports.ts
💤 Files with no reviewable changes (1)
  • src/main/ports/advertised-url-parsing.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.

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

✅ No new issues found.

Reviewed changes

This run re-reviews the three commits since the prior pullfrog review at 60d8855 (cc865e3, ff2d7e1, 470415b).

  • Made the system browser an explicit gesture for remote ports — openWorkspacePortInBrowser now takes systemBrowserRequested, so a remote port stays in the embedded browser on a stock plain click and only trades it away when Shift+Cmd/Ctrl is held; local ports are unchanged.
  • Split open routing into workspace-port-open-routing.ts — resolvePortOpenRouting returns { openInOrcaBrowser, systemBrowserRequested } and honors openLinksInAppModifierInverts, with the modifier hint derived from the same resolution.
  • Rewrote client reachability around hostScanKey — workspace-port-client-reachability.ts resolves a row's owning host from the scan key stamped at all-hosts merge time, so a local row in the merged status-bar popover no longer inherits the active remote workspace's address.
  • Hardened clientReachableBrowserUrlForPort — an advertised DNS origin is preserved, a path-bearing pairing endpoint is refused, and an IPv6 endpoint host stays bracketed exactly once.
  • Extracted preferredRuntimeEndpoint as the single endpoint pick behind both getPreferredPairingOffer and the web client's offer.
  • Tests — new exact-assertion coverage for routing, reachability, and URL building (62 passing across the six affected files); oxlint on the changed sources is clean.

I traced the incremental changes end to end: mergeWorkspacePortScans stamps hostScanKey from the real per-host scan keys (never the synthetic all-hosts:all), workspace-port-groups.ts preserves port references so the field survives grouping, and the new plain-click regression is pinned by an exact openUrl-not-called assertion. The prior review's one inline thread and both nitpicks are addressed.

ℹ️ Inverted modifier leaves no system-browser path for remote ports

For a user with openLinksInAppModifierInverts: true and openLinksInApp: false, a remote port has no gesture that reaches the system browser: a plain click routes to the embedded browser (the deliberate remote default) and the modifier resolves to openInOrcaBrowser: true, which is the same embedded route. The tooltip still advertises ⇧⌘+click to open in Orca, so the hint describes a click that changes nothing for these rows. This is a narrow configuration and non-blocking, but it is worth a deliberate answer since the same "hint promises a no-op" class was fixed for loopback-bound remote ports.

Technical details
# No system-browser gesture for remote ports when the modifier is inverted

## Affected sites
- `src/renderer/src/lib/workspace-port-open-routing.ts:99` — modifier + `openLinksInAppModifierInverts` maps to `openInOrcaBrowser: true`; for a remote port that is the same embedded route a plain click already takes.
- `src/renderer/src/lib/workspace-port-actions.ts:98-103` — `systemBrowserUrl` for a remote target is non-null only when `systemBrowserRequested === true`, which that branch never sets.

## Required outcome
- Choose deliberately: either give the inverted-modifier remote row a way to reach the system browser when one is available, or phrase the hint so it does not imply a difference where both clicks land in Orca.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker

Copy link
Copy Markdown
Contributor

Heads up @mmarabel — @nwparker has taken this over and pushed three commits on top of 60d8855. Nothing of yours was rewritten; the design is yours and I kept it. Summary so the diff isn't a surprise:

  1. The default click was moving, not just the modifier. openLinksInApp defaults to false, so openInOrcaBrowser === false is every ordinary click, not only ⇧⌘. On main the runtimeTarget.kind === 'local' conjunct absorbed that; with it removed, a stock-settings plain click on any remote wildcard-bound port left Orca for a URL a firewall or port-scoped ACL can refuse — and shell.openUrl resolves either way, so there was no fallback and no error. resolvePortOpenRouting now reports the modifier separately from the saved setting, and the embedded browser stays the default for remote ports.
  2. An advertised DNS origin is no longer rewritten. https://local.example.com:3001 + a wildcard bind became https://100.64.1.20:3001, which breaks the certificate and any Host-header routing — strictly worse than main whenever the name resolves.
  3. A path-bearing pairing endpoint is refused. parseHostAccessLink allows a path, so wss://gw.example.com/orca/ws yielded a hostname naming the proxy, not the host.
  4. Merged all-hosts rows resolve their own host. The status-bar popover renders the merged scan, and falling back to the active worktree stamped a local 0.0.0.0 listener with the remote machine's address (and pointed its stop button at the wrong host). The scan key is now a field rather than being encoded in the row id and discarded.
  5. One usePortClientReachability hook replaces the four hand-copied clientReachableAddress(useClientReachableUrlForPort(port)) ?? addressForPort(port) derivations — the same drift that made the details dialog need 60d8855.
  6. openLinksInAppModifierInverts is honoured, so the hint this PR set out to make truthful is now truthful for inversion users too.
  7. Tests for all of the above, each verified to fail with its production change reverted — the branch previously had none covering either behaviour change. Also isUnspecifiedHost/isWildcardBindHost deduped, preferredRuntimeEndpoint extracted, and the routing concern split into workspace-port-open-routing.ts because workspace-port-actions.ts crossed the line cap.

The body has been rewritten with fresh before/after captures and an honest Testing section; it now says Part of #21806 rather than Fixes, since Branches B and C are still open. Your two-machine evidence is cited and still stands. Thanks for the original investigation — the bindHost × endpoint join was the right call and it survived unchanged.

A dev server that advertises `http://feature.localhost:5173` was passed
through unchanged as the client-reachable URL for a remote wildcard port.
`*.localhost` resolves to the client's own loopback, so the row offered an
address pointing at whatever this laptop runs on that port - the exact
silently-wrong-server failure the DNS passthrough exists to avoid.

`classifyRemotePairingHostname` already knows the shape; apply it in the
passthrough branch so loopback aliases fall through to host substitution.
`mergeWorkspacePortScans` skipped the `hostScanKey` stamp whenever only one
host had been scanned, so with a remote workspace active and only the local
scan present, every row fell back to the active workspace's host - the
misattribution the scan key was added to prevent, just with one host.

Stamp on both paths. The id prefix stays off the single-host path: one host's
ids are already unique, and prefixing would churn every row key the moment a
second host appears.
Users with "Invert link-routing modifier" on and Link Routing off could never
open a remote port in their own browser: both the plain click and the
modifier resolved to Orca's embedded browser, while the tooltip advertised
"Shift+Ctrl+click to open in Orca" - a gesture that changed nothing.

Root cause was branching the modifier on settings alone. Inverting means "the
other destination", and on a remote port the other destination is never Orca,
because a plain click already lands there whatever Link Routing says. The
resolver now takes where a plain click on *this row* goes, mirroring
resolveChecksPanelHostedReviewModifierDestination, and names the destination
a plain click does not reach - or nothing, when both coincide. That also
retires the hint on a local port with Link Routing off, where the modifier
has always repeated the plain click.

Two smaller items ride along in the same surfaces: the two hint strings are
the shared terminal-link ones ChecksPanel already uses rather than private
copies, and a reachable address keeps the listener's port, which URL.host
dropped on a :80 or :443 listener.
@nwparker

Copy link
Copy Markdown
Contributor

@mmarabel heads up — I (nwparker) took this over and pushed three commits on top of your four. Nothing of yours was rewritten or force-pushed; the design is yours and I kept it, because joining bindHost with the endpoint the client actually dials, in the renderer, with null meaning "do not offer", is the right root fix and needs no wire change.

What I changed, all found in the last review round:

  1. b131ac1 — the modifier could never reach the system browser for users with "Invert link-routing modifier" on. Inverting means "the other destination", and on a remote port the other destination is never Orca: a plain click already lands in the embedded browser whatever Link Routing says. So both clicks resolved to Orca, the headline feature was unreachable for that cohort, and the tooltip advertised ⇧⌘+click to open in Orca — a no-op — even on ports with no reachable address. resolvePortOpenModifierDestination now takes where a plain click on this row goes rather than branching on settings alone, mirroring resolveChecksPanelHostedReviewModifierDestination, and resolvePortOpenRouting routes through the same answer so the gesture always does what the tooltip said. Side effect worth knowing: the hint is now dropped on a local port with Link Routing off, where the modifier has always just repeated the plain click. The two hint strings are now the shared getTerminalUrlSystemBrowserHint / getTerminalUrlOrcaBrowserHint that ChecksPanel already imports, rather than private copies.
  2. a721c41 — a *.localhost advertised origin was passed through as "client-reachable". feature.localhost resolves to the client's own loopback, so ⇧⌘+click opened whatever this laptop runs on that port — the exact silently-wrong-server failure the DNS passthrough exists to avoid. The module already imported the predicate that catches it; it just was not applied in that branch.
  3. 2eca44c — mergeWorkspacePortScans skipped the hostScanKey stamp on its single-entry fast path, so with one host scanned every row fell back to the active workspace's host, which is the misattribution the scan key was added to prevent.

All three of CodeRabbit's inline threads are answered — two fixed as suggested, one (the inversion hint) fixed the opposite way with the reasoning in the thread.

I also rewrote the PR body: the modifier section now describes what the code does, and the Testing section no longer implies coverage that does not exist. New visual proof for the inversion fix is attached. Required CI is approved and running against b131ac1.

Happy to have you keep pushing to the branch — just pull first.

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

✅ No new issues found.

Reviewed changes

This run re-reviews the three commits since the prior pullfrog review at 470415b.

  • Let the system browser stay reachable for a remote port under an inverted modifier — resolvePortOpenModifierDestination now derives the modifier's meaning from where a plain click lands, so a remote port's modifier means the system browser even when openLinksInAppModifierInverts is on, and the routing, hint, and open action move together (mirroring the checks-panel resolver).
  • Refused a *.localhost advertised origin as a remote address — feature.localhost resolves to the client's own loopback, so the URL builder now substitutes the connected address rather than passing the alias through and opening whatever this machine runs on that port.
  • Stamped the owning host on a single-host scan projection — the one-entry fast path in mergeWorkspacePortScans now carries hostScanKey like the multi-host path (still without an id prefix), so a surface whose active workspace lives elsewhere cannot re-attribute a lone host's rows.
  • Kept a default-port listener readable — reachableAddress builds host:port from the listener rather than URL.host, which drops :80/:443. Shared terminal hint helpers moved the platform pin into one injectable place.

I re-ran the seven affected suites (60 tests, all passing) and traced the delta end to end. The prior review's one informational concern — no system-browser gesture for a remote port under an inverted modifier — is addressed with a matching regression test. No open pullfrog threads remain.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

The forwarded-port row still printed "Shift+Ctrl+click for system browser"
unconditionally while the workspace-port rows beside it now resolve the
destination. With stock settings that hint repeats the plain click, and for an
inverting user it names the wrong end.

A forward listens on this machine's loopback, so it is never a remote-host row
and the same resolver answers it; the panel passes the destination down.
@nwparker

Copy link
Copy Markdown
Contributor

Follow-up in ee1eb5f: the SSH forwarded-port row printed ⇧⌘+click for system browser unconditionally while the workspace-port rows beside it now resolve the destination. With stock settings that hint just repeats the plain click; for an inverting user it names the wrong end. A forward listens on this machine's own loopback, so it is never a remote-host row and the same resolver answers it — the panel passes the destination down. Covered by a new ssh-forwarded-port-row.test.tsx; dropping the threading fails two of its three cases.

Full CI was green on b131ac1 (all 8 test shards, typecheck, static analysis, both package jobs). Re-approved and re-running on ee1eb5f.

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

✅ No new issues found.

Reviewed changes

This run re-reviews the single commit since the prior pullfrog review at b131ac1.

  • Threaded the modifier destination into the SSH forwarded-port row — SshPortsPanel resolves resolvePortOpenModifierDestination({ settings }) once and passes it down; a forward listens on this machine's loopback, so it is never a remote-host row and the same resolver answers it. SshForwardedPortRow's tooltip no longer prints ⇧⌘+click for system browser unconditionally.
  • Pinned the three hint outcomes — new ssh-forwarded-port-row.test.tsx asserts no hint under stock settings (where a plain click already opens the system browser), click to open in Orca for an inverting user, and click for system browser once Link Routing routes a plain click into Orca.

The row's click routing was already correct — handleOpenForwardInBrowser runs through resolvePortOpenInOrcaBrowser — so only the stale hint needed fixing, and it now agrees with the click because both derive from the same resolver. I verified the new test is not theatre: dropping { modifierDestination } from the label call fails two of its three cases. Re-ran the row and resolver suites (17 tests, green) and oxlint on the three changed files (0 findings). The one prior pullfrog thread is resolved and no other threads remain.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

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

Approved to run CI. Taken over and reworked by @nwparker; findings addressed and independently re-verified.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants