Skip to content

fix(ports): route the status-bar popover scan to the workspace's host - #17048

Merged
nwparker merged 14 commits into
stablyai:mainfrom
iverJisty:fix/ports-popover-runtime-host
Sep 4, 2026
Merged

nwparker merged 14 commits into
stablyai:mainfrom
iverJisty:fix/ports-popover-runtime-host

Conversation

@iverJisty

@iverJisty iverJisty commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

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

PortsStatusSegment resolved its runtime target from the global settings.activeRuntimeEnvironmentId
alone. It now resolves the owner host first, via
getRuntimeEnvironmentIdForWorktree(state, activeWorktreeId), matching the three call sites that
already did this: PortsPanel.tsx:178-185, ports-status-popover-rows.tsx:82-95, and
WorktreeCardPorts.tsx:104-114.

2. New publishWorkspacePortScanForHost() — a single host's scan no longer replaces the aggregate

It writes the result to that host's slot with setWorkspacePortScanForKey, then recomputes the merged
view from all of workspacePortScansByKey and publishes it with setWorkspacePortScanProjection.

Using the projection setter is the point: setWorkspacePortScan also writes its payload back into
workspacePortScansByKey, so publishing the aggregate under all-hosts:all stored the aggregate as
if 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 manual
paths 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, whose
private publishScan is removed).

4. A host whose scan failed is now named instead of silently dropped

The merged result only carries unavailableReason when every host failed, so with several hosts
tracked, 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 the
remote 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 to
produce that:

  1. Wrong host. The popover's re-scan resolved to { kind: 'local' }, so it went through
    window.api.workspacePorts.scan() to the client machine instead of
    callRuntimeRpc(target, 'workspacePorts.scan') to the server that owns the workspace — the fork is
    at workspace-port-scan-client.ts:86-103. The client has none of those listeners.
  2. Overwritten aggregate. That single-host result was published with setWorkspacePortScan, which
    replaced 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: refreshWorkspacePortScanAfterStop gated its aggregate on
Object.keys(currentScans).length > 0, but read currentScans after writing its own entry, so a
single tracked host always looked like several.

Linked Issue

Fixes #17046

Visual Proof

Before After

|

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 and
    not 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 hosts
    publish 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 — pass
  • pnpm test for the ports / status-bar / right-sidebar / sidebar suites — pass (51 files, 353 tests)
  • pnpm exec oxlint on the changed files — clean
  • pnpm build:unpack on Linux — pass

Manual:

  • macOS client paired to a Linux orca serve host — opened a remote workspace, started a dev
    server 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 > 1 projection-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:

  • Cross-platform — renderer-only. No path joining, no metaKey/shortcut logic, no platform
    branches. The local host label goes through the existing getLocalExecutionHostLabel(), which
    already returns Local Mac / Local Windows / Local Linux.
  • SSH / remote / local — this is the boundary the PR is about. Scans now always go to the host that
    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.md asks for.
  • Remote wire compatibility — no RPC params, stream opcodes, or host-published content changed;
    only which existing method the client calls.
  • Agent / integration / git provider — not touched.
  • Performance — two extra store selectors (workspacePortScansByKey, runtimeEnvironments) and
    one useMemo; the failed-host list is O(hosts) over a single-digit set. Scan frequency is unchanged
    and the popover's re-scan still shares scanWorkspacePortsForTarget's in-flight de-duplication.
  • UI quality — the notice reuses existing tokens (text-muted-foreground, text-[11px],
    border-border/40) and an existing string; no new color or size tier, and long reasons truncate.
  • Security — no credentials read or rendered; the reason text comes from the existing scan error
    path.

Agent skill upstream boundary

  • Not applicable.

Notes

  • Deliberately left out to keep this focused, happy to file follow-ups:
    1. The popover's re-scan refreshes only the active workspace's host; other hosts keep their last
      poll result, up to 30s old.
    2. WorkspacePortScanner.tsx:54 still derives its activeScan from the global runtime. Harmless
      today because more than one host projects all-hosts:all, but it is a different rule from the
      owner-host one this PR establishes.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • 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
  • pnpm lint, pnpm typecheck, pnpm test pass locally; pnpm build verified via
    pnpm build:unpack on Linux

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

