Skip to content

Fix update checker 406 error and add menu feedback - #8

Merged
nwparker merged 1 commit into
mainfrom
nwparker/check-for-updates-fix
Mar 21, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/check-for-updates-fix

Conversation

@nwparker

Copy link
Copy Markdown
Contributor

Summary

  • Fix 406 error: electron-updater's GitHubProvider sends Accept: application/json to the GitHub web endpoint /releases/latest, which returns 406. Setting allowPrerelease = true bypasses this by extracting the version tag directly from the atom feed (which works). Safe since we don't publish prerelease versions.
  • Add menu feedback: "Check for Updates..." menu item now shows native dialogs ("You're on the latest version" / error details) instead of silently updating IPC state that's only visible on the Settings page.

Test plan

  • Build and launch the app
  • Use Orca > Check for Updates menu item — should show a dialog with result
  • Open Settings > Updates — "Check for Updates" button should still work as before
  • Verify auto-update check on launch still works

🤖 Generated with Claude Code

The GitHub /releases/latest endpoint returns 406 when electron-updater
requests it with Accept: application/json. Setting allowPrerelease=true
bypasses this by parsing the version from the atom feed directly.

The "Check for Updates" menu item now shows native dialogs so users get
feedback without needing to open Settings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nwparker
nwparker merged commit 76d884a into main Mar 21, 2026
brennanb2025 added a commit that referenced this pull request May 10, 2026
Adds `claudeHookService.installRemote(sftp, remoteHome)` and the supporting
SFTP primitives (`installer-utils-remote.ts`). Writes the same managed POSIX
hook script and `~/.claude/settings.json` shape as the local installer, but
to the remote box via the user's SFTP handle. The script body is verbatim
identical to the local one — the only difference is that on the remote it
sources `$ORCA_AGENT_HOOK_ENDPOINT` injected by the relay's pty-handler so
the curl POST goes to the relay's loopback hook server, not Orca's.

The merge logic stays in the existing `installer-utils.ts` (managed-command
matching, removeManagedCommands, hook-event sweep) so a future change to
hook-event mapping cannot drift between local and remote installs. Only the
fs primitives are SFTP-backed:

- atomic tmp+rename writes for settings.json (so a network drop mid-write
  cannot leave a truncated config Claude refuses to load)
- POSIX-only `mkdirp` walk for `~/.claude/` and `~/.orca/agent-hooks/`
- `chmod 0o755` on the managed script

Tests cover: malformed remote settings.json reports `error` rather than
silently overwriting; user-authored hook entries survive a fresh install
alongside the new managed ones; the rendered command paths point at the
remote-shaped script with the `[ -x ... ]` wrapper applied.

Per-CLI extension to Codex/Gemini/Cursor follows the same shape and is left
for a follow-up — the surface is established here so each CLI can add an
`installRemote` sibling without re-deriving the SFTP primitives.

