Files
orca/tools
CroseryandBrennan Benson 90255ab112 [Bug]: Defer full worktree scan until after session restore (#9446)
* perf(startup): defer full worktree scan until after session restore

* fix(startup): normalize worktree recovery session keys

* fix(startup): preserve persisted workspace hydration

* fix(startup): keep SSH repos in pre-hydration worktree fetch

Round 1 review fixes for the selective pre-hydration fetch:

- The prefetch filter gated on LOCAL_EXECUTION_HOST_ID, which excluded
  SSH repos. Old full-scan code populated worktreesByRepo for disconnected
  SSH repos via the local metadata fallback (no network), so hydrateTabsSession
  / editor / browser preserved their chrome. Excluding SSH dropped that chrome
  at hydration and setHydrationSucceeded made the loss durable. Include SSH by
  excluding only runtime-owned repos (which hydrate via placeholders instead).
- collectWorktreeHydrationRepoIdsFromSession never collected activeRepoId, so a
  repo referenced only by active-repo state (no active worktree, no tabs) was
  not prefetched, breaking hydrateWorkspaceSession's main-worktree fallback.

* fix(startup): re-prune visit timestamps after deferred full worktree scan

Round 2 review fix. The selective pre-hydration fetch only populates
session-referenced repos, so the one-shot pruneLastVisitedTimestamps at
startup no longer sees non-session repos and keeps their deleted-worktree
entries (the prune defers unloaded repos to preserve SSH focus recency).
The old full pre-hydration scan had populated all local repos before the
prune. Re-run the prune after the deferred fetchAllWorktrees so stale
lastVisitedAtByWorktreeId entries are dropped once every repo is
authoritative; disconnected SSH stays non-authoritative and is kept.

* fix(startup): exclude unbounded history maps from hydration repo enumeration

Round 3 review fix. collectWorktreeHydrationRepoIdsFromSession collected
repo ids from lastVisitedAtByWorktreeId and defaultTerminalTabsAppliedByWorktreeId,
which accumulate one entry per worktree ever focused / given default tabs.
On the long-lived large profile this fix targets (#9441), those maps
reference nearly every repo, so the 'selective' pre-hydration fetch
degenerated back toward the full all-repos scan the fix removed.

Split the keyed-field list: repo enumeration now scans only chrome-bearing
fields (open tabs/editors/browser), while folder-key detection keeps
scanning all fields. The history maps hydrate unfiltered regardless, and
the deferred re-prune reaps their stale entries, so no data or recency is
lost. Also pin the round-2 re-prune ordering in the routing test.

* fix(startup): prevent competing full worktree scans

* fix(startup): keep selective hydration scans bounded

* fix(startup): ignore stale tab selection markers

* fix(startup): keep deferred worktree recovery selective

* test(windows): dismiss startup overlays before terminal setup

---------

Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
2026-07-23 16:29:59 -07:00
..