coderabbitai Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

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
📝 Walkthrough

Walkthrough

Workspace 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 f5299

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.89% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 36 functions across 23 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary fix: routing status-bar popover scans to the workspace owner host.
Description check ✅ Passed The description follows the repository template and includes the change, rationale, linked issue, visual proof, testing, AI disclosure, review notes, scope considerations, and checklist.
Linked Issues check ✅ Passed The changes satisfy issue [#17046] by routing scans to the workspace owner host, preserving the multi-host aggregate, preventing duplicate rows, and reporting failed hosts while retaining successful r…
Out of Scope Changes check ✅ Passed The implementation and tests remain focused on workspace port scan routing, aggregate publishing, host availability reporting, and the affected UI call sites. No unrelated code changes are evident.
  • 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.

@iverJisty iverJisty changed the title Fix/ports popover runtime host fix(ports): route the status-bar popover scan to the workspace's host Aug 28, 2026
- 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-apps

greptile-apps Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Greptile Summary

The PR routes status-bar port scans to the active workspace’s owning host and preserves the cross-host projection when publishing manual scan results.

  • Introduces a shared per-host scan publication helper that rebuilds the aggregate without storing it as a host scan.
  • Uses workspace ownership when selecting the popover’s runtime target.
  • Reports partial host scan failures while retaining results from reachable hosts.
  • Updates panel and stop-process refresh paths to use the same publication invariant.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

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
Loading

Reviews (2): Last reviewed commit: "Merge branch 'main' of https://github.co..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

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.

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

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/renderer/src/lib/workspace-port-actions.ts (1)

24-25: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Localize the unavailable-host reason.

When runtimeTarget is null, the workspace-port actions return WORKSPACE_PORT_TARGET_UNAVAILABLE_REASON. PortRow and LocalWorkspacePortsPanel pass it directly to toast.error or toast description, so users see hard-coded English. Translate this reason at both display boundaries with translate().


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 6e5a2c91-8df5-4dd0-b864-ee2df7b9013c

📥 Commits

Reviewing files that changed from the base of the PR and between 8854b5d and f5299ae.

📒 Files selected for processing (22)
  • src/renderer/src/components/ports/WorkspacePortScanner.test.tsx
  • src/renderer/src/components/ports/WorkspacePortScanner.tsx
  • src/renderer/src/components/right-sidebar/PortsPanel.test.tsx
  • src/renderer/src/components/right-sidebar/local-workspace-port-sections.test.ts
  • src/renderer/src/components/right-sidebar/local-workspace-port-sections.ts
  • src/renderer/src/components/right-sidebar/local-workspace-ports-panel.tsx
  • src/renderer/src/components/sidebar/WorktreeCard.compact-hover.test.tsx
  • src/renderer/src/components/sidebar/WorktreeCard.compact-ports-hover-independence.test.tsx
  • src/renderer/src/components/sidebar/WorktreeCardPorts.test.tsx
  • src/renderer/src/components/sidebar/WorktreeCardPorts.tsx
  • src/renderer/src/components/status-bar/PortsStatusSegment.host-routing.test.tsx
  • src/renderer/src/components/status-bar/PortsStatusSegment.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.ts
  • src/renderer/src/lib/workspace-port-host-availability.test.ts
  • src/renderer/src/lib/workspace-port-host-availability.ts
  • src/renderer/src/lib/workspace-port-scan-debounce.test.ts
  • src/renderer/src/lib/workspace-port-scan-debounce.ts
  • src/renderer/src/lib/workspace-port-scan-publish.test.ts
  • src/renderer/src/runtime/runtime-client-target.ts
  • src/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

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.

🎯 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.ts

Repository: 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/src

Repository: 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/src

Repository: 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"
done

Repository: 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.

@nwparker
nwparker merged commit 7574ee8 into stablyai:main Sep 4, 2026
27 checks passed
flosrn added a commit to flosrn/orca that referenced this pull request Sep 4, 2026
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.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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]>
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.

[Bug]: Opening the Ports status-bar popover clears remote workspace ports on a paired runtime

2 participants