See docs/design/agent-status-over-ssh.md §8 (commit #8).

Co-authored-by: Orca <help@stably.ai>
brennanb2025 added a commit that referenced this pull request May 11, 2026
…emote

Routes the relay-side `agent.hook` JSON-RPC notification into Orca's shared
`AgentHookServer` via the new `ingestRemote(envelope, connectionId)` entry
point that bypasses the local HTTP path. Stamps `connectionId` from
`SshRelaySession.targetId` so the renderer can drop in-flight events for
connections that have torn down.

After wiring is in place, issues `agent_hook.requestReplay` so any cached
last-status payloads on the relay (held during reconnect / before-handler-up
gaps) survive the reattach. -32601 is silently absorbed for forward-compat
with older relay binaries.

Gated by ORCA_FEATURE_REMOTE_AGENT_HOOKS so the new path stays dark until the
remote installer flow lands (commit #8). Adds focused unit tests for
`ingestRemote` happy/malformed paths.

See docs/design/agent-status-over-ssh.md §5 Path 1 + §8 (commit #5).

Co-authored-by: Orca <help@stably.ai>
brennanb2025 added a commit that referenced this pull request May 14, 2026
…emote

Routes the relay-side `agent.hook` JSON-RPC notification into Orca's shared
`AgentHookServer` via the new `ingestRemote(envelope, connectionId)` entry
point that bypasses the local HTTP path. Stamps `connectionId` from
`SshRelaySession.targetId` so the renderer can drop in-flight events for
connections that have torn down.

After wiring is in place, issues `agent_hook.requestReplay` so any cached
last-status payloads on the relay (held during reconnect / before-handler-up
gaps) survive the reattach. -32601 is silently absorbed for forward-compat
with older relay binaries.

Gated by ORCA_FEATURE_REMOTE_AGENT_HOOKS so the new path stays dark until the
remote installer flow lands (commit #8). Adds focused unit tests for
`ingestRemote` happy/malformed paths.

See docs/design/agent-status-over-ssh.md §5 Path 1 + §8 (commit #5).

Co-authored-by: Orca <help@stably.ai>
brennanb2025 added a commit that referenced this pull request May 14, 2026
Adds `claudeHookService.installRemote(sftp, remoteHome)` and the supporting
SFTP primitives (`installer-utils-remote.ts`). Writes the same managed POSIX
hook script and `~/.claude/settings.json` shape as the local installer, but
to the remote box via the user's SFTP handle. The script body is verbatim
identical to the local one — the only difference is that on the remote it
sources `$ORCA_AGENT_HOOK_ENDPOINT` injected by the relay's pty-handler so
the curl POST goes to the relay's loopback hook server, not Orca's.

The merge logic stays in the existing `installer-utils.ts` (managed-command
matching, removeManagedCommands, hook-event sweep) so a future change to
hook-event mapping cannot drift between local and remote installs. Only the
fs primitives are SFTP-backed:

- atomic tmp+rename writes for settings.json (so a network drop mid-write
  cannot leave a truncated config Claude refuses to load)
- POSIX-only `mkdirp` walk for `~/.claude/` and `~/.orca/agent-hooks/`
- `chmod 0o755` on the managed script

Tests cover: malformed remote settings.json reports `error` rather than
silently overwriting; user-authored hook entries survive a fresh install
alongside the new managed ones; the rendered command paths point at the
remote-shaped script with the `[ -x ... ]` wrapper applied.

Per-CLI extension to Codex/Gemini/Cursor follows the same shape and is left
for a follow-up — the surface is established here so each CLI can add an
`installRemote` sibling without re-deriving the SFTP primitives.

See docs/design/agent-status-over-ssh.md §8 (commit #8).

Co-authored-by: Orca <help@stably.ai>
LesleyMurfin referenced this pull request in LesleyMurfin/orca Jun 20, 2026
…w (4 fixes)

NotebookLM peer review verdict: CHANGES-NEEDED. Applied the genuine
findings (assessed against actual Electron/Node behavior; teardown was
the only hypothesis NLM rated already-Established):

- fix #7: also override XDG_RUNTIME_DIR (scratch, mode 0700) -- Chromium/
  Electron IPC sockets live there (/run/user/UID, shared w/ prod) and are
  NOT covered by app.getPath('userData').
- fix #8: PRE-7b df -h /tmp gate -- --appimage-extract-and-run unpacks the
  full ~400-600MB squashfs into shared /tmp; a full /tmp could hang prod.
- fix #9: correct Step 4 + acceptance #2 -- under the HOME override,
  homedir() resolves to the scratch home, so expect that cwd (avoids a
  false-negative wrong-cwd failure).
- fix #10: documented prod-recovery pointer for Lesley (systemctl restart
  / orca-serve-version restore); STOP-first posture retained per the
  never-hotfix / deviation=STOP governance.

Execution remains GATED on Lesley's approval. Notebook:
cf8d676b-fb68-4f01-9388-922b83568759

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ppw-stack added a commit to ppw-stack/orca that referenced this pull request Jun 29, 2026
Address three documentation and test-coverage findings from /review on
PR stablyai#6752.

1. mobile/src/i18n/README.md (#6)
   The "Translation keys" section still described a PR1/PR2 split with
   ~30 + ~470 keys across only {en,zh}.json. v2 ships 1004 keys across
   all 5 locales with strict parity. Refreshed to reflect the actual
   rollout and add a sentence on interpolation syntax + pluralization
   (the recent #1 fix made this distinction load-bearing).
   Also refreshed "Testing" to note the hook now has a real rendered
   test instead of the original "no RN test infrastructure" framing.

2. docs/superpowers/specs/2026-06-29-mobile-i18n-v2-design.md (#7)
   The "metro.config.js 兼容性" section said "v2 PR1 must retain v1's
   full metro.config.js changes (watchFolders + nodeModulesPaths +
   disableHierarchicalLookup)". Actual implementation:
     - only added watchFolders = [sharedRoot, i18nLocalesRoot]
     - did NOT add nodeModulesPaths
     - did NOT add disableHierarchicalLookup (which broke pnpm's
       @expo/metro-runtime resolution during local validation)
   Updated the section to describe the actual minimal change with a
   "Spec 修订说明" callout explaining why the original draft was
   wrong and how the v2 implementation ended up aligned with upstream
   defaults.

3. mobile/src/i18n/__tests__/useTranslate.test.ts (stablyai#8)
   The previous test reimplemented the hook's t() closure inline
   instead of calling the real hook — so any regression in
   useTranslate itself would still pass. Replaced with a real hook
   test:
     - Renders a tiny HookHost component via react-dom's createRoot
     - Captures the hook's return value through a useEffect callback
     - Asserts resolvedLanguage === 'zh' (the active language)
     - Asserts fallback path (missing key → defaultValue)
     - Asserts hit path (existing zh key → '设置' not 'Settings')
   Uses `@vitest-environment jsdom` per-file directive to opt in to
   DOM access for `document.createElement('div')` while keeping the
   rest of the mobile test suite on the faster 'node' environment.
   jsdom is already in mobile's transitive deps.

Verification:
- pnpm test: 147/147 files, 979 tests pass
- pnpm exec tsc --noEmit: No errors
- pnpm exec oxlint: clean
- pnpm run verify:localization-catalog: 5 locales × 10903 keys
- pnpm run verify:localization-coverage: 208 allowlisted
brennanb2025 added a commit that referenced this pull request Jul 5, 2026
…ted, harden park claim/title (review round 1)

- Warm set never engaged through the real UI: a visible tab was absent from
  terminalPaneMountByTabId, so it unmounted in the same commit it flipped hidden
  and never reported the hide — the managed/warm/park pipeline was unreachable.
  Include visible tabs in the mount map (and prune stale visible ids on close).
- Activity-page terminal portals: an aged-out worktree opened via Activity never
  re-entered the mounted-worktree set, so its overlay layer (and the portaled
  pane) never rendered. Add portal worktrees to the flag-ON mounted set.
- park() claim race: the parked-entry release happened at bind but adoption is
  deferred to a rAF; a dispose before attach orphaned the live PTY (gate #8).
  Defer the release to bindActivePanePty (the adoption chokepoint).
- Parked split-tab titles: the parked onTitleChange drove the tab title
  unconditionally and skipped synthetic-title suppression; mirror the live
  handler's active-pane + Codex-synthetic guards.

Regression tests added for the warm-set transition and the claim-before-adopt
race. Full terminal unit suites + typecheck green.

Co-authored-by: Orca <help@stably.ai>
Jinwoo-H added a commit that referenced this pull request Jul 8, 2026
removeProject now derives the runtime target via settingsForRepoOwner
(threaded with the explicit hostId) instead of getProjectSetupRuntimeTarget.
settingsForRepoOwner already pins runtime owners to their env and clears the
focused runtime for SSH/local owners, so an explicit SSH host removal still
routes local while focused-runtime repos route their repo.rm RPC. The prior
change ignored the focused runtime env for repos with no explicit
executionHostId, breaking three runtime-routing tests.

Add an SSH-explicit-host removeProject regression test.

Co-authored-by: Orca <help@stably.ai>
brennanb2025 added a commit that referenced this pull request Jul 8, 2026
…ted, harden park claim/title (review round 1)

- Warm set never engaged through the real UI: a visible tab was absent from
  terminalPaneMountByTabId, so it unmounted in the same commit it flipped hidden
  and never reported the hide — the managed/warm/park pipeline was unreachable.
  Include visible tabs in the mount map (and prune stale visible ids on close).
- Activity-page terminal portals: an aged-out worktree opened via Activity never
  re-entered the mounted-worktree set, so its overlay layer (and the portaled
  pane) never rendered. Add portal worktrees to the flag-ON mounted set.
- park() claim race: the parked-entry release happened at bind but adoption is
  deferred to a rAF; a dispose before attach orphaned the live PTY (gate #8).
  Defer the release to bindActivePanePty (the adoption chokepoint).
- Parked split-tab titles: the parked onTitleChange drove the tab title
  unconditionally and skipped synthetic-title suppression; mirror the live
  handler's active-pane + Codex-synthetic guards.

Regression tests added for the warm-set transition and the claim-before-adopt
race. Full terminal unit suites + typecheck green.

Co-authored-by: Orca <help@stably.ai>
AmethystLiang added a commit that referenced this pull request Jul 28, 2026
…C1 review #8)

isEvictionExemptTerminalTab read only tab.ptyId — the FIRST leaf's pty —
while the coverage veto that makes a worktree a retention candidate walks
every pane. A split tab whose second leaf held an unrestorable pty therefore
failed coverage (→ force-park target) yet looked exempt-free, so force-park
unmounted it and orphaned the live shell. The exemption now resolves panes
through the same resolveParkedTerminalPaneCandidates, keeping tab.ptyId in
the union for the no-layout/no-capture case.

Also from the same review round:
- force-park's capture passes includeLocalBuffers:false like every other
  shutdownBufferCaptures caller; it was serializing up to 512KB/pane of
  scrollback into the store inside a fix meant to bound renderer heap.
- Terminal.tsx unmount resets the scrollback-demotion registry — module
  state with no reset path, read by a pane effect that runs before the host
  effect that would clear it, so a stale verdict trimmed restore replays.
- memoize watcher coverage per tab within the parking pass; the retention
  candidates re-asked it for every mounted worktree, not just the parked few.
AmethystLiang added a commit that referenced this pull request Jul 28, 2026
…C1 review #8)

isEvictionExemptTerminalTab read only tab.ptyId — the FIRST leaf's pty —
while the coverage veto that makes a worktree a retention candidate walks
every pane. A split tab whose second leaf held an unrestorable pty therefore
failed coverage (→ force-park target) yet looked exempt-free, so force-park
unmounted it and orphaned the live shell. The exemption now resolves panes
through the same resolveParkedTerminalPaneCandidates, keeping tab.ptyId in
the union for the no-layout/no-capture case.

Also from the same review round:
- force-park's capture passes includeLocalBuffers:false like every other
  shutdownBufferCaptures caller; it was serializing up to 512KB/pane of
  scrollback into the store inside a fix meant to bound renderer heap.
- Terminal.tsx unmount resets the scrollback-demotion registry — module
  state with no reset path, read by a pane effect that runs before the host
  effect that would clear it, so a stale verdict trimmed restore replays.
- memoize watcher coverage per tab within the parking pass; the retention
  candidates re-asked it for every mounted worktree, not just the parked few.
AmethystLiang added a commit that referenced this pull request Jul 29, 2026
…(C1) (#10625)

* fix(terminal): park SSH worktrees like local ones (C1 retention, slice A)

SSH ptys were blanket-excluded from hidden-view parking, so a hidden SSH
worktree retained every pane forever (C1: renderer heap climbs to the V8
ceiling). SSH bytes transit local main — fact-mode watchers already cover
them, and main keeps a headless model served over pty:getMainBufferSnapshot
that the SSH reattach path never consulted.

- isParkRestorableTerminalPty: snapshot-backed OR (SSH + policy); threaded
  through both park verdicts, both selectors, watcher coverage, and the
  watcher start guard. Remote-runtime/fail-open/foreign/null unchanged.
- Parked-SSH reveal paints from main's headless model (dimension-matched,
  ~5k rows) and degrades to the relay 100KiB replay unless the snapshot is a
  non-empty source==='headless' payload — never a blank/stale paint.
- Kill switch: settings.terminalSshViewParking (default on).

DESIGN.md records the approved plan and the H1 magnitude non-claim.

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): bound hidden-worktree retention with a force-park budget (C1, slice B)

Un-parkable worktrees (remote-runtime ptys, uncoverable tabs, SSH with the
slice-A switch off) had unlimited retention: the parking cap/TTL only ever
saw eligibility-passing worktrees, so one bad tab pinned a whole worktree's
panes forever. Retention is now memory-bounded, not eligibility-bounded.

- terminal-hidden-worktree-retention.ts: retention budget (12 hidden / 45min
  TTL, sized from the measured 2.5-19MB per-pane V8 cost, DESIGN.md §2) over
  hidden worktrees ordinary parking can never evict; reuses the hot-retain
  ranking so last-active exemption, deterministic ties, and deadline-driven
  rechecks hold. Fail-open/foreign-pty tabs are eviction-exempt (a remount
  would fresh-spawn and orphan the live shell).
- Terminal.tsx: force-parked ids join the parked set AFTER the coverage veto
  (darkness for uncoverable tabs is the accepted cost); buffers captured via
  the sleep-flow registry before the unmount render; retention TTL added to
  the recheck deadlines for budget candidates only.
- Verdict stays out of its own effect deps; policy test asserts idempotence
  and time-monotone membership (flip-loop dwell regression).
- Kill switch: settings.terminalHiddenWorktreeRetentionBudget (default on).

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): demote hidden scrollback for eviction-exempt worktrees (C1, slice C)

The retention budget (slice B) must exempt worktrees holding fail-open or
foreign-worktree ptys — a remount would fresh-spawn and orphan the live
shell — which would leave that class unbounded again. Instead, past the same
45min retention TTL their hidden panes drop to the minimum scrollback tier
(measured: ~19MB -> ~1.3MB V8 heap per 50k-row pane; trimmed history is
gone by design, reveal restores the configured cap for future output).

- terminal-hidden-scrollback-demotion.ts: module-state verdict registry
  (parked-watcher pattern) with content-equality notify damping; applied in
  the existing scrollback-rows effect in use-terminal-pane-lifecycle.
- selectScrollbackDemotedTerminalWorktrees: pure, TTL-gated, time-monotone.
- Retention TTL wakeups now also cover exempt worktrees so demotion fires.
- Kill switch: settings.terminalHiddenScrollbackDemotion (default on).

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): paint the SSH model snapshot inline, not via nested coordinator (C1 slice A fix)

applyMainBufferSnapshot runs its own structuralReplayCoordinator.run; calling
it from applyReattachPayload (already inside the coordinator when a relay
replay exists) deadlocks on the coordinator's tail chain. The model paint now
mirrors the daemon-snapshot branch inline (folded scrollback + rehydrate +
screen, dimension-matched, escape tail last) and arms the restored-snapshot
seq baseline so deferred/live chunks the snapshot covers dedupe instead of
double-painting. Also falls through (no early return) so reattachPayloadApplied
still latches. Adds the folder-workspace id parity unit case.

Co-authored-by: Orca <help@stably.ai>

* test(terminal): SSH park+reveal e2e round-trip + as-built design notes (C1)

Docker-gated (ORCA_E2E_SSH_DOCKER=1) spec: SSH tab parks behind a decoy and
reveal restores marker content at multi-viewport scrollback depth. DESIGN.md
records the as-built deltas (inline paint, force-park shape, last-active
floor) and the residuals so follow-ups aren't lost.

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): paint SSH reveal from main's model even when the relay replay is empty (C1 review #1)

A relay restart empties the replay buffer; the reveal previously painted
nothing even when main's headless model held the session. The reattach now
prefetches the model snapshot when no structural replay exists (SSH-shaped
ptys only) and paints it inside the coordinator; emptiness is judged on the
composed payload (scrollbackAnsi + data + pendingEscapeTailAnsi) so an
alt-screen snapshot with an empty screen frame still paints.

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): decouple scrollback demotion (slice C) from the retention-budget switch (C1 review #2)

Per the approved contract each slice reverts behind its own switch: slice C
now requires only the master terminalHiddenViewParking plus its own
terminalHiddenScrollbackDemotion flag. The TTL wakeup timer fires for
demotion candidates even with the budget switch off. No DEFAULT_SETTINGS
entries exist for sibling flags (defaults are the '!== false' optional
pattern), so no explicit defaults are added.

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): scope eviction exemption to the tab, not the worktree (C1 review #3)

One eviction-exempt tab (fail-open/foreign pty) previously vetoed force-park
for its whole worktree, pinning co-located remote-runtime tabs forever. The
worktree now force-parks while exempt tabs keep their mounted panes via a
per-tab exclusion mirroring the Activity-portal pattern (legacy watcher sync,
legacy render, and the overlay cold-parking hook). Ordinary parking is
untouched — a worktree with an exempt tab still cannot ordinary-park.
Slice C now also demotes exempt tabs' panes as soon as their worktree
force-parks under the count budget (they are the only panes left mounted).

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): demote un-parkable worktrees the force-park lever spared (C1 review #4)

The last-active exemption means a single hidden un-parkable worktree never
force-parks — and slice C previously only targeted exempt-tab worktrees, so
its panes held full scrollback forever. Demotion now also covers un-parkable
non-exempt worktrees past the retention TTL that are absent from the
force-parked set (last-active spared, or slice B switched off). Membership
stays time-monotone for fixed inputs; covered by new idempotence/monotone
selector tests.

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): keep the hidden clock running through transient background-measure windows (C1 review #5)

Whole-worktree background mounts (browser-automation bootstrap lease, mobile
mounts, agent wakes) open a ~3s self-clearing measure window that previously
deleted hiddenSince — every remount restarted the 30s hysteresis and the
45min retention TTL, so a periodically re-mounted force-parked worktree
never re-parked. The measure window still pauses parking/eviction verdicts
(all selectors skip measuring candidates); only the clock survives, so the
prior verdict resumes as soon as the window closes. Visible and
portal-holding worktrees still reset the clock.

Co-authored-by: Orca <help@stably.ai>

* test(terminal): make the SSH park+reveal depth assertion prove the model paint (C1 review #6a)

Pad the session with ~180KB of output after the numbered markers so the
earliest marker falls outside the relay's 100KiB rolling replay buffer while
staying inside main's ~5k-row headless model; asserting marker_1 after
reveal now proves the headless-model paint rather than passing under the
relay fallback.

Co-authored-by: Orca <help@stably.ai>

* docs(terminal): rewrite DESIGN.md as the single as-built C1 contract (review #7)

One contract matching the code: status IMPLEMENTED around force-park (not
the unmount proposal), real kill-switch names with coupling + revert
matrices, the true retention-floor formula with measured per-pane and
demotion numbers, an explicit when-OOM-is-still-possible paragraph naming
the H2 pendingSideEffects residual, the applyMainBufferSnapshot deadlock
constraint inside the slice-A section, stable-signal phrasing instead of a
capability latch, fail-open AND foreign-worktree exemption class, verified
cites, and a planned/landed/follow-up test matrix.

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): resolve the eviction exemption per pane, not per tab (C1 review #8)

isEvictionExemptTerminalTab read only tab.ptyId — the FIRST leaf's pty —
while the coverage veto that makes a worktree a retention candidate walks
every pane. A split tab whose second leaf held an unrestorable pty therefore
failed coverage (→ force-park target) yet looked exempt-free, so force-park
unmounted it and orphaned the live shell. The exemption now resolves panes
through the same resolveParkedTerminalPaneCandidates, keeping tab.ptyId in
the union for the no-layout/no-capture case.

Also from the same review round:
- force-park's capture passes includeLocalBuffers:false like every other
  shutdownBufferCaptures caller; it was serializing up to 512KB/pane of
  scrollback into the store inside a fix meant to bound renderer heap.
- Terminal.tsx unmount resets the scrollback-demotion registry — module
  state with no reset path, read by a pane effect that runs before the host
  effect that would clear it, so a stale verdict trimmed restore replays.
- memoize watcher coverage per tab within the parking pass; the retention
  candidates re-asked it for every mounted worktree, not just the parked few.

* docs(terminal): drop DESIGN.md — the as-built C1 contract moves to the PR body

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): cap the deferred PTY side-effect queue (C1 residual H2)

pendingSideEffects grew without bound under background timer throttling
(~64 drained/s vs hundreds queued/s overnight). Cap at 512 entries with
oldest-first eviction: titles drop (last-wins), a pending bell latches
onto the next survivor, agent-status payloads collapse onto the survivor
keeping the newest 16 (last-wins store state, KB-scale strings).

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): carry command-lifecycle facts through parked watchers (C1 follow-up)

Parked fact-mode watchers omitted onCommandFinished/onCommandCode*, so
OSC 133;D and Command Code scrape signals went dark while parked. New
parked-terminal-command-status.ts ports the store-level subset: git-UI
nudge on every command finish, same-turn status-row drop for SSH PTYs
(exact mounted-path parity — the foreground tracker refuses SSH ids),
and the Command Code working seed / 1500ms done settle. Byte mode scans
the same shared parsers for authority-off parity. Local-PTY status drops
stay with the mounted pane: they need pty-connection's process-confirm
ladder to tell a leaked nested-shell 133;D from a real agent exit.

Co-authored-by: Orca <help@stably.ai>

* test(terminal): retention-budget force-park e2e with a retentionLimit override (C1 6b)

ORCA_E2E_TERMINAL_RETENTION_LIMIT flows preload → e2e-config →
getTerminalParkingPolicyOverrides (exposeStore-gated, positive-integer
only) so a spec can shrink the force-park budget to 1. The Docker-gated
spec opens two remote worktrees on one relay target (second pre-seeded
remote repo), disables terminalSshViewParking to make both un-parkable,
hides both behind the local context, and proves the older one force-parks
while the last-active exemption spares the newest; re-activating the
evicted worktree restores the marker tail via relay replay.

Co-authored-by: Orca <help@stably.ai>

* test(terminal): retention-budget e2e via same-repo remote worktrees (passes docker lane)

The first draft added a second remote repo mid-session, whose pane pty
spawn misroutes to the local daemon with the remote cwd (pre-existing
multi-repo issue, reproducible without any retention override — a seeded
local repo plus one remote repo shows the same misroute). The spec now
budgets across three worktrees of the ONE connected repo, created through
the product createWorktree path (an external git-worktree-add only lands
as a detected worktree needing adoption) and polled through the relay's
transient post-connect reconnect window. Verified green on the local
Docker lane in 20.8s.

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): prevent remount thrashing during post-measure cool-down (

Implements the C1 retention contract: preserve worktree `hiddenSinceMs` through a
background-measure window (so TTL/ranking stay honest), but re-park waits for a
full `coldParkDelayMs` cool-down after the measure ends. Without the cool-down,
every ~3s measure lease on a past-deadline worktree thrashes remount/reattach.

Core changes:
- Terminal.tsx: add measure clock (measuringTerminalWorktreeIdsRef) and post-measure
  cool-down tracking (terminalWorktreeParkCooldownUntilRef); gate parking candidates
  until cool-down expires.
- Extract snapshot replay choreography to shared terminal-snapshot-replay-paint.ts
  (used by SSH reattach + daemon restore paths).
- Add SSH model snapshot timeout (750ms) with fallback to relay replay.
- Move cold-park recheck deadline logic to terminal-cold-park-recheck-deadlines.ts;
  add cool-down deadline to scheduling.
- useTerminalTabColdParking: implement matching measure-clock contract with per-tab
  cool-down gate to keep tab deadlines synced with worktree retention clock.
- Add resolveTerminalMountScrollbackRows() to demote new xterms under demoted
  worktrees (pane births during demotion must take the demoted tier at create).
- Add kill switches: terminalSshViewParking, terminalHiddenWorktreeRetentionBudget,
  terminalHiddenScrollbackDemotion.

* fix(terminal): detect Command Code completion in parked mid-turn panes

Seed the byte watcher with in-flight turn state from agent status: the
watcher is recreated per park cycle with no startup command to arm it,
and the banner scrolled away before parking. Also memoize
eviction-exempt checks and use SSH PTY ID builder in tests.

* fix(terminal): flush pending command-code settles on reveal remount

When a parked pane reveals mid-Command Code turn, the new detector
cannot re-observe the already-passed idle composer. Cancelling the settle
leaves the row stranded at 'working', so dispose now flushes the pending
settle instead.

Extract readInFlightCommandCodeTurn to shared space and seed detectors
with in-flight turns so remounts complete mid-flight commands. Also
memoize SSH model probes to prevent double timeouts on reattach.

* fix(terminal): remove scrollback demotion (C1 slice C)

The scrollback demotion feature for eviction-exempt hidden worktrees is no longer needed. Retention budget limits are now sufficient without this additional bound. Remove the terminal-hidden-scrollback-demotion module, the selectScrollbackDemotedTerminalWorktrees function, and related per-pane demotion logic.

* test(terminal): assert bounded probe during stalled reveal

Add assertion to verify that a stalled reveal operation makes exactly one
`getMainBufferSnapshot` call, ensuring retry logic doesn't introduce
redundant probes that would extend the timeout window before relay fallback.

* fix(terminal): implement C1 retention budget for hidden parked worktrees

Addresses OOM regressions in hidden parked terminals by force-evicting
worktrees past a retention budget: at most 12 mounted while hidden, none
past 45 minutes (absolute, not exempted by last-active). Eviction is
least-recently-hidden-first. Exempt tabs (unrestorable local PTYs) keep
their panes to avoid orphaning shells; worktrees are force-parked even
if they contain exempts, and their buffers released elsewhere. SSH/remote
worktrees serialize buffers pre-eviction for reveal; local worktrees keep
daemon snapshots. Command Code's done-settle window is transferred across
park/reveal boundaries so the row cannot strand at 'working'. Model probe
on SSH reattach is scoped to park-reveal only, not ordinary reconnects.
Includes new E2E suite proving the budget actually releases memory.

* memoize eviction-exempt terminal tabs to avoid redundant store reads

Each tab's exemption check re-reads the store and walks the layout tree.
Introduce selectEvictionExemptTerminalTabIds() to resolve all exempt tabs
for a worktree in a single pass, then memoize the result in Terminal.tsx
and useTerminalTabColdParking. This prevents O(n) store reads when checking
exemptions across multiple tabs and ensures the set remains stable across
unrelated re-renders.

* refactor: reformat hidden-worktree retention comments

Reflow to 80-character lines and remove internal ticket references
(C1, C1 slice C).

* fix(lint): split overlay slot and eviction-exempt tabs under max-lines

Static analysis failed because TerminalPaneOverlayLayer (401) and
terminal-parked-tab-watchers (304) exceeded oxlint max-lines. Extract the
slot component and eviction-exempt helpers into dedicated modules.

* test(terminal): stabilize retention budget e2e control arm

Stage un-parkable remote pty ids only after both worktrees are hidden, and
keep re-staging during the control-arm poll so a late updateTabPtyId cannot
flip the decoy back to park-restorable and ordinary-park it before budget
engages.

* test(terminal): pin retention e2e decoy to a mounted pane snapshot

Use the active pane-identity snapshot for the decoy tab instead of all
worktree tabs, and re-assert un-parkable ids after the control-arm hold so
a deferred/empty tab id cannot fail the budget-off mounted-count check.

* fix: memoize terminal eviction exemptions on layout leaf PTYs

Splits add leaf panes to the layout store without changing the tabs
array. A memo keyed only on tabs misses this change, leaving new panes
unexempted for unmount. Include layout leaf PTYs in the exemption memo
key so it recalculates when splits occur or PTYs are re-minted.

---------

Co-authored-by: Orca <help@stably.ai>
scolety1 added a commit to scolety1/orca that referenced this pull request Sep 10, 2026
…ble/mishandled across every chat surface -- P1, live-confirmed

Real, previously-undisclosed finding, same severity class as findings
stablyai#7/stablyai#8 (PAUSE/RESUME/ADOPT HTTP-reachability): command-multi-action-
bridge.mjs's classifyMultiActionEntries gate (deliberately conservative,
>=2 targets AND >=2 distinct intents) is the ONLY place
EXTERNAL_WORK_HOLD/applyExternalWorkHold -- setting a real, durable
project execution hold -- is handled anywhere in this codebase. Its own
comment assumed a genuinely single-target hold request had "its own
existing, correct handling" elsewhere; it never did. Live-reproduced
over the real HTTP /api/chat route before fixing: a natural message
like "NWR is being handled by another agent, leave it alone" on BOTH
per-project chat and Global Command exact-match never set a real hold,
with a generic fallback response giving no honest indication anything
failed. Safety-relevant, not just UX: a hold exists specifically to
prevent unwanted concurrent work, so an operator believing they'd
protected a project (and acting on that belief) when they silently had
not is a real risk.

Root cause confirmed: decomposeMultiAction (the real per-clause
decomposer, already reused by the working >=2-target gate) already
correctly classifies a single-target hold clause as EXTERNAL_WORK_HOLD
-- detection was fine, only the gating was too narrow.

Fixed with a new, narrower ADDITIONAL gate,
classifySingleTargetHoldEntries (exactly 1 target + has an
EXTERNAL_WORK_HOLD entry), wired into:
- command-responder.mjs (fixes Global Command's ambiguous-match
  surface)
- chat-http-routes.mjs directly (fixes per-project chat + exact-match
  Global Command, mirroring stablyai#7/stablyai#8's own precedence gate: loses to
  research/TIM_REQUIRED/adoption)
Both reuse the same real, proven respondMultiActionCommand execution
path, never a second implementation.

Three independent red-team review rounds, two real issues found and
fixed before this landed:
- Round 1: (a) a precedence gap in chat-http-routes.mjs -- a message
  combining a genuine PAUSE/RESUME directive with a genuine hold
  directive for the SAME project silently executed the run-action and
  DROPPED the hold entirely, reporting complete success with no honest
  indication. Fixed by computing the hold check independently and
  merging both real outcomes when both fire, never letting one silently
  shadow the other. (b) A test-quality gap -- the original "wrong
  project" test proved the end-to-end outcome but didn't isolate which
  of two real, redundant safety layers did the work; a regression in
  just one layer shipped silently, masked by the other. Fixed with a
  dedicated unit test isolating classifySingleTargetHoldEntries
  directly.
- Round 2 (re-checking round 1's fixes): both confirmed clean,
  independently re-verified with the reviewer's own live reproductions
  and mutations -- PLUS one more real finding, the identical bug shape
  in command-responder.mjs (a different file round 1 never touched):
  its own singleTargetHoldEntries check also returned early, before
  classifyRunActionVerb ever ran, so the same combined pause+hold
  message reaching respondCommand via Global Command's ambiguous path
  silently dropped the pause. Fixed with the same merge pattern (a
  mergeMatchingHold helper wired into all 4 PAUSE/RESUME success/
  failure return points); the RESUME-reclassified-to-DISPATCH path was
  deliberately left as a disclosed, lower-priority residual gap
  (different response shape, silently omits rather than corrupts).
- Round 3 (re-checking round 2's newest fix): fully clean across all 5
  checked dimensions, including independent live reproduction of the
  disclosed RESUME->DISPATCH gap (confirmed safe: no crash, no
  fabricated claim, no wrong-project write, just an honest omission)
  and independent reproduction of the author's own mutation-testing
  claim.

Wrong-project risk (the exact class stablyai#8's own review rounds found)
checked and confirmed safe by construction, independently verified by
2 reviewers: chat-http-routes.mjs passes only [project] (the chat's own
fixed scope) to the decomposer, so it structurally cannot resolve a
different, unlisted project as a target at all; respondMultiActionCommand
itself also independently validates the resolved project exists before
ever writing, a second, redundant safety layer.

10 new/modified tests across 2 files, 138/138 green across every real
caller and related surface-parity/dispatch-bridge/follow-up-context
test file. Every fix mutation-verified, several verified independently
by more than one reviewer using their own separate mutations.

TSF Overnight Control-Plane Burn-In V2. Finding stablyai#16.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CdU7C6R8tKG5diqfdjNCPp
scolety1 added a commit to scolety1/orca that referenced this pull request Sep 11, 2026
…ion, not a bug

Traced the real code path (chat-http-routes.mjs) rather than assuming:
respondCommand IS already reached from the per-project chat HTTP
route, but only on its own Global-Command-style ambiguous fallback --
a genuinely project-scoped thread (body.projectId set) never reaches
it, and so never reaches the 4 global-scope bridges (dogfood/self-
improvement/fleet-attention/runtime-identity). Unlike stablyai#7/stablyai#8 (an
unambiguous defect -- "pause it" in a project's own chat clearly means
that project), whether a project-scoped thread should answer
fleet-wide questions at all is a real product decision this session
declined to make unilaterally. Updates §7's disclosure and §17's next
step to reflect this -- not pursued further, correctly re-deferred
with sharper reasoning rather than mechanically wired in.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CdU7C6R8tKG5diqfdjNCPp
gaberudy added a commit to goldenhelix/vsagent that referenced this pull request Sep 12, 2026
Ported the VSAgent brand mark and the CLI help-text rebrand seam, plus one
package.json script addition, per B5 (stablyai#6, stablyai#8, stablyai#9, stablyai#10, stablyai#14):

- resources/vsagent.svg: net-new flat SVG logo (blue #068AFE mark), copied
  verbatim from the fork (no upstream collision).
- src/renderer/web-index.html: title -> "VSAgent"; inlined SVG favicon (data:
  URI, base64) since `orca serve`'s static handler only exposes
  /web-index.html and /assets/*. Re-derived the base64 from this commit's own
  resources/vsagent.svg (base64 -w0) rather than copying the fork's literal
  string, then diffed byte-for-byte against the fork's inlined value to
  confirm they match exactly.
- src/renderer/src/assets/main.css: added the 9-line `.titlebar-brand-logo`
  rule immediately after `:root:not(.dark) .titlebar-logo { filter:
  invert(1); }` — the VSAgent mark is full-color and must not be inverted in
  light mode the way the monochrome Orca mark is.
- src/cli/help.ts: added `brandHelpText()` (rewrites /\bOrca\b/ and /\borca\b/
  when VSAGENT_BRAND_CLI=1) and wrapped all 3 printHelp() console.log sites
  with it. printHelp's shape and the ROOT_HELP_TEXT_PRIMARY/SECONDARY split
  (upstream's own refactor, unrelated to this bucket) were untouched.
  VSAGENT_BRAND_CLI is the same seam name S15/B2's formatRuntimePairingOffer
  reads and B6's scripts/vsagent-cli launcher sets — not renamed here.
- package.json: added "smoke:web": "node tests/web-client-smoke.mjs" next to
  "smoke:computer" (script backing file lands with B6/S38-S39; the entry is
  inert but harmless until then). Left "name": "orca" and "version": "1.4.197"
  untouched per Q7 — vsagent-next tracks upstream's version, not the fork's
  0.6.10.

Did not touch root-help-text-primary.ts/-secondary.ts (S15's pairing-url
content) or notification-permission-probe.ts/startup-notification-
registration.ts (left unbranded per Q9).

Verification: corepack pnpm tc (tc:node/tc:cli/tc:web) clean; brandHelpText
sanity (`Usage: orca foo` -> `Usage: vsagent foo` only when
VSAGENT_BRAND_CLI=1, unchanged otherwise); src/cli/handlers/terminal.test.ts
(16 tests, exercises printHelp with no VSAGENT_BRAND_CLI set — unbranded
regression) and src/cli/index.test.ts (27 tests) both pass;
check:code-quality:changed clean (0 findings, 13 changed files);
check:max-lines-ratchet and check:runtime-electron-ratchet both unchanged.

Fork-origin: 6669054

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wekb1M8qsHPobDxMHzoMEZ
scolety1 added a commit to scolety1/orca that referenced this pull request Sep 15, 2026
…e override moved to Advanced disclosure

New shared ui/src/components/AdvancedDisclosure.tsx (a plain native
<details>, collapsed by default) -- the one reusable progressive-disclosure
surface this batch's Global rule calls for, reused by both findings below.

Finding stablyai#8 (IA problem): ProjectCard.tsx's card footer showed a raw git SHA
prefix; now shows the real, already-populated release.stable.branch (plain
language). ProjectDetailPage.tsx's Release card now leads with
Branch/Testing/Adoption/Published in plain language; exact
Stable/Previous Stable/Upgrade commit+tree identity moves into an
AdvancedDisclosure -- never deleted, one click away.

Finding stablyai#10 (IA problem): KeepGoingTickForm.tsx's worktree/agent fields
(the "Run now" dispatch form's own placement controls) move into an
AdvancedDisclosure, collapsed by default. Ordinary use of this form (work
item id, scope, optional spec) no longer requires engaging with placement
at all. Worktree remains a real, required field with no fabricated
default -- hasExplicitPlacement's own safety history (a prior default
silently resolved to the coordinator's own working directory, not the
project's) is exactly why no default is introduced here either; the
existing client-side validation error already tells an operator who
forgets it to provide one, so expert capability is fully preserved.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CdU7C6R8tKG5diqfdjNCPp
scolety1 added a commit to scolety1/orca that referenced this pull request Sep 15, 2026
…ehind Advanced

The Overview tab's Recent Decision card was already plain-language
(title/rationale from analysis.direction.recommendedNextMission) --
unchanged. The Onboarding card's own maturity/alignment/unfinished-summary/
upgrade-backlog fields are already reasonably plain-language too; only its
Orca-registration-check and exact analysis timestamp read as engineering
mechanics rather than owner-facing summary. Moved into the same
AdvancedDisclosure Finding stablyai#8/stablyai#10 already established, never deleted.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CdU7C6R8tKG5diqfdjNCPp
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…(C1) (stablyai#10625)

* fix(terminal): park SSH worktrees like local ones (C1 retention, slice A)

SSH ptys were blanket-excluded from hidden-view parking, so a hidden SSH
worktree retained every pane forever (C1: renderer heap climbs to the V8
ceiling). SSH bytes transit local main — fact-mode watchers already cover
them, and main keeps a headless model served over pty:getMainBufferSnapshot
that the SSH reattach path never consulted.

- isParkRestorableTerminalPty: snapshot-backed OR (SSH + policy); threaded
  through both park verdicts, both selectors, watcher coverage, and the
  watcher start guard. Remote-runtime/fail-open/foreign/null unchanged.
- Parked-SSH reveal paints from main's headless model (dimension-matched,
  ~5k rows) and degrades to the relay 100KiB replay unless the snapshot is a
  non-empty source==='headless' payload — never a blank/stale paint.
- Kill switch: settings.terminalSshViewParking (default on).

DESIGN.md records the approved plan and the H1 magnitude non-claim.

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): bound hidden-worktree retention with a force-park budget (C1, slice B)

Un-parkable worktrees (remote-runtime ptys, uncoverable tabs, SSH with the
slice-A switch off) had unlimited retention: the parking cap/TTL only ever
saw eligibility-passing worktrees, so one bad tab pinned a whole worktree's
panes forever. Retention is now memory-bounded, not eligibility-bounded.

- terminal-hidden-worktree-retention.ts: retention budget (12 hidden / 45min
  TTL, sized from the measured 2.5-19MB per-pane V8 cost, DESIGN.md §2) over
  hidden worktrees ordinary parking can never evict; reuses the hot-retain
  ranking so last-active exemption, deterministic ties, and deadline-driven
  rechecks hold. Fail-open/foreign-pty tabs are eviction-exempt (a remount
  would fresh-spawn and orphan the live shell).
- Terminal.tsx: force-parked ids join the parked set AFTER the coverage veto
  (darkness for uncoverable tabs is the accepted cost); buffers captured via
  the sleep-flow registry before the unmount render; retention TTL added to
  the recheck deadlines for budget candidates only.
- Verdict stays out of its own effect deps; policy test asserts idempotence
  and time-monotone membership (flip-loop dwell regression).
- Kill switch: settings.terminalHiddenWorktreeRetentionBudget (default on).

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): demote hidden scrollback for eviction-exempt worktrees (C1, slice C)

The retention budget (slice B) must exempt worktrees holding fail-open or
foreign-worktree ptys — a remount would fresh-spawn and orphan the live
shell — which would leave that class unbounded again. Instead, past the same
45min retention TTL their hidden panes drop to the minimum scrollback tier
(measured: ~19MB -> ~1.3MB V8 heap per 50k-row pane; trimmed history is
gone by design, reveal restores the configured cap for future output).

- terminal-hidden-scrollback-demotion.ts: module-state verdict registry
  (parked-watcher pattern) with content-equality notify damping; applied in
  the existing scrollback-rows effect in use-terminal-pane-lifecycle.
- selectScrollbackDemotedTerminalWorktrees: pure, TTL-gated, time-monotone.
- Retention TTL wakeups now also cover exempt worktrees so demotion fires.
- Kill switch: settings.terminalHiddenScrollbackDemotion (default on).

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): paint the SSH model snapshot inline, not via nested coordinator (C1 slice A fix)

applyMainBufferSnapshot runs its own structuralReplayCoordinator.run; calling
it from applyReattachPayload (already inside the coordinator when a relay
replay exists) deadlocks on the coordinator's tail chain. The model paint now
mirrors the daemon-snapshot branch inline (folded scrollback + rehydrate +
screen, dimension-matched, escape tail last) and arms the restored-snapshot
seq baseline so deferred/live chunks the snapshot covers dedupe instead of
double-painting. Also falls through (no early return) so reattachPayloadApplied
still latches. Adds the folder-workspace id parity unit case.

Co-authored-by: Orca <help@stably.ai>

* test(terminal): SSH park+reveal e2e round-trip + as-built design notes (C1)

Docker-gated (ORCA_E2E_SSH_DOCKER=1) spec: SSH tab parks behind a decoy and
reveal restores marker content at multi-viewport scrollback depth. DESIGN.md
records the as-built deltas (inline paint, force-park shape, last-active
floor) and the residuals so follow-ups aren't lost.

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): paint SSH reveal from main's model even when the relay replay is empty (C1 review stablyai#1)

A relay restart empties the replay buffer; the reveal previously painted
nothing even when main's headless model held the session. The reattach now
prefetches the model snapshot when no structural replay exists (SSH-shaped
ptys only) and paints it inside the coordinator; emptiness is judged on the
composed payload (scrollbackAnsi + data + pendingEscapeTailAnsi) so an
alt-screen snapshot with an empty screen frame still paints.

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): decouple scrollback demotion (slice C) from the retention-budget switch (C1 review stablyai#2)

Per the approved contract each slice reverts behind its own switch: slice C
now requires only the master terminalHiddenViewParking plus its own
terminalHiddenScrollbackDemotion flag. The TTL wakeup timer fires for
demotion candidates even with the budget switch off. No DEFAULT_SETTINGS
entries exist for sibling flags (defaults are the '!== false' optional
pattern), so no explicit defaults are added.

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): scope eviction exemption to the tab, not the worktree (C1 review stablyai#3)

One eviction-exempt tab (fail-open/foreign pty) previously vetoed force-park
for its whole worktree, pinning co-located remote-runtime tabs forever. The
worktree now force-parks while exempt tabs keep their mounted panes via a
per-tab exclusion mirroring the Activity-portal pattern (legacy watcher sync,
legacy render, and the overlay cold-parking hook). Ordinary parking is
untouched — a worktree with an exempt tab still cannot ordinary-park.
Slice C now also demotes exempt tabs' panes as soon as their worktree
force-parks under the count budget (they are the only panes left mounted).

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): demote un-parkable worktrees the force-park lever spared (C1 review stablyai#4)

The last-active exemption means a single hidden un-parkable worktree never
force-parks — and slice C previously only targeted exempt-tab worktrees, so
its panes held full scrollback forever. Demotion now also covers un-parkable
non-exempt worktrees past the retention TTL that are absent from the
force-parked set (last-active spared, or slice B switched off). Membership
stays time-monotone for fixed inputs; covered by new idempotence/monotone
selector tests.

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): keep the hidden clock running through transient background-measure windows (C1 review stablyai#5)

Whole-worktree background mounts (browser-automation bootstrap lease, mobile
mounts, agent wakes) open a ~3s self-clearing measure window that previously
deleted hiddenSince — every remount restarted the 30s hysteresis and the
45min retention TTL, so a periodically re-mounted force-parked worktree
never re-parked. The measure window still pauses parking/eviction verdicts
(all selectors skip measuring candidates); only the clock survives, so the
prior verdict resumes as soon as the window closes. Visible and
portal-holding worktrees still reset the clock.

Co-authored-by: Orca <help@stably.ai>

* test(terminal): make the SSH park+reveal depth assertion prove the model paint (C1 review #6a)

Pad the session with ~180KB of output after the numbered markers so the
earliest marker falls outside the relay's 100KiB rolling replay buffer while
staying inside main's ~5k-row headless model; asserting marker_1 after
reveal now proves the headless-model paint rather than passing under the
relay fallback.

Co-authored-by: Orca <help@stably.ai>

* docs(terminal): rewrite DESIGN.md as the single as-built C1 contract (review stablyai#7)

One contract matching the code: status IMPLEMENTED around force-park (not
the unmount proposal), real kill-switch names with coupling + revert
matrices, the true retention-floor formula with measured per-pane and
demotion numbers, an explicit when-OOM-is-still-possible paragraph naming
the H2 pendingSideEffects residual, the applyMainBufferSnapshot deadlock
constraint inside the slice-A section, stable-signal phrasing instead of a
capability latch, fail-open AND foreign-worktree exemption class, verified
cites, and a planned/landed/follow-up test matrix.

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): resolve the eviction exemption per pane, not per tab (C1 review stablyai#8)

isEvictionExemptTerminalTab read only tab.ptyId — the FIRST leaf's pty —
while the coverage veto that makes a worktree a retention candidate walks
every pane. A split tab whose second leaf held an unrestorable pty therefore
failed coverage (→ force-park target) yet looked exempt-free, so force-park
unmounted it and orphaned the live shell. The exemption now resolves panes
through the same resolveParkedTerminalPaneCandidates, keeping tab.ptyId in
the union for the no-layout/no-capture case.

Also from the same review round:
- force-park's capture passes includeLocalBuffers:false like every other
  shutdownBufferCaptures caller; it was serializing up to 512KB/pane of
  scrollback into the store inside a fix meant to bound renderer heap.
- Terminal.tsx unmount resets the scrollback-demotion registry — module
  state with no reset path, read by a pane effect that runs before the host
  effect that would clear it, so a stale verdict trimmed restore replays.
- memoize watcher coverage per tab within the parking pass; the retention
  candidates re-asked it for every mounted worktree, not just the parked few.

* docs(terminal): drop DESIGN.md — the as-built C1 contract moves to the PR body

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): cap the deferred PTY side-effect queue (C1 residual H2)

pendingSideEffects grew without bound under background timer throttling
(~64 drained/s vs hundreds queued/s overnight). Cap at 512 entries with
oldest-first eviction: titles drop (last-wins), a pending bell latches
onto the next survivor, agent-status payloads collapse onto the survivor
keeping the newest 16 (last-wins store state, KB-scale strings).

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): carry command-lifecycle facts through parked watchers (C1 follow-up)

Parked fact-mode watchers omitted onCommandFinished/onCommandCode*, so
OSC 133;D and Command Code scrape signals went dark while parked. New
parked-terminal-command-status.ts ports the store-level subset: git-UI
nudge on every command finish, same-turn status-row drop for SSH PTYs
(exact mounted-path parity — the foreground tracker refuses SSH ids),
and the Command Code working seed / 1500ms done settle. Byte mode scans
the same shared parsers for authority-off parity. Local-PTY status drops
stay with the mounted pane: they need pty-connection's process-confirm
ladder to tell a leaked nested-shell 133;D from a real agent exit.

Co-authored-by: Orca <help@stably.ai>

* test(terminal): retention-budget force-park e2e with a retentionLimit override (C1 6b)

ORCA_E2E_TERMINAL_RETENTION_LIMIT flows preload → e2e-config →
getTerminalParkingPolicyOverrides (exposeStore-gated, positive-integer
only) so a spec can shrink the force-park budget to 1. The Docker-gated
spec opens two remote worktrees on one relay target (second pre-seeded
remote repo), disables terminalSshViewParking to make both un-parkable,
hides both behind the local context, and proves the older one force-parks
while the last-active exemption spares the newest; re-activating the
evicted worktree restores the marker tail via relay replay.

Co-authored-by: Orca <help@stably.ai>

* test(terminal): retention-budget e2e via same-repo remote worktrees (passes docker lane)

The first draft added a second remote repo mid-session, whose pane pty
spawn misroutes to the local daemon with the remote cwd (pre-existing
multi-repo issue, reproducible without any retention override — a seeded
local repo plus one remote repo shows the same misroute). The spec now
budgets across three worktrees of the ONE connected repo, created through
the product createWorktree path (an external git-worktree-add only lands
as a detected worktree needing adoption) and polled through the relay's
transient post-connect reconnect window. Verified green on the local
Docker lane in 20.8s.

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): prevent remount thrashing during post-measure cool-down (

Implements the C1 retention contract: preserve worktree `hiddenSinceMs` through a
background-measure window (so TTL/ranking stay honest), but re-park waits for a
full `coldParkDelayMs` cool-down after the measure ends. Without the cool-down,
every ~3s measure lease on a past-deadline worktree thrashes remount/reattach.

Core changes:
- Terminal.tsx: add measure clock (measuringTerminalWorktreeIdsRef) and post-measure
  cool-down tracking (terminalWorktreeParkCooldownUntilRef); gate parking candidates
  until cool-down expires.
- Extract snapshot replay choreography to shared terminal-snapshot-replay-paint.ts
  (used by SSH reattach + daemon restore paths).
- Add SSH model snapshot timeout (750ms) with fallback to relay replay.
- Move cold-park recheck deadline logic to terminal-cold-park-recheck-deadlines.ts;
  add cool-down deadline to scheduling.
- useTerminalTabColdParking: implement matching measure-clock contract with per-tab
  cool-down gate to keep tab deadlines synced with worktree retention clock.
- Add resolveTerminalMountScrollbackRows() to demote new xterms under demoted
  worktrees (pane births during demotion must take the demoted tier at create).
- Add kill switches: terminalSshViewParking, terminalHiddenWorktreeRetentionBudget,
  terminalHiddenScrollbackDemotion.

* fix(terminal): detect Command Code completion in parked mid-turn panes

Seed the byte watcher with in-flight turn state from agent status: the
watcher is recreated per park cycle with no startup command to arm it,
and the banner scrolled away before parking. Also memoize
eviction-exempt checks and use SSH PTY ID builder in tests.

* fix(terminal): flush pending command-code settles on reveal remount

When a parked pane reveals mid-Command Code turn, the new detector
cannot re-observe the already-passed idle composer. Cancelling the settle
leaves the row stranded at 'working', so dispose now flushes the pending
settle instead.

Extract readInFlightCommandCodeTurn to shared space and seed detectors
with in-flight turns so remounts complete mid-flight commands. Also
memoize SSH model probes to prevent double timeouts on reattach.

* fix(terminal): remove scrollback demotion (C1 slice C)

The scrollback demotion feature for eviction-exempt hidden worktrees is no longer needed. Retention budget limits are now sufficient without this additional bound. Remove the terminal-hidden-scrollback-demotion module, the selectScrollbackDemotedTerminalWorktrees function, and related per-pane demotion logic.

* test(terminal): assert bounded probe during stalled reveal

Add assertion to verify that a stalled reveal operation makes exactly one
`getMainBufferSnapshot` call, ensuring retry logic doesn't introduce
redundant probes that would extend the timeout window before relay fallback.

* fix(terminal): implement C1 retention budget for hidden parked worktrees

Addresses OOM regressions in hidden parked terminals by force-evicting
worktrees past a retention budget: at most 12 mounted while hidden, none
past 45 minutes (absolute, not exempted by last-active). Eviction is
least-recently-hidden-first. Exempt tabs (unrestorable local PTYs) keep
their panes to avoid orphaning shells; worktrees are force-parked even
if they contain exempts, and their buffers released elsewhere. SSH/remote
worktrees serialize buffers pre-eviction for reveal; local worktrees keep
daemon snapshots. Command Code's done-settle window is transferred across
park/reveal boundaries so the row cannot strand at 'working'. Model probe
on SSH reattach is scoped to park-reveal only, not ordinary reconnects.
Includes new E2E suite proving the budget actually releases memory.

* memoize eviction-exempt terminal tabs to avoid redundant store reads

Each tab's exemption check re-reads the store and walks the layout tree.
Introduce selectEvictionExemptTerminalTabIds() to resolve all exempt tabs
for a worktree in a single pass, then memoize the result in Terminal.tsx
and useTerminalTabColdParking. This prevents O(n) store reads when checking
exemptions across multiple tabs and ensures the set remains stable across
unrelated re-renders.

* refactor: reformat hidden-worktree retention comments

Reflow to 80-character lines and remove internal ticket references
(C1, C1 slice C).

* fix(lint): split overlay slot and eviction-exempt tabs under max-lines

Static analysis failed because TerminalPaneOverlayLayer (401) and
terminal-parked-tab-watchers (304) exceeded oxlint max-lines. Extract the
slot component and eviction-exempt helpers into dedicated modules.

* test(terminal): stabilize retention budget e2e control arm

Stage un-parkable remote pty ids only after both worktrees are hidden, and
keep re-staging during the control-arm poll so a late updateTabPtyId cannot
flip the decoy back to park-restorable and ordinary-park it before budget
engages.

* test(terminal): pin retention e2e decoy to a mounted pane snapshot

Use the active pane-identity snapshot for the decoy tab instead of all
worktree tabs, and re-assert un-parkable ids after the control-arm hold so
a deferred/empty tab id cannot fail the budget-off mounted-count check.

* fix: memoize terminal eviction exemptions on layout leaf PTYs

Splits add leaf panes to the layout store without changing the tabs
array. A memo keyed only on tabs misses this change, leaving new panes
unexempted for unmount. Include layout leaf PTYs in the exemption memo
key so it recalculates when splits occur or PTYs are re-minted.

---------

Co-authored-by: Orca <help@stably.ai>
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