Repository navigation
fix(ports): route the status-bar popover scan to the workspace's host - #17048
Conversation
- PortsStatusSegment resolved its runtime target from the global active runtime, so opening the popover on a paired-remote workspace scanned the client OS and reported zero workspace ports - Resolve the target from the active worktree's owner host, matching PortsPanel, PortRow, and WorktreeCardPorts - Add publishWorkspacePortScanForHost: store the host's scan under its own key, then republish the aggregate through setWorkspacePortScanProjection so a single-host refresh no longer drops every other host's ports - Publish through the projection setter instead of setWorkspacePortScan, which wrote the synthetic all-hosts key back into workspacePortScansByKey and made the next merge fold the aggregate into itself (duplicate rows) - Reuse the helper for the manual panel refresh and the post-stop refresh, and share the aggregate key constant with WorkspacePortScanner
- PortsStatusSegment.host-routing: popover scans the active workspace's owner host, keeps other hosts in the projection, publishes a failed scan under its own host, and stays local when the workspace has no owner - workspace-port-scan-publish: single-host key vs all-hosts projection, and repeated publishes never accumulate duplicate rows
- The merged projection only carries unavailableReason when every host failed, so one unreachable server read as "this workspace has no ports" - Add getUnavailableWorkspacePortHosts: hosts that failed while another host still answered, with the local host distinguished by a null environment id - Show one notice per failed host in the popover, named by its runtime environment or the local host label, above the surviving hosts' ports - Reuse the existing scan-unavailable string so no catalog entry is added
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughWorkspace port scans now publish per-host results and a merged all-hosts projection through a shared helper. The status bar selects the active worktree runtime target, preserves ports from other hosts, and displays partial host failures with resolved labels. Port panels, worktree cards, popover rows, and the workspace scanner use the unified replacement callback. Tests cover keyed publication, projection preservation, host routing, failure reporting, and post-stop refresh behavior. Merge Risk: 🟡 Moderate · up to In multi-host workspaces, opening a displayed non-workspace port can target the active worktree’s host instead of the host that reported it. Preserve source-host routing before merge. 🚥 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 |
- Make the mocked store setters write back, so a publish and the notice that reads it can no longer name different scan keys with every assertion green - Cover open popover -> remote scan rejects -> notice names the host, the seam the store-write and render-only tests each stopped short of - Drop an assertion comment that claimed to prove port preservation when it only exercised the render path
Greptile SummaryThe PR routes status-bar port scans to the active workspace’s owning host and preserves the cross-host projection when publishing manual scan results.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| src/renderer/src/lib/workspace-port-actions.ts | Adds centralized per-host publication and recomputes the shared projection without persisting the synthetic aggregate as a host. |
| src/renderer/src/components/status-bar/PortsStatusSegment.tsx | Resolves scans through the active worktree’s owner and displays partial host-unavailability notices. |
| src/renderer/src/lib/workspace-port-host-availability.ts | Extracts failed hosts from a partially successful multi-host scan map. |
| src/renderer/src/components/right-sidebar/local-workspace-ports-panel.tsx | Migrates panel refresh and post-stop publication to the shared aggregate-preserving path. |
| src/renderer/src/components/ports/WorkspacePortScanner.tsx | Replaces the aggregate scan-key literal with the shared constant while preserving scanner behavior. |
Sequence Diagram
sequenceDiagram
participant U as User
participant P as Ports UI
participant H as Workspace owner host
participant S as Per-host scan store
participant A as Aggregate projection
U->>P: Open popover or refresh
P->>P: Resolve active worktree owner
P->>H: Scan workspace ports
H-->>P: Host scan result
P->>S: Update owning host slot
P->>S: Read all host slots
S-->>P: Current host scans
P->>A: Publish merged projection
Reviews (2): Last reviewed commit: "Merge branch 'main' of https://github.co..." | Re-trigger Greptile
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
… failure port retention, docstrings
…failed host - A failed scan retains the host's last-good ports, and the badge/header count them; the notice now sits above the list instead of replacing it, so the popover no longer claims N ports over an empty body. - getUnavailableWorkspacePortHosts reports all-hosts-failed too, so total loss of contact names each host instead of printing raw scan keys under platform 'unknown'. - Scan keys parse to a discriminated host ref, so an unrecognised key is 'unknown' rather than silently blamed on the local machine. - Extract useWorktreeRuntimeTarget for the four ports surfaces that hand-rolled the same owner-settings spread.
… the renderer's userAgent A paired web client's browser is not the Orca host, so deriving 'Local Mac' from navigator.userAgent mislabels a Linux host. Carry each failed scan's own platform through the unavailable-host list instead.
The retained-ports change gave a failed scan both ports and an unavailableReason, and the right-sidebar panel hid every section behind the notice — stripping the stop and open actions for ports the status bar still counts. Gate the sections on whether anything is left to list, matching the popover, behind a testable predicate.
The popover publishes the host's last-good ports alongside the failure reason the moment its own scan fails. reconcileTransientPortScanFailures treated any published result carrying unavailableReason as a spent grace period, so the very next background poll replaced those ports with an empty unavailable scan — the retention never survived one poll interval. Keep the grace while the published result still has ports; the tolerance still clears them on schedule.
A manual publish (the ports popover) can resolve after the host-set change already pruned its key, re-adding it; the poll's per-key writes only ever added, so a removed host kept its ports in the count and held a permanent unavailable notice until the next host-set change. Publish the poll's already-pruned map in one replaceWorkspacePortScans instead, which also collapses N per-host notifications into one and drops any synthetic all-hosts key that leaked in.
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/renderer/src/lib/workspace-port-actions.ts (1)
24-25: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winLocalize the unavailable-host reason.
When
runtimeTargetisnull, the workspace-port actions returnWORKSPACE_PORT_TARGET_UNAVAILABLE_REASON.PortRowandLocalWorkspacePortsPanelpass it directly totoast.erroror toastdescription, so users see hard-coded English. Translate this reason at both display boundaries withtranslate().
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 6e5a2c91-8df5-4dd0-b864-ee2df7b9013c
📒 Files selected for processing (22)
src/renderer/src/components/ports/WorkspacePortScanner.test.tsxsrc/renderer/src/components/ports/WorkspacePortScanner.tsxsrc/renderer/src/components/right-sidebar/PortsPanel.test.tsxsrc/renderer/src/components/right-sidebar/local-workspace-port-sections.test.tssrc/renderer/src/components/right-sidebar/local-workspace-port-sections.tssrc/renderer/src/components/right-sidebar/local-workspace-ports-panel.tsxsrc/renderer/src/components/sidebar/WorktreeCard.compact-hover.test.tsxsrc/renderer/src/components/sidebar/WorktreeCard.compact-ports-hover-independence.test.tsxsrc/renderer/src/components/sidebar/WorktreeCardPorts.test.tsxsrc/renderer/src/components/sidebar/WorktreeCardPorts.tsxsrc/renderer/src/components/status-bar/PortsStatusSegment.host-routing.test.tsxsrc/renderer/src/components/status-bar/PortsStatusSegment.tsxsrc/renderer/src/components/status-bar/ports-status-popover-rows.test.tsxsrc/renderer/src/components/status-bar/ports-status-popover-rows.tsxsrc/renderer/src/lib/workspace-port-actions.tssrc/renderer/src/lib/workspace-port-host-availability.test.tssrc/renderer/src/lib/workspace-port-host-availability.tssrc/renderer/src/lib/workspace-port-scan-debounce.test.tssrc/renderer/src/lib/workspace-port-scan-debounce.tssrc/renderer/src/lib/workspace-port-scan-publish.test.tssrc/renderer/src/runtime/runtime-client-target.tssrc/renderer/src/runtime/use-worktree-runtime-target.ts
🚧 Files skipped from review as they are similar to previous changes (7)
- src/renderer/src/components/sidebar/WorktreeCardPorts.test.tsx
- src/renderer/src/components/sidebar/WorktreeCard.compact-ports-hover-independence.test.tsx
- src/renderer/src/components/status-bar/ports-status-popover-rows.test.tsx
- src/renderer/src/lib/workspace-port-scan-publish.test.ts
- src/renderer/src/components/right-sidebar/PortsPanel.test.tsx
- src/renderer/src/components/sidebar/WorktreeCard.compact-hover.test.tsx
- src/renderer/src/components/status-bar/PortsStatusSegment.tsx
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| () => getActiveRuntimeTarget({ ...settings, activeRuntimeEnvironmentId: runtimeEnvironmentId }), | ||
| [runtimeEnvironmentId, settings] | ||
| const runtimeTarget = useWorktreeRuntimeTarget( | ||
| port.kind === 'workspace' ? port.owner.worktreeId : activeWorktreeId |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect whether merged scans retain non-workspace ports from multiple hosts.
rg -n -C 12 'mergeWorkspacePortScans|getExternalWorkspacePorts|kind: .external.|kind: .container.' \
src/renderer/src/lib/workspace-port-actions.ts src/shared/workspace-ports.ts
# Inspect whether opening a non-workspace port consumes runtimeTarget.
rg -n -C 12 'function openWorkspacePortInBrowser|runtimeTarget' \
src/renderer/src/lib/workspace-port-actions.tsRepository: stablyai/orca
Length of output: 12645
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- merge implementation ---'
sed -n '250,315p' src/renderer/src/lib/workspace-port-actions.ts
printf '%s\n' '--- port types and scan result ---'
sed -n '1,90p' src/shared/workspace-ports.ts
printf '%s\n' '--- status-row call site ---'
sed -n '1,145p' src/renderer/src/components/status-bar/ports-status-popover-rows.tsx
printf '%s\n' '--- browser action callers ---'
rg -n -C 8 'openWorkspacePortInBrowser\(' src/renderer/srcRepository: stablyai/orca
Length of output: 25542
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- all-host scan consumption ---'
rg -n -C 10 'WORKSPACE_PORT_ALL_HOSTS_SCAN_KEY|all-host|all hosts|PortRow\(' \
src/renderer/src/components src/renderer/src/lib/workspace-port-actions.ts
printf '%s\n' '--- runtime target resolution ---'
rg -n -C 12 'function useWorktreeRuntimeTarget|export .*useWorktreeRuntimeTarget|useWorktreeRuntimeTarget' \
src/renderer/src/runtime src/renderer/srcRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- status popover caller ---'
rg -n -C 14 '<PortRow|PortRow\(' src/renderer/src/components/status-bar/PortsStatusSegment.tsx src/renderer/src/components/status-bar
printf '%s\n' '--- target hook implementation ---'
fd -i 'use-worktree-runtime-target' src/renderer/src/runtime src/renderer/src
for f in $(fd -i 'use-worktree-runtime-target' src/renderer/src/runtime src/renderer/src); do
sed -n '1,180p' "$f"
doneRepository: stablyai/orca
Length of output: 20769
Preserve the source host for aggregate non-workspace ports.
mergeWorkspacePortScans combines ports from multiple host scan keys but stores no source target. The status-bar row resolves a non-workspace port through activeWorktreeId, so openWorkspacePortInBrowser can use the wrong host. Carry the source target into aggregate ports, or disable target-dependent actions until it is known.
Le build 6feef25 a livré une barre d'état vide et quatre crashs par seconde (React stablyai#185, upstream stablyai#17048 : un sélecteur Zustand qui alloue son snapshot). Le job test ne pouvait pas le voir : vitest ciblé sur deux arbres du main process, et les tests renderer amont mockent le store. Le spec vit sur cette branche, copié dans tests/e2e/ au vol, pour garder ce que le canal livre quelles que soient les branches patch et perso. Il lit crash-reports.json dans le userData du run, le même fichier qu'en prod, donc un boundary parti avant que Playwright s'attache compte aussi. Prouvé en local : rouge sur 6feef25 (overlay.status-bar: React stablyai#185), vert sur c6e518b.
…stablyai#17048) * fix(ports): route the status-bar popover scan to the workspace's host - PortsStatusSegment resolved its runtime target from the global active runtime, so opening the popover on a paired-remote workspace scanned the client OS and reported zero workspace ports - Resolve the target from the active worktree's owner host, matching PortsPanel, PortRow, and WorktreeCardPorts - Add publishWorkspacePortScanForHost: store the host's scan under its own key, then republish the aggregate through setWorkspacePortScanProjection so a single-host refresh no longer drops every other host's ports - Publish through the projection setter instead of setWorkspacePortScan, which wrote the synthetic all-hosts key back into workspacePortScansByKey and made the next merge fold the aggregate into itself (duplicate rows) - Reuse the helper for the manual panel refresh and the post-stop refresh, and share the aggregate key constant with WorkspacePortScanner * test(ports): cover popover host routing and aggregate preservation - PortsStatusSegment.host-routing: popover scans the active workspace's owner host, keeps other hosts in the projection, publishes a failed scan under its own host, and stays local when the workspace has no owner - workspace-port-scan-publish: single-host key vs all-hosts projection, and repeated publishes never accumulate duplicate rows * fix(ports): surface a host whose port scan failed instead of dropping it - The merged projection only carries unavailableReason when every host failed, so one unreachable server read as "this workspace has no ports" - Add getUnavailableWorkspacePortHosts: hosts that failed while another host still answered, with the local host distinguished by a null environment id - Show one notice per failed host in the popover, named by its runtime environment or the local host label, above the surviving hosts' ports - Reuse the existing scan-unavailable string so no catalog entry is added * test(ports): prove the popover's own failed scan reaches the host notice - Make the mocked store setters write back, so a publish and the notice that reads it can no longer name different scan keys with every assertion green - Cover open popover -> remote scan rejects -> notice names the host, the seam the store-write and render-only tests each stopped short of - Drop an assertion comment that claimed to prove port preservation when it only exercised the render path * fix(ports): review nits — single-write publish, colon-safe host keys, failure port retention, docstrings * fix(ports): keep the popover count and body in agreement, name every failed host - A failed scan retains the host's last-good ports, and the badge/header count them; the notice now sits above the list instead of replacing it, so the popover no longer claims N ports over an empty body. - getUnavailableWorkspacePortHosts reports all-hosts-failed too, so total loss of contact names each host instead of printing raw scan keys under platform 'unknown'. - Scan keys parse to a discriminated host ref, so an unrecognised key is 'unknown' rather than silently blamed on the local machine. - Extract useWorktreeRuntimeTarget for the four ports surfaces that hand-rolled the same owner-settings spread. * fix(ports): label the local host from the failed scan's platform, not the renderer's userAgent A paired web client's browser is not the Orca host, so deriving 'Local Mac' from navigator.userAgent mislabels a Linux host. Carry each failed scan's own platform through the unavailable-host list instead. * fix(ports): keep the Ports panel list under its failure notice too The retained-ports change gave a failed scan both ports and an unavailableReason, and the right-sidebar panel hid every section behind the notice — stripping the stop and open actions for ports the status bar still counts. Gate the sections on whether anything is left to list, matching the popover, behind a testable predicate. * fix(ports): let a retained-port failure keep its debounce grace period The popover publishes the host's last-good ports alongside the failure reason the moment its own scan fails. reconcileTransientPortScanFailures treated any published result carrying unavailableReason as a spent grace period, so the very next background poll replaced those ports with an empty unavailable scan — the retention never survived one poll interval. Keep the grace while the published result still has ports; the tolerance still clears them on schedule. * fix(ports): prune stale hosts in the poll's single map write A manual publish (the ports popover) can resolve after the host-set change already pruned its key, re-adding it; the poll's per-key writes only ever added, so a removed host kept its ports in the count and held a permanent unavailable notice until the next host-set change. Publish the poll's already-pruned map in one replaceWorkspacePortScans instead, which also collapses N per-host notifications into one and drops any synthetic all-hosts key that leaked in. * fix(ports): fail closed for direct SSH workspaces --------- Co-authored-by: Neil <[email protected]>
ELI5
Orca's status bar has a plug icon that counts the dev servers you have running. A background poll
keeps that number fresh by asking every machine you use — your own computer and each paired remote
Orca server — and adding up the answers.
Clicking the icon triggers an immediate re-scan, and that is where it went wrong. It asked "which
machine is globally selected?" instead of "which machine owns the workspace I am looking at?". For a
workspace hosted on a remote server, it scanned your laptop instead, found none of those ports, and
reported zero. Worse, that single machine's answer overwrote the combined total, so ports from every
other machine disappeared too, until the next background poll rebuilt it 30 seconds later.
This PR makes the click ask the right machine, and makes every manual re-scan update only that
machine's slot and then recompute the total from all slots, instead of replacing the total outright.
It also surfaces a host whose scan failed, so an unreachable server no longer reads as "this
workspace has no ports".
What Changed
1. The popover scan targets the active workspace's owner host
PortsStatusSegmentresolved its runtime target from the globalsettings.activeRuntimeEnvironmentIdalone. It now resolves the owner host first, via
getRuntimeEnvironmentIdForWorktree(state, activeWorktreeId), matching the three call sites thatalready did this:
PortsPanel.tsx:178-185,ports-status-popover-rows.tsx:82-95, andWorktreeCardPorts.tsx:104-114.2. New
publishWorkspacePortScanForHost()— a single host's scan no longer replaces the aggregateIt writes the result to that host's slot with
setWorkspacePortScanForKey, then recomputes the mergedview from all of
workspacePortScansByKeyand publishes it withsetWorkspacePortScanProjection.Using the projection setter is the point:
setWorkspacePortScanalso writes its payload back intoworkspacePortScansByKey, so publishing the aggregate underall-hosts:allstored the aggregate asif it were a host. The next merge then folded the aggregate into itself and rows multiplied.
WorkspacePortScanner's background poll already used the projection setter; this brings the manualpaths in line with it.
3. Four call sites now share that one function
Opening the status-bar popover, the Ports panel's manual refresh, Stop Process in the popover, and
Stop Process on a sidebar card (the last two through
refreshWorkspacePortScanAfterStop, whoseprivate
publishScanis removed).4. A host whose scan failed is now named instead of silently dropped
The merged result only carries
unavailableReasonwhen every host failed, so with several hoststracked, one unreachable server read as "this workspace has no ports". New
getUnavailableWorkspacePortHosts()returns the hosts that failed while another host still answered,and the popover renders one line per failed host under its header, named by its runtime environment
or by the local host label.
No new i18n strings: this reuses the existing
auto.components.status.bar.PortsStatusSegment.95495019ed(
Port scan unavailable on {{value0}}: {{value1}}).Why
Fixes #17046. With a client paired to a remote runtime (
orca serve), the status bar counted theremote workspace's ports correctly, but opening the popover cleared it to
No workspace ports detected, and closing it restored the count 3–5 seconds later. Two independent faults were needed toproduce that:
{ kind: 'local' }, so it went throughwindow.api.workspacePorts.scan()to the client machine instead ofcallRuntimeRpc(target, 'workspacePorts.scan')to the server that owns the workspace — the fork isat
workspace-port-scan-client.ts:86-103. The client has none of those listeners.setWorkspacePortScan, whichreplaced the cross-host projection the status bar and popover read, so other hosts' ports vanished
until the next background poll (
WorkspacePortScanner.tsx:146-160).The invariant after this change: a single-host re-scan only updates that host's slot, and the
projection is always recomputed from every slot — the same rule the background poll follows.
One more thing this removes:
refreshWorkspacePortScanAfterStopgated its aggregate onObject.keys(currentScans).length > 0, but readcurrentScansafter writing its own entry, so asingle tracked host always looked like several.
Linked Issue
Fixes #17046
Visual Proof
|
2026-08-29.3.08.47_.17.mov
|
2026-08-29.3.21.02.mov
|
Testing
Automated (3 new files, 14 cases):
PortsStatusSegment.host-routing.test.tsx— the popover scans the active workspace's owner host andnot the globally focused runtime; other hosts survive in the projection; a failed scan is stored
under its own host; a workspace with no owner still resolves to local; a failed host is named while
the surviving host's ports keep rendering.
workspace-port-scan-publish.test.ts— single host publishes under its own key, several hostspublish
all-hosts:all, and repeated publishes never accumulate duplicate rows.workspace-port-host-availability.test.ts— partial failure, total failure, single-host failure,and no failure.
Local verification:
pnpm typecheck— passpnpm testfor the ports / status-bar / right-sidebar / sidebar suites — pass (51 files, 353 tests)pnpm exec oxlinton the changed files — cleanpnpm build:unpackon Linux — passManual:
macOS client paired to a Linux
orca servehost — opened a remote workspace, started a devserver on the remote host, opened the popover: the count no longer collapses and the remote ports
stay listed.
Linux, local-only workspace (single host) — no regression; the count holds and rows render.
Windows — not tested. The change is renderer-only with no path handling, no shortcut handling,
and no platform branches; the host label reuses the existing
getLocalExecutionHostLabel().I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Claude Opus 5 via Claude Code: root-cause investigation, implementation, tests, and driving the manual paired-runtime verification. Reviewed by me before every commit.
Test quality was verified by mutation, not by inspection — each fix was reverted in isolation to confirm the suite fails: popover host routing (3 tests), single-host projection overwrite (5 tests across 3 files), the
> 1projection-key threshold (3 tests), the all-hosts-failed guard (2 tests), and the unavailable-host notice (1 test each for rendering and host naming). No mutation survived.Review
Agent review summary:
metaKey/shortcut logic, no platformbranches. The local host label goes through the existing
getLocalExecutionHostLabel(), whichalready returns Local Mac / Local Windows / Local Linux.
owns the workspace, and losing contact with a host is reported as an unavailable scan for that host
rather than as an empty port list, which is the distinction
docs/reference/ssh-execution-boundary.mdasks for.only which existing method the client calls.
workspacePortScansByKey,runtimeEnvironments) andone
useMemo; the failed-host list is O(hosts) over a single-digit set. Scan frequency is unchangedand the popover's re-scan still shares
scanWorkspacePortsForTarget's in-flight de-duplication.text-muted-foreground,text-[11px],border-border/40) and an existing string; no new color or size tier, and long reasons truncate.path.
Agent skill upstream boundary
Notes
poll result, up to 30s old.
WorkspacePortScanner.tsx:54still derives itsactiveScanfrom the global runtime. Harmlesstoday because more than one host projects
all-hosts:all, but it is a different rule from theowner-host one this PR establishes.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm testpass locally;pnpm buildverified viapnpm build:unpackon Linux