Files
orca/src
Jinjing 68b6e9f70d Reland canonical PTY hydration without evicting live legacy rows (#13132)
* fix(terminal): restore canonical terminal rows from unified sessions

During session hydration, non-canonical terminal rows (closed/stale tabs)
were being restored alongside canonical ones. Filter to only canonical
terminal rows from unified sessions, treating legacy rows as terminal
backing data only.

* fix(terminal): preserve independent legacy PTY rows

* fix(terminal): stop canonical PTY filter from evicting live legacy rows

Two regressions in the hydrateWorkspaceSession canonical-PTY filter:

1. canonicalPtyIds was built before isValidTerminalTabId ran, so a web-client
   mirror row with a "::" id seeded its PTY into the set and then evicted the
   valid local row owning the same PTY - wiping every terminal in the worktree
   and orphaning the daemon PTY, persisted back to disk on the next write.

2. `.some()` dropped an entire legacy split tab for a single overlapping leaf,
   discarding panes whose PTYs nothing else referenced.

Only rows that survive the id check now claim ownership, and only pure
duplicates (every PTY already canonical, guarded against PTY-less rows) drop.

* fix(terminal): deduplicate rows with correct orphaned PTY handling

- Extract row hydration to terminal-session-row-hydration.ts
- Distinguish mounted vs orphaned PTY bindings when scoring ownership
- Strip shared PTYs from retained rows to prevent duplicate reconnection
- Follow dropped row focus to canonical twin; clean up orphaned agent sessions

* fix(terminal): clear sleeping-agent records for invalid-tab-id rows

Rows with invalid tab IDs are dropped like subsumed rows but were not getting their sleeping-agent records cleaned up. Extract common test mocks into a bootstrap file to reduce duplication.

* fix(terminal): anchor retained rows on remaining leaf PTYs

When a canonical row claims a retained row's tab-level PTY, the row
still owns leaf-level PTYs in split panes. Anchor on the surviving
leaf PTY so the orphan sweep doesn't delete the row before its pane
reattaches (#10486). Also cleans up sleeping agent sessions for
released leaves and improves PTY categorization.

* persisted ptyIdsByLeafId keys are unvalidated strings, and makePaneKey throws on non-UUIDs.
2026-08-09 14:50:46 -07:00
..