Skip to content

fix(runtime): stop one unreachable relay from freezing every workspace as active (STA-517) - #14649

Merged
brennanb2025 merged 3 commits into
mainfrom
brennanb2025/mobile-ssh-active-517
Aug 18, 2026
Merged

brennanb2025 merged 3 commits into
mainfrom
brennanb2025/mobile-ssh-active-517

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​379 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​369
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​53 $\color{#cf222e}{\Huge{\mathbf{−}}}$​28 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​25

ELI5

Your phone asks the desktop "which workspaces are busy?". To answer, the desktop counts the terminals that are still alive — and that count is the only thing that can ever mark a forgotten terminal as dead. It asks every machine and waits.

If one SSH machine goes silent — not refusing, just never answering — the desktop waits on it far longer than it is willing to wait for the whole answer, so it throws the entire count away, including the machines that did reply. Nothing gets marked dead, and those workspaces stay lit up as active.

This PR gives each machine its own time limit, strictly inside the overall one. A silent machine now gives up early, and the answer still comes back with everyone else's terminals in it.

What Changed

Scope note (post-rebase): main's #14977 already made each provider settle independently — a relay that rejects is caught, dropped from both processes and hostIds, and recorded as unverifiable. This PR now contributes only the missing deadline, which is the half that covers the actual failure: a relay that goes silent never rejects, so it never reaches #14977's catch. Earlier revisions of this PR also introduced the settle; that part is now main's, and the resolution here deliberately keeps main's try/catch (and its markSshInventoryUnverifiable call) rather than replacing it with a .catch(...) that would have silently dropped the verdict.

The deadline does not merely coexist with #14977 — it closes a hole in it. #14977's verdict machinery hangs off the catch: a relay that fails to list is supposed to be recorded unverifiable so nothing downstream mistakes lost contact for a confirmed exit. But a silent relay never throws, so before this change that branch was simply never reached for the silent case — the aggregate died on the runtime's own timeout first and the verdict was never recorded at all. With the deadline forwarded, a silent relay now rejects at the deadline, falls into main's catch, fires onSshInventoryUnavailable, and lands the unverifiable verdict that #14977 intended. The two changes compose: one supplies the branch, the other makes it reachable.

src/main/ipc/pty.ts — the aggregate PTY inventory:

async function listRegisteredPtyProcessesWithHostScope(
  onSshInventoryUnavailable?: (connectionId: string, error: unknown) => void,
  opts?: { deadlineMs?: number }   // ← added
)
…
  // Why: the deadline only applies to relay round-trips; the local provider answers in-process.
  processes: await (connectionId ? provider.listProcesses(opts) : provider.listProcesses()),

The deadline is threaded through all three entry points: the aggregate, the targeted single-connection path (listProcesses(connectionId, opts)), and listProcessesWithHostScope(opts). The local provider is deliberately not given a deadline — it answers in-process, and a local failure still fails the aggregate.

src/main/runtime/orca-runtime.ts:

  • refreshPtyWorktreeRecordsWithControllerInventory computes its list budget once and passes a deadline strictly inside it (PTY_CONTROLLER_LIST_PROVIDER_MARGIN_MS = 500), so a relay that gives up still leaves the aggregate time to return the providers that answered;
  • RuntimePtyController.listProcesses / listProcessesWithHostScope gain the optional opts to carry it (main-process internal type; not a wire contract);
  • the restored-orchestration-authority sweep moved to after the hasPty rescue, so a pane the controller still vouches for keeps its handle.

Why

worktree.ps is mobile's only status source, and its liveness refresh is the only code path that can flip a retained PTY to connected = false.

SshPtyProvider.listProcesses falls through to the mux's own REQUEST_TIMEOUT_MS = 30_000, while the runtime wraps the whole aggregate in PTY_CONTROLLER_LIST_TIMEOUT_MS = 3_000. A registered-but-unresponsive relay therefore blows the budget every single time — and #14977's per-provider try/catch does not help, because a silent relay never throws. Promise.all simply does not settle inside 3s, withTimeoutResult fires, and refreshPtyWorktreeRecordsWithControllerInventory returns null before the sweep that marks PTYs disconnected. The entire inventory is lost, local included.

Which panes actually get stuck — corrected. An earlier revision of this description implied that local panes stay "active" after their processes exit. That is not accurate, and live testing falsified it. Orca has two independent retirement paths:

  1. The PTY exit event — a shell that exits under observation is retired immediately and never consults the inventory.
  2. The inventory sweep — the only path that can retire a pane whose death was never observed.

So the stuck-active symptom applies to panes that must be proven dead by the listing: records restored from persistence after an app restart, and retained/unconfirmed records generally. A pane that exits while the app is watching retires normally even with the inventory broken. The user-visible bug is real; this is the accurate statement of its scope.

A provider that does not answer is unknown, not empty. Its panes are not retired: the existing hasPty rescue re-adds them (SshPtyProvider.livePtyIds is cleared only on dispose()), and it drops out of hostIds so the listing never claims coverage it lacks. When the connection is genuinely lost, teardownProviders('connection_lost') disposes and unregisters the provider, hasPty returns null, and the workspace correctly goes inactive. That self-healing path is what the failed aggregate was preventing.

Linked Issue

Fixes STA-517 — https://linear.app/stably/issue/STA-517/fix-incorrect-active-status-display-for-ssh-work-trees-on-mobile

Visual Proof

N/A for screenshots — no UI change; this is a host-side correctness fix to the values worktree.ps publishes, and mobile's rendering code is untouched. The proof is a measured before/after against a real SSH relay, below.

Testing

  • I manually tested these changes locally

Live rig

A throwaway ubuntu:22.04 Docker container as the SSH target (key-only root login, node 22.14.0, build-essential + python3 — required or node-pty will not build on the remote and remote PTYs never come up — and a real git repo at /work/demo-project). The client was this worktree running as an isolated Electron dev instance (own ORCA_DEV_USER_DATA_PATH, own CDP port, getIdentity() re-verified before every interaction batch, repos.list() returning [] on first attach confirming a genuinely fresh profile), connected through the real ssh.connect path with the real relay deployed and running on the container (detached daemon + --connect bridge both verified by PID inside the container).

4 real PTYs, 2 per host: 2 local (darwin) and 2 remote (ssh:…@@pty-1/2, real /bin/bash on pts/0 inside the container, titles resolving to root@c4a120d1207b: /work/demo-project).

Unreachability = docker pause. This is the important detail: the TCP socket stays open and nothing ever answers. That is the actual failure mode — killing the container or blackholing the port produces a clean error instead, which exercises #14977's branch rather than this one. The mux confirmed it: [ssh-mux] Protocol error: Connection timed out (no ack received).

Each arm's running bundle was verified to be the code under test, not assumed: PTY_CONTROLLER_LIST_PROVIDER_MARGIN_MS occurs 2× in out/main/index.js with the fix and 0× without it.

Result

Baseline, relay healthy — hostIds: ["local","ssh:…"], omittedHostIds: [], both workspaces active:true live:2.

With the relay hung:

pre-fix post-fix
terminal.list latency 3004 ms (hit the 3s ceiling, returned nothing) 5395 ms (returned)
hostScope.hostIds [] — whole inventory lost, local included ["local"]
hostScope.omittedHostIds ["local","ssh:…"] ["ssh:…"]
local panes never reconciled retired (active:false live:0)
remote panes — retained, active:true live:2 (UNKNOWN, not empty)

Pre-fix rows, verbatim:

{"arm":"PREFIX","tag":"BEFORE-pause","listMs":14,  "covered":["local","ssh:…"],"notCovered":[],           "localTerms":2,"sshTerms":2}
# PAUSED
{"arm":"PREFIX","tag":"T1","listMs":3004,"covered":[],"notCovered":["local","ssh:…"],"sshTerms":2}
{"arm":"PREFIX","tag":"T2","listMs":3004,"covered":[],"notCovered":["local","ssh:…"],"sshTerms":2}

Corroborated in the same run by terminal_liveness_unavailable thrown out of refreshRestoredOrchestrationAuthority — the requireFreshPtyLiveness callers failing on the null inventory.

— not covered: renders correctly

The live terminal.list payload was captured off the running runtime and fed to the real formatTerminalList from src/cli/terminal-format.ts:

post-fix:  scope: local — not covered: ssh:ssh-1786951515639-b1xqbj
pre-fix:   scope: none — not covered: local, ssh:ssh-1786951515639-b1xqbj

A dead relay prints "not covered" rather than an empty list that would read as "no terminals there".

Caveat, stated plainly: only the post-fix line comes from a fully captured payload. The pre-fix line substitutes the hostScope the pre-fix runtime actually reported into that captured payload — the hostScope values are measured, the surrounding body is not a pre-fix capture.

Re-run against the rebased tree — the caveat is now a measurement

The section this replaces said the "current main behaves identically under a hang" claim was code inspection, not measurement, and that the rig had not been re-run after the rebase. It has now been re-run against this exact tree (141d45db76), and the inspection was correct.

Full log: sta517-rebased-measurement.txt

Rig. Fresh throwaway debian:bookworm-slim sshd container (key-only, node 20.18.1 + build-essential/python3, aarch64 — node-pty will not build on the remote without them and every remote PTY comes up unavailable), plus pnpm run build:relay first because the dev build ships no linux-arm64 relay. Isolated Electron dev instance (own ORCA_DEV_USER_DATA_PATH, own CDP port, getIdentity() verified), with the orca CLI pointed at that runtime via ORCA_USER_DATA_PATH=<same dir> so the measurement cannot read another instance. Real PTYs on both hosts. Unreachability is again docker pause — socket open, nothing answers.

Rebased baseline confirmed: origin/main already carries #14977's per-provider settle (7afce2ea41), so this PR contributes only the forwarded deadline.

relay hung pre-fix (deadline removed) post-fix (this PR)
terminal.list latency 3.18 s — the 3 s ceiling 2.70 s — the provider deadline, inside it
hostScope.hostIds [] — whole inventory lost, local included ["local"]
hostScope.omittedHostIds ["local","ssh:…"] ["ssh:…"]
rendered scope line scope: none — not covered: local, ssh:… scope: local — not covered: ssh:…
terminals returned 5, all stale — nothing retired 1 (local); the dead host's records retired
onSshInventoryUnavailable never fired fired

Both arms are real orca terminal list output from the running runtime — the pre-fix scope line is a genuine pre-fix capture this time, not a substitution.

The composition with #14977, observed. This is the part that had never been seen. Two temporary console.log calls in markSshInventoryUnverifiable (reverted afterwards; not in this diff) recorded:

[STA517-PROBE] onSshInventoryUnavailable conn=ssh-… reason=Request "pty.listProcesses" timed out after 2500ms
[STA517-PROBE] markPtyLivenessUnverifiable pty=ssh:…@@pty-1
[STA517-PROBE] markPtyLivenessUnverifiable pty=ssh:…@@pty-2
[STA517-PROBE] markPtyLivenessUnverifiable pty=ssh:…@@pty-4

2500 ms is exactly PTY_CONTROLLER_LIST_TIMEOUT_MS (3000) minus PTY_CONTROLLER_LIST_PROVIDER_MARGIN_MS (500). The silent relay rejects at the deadline, falls into main's per-provider catch, fires onSshInventoryUnavailable, and lands the unverifiable verdict on every PTY that connection owns. With the deadline removed the same probe printed zero lines across the whole arm: main's verdict machinery is genuinely unreachable for a silent relay, and the deadline is what makes it reachable. That is the deadline's contribution stated exactly.

Still not measured. The unverifiable verdict was observed at the point it is recorded, not at a user-facing surface: terminal.close is the only CLI surface that reports ptyStopVerdict, and it returns tab_not_found for CLI-created terminals in a headless rig (for local terminals too), so the verdict was not read back out through an RPC. Only the aggregate (connectionId === undefined) path was exercised; the per-connection path shares the same forwarding but was not driven separately.

Automated

  • src/main/ipc/pty-controller-process-inventory.test.ts — the aggregate still reports local + healthy relays when one relay is unavailable; the deadline is forwarded on both the aggregate and targeted paths; a local failure still fails the aggregate (contract lock).
  • src/main/runtime/pty-inventory-partial-relay-liveness.test.ts — the provider deadline lands strictly inside the runtime's own budget, a tighter caller deadline is honoured, a vouched-for pane keeps its orchestration authority, and a pane no provider vouches for is retired.
  • src/main/ipc/pty-runtime-kill-and-exit.test.ts / src/main/runtime/orca-runtime.test.ts — existing assertions matched the inventory call on exact arity; their intent is which provider scope was asked, so they now match the scope argument and require a numeric deadline beside it, so the added budget is covered rather than merely tolerated.
pnpm exec vitest run --config config/vitest.config.ts \
  src/main/runtime/pty-inventory-partial-relay-liveness.test.ts \
  src/main/ipc/pty-controller-process-inventory.test.ts \
  src/main/ipc/pty-runtime-kill-and-exit.test.ts \
  src/main/runtime/orca-runtime.test.ts \
  src/main/runtime/terminal-list-execution-host-scope.test.ts

Post-rebase: 5 files, 1202 passed, 1 skipped. tsc --noEmit -p config/tsconfig.node.json --composite false clean. oxlint + oxfmt --check clean on all 6 changed files, and the lint gate was proven live by injecting a no-unused-vars / no-debugger violation and confirming both were reported, rather than trusting silent output.

  • Automated tests added/updated, or explained why not below

Review

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • Remote SSH — the point of the change. Strictly more correct: a silent relay no longer poisons the inventory, and its own panes are still protected by hasPty rather than being wrongly retired.
  • Interaction with fix(ssh): stop reporting a confirmed kill when the SSH provider is gone #14977 — complementary, and verified on the rebased tree rather than assumed. The deadline is what feeds fix(ssh): stop reporting a confirmed kill when the SSH provider is gone #14977's verdict machinery: without it a hung relay never reaches the catch, so markSshInventoryUnverifiable never fires for the silent case. listProcessesWithHostScope still binds the hoisted module-level listRegisteredPtyProcessesWithHostScope, and orca-runtime.ts still calls exactly that — checked explicitly, since a clean merge does not prove the fix stayed on the live path.
  • Wire compatibility — checked against docs/reference/remote-wire-compatibility.md. No frame shape change, no new opcode, no RPC params touched. This is Rule 3 territory (host-published content on worktree.ps): no field changes meaning, units, or nullability, and the host does not stop populating anything. It stops emitting a false positive. An older client reads the same status / hasHostSidebarActivity / liveTerminalCount fields with the same semantics, just accurate, so no capability gate is needed.
  • Cross-platform — no platform-conditional code, no paths, no shortcuts.
  • Folder workspaces — untouched; the summary builder treats them identically.
  • Performance — strictly better. The providers already ran concurrently; bounding each one stops a dead relay from holding the refresh for up to 30s. Measured above: 3004 ms and no answer, versus 5395 ms with the local inventory intact.
  • Mobile — no mobile source changed; mobile renders whatever worktree.ps publishes.

Adjacent finding, deliberately not fixed here (flagging so it is not lost; it wants its own ticket): mobile/src/worktree/agent-row-display.ts decays a stale agent row using the phone's Date.now() against a host-stamped row.updatedAt — the two-machine clock comparison STA-3455 describes. A phone clock behind the host makes that delta negative, so the per-agent dot never decays. It styles the agent row rather than the worktree's active status, so it is a separate defect and out of scope for a focused fix.

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 (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred) — scoped equivalents run locally as listed in Testing; full typecheck/build left to CI

Author

  • X / Twitter: @BrennanKB5

@coderabbitai

coderabbitai Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

PTY process inventory now forwards caller deadlines through targeted and aggregate listings. SSH provider failures produce partial aggregate results, while local provider failures still reject the aggregate request. Runtime inventory refreshes apply bounded provider and aggregate deadlines. Restored orchestration authority cleanup now runs after PTY rescue processing. Tests cover provider failure handling, deadline propagation, partial relay liveness, and updated call assertions.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. 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 clearly summarizes the main fix: preventing an unreachable SSH relay from blocking workspace activity updates.
Description check ✅ Passed The description is complete and detailed, with required sections, issue linkage, testing evidence, scope notes, and an appropriate N/A visual proof.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@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 (2)
src/main/ipc/pty.ts (1)

5746-5753: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Shorten the new comment.

Keep the behavior rationale in one concise sentence. The detailed incident history is not needed beside this branch.

-      // Why: one unreachable relay must not decide liveness for every other provider.
-      // Promise.all failed the whole aggregate on a single SSH rejection, and an
-      // unanswered relay list runs to the mux's 30s default — far past the caller's
-      // budget — so the runtime kept losing the inventory it needs to retire exited
-      // PTYs and every retained pane stayed "active" (STA-517). Settle each SSH
-      // provider on its own and bound it by the caller's deadline; a provider that
-      // does not answer is unknown, not empty — the runtime's hasPty rescue keeps its
-      // panes. A local failure still fails the aggregate, matching pty:listSessions.
+      // Treat failed SSH listings as unavailable; keep local listing failures fatal.

Source: Coding guidelines

src/main/runtime/pty-inventory-partial-relay-liveness.test.ts (1)

6-9: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Reduce explanatory test comments.

The test names and assertions already specify these contracts. Remove these comments, or replace each with one short comment only where needed.

  • src/main/runtime/pty-inventory-partial-relay-liveness.test.ts#L6-L9: remove the suite rationale.
  • src/main/runtime/pty-inventory-partial-relay-liveness.test.ts#L72-L73: remove the mock implementation rationale.
  • src/main/runtime/pty-inventory-partial-relay-liveness.test.ts#L95-L96: remove the deadline failure explanation.
  • src/main/runtime/pty-inventory-partial-relay-liveness.test.ts#L135-L136: remove the rescue assertion explanation.
  • src/main/runtime/pty-inventory-partial-relay-liveness.test.ts#L161-L162: remove the retirement assertion explanation.

As per coding guidelines, “Comments must be concise, non-obvious, and brief—prefer one line; do not explain obvious behavior or walk through code.”

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ffecbf00-f36f-4387-9289-4a2bb044c28f

📥 Commits

Reviewing files that changed from the base of the PR and between 83d79f3 and e167472.

📒 Files selected for processing (5)
  • src/main/ipc/pty-controller-process-inventory.test.ts
  • src/main/ipc/pty.test.ts
  • src/main/ipc/pty.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/pty-inventory-partial-relay-liveness.test.ts

Comment thread src/main/ipc/pty.ts Resolved
@coderabbitai

coderabbitai Bot commented Aug 17, 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.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/mobile-ssh-active-517 branch from cd7e186 to 42bd5ee Compare August 17, 2026 05:27
…e as active

The worktree.ps liveness refresh is the only thing that retires an exited PTY,
and mobile renders "active" straight off the summary it produces. Its aggregate
inventory ran every provider through Promise.all with no per-provider deadline,
so a single SSH relay that rejected — or simply did not answer inside the 3s
budget, since a relay list runs to the mux's own 30s default — cost the runtime
the whole inventory. Nothing was ever proven dead, so every retained pane kept
reporting hasHostSidebarActivity/liveTerminalCount, and the SSH workspaces stayed
"active" on mobile for as long as the connection stayed unreachable.

Settle each SSH provider independently and forward the caller's deadline, so
local and healthy relays are still reconciled. A provider that does not answer is
unknown, not empty: the runtime's existing hasPty rescue keeps its panes. A local
failure still fails the aggregate, matching pty:listSessions.

The restored-orchestration-authority sweep now runs after that rescue, so a pane
the controller still vouches for keeps its handle instead of losing it to a
listing that merely omitted it.

STA-517
…entory calls

These assertions exist to prove which provider scope the inventory asked for.
Forwarding the caller's deadline added a second argument, which broke them on
arity alone. Match the scope argument and require a numeric deadline beside it,
so the intent is preserved and the budget is covered too.
A bare `async () =>` mock types mock.calls as an empty tuple, so reading the
scope argument off it fails typecheck. Declare the parameter the runtime
actually passes.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/mobile-ssh-active-517 branch from 42bd5ee to 141d45d Compare August 17, 2026 08:21
@coderabbitai

coderabbitai Bot commented Aug 17, 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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 521a080e-083b-4e20-b8ab-cb37b1eb19a9

📥 Commits

Reviewing files that changed from the base of the PR and between 1aa51f6 and 141d45d.

📒 Files selected for processing (6)
  • src/main/ipc/pty-controller-process-inventory.test.ts
  • src/main/ipc/pty-runtime-kill-and-exit.test.ts
  • src/main/ipc/pty.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/pty-inventory-partial-relay-liveness.test.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/main/ipc/pty-controller-process-inventory.test.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/pty-inventory-partial-relay-liveness.test.ts
  • src/main/runtime/orca-runtime.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 0 remain after this review.

Comment thread src/main/ipc/pty.ts
Comment on lines +289 to +290
// Why: the deadline only applies to relay round-trips; the local provider answers in-process.
processes: await (connectionId ? provider.listProcesses(opts) : provider.listProcesses()),

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.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Forward opts on both local listing paths.

localProvider can be daemon-backed, so the connectionId check does not guarantee an in-process call. Without opts, aggregate and targeted listings can exceed their caller deadlines.

  • src/main/ipc/pty.ts#L289-L290: call provider.listProcesses(opts) for the local aggregate session.
  • src/main/ipc/pty.ts#L5845-L5848: call localProvider.listProcesses(opts) for targeted local requests.
Proposed fix
-          processes: await (connectionId ? provider.listProcesses(opts) : provider.listProcesses()),
+          processes: await provider.listProcesses(opts)

-        return localProvider.listProcesses()
+        return localProvider.listProcesses(opts)
📍 Affects 1 file
  • src/main/ipc/pty.ts#L289-L290 (this comment)
  • src/main/ipc/pty.ts#L5845-L5848

@brennanb2025

brennanb2025 commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Review status

State: MERGEABLE / CLEAN against main. CI green — 44 successful checks, 1 skipped, 0 failing. 6 files, +432/-38 (2 prod / 4 test). Branch is 3 commits behind main but merges clean.

Scope has changed since the validation was run — read this before assessing the evidence. #14977 merged to main on 2026-08-17 and shipped the per-provider settle: a relay that rejects is now caught, dropped from both processes and hostIds, and recorded unverifiable. I confirmed the branch is strictly ahead of #14977's merge commit 7afce2e, and that src/main/ipc/pty.ts on this head carries both main's try/catch + onSshInventoryUnavailable and the new opts?: { deadlineMs?: number } — the rebase kept main's verdict machinery rather than replacing it with a .catch(...) that would have dropped the verdict.

So this PR now contributes only the deadline. That is not a leftover; it is the half that covers the reported failure. A relay that goes silent never rejects, so it never reaches #14977's catch — Promise.all simply fails to settle inside the runtime's PTY_CONTROLLER_LIST_TIMEOUT_MS = 3_000 while SshPtyProvider.listProcesses falls through to the mux's own 30s REQUEST_TIMEOUT_MS. The deadline (PTY_CONTROLLER_LIST_PROVIDER_MARGIN_MS = 500, strictly inside the aggregate budget) makes a silent relay reject, which lands it in main's catch and fires the unverifiable verdict that #14977 intended but could not reach for the silent case. The two compose: one supplies the branch, the other makes it reachable.

What the review loop established. worktree.ps is mobile's only status source, and the liveness refresh is the only path that can flip a retained PTY to connected = false. One unresponsive relay blew the whole budget, so refreshPtyWorktreeRecordsWithControllerInventory returned null before the sweep and the entire inventory was lost, local included. The loop also corrected an earlier claim in the description: local panes do not stay active after their processes exit, because a shell that exits under observation is retired by the PTY exit event and never consults the inventory. The stuck-active symptom applies to panes that must be proven dead by the listing — records restored from persistence after an app restart, and retained/unconfirmed records. A provider that does not answer is treated as unknown, not empty: its panes are re-added by the existing hasPty rescue and it drops out of hostIds, so the listing never claims coverage it lacks.

Validation — what was and was not done.

Live, done: a throwaway ubuntu:22.04 Docker SSH target (key-only root login, node 22.14.0, build toolchain — required or node-pty will not build and remote PTYs never come up), 4 real PTYs across 2 hosts, driven from an isolated Electron dev instance through the real ssh.connect path with the relay actually running on the container. Unreachability was induced with docker pause specifically so the socket stays open and nothing answers — killing the container or blackholing the port produces a clean error, which exercises #14977's branch rather than this one. Each arm's running bundle was verified to be the code under test (PTY_CONTROLLER_LIST_PROVIDER_MARGIN_MS present 2× in out/main/index.js with the fix, 0× without), not assumed.

Pre-fix the aggregate returned covered: [] at the 3004 ms ceiling — the whole inventory lost, not even the local provider survived a hung relay — corroborated in the same run by terminal_liveness_unavailable thrown out of refreshRestoredOrchestrationAuthority. Post-fix: 5395 ms, hostIds: ["local"], omittedHostIds: ["ssh:…"], local panes retired, remote panes retained as unknown. The — not covered: rendering was checked by feeding the captured payload to the real formatTerminalList.

CORRECTION — the gap named below has since been closed. Everything from here to the next heading was accurate when written and is now superseded; it is left visible rather than deleted so the record shows what changed.

The rig has been re-run against the rebased tree. Two things I said could not be measured, now measured:

1. The headline contrast reproduces on the rebased tree. Fresh debian:bookworm-slim SSH target, real relay, docker pause for the hang, both arms genuine orca terminal list output rather than a substituted hostScope:

relay hung pre-fix (deadline removed) post-fix
latency 3.18 s (the 3 s ceiling) 2.70 s (provider deadline, inside it)
hostIds [] — whole inventory lost, local included ["local"]
omittedHostIds ["local","ssh:…"] ["ssh:…"]
scope line scope: none — not covered: local, ssh:… scope: local — not covered: ssh:…
terminals returned 5, all stale, nothing retired 1 (local); dead host's records retired

2. The bridging claim is no longer inference — the composition was observed directly. With two temporary probes in markSshInventoryUnverifiable (added as instrumentation, reverted after):

[PROBE] onSshInventoryUnavailable conn=ssh-… reason=Request "pty.listProcesses" timed out after 2500ms
[PROBE] markPtyLivenessUnverifiable pty=ssh:…@@pty-1 / @@pty-2 / @@pty-4

2500 ms is exactly 3000 − 500 — PTY_CONTROLLER_LIST_TIMEOUT_MS minus PTY_CONTROLLER_LIST_PROVIDER_MARGIN_MS. The silent relay rejects at the deadline, falls into main's per-provider catch, fires onSshInventoryUnavailable, and lands the unverifiable verdict on every PTY that connection owns. With the deadline removed the same probe printed zero lines across the whole arm — so #14977's verdict machinery really is unreachable for a silent relay, and this PR's deadline is what makes it reachable.

Also corrected: the Docker daemon was not wedged. That was a stale claim of mine, and it is why the re-run was reported as blocked here.

Still not verified:

  • The unverifiable verdict was observed where it is recorded, not read back at a user-facing surface — terminal.close is the only CLI surface exposing ptyStopVerdict and it returns tab_not_found for CLI-created terminals in a headless rig.
  • Only the aggregate (connectionId === undefined) path was driven live; the per-connection path shares the same forwarding but was not exercised separately.
  • One rendering caveat from the body still stands: only the post-fix formatTerminalList line comes from a fully captured payload.

Automated (post-rebase): 5 files, 1202 passed, 1 skipped. New coverage asserts the deadline lands strictly inside the runtime budget, that a tighter caller deadline is honoured, that a local failure still fails the aggregate (contract lock), and that a pane no provider vouches for is retired. Two pre-existing suites that matched the inventory call on exact arity were tightened to match the scope argument and require a numeric deadline beside it, so the budget is covered rather than merely tolerated. tsc --noEmit clean; oxlint/oxfmt clean, with the lint gate proven live by injecting no-unused-vars / no-debugger violations and confirming both were reported rather than trusting silent output.

Wire: no frame shape change, no new opcode, no RPC params touched. Rule 3 territory (host-published content on worktree.ps): no field changes meaning, units, or nullability, and the host does not stop populating anything — it stops emitting a false positive. No capability gate needed.

Supersedes: nothing.

Adjacent finding, deliberately not fixed here and worth its own ticket: mobile/src/worktree/agent-row-display.ts decays a stale agent row using the phone's Date.now() against a host-stamped row.updatedAt. A phone clock behind the host makes that delta negative, so the per-agent dot never decays. It styles the agent row rather than the worktree's active status, so it is a separate defect.

@brennanb2025
brennanb2025 merged commit eb0ec39 into main Aug 18, 2026
45 checks passed
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 21, 2026
…e as active (STA-517) (stablyai#14649)

* fix(runtime): stop one unreachable relay from freezing every workspace as active

The worktree.ps liveness refresh is the only thing that retires an exited PTY,
and mobile renders "active" straight off the summary it produces. Its aggregate
inventory ran every provider through Promise.all with no per-provider deadline,
so a single SSH relay that rejected — or simply did not answer inside the 3s
budget, since a relay list runs to the mux's own 30s default — cost the runtime
the whole inventory. Nothing was ever proven dead, so every retained pane kept
reporting hasHostSidebarActivity/liveTerminalCount, and the SSH workspaces stayed
"active" on mobile for as long as the connection stayed unreachable.

Settle each SSH provider independently and forward the caller's deadline, so
local and healthy relays are still reconciled. A provider that does not answer is
unknown, not empty: the runtime's existing hasPty rescue keeps its panes. A local
failure still fails the aggregate, matching pty:listSessions.

The restored-orchestration-authority sweep now runs after that rescue, so a pane
the controller still vouches for keeps its handle instead of losing it to a
listing that merely omitted it.

STA-517

* test(runtime): assert the provider scope, not the exact arity, of inventory calls

These assertions exist to prove which provider scope the inventory asked for.
Forwarding the caller's deadline added a second argument, which broke them on
arity alone. Match the scope argument and require a numeric deadline beside it,
so the intent is preserved and the budget is covered too.

* test(runtime): type the inventory mock's scope parameter

A bare `async () =>` mock types mock.calls as an empty tuple, so reading the
scope argument off it fails typecheck. Declare the parameter the runtime
actually passes.
dallascrilley pushed a commit to dallascrilley/orca that referenced this pull request Aug 27, 2026
…e as active (STA-517) (stablyai#14649)

* fix(runtime): stop one unreachable relay from freezing every workspace as active

The worktree.ps liveness refresh is the only thing that retires an exited PTY,
and mobile renders "active" straight off the summary it produces. Its aggregate
inventory ran every provider through Promise.all with no per-provider deadline,
so a single SSH relay that rejected — or simply did not answer inside the 3s
budget, since a relay list runs to the mux's own 30s default — cost the runtime
the whole inventory. Nothing was ever proven dead, so every retained pane kept
reporting hasHostSidebarActivity/liveTerminalCount, and the SSH workspaces stayed
"active" on mobile for as long as the connection stayed unreachable.

Settle each SSH provider independently and forward the caller's deadline, so
local and healthy relays are still reconciled. A provider that does not answer is
unknown, not empty: the runtime's existing hasPty rescue keeps its panes. A local
failure still fails the aggregate, matching pty:listSessions.

The restored-orchestration-authority sweep now runs after that rescue, so a pane
the controller still vouches for keeps its handle instead of losing it to a
listing that merely omitted it.

STA-517

* test(runtime): assert the provider scope, not the exact arity, of inventory calls

These assertions exist to prove which provider scope the inventory asked for.
Forwarding the caller's deadline added a second argument, which broke them on
arity alone. Match the scope argument and require a numeric deadline beside it,
so the intent is preserved and the budget is covered too.

* test(runtime): type the inventory mock's scope parameter

A bare `async () =>` mock types mock.calls as an empty tuple, so reading the
scope argument off it fails typecheck. Declare the parameter the runtime
actually passes.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…e as active (STA-517) (stablyai#14649)

* fix(runtime): stop one unreachable relay from freezing every workspace as active

The worktree.ps liveness refresh is the only thing that retires an exited PTY,
and mobile renders "active" straight off the summary it produces. Its aggregate
inventory ran every provider through Promise.all with no per-provider deadline,
so a single SSH relay that rejected — or simply did not answer inside the 3s
budget, since a relay list runs to the mux's own 30s default — cost the runtime
the whole inventory. Nothing was ever proven dead, so every retained pane kept
reporting hasHostSidebarActivity/liveTerminalCount, and the SSH workspaces stayed
"active" on mobile for as long as the connection stayed unreachable.

Settle each SSH provider independently and forward the caller's deadline, so
local and healthy relays are still reconciled. A provider that does not answer is
unknown, not empty: the runtime's existing hasPty rescue keeps its panes. A local
failure still fails the aggregate, matching pty:listSessions.

The restored-orchestration-authority sweep now runs after that rescue, so a pane
the controller still vouches for keeps its handle instead of losing it to a
listing that merely omitted it.

STA-517

* test(runtime): assert the provider scope, not the exact arity, of inventory calls

These assertions exist to prove which provider scope the inventory asked for.
Forwarding the caller's deadline added a second argument, which broke them on
arity alone. Match the scope argument and require a numeric deadline beside it,
so the intent is preserved and the budget is covered too.

* test(runtime): type the inventory mock's scope parameter

A bare `async () =>` mock types mock.calls as an empty tuple, so reading the
scope argument off it fails typecheck. Declare the parameter the runtime
actually passes.
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.

1 participant