Files
orca/src/renderer
7d367b2aa4 fix(terminal): stop the recovery budget erasing itself during a remount (#19745)
* fix(terminal): stop the recovery budget erasing itself during a remount

A recovery remount disposes the pane's xterm, and the disposal handler
released the tab's recovery budget whenever getTab said the tab was gone.
getTab reads unifiedTabsByWorktree while remountTerminalTabForRecovery
reads and mutates tabsByWorktree; on the direct-SSH path the two indices
diverge, so every successful remount deleted the timestamp it had just
written. The cap never engaged and the pane remounted at render speed.

Report b5cfc6ca (1.4.198, Windows): 8878 remounts across 8 tabs in 122s,
all reason=reattach-unverifiable, against a cap of 3 per tab per 5 min,
ending in a Skia bitmap allocation abort.

Gate the release on the same index that governs remounting, via a shared
locateTerminalTabForRecovery so the two cannot drift apart again.

* refactor(terminal): resolve a recovery tab through one tabsByWorktree scan

Collapse the recovery lookup onto a single primitive, locateTerminalTab, and
express the already-exported isTerminalTabPresent in terms of it. The budget
release now calls isTerminalTabPresent directly, so the store drops the
hasTerminalTabForRecovery action added alongside it.

The native-chat ownership guard also consults tabsByWorktree: the unified tab
index owns viewMode, but it can transiently drop a row the remount index still
holds, and that hole used to read as "not chat-owned" and remount a chat-owned
tab.

Drops the storm control case that passed with and without the fix, and pins the
surviving drift case to the exact remount count the cooldown produces.

---------

Co-authored-by: m4air <m4air@m4airs-MacBook-Air.local>
Co-authored-by: Neil <neil@stably.ai>
2026-09-10 23:44:09 -07:00
..