orca/tools
Jinjing cbe8635f46
fix(worktrees): prevent deletion from blocking Orca (#11233)
* fix(worktrees): prevent deletion from blocking Orca

* test(worktrees): loosen async history-delete event-loop bound for CI

The main-thread safety check failed on a loaded runner when a single
timer gap hit ~48ms under the prior 30ms threshold. Keep the bound well
below a recursive sync-rm stall without treating CI jitter as a block.

* test(worktrees): measure history-delete critical path, not timer gaps

setInterval gaps during async rm of thousands of files still flake under
CI scheduling. deleteWorktreeHistoryDir is sync and must only rename, so
assert that critical-path wall time stays well below a recursive walk.

* fix(worktrees): prevent deletion from blocking Orca

Add timeout-based draining of watcher closes so SSH round-trip delays don't
indefinitely block the worktree removal path. Also: order durable temp-file
sweeps ahead of writes to reclaim orphans before accumulation, skip own-process
temps to avoid deleting live writes, swallow persistence errors so disk failures
don't cascade to query callers, and measure history-deletion progress by loop
turns rather than timer gaps to detect blocking on CI runners.

* fix(worktrees): prevent deletion from blocking Orca

Worktree deletion can now proceed even if filesystem watchers or history cleanup operations hang, preventing Orca from freezing. Changes:

- Fence install slots with tokens instead of counters so removals can abandon wedged installs without corrupting later removals
- Timeout-bound watcher unsubscribe operations with a shared drain budget
- Move JSON serialization of large usage caches from queue-time to write-time to avoid blocking main thread
- Async tombstone + schedule history tree deletion instead of blocking recursive rmSync during GC, preventing main-thread stalls ~10s after startup

* Extract usage cache writer into reusable durable snapshot class

Consolidates serialized durable-write and generation-veto logic from
three usage stores into UsageCacheSnapshotWriter. Eliminates duplication,
centralizes multi-MB JSON serialization on the main thread via write-queue
serialization, and vetoes superseded snapshots to avoid wasted rewrites.

* fix(worktrees): prevent deletion from blocking Orca

Worktree deletion used to recursively delete large session trees (hundreds
of MB) on the critical path, stalling the event loop. Instead, rename trees
into a `.pending-delete` tombstone queue and reclaim them asynchronously
off the removal's critical path.

Extracted host tree removal into a reusable helper (`removeHostTree`) that
centralizes Windows retry logic. Added usage-cache flush on quit to prevent
data loss when scans complete right before shutdown. Improved watcher
removal deadline management with reserved tail slices for the final
unsubscribe, and added retry logic for tombstone removals that fail once
under transient Windows locking.

* fix(history): retry failed session tree removals

Tombstoned session trees whose removal fails transiently (e.g., EBUSY
under Windows AV) are now re-queued in-process with bounded exponential
backoff instead of sitting until the next HistoryManager construction.
Prevents a single stuck tree from blocking the entire Orca process.
2026-07-29 18:21:26 -07:00
..
benchmarks fix(worktrees): prevent deletion from blocking Orca (#11233) 2026-07-29 18:21:26 -07:00
daemon-relocation-spike Windows terminal update-survival (single consolidated PR) (#7538) 2026-07-07 19:21:07 -04:00
repro-watcher-crash-7547 fix(watcher): isolate @parcel/watcher in a forked process so native crashes can't kill the app (#7547) (#7757) 2026-07-07 22:10:22 -04:00
spikes
win-crash-survival-e2e test(e2e): prove the terminal daemon survives a main-process crash on Windows (#7742) (#9311) 2026-07-19 11:27:29 -07:00
win-update-e2e fix(windows): separate updater from orchestration migration (#11405) 2026-07-29 15:23:06 -07:00
repro-macos-renderer-close-teardown.cjs Suppress macOS renderer teardown crash reports (#4655) 2026-06-04 13:02:51 -07:00
repro-orchestration-long-prompt.mjs Fix orchestration agent prompt injection (#7758) 2026-07-07 19:50:57 -07:00
terminal-garble-frame-analysis.mjs fix(terminal): invalidate cached glyphs when WebGL atlas changes (#8899) 2026-07-17 16:16:17 -07:00
terminal-garble-production-repro.mjs fix(terminal): invalidate cached glyphs when WebGL atlas changes (#8899) 2026-07-17 16:16:17 -07:00
terminal-garble-react-terminal-recovery.mjs fix(terminal): invalidate cached glyphs when WebGL atlas changes (#8899) 2026-07-17 16:16:17 -07:00
terminal-garble-session-replay.mjs fix(terminal): invalidate cached glyphs when WebGL atlas changes (#8899) 2026-07-17 16:16:17 -07:00