Skip to content

fix(terminal): only skip the quit warning when the work actually survives - #17085

Closed
brennanb2025 wants to merge 25 commits into
brennanb2025/window-close-ssh-guard-r1from
brennanb2025/quit-bypass-survival-r1
Closed

brennanb2025 wants to merge 25 commits into
brennanb2025/window-close-ssh-guard-r1from
brennanb2025/quit-bypass-survival-r1

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​753 $\color{#cf222e}{\Huge{\mathbf{−}}}$​51 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​702
Prod 16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​258 $\color{#cf222e}{\Huge{\mathbf{−}}}$​48 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​210

ELI5

Orca has a background helper (the daemon) that adopts your terminal shells. When it's
there, quitting Orca hands your running commands over to it and they keep going — so
quitting doesn't need to warn you.

The catch: Orca skipped that warning on every quit, whether or not the helper was
actually there. When it wasn't, the shells were Orca's own children and died with it,
silently. Same keystroke, same lack of a warning, opposite outcome — and no way to tell
which one you just got.

Now Orca asks the question first: do these shells actually survive this quit? Only a
clear yes skips the warning.

User-facing before / after

Before — quitting Orca could kill a running command with no warning whenever the
background helper that normally keeps it alive wasn't there, and you had no way to tell
the difference.

After — Orca only skips the warning when the work genuinely keeps running. Otherwise
it asks, the same way closing a window already does.

Nothing changes in the common case. With a healthy daemon — the normal setup — a quit
still closes immediately and silently, and does not even run the probe. Ordinary window
close is untouched.

What changes, per platform

The gate is platform-independent; no new platform branch was added.

Platform X / red-button close Quit (⌘Q, File→Exit, tray Quit)
macOS unchanged — already prompts prompts only when the local shells would die with the app
Windows unchanged — prompts, or minimizes to tray when that setting is on prompts only when the local shells would die with the app
Linux unchanged — already prompts prompts only when the local shells would die with the app

The existing win32 minimize-to-tray branch still short-circuits ahead of all of this.

How it decides

Main is the only side that knows whether the daemon owns the shells, so it answers on the
close request itself:

  • window:close-requested gains localPtysSurviveQuit, resolved per request. The
    adapter is installed, swapped and lost over a run, so a value captured at window creation
    would be stale.
  • The question is about the PTYs, not the provider. daemonOwnsFreshPersistentPtys()
    answers about the adapter installed at the moment of asking. Degraded mode spawns fresh
    terminals on the in-process local provider — those shells are this process's own children —
    and a daemon restart that recovers from degraded mode swaps in a provider that does own
    fresh persistent PTYs while those shells are still running. shutdownFallbackSessions is
    best-effort by design, so a restart that succeeded can leave one behind. localPtysSurviveQuit()
    therefore keeps the swapped-out degraded provider reachable and asks it whether its app-owned
    shells are still there; an id the fallback cannot answer for counts as alive.
  • An undetermined answer is not a yes. A missing getter, a throwing read, an absent
    field, a truthy non-boolean — all resolve to does not survive, and ask.
  • Both consumers read the one value main computes — the close request and the deferred
    dirty-editor close that reuses the stored answer — so they cannot drift apart.

Reuse, not a fourth reading

The probe is the one #17044 and #17077 settled: anyPtyBlocksWindowClose. The verdict
vocabulary is unchanged — exited is still the only verdict that closes with no prompt. Pane
selection moved next to it as collectWindowClosePtyIds, so the quit path and the
window-close path share one selector.

What that probe reads changed underneath this PR and is worth restating. #17077 now routes
it through readPtyProcessInspectionEvidenceForAbsenceAction, a shared reader that refuses to
let a host which published no evidence state an absence. The inline
!hasPublishedPtyProcessInspectionEvidence fence #17077 carried a commit earlier is gone, and
the host conjunct that fence originally used (getPtyExecutionHost(...) !== null) is gone with
it — it skipped daemon panes, whose session ids carry no host at all. This PR's gate sits above
all of that and is unaffected in behaviour, but two of #17077's own gate rows shifted as a
result; see that PR's table, not an older copy of it.

SSH panes are not newly prompted for. A quit drops panes on a resolved SSH target:
shutdown marks the lease detached rather than terminated and the remote shell is
nohup-detached, so quitting ends nothing there and probing it would only make the quit
slower. Only a resolved target is dropped — getConnectionIdFromState answers
undefined while the backing repo has not hydrated, and an unresolved host is not
evidence the work survives, so those panes stay in the probe.

Evidence this is real

The lane that traced the quit path measured each case:

Case Outcome Evidence
Local, daemon-backed survives Observed in production: daemon + PTY shells up 12 days against an app main started that morning
Local, no daemon destroyed silently Observed in an isolated node-pty probe: the foreground worker died on an explicit kill and on a bare parent exit, while a detached-fork control survived
SSH / relay survives Leases marked detached, not terminated; remote side nohup-detached; shipped grace default arms no reaping timer
Unsaved editor buffers already warned The dirty-file check sits ahead of the quit branch

Note the third row's trap: "there is no kill call" is not protection. The child dies on
bare parent exit anyway, which is why this is gated on the daemon owning the shells rather
than on the absence of a kill.

Failing-first

New tests run against the pre-change source (tests kept):

Test Before After
warns about a live local process when the daemon does not own the PTYs ❌ ✅
warns when the local read was degraded ("could not tell" is not "idle") ❌ ✅
warns when the payload never said whether the PTYs survive ❌ ✅
warns about the local pane of a mixed window, leaving the SSH pane alone ❌ ✅
probes a pane whose owning host has not resolved yet ❌ ✅
closes silently while the daemon owns the PTYs, without probing at all ✅ ✅
does not probe or warn about a direct-SSH pane on quit ✅ ✅
still probes an ordinary window close even while the daemon owns the PTYs ✅ ✅

The last three cannot fail pre-fix — the old behaviour is a superset (it never probed on
quit at all). They are pinned by ablation instead, below, and that is stated rather than
papered over.

Whole-suite failing-first, re-measured at head b625277d78 (live, git ls-remote): 26 reds
across 5 suites, with the renderer prompt suite at 7 — the same two figures this section first
reported at the earlier head d2bd7720e2, reproduced exactly. Per suite: 4 / 4 / 7 / 4 / 7 across
window-close-decision, daemon-quit-survival-after-restart, window-close-running-process-prompt,
createMainWindow-tray-minimize-close, createMainWindow-close-confirmation.
Method: every production file this PR changes reverted to the base
(#17077's live head 6d4cdd572a, which supersedes the fcc004cc1a this page used to name),
all new tests kept, tree byte-verified mutated and restored --hard between runs. Baseline at
head over the same 9 changed test files: 140 passed, 0 failed. The two files this PR adds —
src/shared/window-close-request.ts and resolveLocalPtysSurviveQuit — are kept real,
because they are pure readers with no pre-change counterpart to revert to; without them two
suites fail to collect rather than to discriminate, which is not a failing-first signal.
Reverting those two as well (scaffolded to the old unconditional "quit always survives")
raises it to 32 across 6, the extra 6 being the shared-reader unit tests. Both numbers are
real; the 26 is the one that isolates behaviour. A third shape — deleting those two files
instead of scaffolding them — reads 19 across 7, and is the misleading one: two suites then
fail to collect, so the run discriminates on fewer tests rather than more. Quoted here only
because a lower number from a harsher ablation is a shape artefact, not weaker coverage.

Per-gate ablation (re-measured at head d2bd7720e2)

Seven test files, 103 tests, all green at head: src/main/window/window-close-decision.test.ts,
createMainWindow-close-confirmation.test.ts, createMainWindow-tray-minimize-close.test.ts,
src/main/daemon/daemon-quit-survival-after-restart.test.ts,
src/renderer/src/components/terminal/window-close-running-process-prompt.test.tsx,
src/renderer/src/components/window-close-request-coordinator.test.ts,
src/shared/window-close-request.test.ts.

Each gate broken separately, on top of the full fix, tree restored between runs.

Ablation Goes red
A — delete the survival gate (!isQuitting || !localPtysSurviveQuit → !isQuitting) 5 — the 5 failing-first tests
A2 — gate ignores isQuitting (!localPtysSurviveQuit) 1 — only "still probes an ordinary window close…"
A3 — quit always probes (survival fact never consulted, condition forced to true) 4 — "closes silently while the daemon owns the PTYs, without probing at all", "still closes the window directly on a quit that no checkpoint vetoes", and the two stale-probe fences the never-probing quit path used to satisfy for free
B — delete the SSH skip in collectWindowClosePtyIds 2 — the 2 SSH-scoping tests
C — unresolved host treated as SSH (typeof === 'string' → !== null) 1 — only "probes a pane whose owning host has not resolved yet"
D — main resolver coerces an undetermined answer to yes (missing getter → true, throw → true, !== false) 10 — both resolveLocalPtysSurviveQuit unknown/throw pins, 4 tray/close-flow payload assertions, the quit-latch and reload paths, and the hung-renderer confirmation
E1 — shared reader accepts any truthy value (=== true → Boolean(...)) 2 — the truthy-string and truthy-number reader tests only. An absent field is still falsy, so the renderer "payload never said" test does not redden
E2 — shared reader accepts anything but an explicit false (=== true → !== false) 7 — all 6 reader tests and the renderer "payload never said" test
F — main stops resolving and hardcodes true 9 — 4 tray/close-flow payload assertions, the quit-latch, reload and hung-renderer paths, "re-reads the daemon on every attempt", and "reports no survival when the daemon read throws"
G — localPtysSurviveQuit() ignores the stranded degraded provider 2 — the two daemon-restart survival tests
H — a swapped-out degraded provider is not retained at all 2 — the same two
I — the deferred dirty-editor close hardcodes survival instead of passing the stored answer 1 — "carries the survival fact through the deferred dirty-editor close as well"
J — the runtime-environment exclusion dropped (!isRemoteRuntimePtyId filter removed) 3 — the three runtime-environment pane cases

A is the rule of this PR deleted outright; it goes red. A2 and A3 are the two arms of that
one condition broken independently, so neither is riding on the other.

E's two rows are the honest version of one row that used to be there. The old row was
labelled "accepts any truthy value" and claimed 7 reds. The claim it was making — that the
shared reader really is the thing feeding the renderer prompt, not a double standing in for
it — is true, and E2 demonstrates it. But a truthy-only mutation is not what produces those
7: Boolean(undefined) is still false, so absence keeps behaving and only 2 reader tests
go red. The mutation that reddens the renderer test is the absence-tolerant one. Both are
listed rather than one being quietly relabelled.

G, H and I are round-2 gates the earlier table predated. G and H are the two halves of
"answer from the PTYs that exist, not the provider"; either half alone leaves a degraded-mode
shell invisible to the survival question. I is a second call site — the deferred dirty-editor
close — that was reading the fact but not pinned to it.

J is new in d2bd7720e2, and it is a gate that was load-bearing but unpinned. The
!isRemoteRuntimePtyId filter reddened nothing in #17077's own guard suite: no fixture
anywhere used a remote:-prefixed id, so the filter was never exercised even though
updateTabPtyId writes runtime ids into ptyIdsByTabId unfiltered in production. It is now
pinned by construction — the id is minted by the real toRemoteRuntimePtyId and bound to the
local worktree, so the SSH skip (gate B) cannot be what excludes it — never by a whitelist.
Uncovered is not the same as inert, and the distinction was only visible by instrumenting what
the filter actually examined rather than counting reds.

Real producer into real reader

readWindowCloseRequestPayload is the reader the preload actually installs; the renderer
quit tests drive the prompt through it, so absence and non-boolean values arrive exactly
as they would on the wire. The main-side tests assert on the payload the real close
handler sends
— including that it is re-read on every attempt, so a daemon lost mid-run
is not still trusted. No double omits a field the real object carries. The renderer and
main halves are separate processes and renderer tests cannot import src/main/**
(TS6307), so the two halves are joined by the shared payload type rather than by one
end-to-end test; that is the honest limit here.

Gates

pnpm tc (both projects) clean · oxlint clean, no suppressions, no max-lines disable ·
node config/scripts/check-changed-code-quality.mjs → 0 new findings (code quality,
type-aware, React Doctor) · git diff --check clean · formatted with
npx oxfmt --write <changed paths>.

Targeted suites green: src/main/window/, src/renderer/src/components/terminal/,
src/renderer/src/app-shell/, src/preload/, src/shared/window-close-request.test.ts,
src/renderer/src/components/window-close-request-coordinator.test.ts,
src/main/daemon/daemon-quit-survival-after-restart.test.ts, daemon-init-provider-installation,
src/main/orcad/. The 7-file gate suite named above is 103 passed, 0 failed at d2bd7720e2.

Base

Branched off brennanb2025/window-close-ssh-guard-r1 (#17077), the tip of the window-close
stack (#17044 → #17077) and the branch that owns the settled
window-close-running-process-evidence.ts helper this PR reuses.

Live head: b625277d7845188c95e8f01afcfa3dbd59fee2d7, and #17077's live head is
6d4cdd572a5704ffc7704d126e375796cc433038, which git merge-base --is-ancestor confirms is an
ancestor of this head — both re-resolved with git ls-remote. The whole-suite failing-first count above was
re-measured at that live head and is unchanged at 26/5. The per-gate ablation table and the
103-test gate-suite baseline below still carry their original head d2bd7720e2 (an ancestor of
the live head) and have not been re-run since; the earlier fcc004cc1a tip for #17077 that
this section used to name is likewise superseded.

This branch has an active concurrent writer and has moved several times; re-resolve the head
before trusting any SHA here.

…ives

Quitting skipped the running-process confirmation unconditionally. That is
correct in exactly one state: with the daemon adapter installed, quit's
killAllPty() is a no-op against it and the shells are the daemon's children,
which it declines to retire while a session is live — observed in production
with a daemon and its PTY shells up 12 days against an app main started that
morning. The bypass was written for that world but was never conditional on
it, so in the degraded states — daemon init threw, the fail-open elapsed, or
DegradedDaemonPtyProvider is installed and spawns fresh sessions in-process —
the same silent quit killed live local processes with no warning and no way
for the user to tell the two apart. Measured in an isolated node-pty probe:
the foreground worker died both on an explicit kill and on a bare parent exit,
while a detached-fork control survived. "There is no kill call" is not
protection.

Main now answers the one fact the renderer cannot see and sends it on
window:close-requested as localPtysSurviveQuit, resolved per request from the
existing daemonOwnsFreshPersistentPtys() — the adapter is installed, swapped
and lost over a run, so a value captured at window creation would be stale. A
quit skips the confirmation only on an explicit yes: a missing getter, a
throwing read, an absent or non-boolean wire field all resolve to "does not
survive" and ask, because an undetermined answer is not a yes.

No fourth reading of "is anything running" — the probe is the one #17044 and
#17077 settled, anyPtyBlocksWindowClose over readPtyProcessInspectionEvidence,
with the whole verdict vocabulary unchanged. Pane selection moves next to it
as collectWindowClosePtyIds. A quit drops panes on a RESOLVED SSH target:
shutdown marks the lease detached rather than terminated and the remote shell
is nohup-detached, so quitting ends nothing there and probing would only make
the quit slower. Only a resolved target — getConnectionIdFromState answers
undefined while the backing repo has not hydrated, and an unresolved host is
not evidence the work survives, so those panes stay in.

Nothing changes for an ordinary window close, which still probes every pane on
its execution host, and nothing changes on a quit with a healthy daemon. No
platform-specific behaviour is added: the gate is the same on all three, and
the win32 minimize-to-tray branch still short-circuits ahead of it. No new
stream opcode; the payload gains one optional-by-absence boolean that older
readers already fall safe on.
@greptile-apps

greptile-apps Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Greptile Summary

The PR makes quit confirmation conditional on whether existing local PTYs actually survive application shutdown.

  • Computes the survival verdict in the main process for each close request and validates it across the preload boundary.
  • Retains a swapped-out degraded provider while app-owned fallback PTYs remain live.
  • Reuses shared pane selection and process-inspection logic while excluding resolved SSH and remote-runtime panes that survive quit.
  • Preserves the survival verdict through deferred dirty-editor confirmation.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/main/daemon/daemon-provider-state.ts Retains the swapped-out degraded provider and conservatively rejects quit survival while it still owns fallback PTYs.
src/main/daemon/degraded-daemon-session-routing.ts Adds a conservative provider-scoped liveness check that treats an indeterminate answer as live.
src/main/window/main-window-close-lifecycle.ts Resolves the current PTY-survival state per close request and includes it in the shared payload.
src/preload/window-close-request-subscription.ts Validates untyped close-request IPC data before acknowledging and forwarding it to the renderer.
src/renderer/src/components/terminal/window-close-running-process-prompt.tsx Skips process inspection only for quits with an explicit local-PTY survival verdict.
src/renderer/src/components/terminal/window-close-running-process-evidence.ts Centralizes pane selection, excluding surviving resolved-SSH and remote-runtime panes while retaining unresolved targets for inspection.
src/shared/window-close-request.ts Defines and conservatively parses the shared close-request contract.

Sequence Diagram

sequenceDiagram
    participant U as User
    participant M as Main process
    participant P as Preload
    participant R as Renderer
    participant D as PTY providers
    U->>M: Request quit
    M->>D: Do existing local PTYs survive?
    D-->>M: Explicit survival verdict
    M->>P: window:close-requested
    P->>P: Validate payload
    P->>R: Deliver close request
    alt Local PTYs survive
        R->>M: Confirm close without process probe
    else Local PTYs may die
        R->>R: Inspect relevant local panes
        R->>U: Warn when running work blocks close
    end
Loading

Reviews (17): Last reviewed commit: "Merge commit '6d4cdd572a5704ffc7704d126e..." | Re-trigger Greptile

Comment thread src/main/index.ts Resolved
…val-r1

# Conflicts:
#	src/renderer/src/components/terminal/window-close-running-process-prompt.test.tsx
#	src/renderer/src/components/terminal/window-close-running-process-prompt.tsx
…or close

The dirty-editor branch defers the close rather than taking it, so the survival
fact has a second call site: stashed on the pending record, spent when the
save/discard flow finishes. Only the direct call was pinned, leaving this one
free to drop the fact and restore the unconditional quit bypass for any window
with unsaved work. Both halves now falsify the assertion independently.
Comment thread src/main/index.ts Resolved
# Conflicts:
#	src/renderer/src/components/terminal/window-close-running-process-evidence.ts
…the provider

The bypass read `daemonOwnsFreshPersistentPtys()`, which answers about the
provider installed at the moment of asking. Degraded mode spawns fresh terminals
on the in-process local provider, so those shells are this process's own children
— and a daemon restart that recovers from degraded mode swaps in a provider that
does own fresh persistent PTYs while those shells are still running.
`shutdownFallbackSessions` is best-effort by design, logging and continuing so
fallback cleanup cannot abort the user's recovery, so a restart that SUCCEEDED
leaves them behind. The quit then skipped inspection and the work died silently.

Keep the swapped-out degraded provider reachable and ask it whether its
app-owned shells are still there, reading the fallback itself rather than a
routing table the swap froze. An id the fallback cannot answer for counts as
alive: an undetermined answer is not proof the work survives.

Both consumers of this fact — the close request and the deferred dirty-editor
close that reuses the stored answer — read the one value main computes, so they
move together.
Refresh onto #17077 0d639e4. One file conflicted:
window-close-running-process-evidence.ts, and only its import preamble —
#17077 dropped the `getPtyExecutionHost` import along with the host-keyed
legacy-distrust arm, while #17085 rewrote the same region to add
`collectWindowClosePtyIds` and its imports.

Resolved as a union: #17085's pane-selection block and its
`getConnectionIdFromState` / `isRemoteRuntimePtyId` imports are kept in
full, and #17077's deletion of the now-unused `getPtyExecutionHost` import
is honoured. The legacy arm itself auto-merged to #17077's verdict-absence
form, which is what #17085 reads through.
…lose probe

`collectWindowClosePtyIds` drops panes whose PTY id names a runtime environment:
that host is one this window only views, and it outlives the window by design.
The rule has now been carried through three homes — the prompt hook, then the
evidence module — with nothing asserting it. Deleting the filter outright reddened
0 of 39 tests in this suite, not because it is inert but because no case here ever
built a runtime pane: every fixture binds a local, direct-SSH or daemon id, and the
suite contained no `remote:`-prefixed id at all.

It is load-bearing in production. `updateTabPtyId` writes runtime ids into
`ptyIdsByTabId` unfiltered (store tests bind `remote:env@@terminal` there today),
so without the exclusion every window close would probe the runtime host and a busy
runtime pane would raise the warning on work the close does not end.

Pinned by construction, not by an id whitelist: the fixture id is minted by the real
`toRemoteRuntimePtyId`, and it is bound to the LOCAL worktree so the SSH skip cannot
be what excludes it. Three cases — the runtime pane alone, mixed with a local pane,
and live work on the runtime host — which redden under deletion and under inversion
alike, the two shapes that previously disagreed.
# Conflicts:
#	src/renderer/src/components/terminal/window-close-running-process-prompt.tsx
…fordance harness

#17077's harness typed proceedToNativeWindowClose at the pre-#17085 arity, so
merging the two lanes broke the web typecheck. Both quit cases assert the probe
is skipped, which #17085 gates on localPtysSurviveQuit.
brennanb2025 added a commit that referenced this pull request Aug 29, 2026
`native-smoke (windows-latest)` fails ~4.5% of runs on
`preserves a multiline argument through the compiled remote launcher`
with "Test timed out in 15000ms" — on unrelated PRs, for reasons that
have nothing to do with them. Across 176 sampled attempts it is the only
red that job produced, and it hit seven different PRs in two days:
#16900, #16904, #16915, #16955 (twice), #16979, #17014, #17085.

The test is six process creations: powershell.exe forks csc.exe, then
the freshly compiled orca.exe forks node.exe, twice. Hosted Windows
runners periodically slow process creation down, and this test amplifies
that far harder than anything else in the job. Comparing the 80 attempts
where it ran under 3s against the 12 where it ran over 12s, its own
median goes 2198ms -> 15917ms (7.2x) while the same file's
powershell-only test moves 556 -> 686ms (1.2x), the cmd.exe and Git Bash
process tests in the neighbouring file move 1.4x, and the other 35 files
put together move 1.5x.

Measured across those 176 attempts: 1881ms to 35438ms, p50 4264ms,
correlation +0.881 with the job's total Vitest duration. 8 of 176 (4.5%)
exceeded the 15s cap; 2 of 176 (1.1%) also exceeded the shared 30s
testTimeout, so deleting the override and inheriting the config is not
enough on its own. 60s clears all 176 with 1.7x headroom on the worst.

This is slow, not hung. Every body here is synchronous spawnSync, so
Vitest cannot interrupt one — the timer fires only after the body
returns and the reported duration is real elapsed time. That is why a
failure reads `× ... 22464ms` under `Test timed out in 15000ms`. The
work finished; the stopwatch was short. Seven reruns at one identical
head measured 2053 / 4680 / 5551 / 8732 / 13506 / 14868 / 21937ms — the
last of those would have been red on code that had not changed.

The 15s came from #8897, which raised this test off Vitest's built-in 5s
default because the job then ran bare `pnpm vitest run`. #8909 landed
3h27m later and pointed the job at config/vitest.config.ts, which is the
real fix for that. The constant stayed behind and has been the binding
budget ever since.
Absorbs #17077's completion-monitor absence fix (614044d). File sets are
disjoint, so the union is textual; the behavioural check is that #17085 still
reads the verdict through the one shared reader rather than a copy of its own,
and that the arity crossing that shipped red in the previous restack still
matches on both sides.
… from skipping the quit warning

The rule that only an explicit yes is a yes had two expressions. The one in
resolveLocalPtysSurviveQuit answers a typed in-process getter with a single
production call site whose every path returns a boolean literal: instrumented
across 35,022 tests it was evaluated 6 times, saw 'boolean' 6 times, and
discriminated 0 times, and both deleting the check and swapping it for Boolean()
reddened 0 of 115 while inverting it reddened 5. Deleted, since even a type
violation there is caught downstream.

The expression that survives is readWindowCloseRequestPayload, on the IPC hop
where the answer really is unknown. Its own tests were green, but its only
production call site was inline in the api object and no test in the tree
imported it — forwarding the raw payload instead reddened 0 of 11,136. Extracted
so the hop is reachable, and pinned: bypassing the reader now reddens 7,
weakening it to Boolean() 5, acking after the callback 1, echoing a raw
requestId 1, and dropping the unsubscribe 1.
Keeps this PR's widened proceedToNativeWindowClose(isQuitting, localPtysSurviveQuit)
and reads the close-request id from the coordinator instead of a ref the hook owns,
because most close requests never reach that function at all. The prompt suite now
drives dispatchWindowCloseRequest rather than the hook, carrying both arguments.
The quit decision reads two values through one reader, but only
`localPtysSurviveQuit` was defended against a malformed-but-truthy input.
Relaxing `isQuitting` to a bare truthiness check reddened nothing across the
131-test suite, while the same relaxation on its sibling redden 5.

`isQuitting` is not just the conjunct's other half: `collectWindowClosePtyIds`
drops SSH-backed panes from the evidence on a quit, so a truthy non-boolean
coerced to a yes closes over remote work with no probe and no warning, even
while the survival answer is a clean no. That third pin covers the read site
the two unit pins cannot.
brennanb2025 added a commit that referenced this pull request Aug 30, 2026
`native-smoke (windows-latest)` fails ~4.5% of runs on
`preserves a multiline argument through the compiled remote launcher`
with "Test timed out in 15000ms" — on unrelated PRs, for reasons that
have nothing to do with them. Across 176 sampled attempts it is the only
red that job produced, and it hit seven different PRs in two days:
#16900, #16904, #16915, #16955 (twice), #16979, #17014, #17085.

The test is six process creations: powershell.exe forks csc.exe, then
the freshly compiled orca.exe forks node.exe, twice. Hosted Windows
runners periodically slow process creation down, and this test amplifies
that far harder than anything else in the job. Comparing the 80 attempts
where it ran under 3s against the 12 where it ran over 12s, its own
median goes 2198ms -> 15917ms (7.2x) while the same file's
powershell-only test moves 556 -> 686ms (1.2x), the cmd.exe and Git Bash
process tests in the neighbouring file move 1.4x, and the other 35 files
put together move 1.5x.

Measured across those 176 attempts: 1881ms to 35438ms, p50 4264ms,
correlation +0.881 with the job's total Vitest duration. 8 of 176 (4.5%)
exceeded the 15s cap; 2 of 176 (1.1%) also exceeded the shared 30s
testTimeout, so deleting the override and inheriting the config is not
enough on its own. 60s clears all 176 with 1.7x headroom on the worst.

This is slow, not hung. Every body here is synchronous spawnSync, so
Vitest cannot interrupt one — the timer fires only after the body
returns and the reported duration is real elapsed time. That is why a
failure reads `× ... 22464ms` under `Test timed out in 15000ms`. The
work finished; the stopwatch was short. Seven reruns at one identical
head measured 2053 / 4680 / 5551 / 8732 / 13506 / 14868 / 21937ms — the
last of those would have been red on code that had not changed.

The 15s came from #8897, which raised this test off Vitest's built-in 5s
default because the job then ran bare `pnpm vitest run`. #8909 landed
3h27m later and pointed the job at config/vitest.config.ts, which is the
real fix for that. The constant stayed behind and has been the binding
budget ever since.
Merge Sim and others added 2 commits August 29, 2026 22:12
… provider onto daemon-provider-state

main (#17161) reduced daemon-init.ts to a re-export barrel, so this branch's three
hooks moved to daemon-provider-state.ts, which now owns the module-level adapter:

- strandedDegradedProvider declared beside adapter
- replaceDaemonProvider retains an outgoing DegradedDaemonPtyProvider
- localPtysSurviveQuit added there and re-exported through the daemon-init barrel,
  which is what src/main/index.ts and the fresh-import test harness both load

hasLiveFallbackPtys reads in-process state the execution host owns and is total,
so the survival answer has no "could not ask" case to collapse: it is a local
predicate, not a liveness verdict, and it still refuses to skip the quit warning
whenever a retired provider's app-owned shells are still running.
nwparker pushed a commit that referenced this pull request Aug 31, 2026
`native-smoke (windows-latest)` fails ~4.5% of runs on
`preserves a multiline argument through the compiled remote launcher`
with "Test timed out in 15000ms" — on unrelated PRs, for reasons that
have nothing to do with them. Across 176 sampled attempts it is the only
red that job produced, and it hit seven different PRs in two days:
#16900, #16904, #16915, #16955 (twice), #16979, #17014, #17085.

The test is six process creations: powershell.exe forks csc.exe, then
the freshly compiled orca.exe forks node.exe, twice. Hosted Windows
runners periodically slow process creation down, and this test amplifies
that far harder than anything else in the job. Comparing the 80 attempts
where it ran under 3s against the 12 where it ran over 12s, its own
median goes 2198ms -> 15917ms (7.2x) while the same file's
powershell-only test moves 556 -> 686ms (1.2x), the cmd.exe and Git Bash
process tests in the neighbouring file move 1.4x, and the other 35 files
put together move 1.5x.

Measured across those 176 attempts: 1881ms to 35438ms, p50 4264ms,
correlation +0.881 with the job's total Vitest duration. 8 of 176 (4.5%)
exceeded the 15s cap; 2 of 176 (1.1%) also exceeded the shared 30s
testTimeout, so deleting the override and inheriting the config is not
enough on its own. 60s clears all 176 with 1.7x headroom on the worst.

This is slow, not hung. Every body here is synchronous spawnSync, so
Vitest cannot interrupt one — the timer fires only after the body
returns and the reported duration is real elapsed time. That is why a
failure reads `× ... 22464ms` under `Test timed out in 15000ms`. The
work finished; the stopwatch was short. Seven reruns at one identical
head measured 2053 / 4680 / 5551 / 8732 / 13506 / 14868 / 21937ms — the
last of those would have been red on code that had not changed.

The 15s came from #8897, which raised this test off Vitest's built-in 5s
default because the job then ran bare `pnpm vitest run`. #8909 landed
3h27m later and pointed the job at config/vitest.config.ts, which is the
real fix for that. The constant stayed behind and has been the binding
budget ever since.
nwparker added a commit that referenced this pull request Aug 31, 2026
* fix(ssh): fence stale kills and retired pane replay

* fix(ssh): support cancellable interactive authentication

* fix(ssh): await remote catalog before snapshot adoption

* fix(pty): contain Windows ConPTY input failures

* fix(power): avoid redundant macOS display blocking

* perf(editor): narrow markdown override subscriptions

* fix(quick-open): close directory handles after reads

* refactor(linux): remove unused proc socket scanner

* fix(usage): apply flat Sonnet 4.6 pricing

* ci: prime Node next native test cache

* docs(skills): resolve snapshot cleanup data path

* fix(ssh): recover install locks after host reboot

* test(ssh): recognize boot-aware install locks

* test(ssh): prove previous-boot lock recovery live

* test(wire): pin pre-metadata release coverage

* fix(terminal): preserve remote tab ownership through recovery races

* test(runtime): fence replaced terminal handles in agent guard

* fix(ssh): preserve remote snapshot authority across polls

* fix(pty): contain late ConPTY output EPIPE

* test(pty): register Windows exit watcher before kill

* fix: close SSH and tab readiness race gaps

* fix(tabs): retain headless order and placeholder titles

* fix(build): avoid parallel electron-vite config race

* test(windows): avoid MSYS temp path rewriting

* test(windows): avoid killing exited PTY

* fix(pty): avoid late ConPTY input teardown race

* fix(terminal): sync reconnect error ownership after commit

* fix(runtime): use canonical worktree identity comparison

* test(ssh): assert complete cold-hydration baseline

* test(windows): invoke quoted retention fixture via PowerShell

* test(windows): read ConPTY grid through mode con

* fix(terminal): publish PTY replacements atomically

* fix(terminal): infer stale identity on reattach

* fix(terminal): fence stale pane PTY callbacks

* fix(terminal): fence stale pane binds after rebind

* fix(terminal): reject stale pane transport callbacks

* fix(terminal): fence mirrored reattach spawn callbacks

* fix(terminal): replace stale pane PTYs on remount

* fix(ci): size the Windows launcher-compile test budget from measurement

`native-smoke (windows-latest)` fails ~4.5% of runs on
`preserves a multiline argument through the compiled remote launcher`
with "Test timed out in 15000ms" — on unrelated PRs, for reasons that
have nothing to do with them. Across 176 sampled attempts it is the only
red that job produced, and it hit seven different PRs in two days:
#16900, #16904, #16915, #16955 (twice), #16979, #17014, #17085.

The test is six process creations: powershell.exe forks csc.exe, then
the freshly compiled orca.exe forks node.exe, twice. Hosted Windows
runners periodically slow process creation down, and this test amplifies
that far harder than anything else in the job. Comparing the 80 attempts
where it ran under 3s against the 12 where it ran over 12s, its own
median goes 2198ms -> 15917ms (7.2x) while the same file's
powershell-only test moves 556 -> 686ms (1.2x), the cmd.exe and Git Bash
process tests in the neighbouring file move 1.4x, and the other 35 files
put together move 1.5x.

Measured across those 176 attempts: 1881ms to 35438ms, p50 4264ms,
correlation +0.881 with the job's total Vitest duration. 8 of 176 (4.5%)
exceeded the 15s cap; 2 of 176 (1.1%) also exceeded the shared 30s
testTimeout, so deleting the override and inheriting the config is not
enough on its own. 60s clears all 176 with 1.7x headroom on the worst.

This is slow, not hung. Every body here is synchronous spawnSync, so
Vitest cannot interrupt one — the timer fires only after the body
returns and the reported duration is real elapsed time. That is why a
failure reads `× ... 22464ms` under `Test timed out in 15000ms`. The
work finished; the stopwatch was short. Seven reruns at one identical
head measured 2053 / 4680 / 5551 / 8732 / 13506 / 14868 / 21937ms — the
last of those would have been red on code that had not changed.

The 15s came from #8897, which raised this test off Vitest's built-in 5s
default because the job then ran bare `pnpm vitest run`. #8909 landed
3h27m later and pointed the job at config/vitest.config.ts, which is the
real fix for that. The constant stayed behind and has been the binding
budget ever since.

* fix(terminal): fence stale remount reattach ownership

* fix(terminal): reconcile mounted pane identity after replacement

* fix(terminal): fence stale reattach fallback ownership

* fix(terminal): fence deferred SSH reattach ownership

* fix(terminal): fence stale split pane ownership callbacks

* fix(terminal): keep stale spawns from consuming startup

---------

Co-authored-by: Brennan Benson <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* fix(ssh): fence stale kills and retired pane replay

* fix(ssh): support cancellable interactive authentication

* fix(ssh): await remote catalog before snapshot adoption

* fix(pty): contain Windows ConPTY input failures

* fix(power): avoid redundant macOS display blocking

* perf(editor): narrow markdown override subscriptions

* fix(quick-open): close directory handles after reads

* refactor(linux): remove unused proc socket scanner

* fix(usage): apply flat Sonnet 4.6 pricing

* ci: prime Node next native test cache

* docs(skills): resolve snapshot cleanup data path

* fix(ssh): recover install locks after host reboot

* test(ssh): recognize boot-aware install locks

* test(ssh): prove previous-boot lock recovery live

* test(wire): pin pre-metadata release coverage

* fix(terminal): preserve remote tab ownership through recovery races

* test(runtime): fence replaced terminal handles in agent guard

* fix(ssh): preserve remote snapshot authority across polls

* fix(pty): contain late ConPTY output EPIPE

* test(pty): register Windows exit watcher before kill

* fix: close SSH and tab readiness race gaps

* fix(tabs): retain headless order and placeholder titles

* fix(build): avoid parallel electron-vite config race

* test(windows): avoid MSYS temp path rewriting

* test(windows): avoid killing exited PTY

* fix(pty): avoid late ConPTY input teardown race

* fix(terminal): sync reconnect error ownership after commit

* fix(runtime): use canonical worktree identity comparison

* test(ssh): assert complete cold-hydration baseline

* test(windows): invoke quoted retention fixture via PowerShell

* test(windows): read ConPTY grid through mode con

* fix(terminal): publish PTY replacements atomically

* fix(terminal): infer stale identity on reattach

* fix(terminal): fence stale pane PTY callbacks

* fix(terminal): fence stale pane binds after rebind

* fix(terminal): reject stale pane transport callbacks

* fix(terminal): fence mirrored reattach spawn callbacks

* fix(terminal): replace stale pane PTYs on remount

* fix(ci): size the Windows launcher-compile test budget from measurement

`native-smoke (windows-latest)` fails ~4.5% of runs on
`preserves a multiline argument through the compiled remote launcher`
with "Test timed out in 15000ms" — on unrelated PRs, for reasons that
have nothing to do with them. Across 176 sampled attempts it is the only
red that job produced, and it hit seven different PRs in two days:
stablyai#16900, stablyai#16904, stablyai#16915, stablyai#16955 (twice), stablyai#16979, stablyai#17014, stablyai#17085.

The test is six process creations: powershell.exe forks csc.exe, then
the freshly compiled orca.exe forks node.exe, twice. Hosted Windows
runners periodically slow process creation down, and this test amplifies
that far harder than anything else in the job. Comparing the 80 attempts
where it ran under 3s against the 12 where it ran over 12s, its own
median goes 2198ms -> 15917ms (7.2x) while the same file's
powershell-only test moves 556 -> 686ms (1.2x), the cmd.exe and Git Bash
process tests in the neighbouring file move 1.4x, and the other 35 files
put together move 1.5x.

Measured across those 176 attempts: 1881ms to 35438ms, p50 4264ms,
correlation +0.881 with the job's total Vitest duration. 8 of 176 (4.5%)
exceeded the 15s cap; 2 of 176 (1.1%) also exceeded the shared 30s
testTimeout, so deleting the override and inheriting the config is not
enough on its own. 60s clears all 176 with 1.7x headroom on the worst.

This is slow, not hung. Every body here is synchronous spawnSync, so
Vitest cannot interrupt one — the timer fires only after the body
returns and the reported duration is real elapsed time. That is why a
failure reads `× ... 22464ms` under `Test timed out in 15000ms`. The
work finished; the stopwatch was short. Seven reruns at one identical
head measured 2053 / 4680 / 5551 / 8732 / 13506 / 14868 / 21937ms — the
last of those would have been red on code that had not changed.

The 15s came from stablyai#8897, which raised this test off Vitest's built-in 5s
default because the job then ran bare `pnpm vitest run`. stablyai#8909 landed
3h27m later and pointed the job at config/vitest.config.ts, which is the
real fix for that. The constant stayed behind and has been the binding
budget ever since.

* fix(terminal): fence stale remount reattach ownership

* fix(terminal): reconcile mounted pane identity after replacement

* fix(terminal): fence stale reattach fallback ownership

* fix(terminal): fence deferred SSH reattach ownership

* fix(terminal): fence stale split pane ownership callbacks

* fix(terminal): keep stale spawns from consuming startup

---------

Co-authored-by: Brennan Benson <[email protected]>
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Superseded by #18593.

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