Skip to content

fix(session): preserve tab/editor/browser chrome when a repo's startup scan degrades - #9991

Merged
brennanb2025 merged 2 commits into
mainfrom
fix-9972-hydration-degraded-guard
Jul 23, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
fix-9972-hydration-degraded-guard

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #9972

Follow-up from the #9446 review.

Problem

hydrateWorkspaceSession keeps persisted state for a worktree key when its repo is known but has no loaded worktrees and no authoritative detected scan (the #1158 graceful-degradation guard). The parallel hydrators — hydrateTabsSession, editor, and browser — lacked this guard and validated purely against worktreesByRepo, so a repo whose worktree fetch fails at startup (transient IPC/git error) had its unified-tab / editor / browser chrome dropped. Once setHydrationSucceeded(true) unlocks the session writer, that loss is persisted.

A terminal-free editor/browser workspace exposed a second edge: deriving degraded validity only from tabsByWorktree preserved its chrome in the parallel hydrators but still cleared the selected worktree.

Fix

Extracted the #1158 validity computation into a shared degraded-repo-worktree-validity helper and applied it across all four hydrators. The workspace and tab hydrators now collect concrete persisted terminal, unified-tab, editor, and browser worktree keys, so terminal-free workspaces retain their selection without treating a stale selection-only ID as valid.

Reliability contract

  • Invariant (workspace-session.degraded-hydration-chrome-retention): a missing or non-authoritative repo scan cannot discard persisted terminal/tab/editor/browser state; an authoritative scan or removed repo still can.
  • Failure source: Replicate hydrateWorkspaceSession's degraded-repo guard into tabs/editor/browser hydrators #9972 / Fix silent data loss when workspace session hydration fails #1158 startup scan degradation.
  • Oracle: deterministic full hydrate → persist → rehydrate tests cover mixed chrome and terminal-free editor/browser chrome; a negative test proves an authoritative empty scan removes the same state.
  • Gate: no exact config/reliability-gates.jsonc entry exists; focused store tests are the executable gate, with live packaged startup fault injection remaining an accepted gap.
  • Provider/platform coverage: the decision is pure persisted-state/catalog logic with no filesystem, process, path, Git, or local-host assumptions. Local, daemon, SSH, WSL, runtime, relay/mobile, macOS, Linux, and Windows routing/lifecycle behavior is otherwise unchanged.
  • Performance budget: work is limited to existing startup/explicit rehydration calls and one linear pass over persisted workspace-key maps. It adds no polling, timers, IPC, provider inventory, subprocesses, store subscriptions, or render-path work.
  • Diagnostics: existing authoritative worktree-purge diagnostics remain unchanged; deterministic tests identify degraded-retention versus authoritative-cleanup failures.
  • Residual gap: no packaged-app fault-injection journey currently simulates a real startup scan failure.

Verification

  • pnpm typecheck
  • 283 focused store/worktree tests
  • changed-file oxlint and oxfmt --check
  • pnpm run check:reliability-gates
  • pnpm run check:max-lines-ratchet

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Session hydration now uses shared worktree-validity helpers across workspace, tabs, editor, and browser state. Persisted worktrees remain eligible when repository scans are incomplete, while authoritative deletion scans remove their hydrated state. New Vitest coverage verifies preservation and removal of terminal, editor, browser, and active-tab state across hydration and persistence.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is informative, but it does not follow the required template and omits Screenshots, AI Review Report, Security Audit, and Notes. Restructure the PR body to match the template: add Summary, Screenshots, Testing checklist, AI Review Report, Security Audit, and Notes sections, and fill in the missing details.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes implement the shared degraded-repo guard across workspace, tabs, editor, and browser hydrators and add regression coverage as requested.
Out of Scope Changes check ✅ Passed The PR stays focused on degraded-session hydration and related tests, with no clear unrelated code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title is concise and accurately summarizes the main session-hydration fix for degraded repo scans.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@brennanb2025
brennanb2025 merged commit ee87bb3 into main Jul 23, 2026
2 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…p scan degrades (stablyai#9991)

* fix(session): preserve chrome after degraded repo scan

* fix(session): retain terminal-free degraded workspaces
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.

Replicate hydrateWorkspaceSession's degraded-repo guard into tabs/editor/browser hydrators

1 participant