Skip to content

fix: restore the active top-level view across renderer reload#8265

Merged
nwparker merged 2 commits into
stablyai:mainfrom
myungjuice:fix/persist-active-view-on-reload
Jul 12, 2026
Merged

fix: restore the active top-level view across renderer reload#8265
nwparker merged 2 commits into
stablyai:mainfrom
myungjuice:fix/persist-active-view-on-reload

Conversation

@myungjuice

@myungjuice myungjuice commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary / description

The active top-level view (Tasks, Automations, Mobile, Settings, Skills, Space, or the enabled Activity view) now survives a renderer reload or app relaunch instead of always resetting to the terminal.

activeView now uses Orca's existing persisted UI pipeline. Startup hydration restores a validated value once, while later ui:stateChanged broadcasts continue syncing preferences without unexpectedly navigating an already-open window. Unknown values and a disabled experimental Activity view safely fall back to the terminal.

Closes #8264

Evidence of fix

  • Added an Electron E2E regression test that launches Orca twice against the same user-data directory. It opens Tasks on the first launch, verifies activeView reached persisted main-process state, relaunches, and verifies the Tasks DOM is visible while the terminal DOM is hidden.
  • E2E result on current main: 1 passed (8.9s); the restore scenario itself completed in 8.2s.
  • Focused renderer tests: 151 passed across ui.test.ts and startup-ui-hydration.test.ts.
  • All node, CLI, and web TypeScript targets passed.
  • The E2E-mode Electron build, focused Oxlint checks, diff whitespace check, and max-lines ratchet passed.

ELI5

Orca remembered the details inside each screen, but it forgot which screen you were looking at. This change saves that screen name too. When Orca starts again, it checks that the saved name is still valid and opens that screen; background settings updates are not allowed to pull you away from the screen you are currently using.

Trade-offs / expected user regressions

No user regression is expected. The value uses the existing profile-level UI state, so the last desktop view written is the one restored on the next launch; a live window is never navigated by a cross-window/mobile sync. Like the surrounding UI preferences, writes are debounced by 150 ms, so a reload triggered almost immediately after navigation could still restore the prior view.

Screenshots

No visual change. The E2E test provides render-layer evidence for both the restored Tasks page and hidden terminal surface.

Testing

  • pnpm lint (focused Oxlint and the max-lines ratchet passed; the full repository lint suite was not run)
  • pnpm typecheck
  • pnpm test (focused suites passed: 151 tests)
  • pnpm build (the E2E-mode Electron build passed; the full release build was not run)
  • Added or updated high-quality tests that would catch regressions

Commands run:

pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/store/slices/ui.test.ts src/renderer/src/lib/startup-ui-hydration.test.ts
pnpm run typecheck
pnpm check:max-lines-ratchet
pnpm exec oxlint <changed files>
pnpm exec electron-vite build --mode e2e
SKIP_BUILD=1 pnpm exec playwright test tests/e2e/active-view-restart-restore.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1

AI Review Report

Final review checked startup ordering, legacy/corrupt values, experimental-view gating, startup failure fallback, cross-window/mobile rebroadcast behavior, the debounced writer, and the full restart/render path. It identified that the contributor branch was behind main; the branch was merged with current main, then all focused checks were repeated successfully.

Cross-platform review covered macOS, Linux, and Windows. This change adds no shortcuts, shortcut labels, shell commands, platform-specific paths, or OS-specific Electron behavior. It uses the same typed IPC and persistence path on every platform. The SSH/remote use case is preserved because the restored view is app UI state and does not assume a local repository or filesystem path.

Security Audit

The persisted value is treated as untrusted: unknown, missing, legacy, or unavailable view values fall back to terminal. The change adds no command execution, path handling, authentication, secrets, dependencies, or new IPC channel. It only extends the existing trusted partial UI-state payload with a validated navigation value. No security follow-up is needed.

Notes

The original contributor PR was selected because it is the only linked candidate and already covered the important persistence and synchronization edge cases. It has been updated to current main and retained as the final PR so the contributor keeps authorship and discussion history.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Persisted UI state now includes the active top-level view, defaulting to terminal. Hydration validates stored views, handles unavailable experimental views, restores the view only during startup hydration, and preserves per-window navigation during synchronization. Debounced persistence tracks view changes, and an end-to-end test verifies that the Tasks view survives an application restart.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes implement #8264 by persisting activeView, restoring it on startup, and adding regression tests.
Out of Scope Changes check ✅ Passed The changes stay focused on activeView persistence, hydration, sync behavior, and tests; no unrelated scope stands out.
Title check ✅ Passed The title is concise and accurately summarizes the main user-visible change: persisting the active top-level view across reloads.
Description check ✅ Passed The description covers all required sections and includes testing, screenshots, AI review, security, and notes, with only minor heading variation.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/e2e/active-view-restart-restore.spec.ts (1)

101-109: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Guard each cleanup step in the finally block to prevent leaked resources.

If session.close(secondApp) throws, firstApp cleanup and session.dispose() are skipped, potentially leaving Electron processes and temp directories lingering in CI. Wrapping each close in its own try/catch ensures all cleanup steps run.

♻️ Proposed refactor
   } finally {
-    if (secondApp) {
-      await session.close(secondApp)
-    }
-    if (firstApp) {
-      await session.close(firstApp)
-    }
+    for (const app of [secondApp, firstApp]) {
+      if (app) {
+        try {
+          await session.close(app)
+        } catch (error) {
+          console.error('Failed to close Electron app during cleanup:', error)
+        }
+      }
+    }
     await session.dispose()
   }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 964f2d1e-0f30-425b-8b09-8af5b56cb731

📥 Commits

Reviewing files that changed from the base of the PR and between 6e3ebf5 and b90b2ff.

📒 Files selected for processing (7)
  • src/renderer/src/App.tsx
  • src/renderer/src/lib/startup-ui-hydration.ts
  • src/renderer/src/store/slices/ui.test.ts
  • src/renderer/src/store/slices/ui.ts
  • src/shared/constants.ts
  • src/shared/types.ts
  • tests/e2e/active-view-restart-restore.spec.ts

Comment thread src/renderer/src/store/slices/ui.ts Outdated
@myungjuice myungjuice force-pushed the fix/persist-active-view-on-reload branch from b90b2ff to 2245593 Compare July 11, 2026 10:44

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/renderer/src/lib/startup-ui-hydration.test.ts (1)

36-48: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add activeView coverage to the fallback assertion. The fallback test only checks width/group/sort and sleeping-workspace flags, so the new activeView: 'terminal' default isn’t exercised yet.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: eb5e3f58-e74e-49b2-8660-e8d6537b91ba

📥 Commits

Reviewing files that changed from the base of the PR and between b90b2ff and 2245593.

📒 Files selected for processing (10)
  • src/renderer/src/App.tsx
  • src/renderer/src/components/automations/AutomationsPage.tsx
  • src/renderer/src/hooks/useIpcEvents.ts
  • src/renderer/src/lib/startup-ui-hydration.test.ts
  • src/renderer/src/lib/startup-ui-hydration.ts
  • src/renderer/src/store/slices/ui.test.ts
  • src/renderer/src/store/slices/ui.ts
  • src/shared/constants.ts
  • src/shared/types.ts
  • tests/e2e/active-view-restart-restore.spec.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • tests/e2e/active-view-restart-restore.spec.ts
  • src/shared/constants.ts
  • src/shared/types.ts
  • src/renderer/src/store/slices/ui.ts
  • src/renderer/src/store/slices/ui.test.ts

@myungjuice myungjuice force-pushed the fix/persist-active-view-on-reload branch from 2245593 to f8c9f38 Compare July 11, 2026 11:11
@AmethystLiang AmethystLiang self-assigned this Jul 11, 2026
@AmethystLiang AmethystLiang self-requested a review July 11, 2026 16:47
@nwparker nwparker merged commit 8b8e1bb into stablyai:main Jul 12, 2026
1 check passed
@nwparker

Copy link
Copy Markdown
Contributor

Thanks for the PR!
Will merge shortly and will be in the next or next next release

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.

[Bug] Active top-level view is not restored after a renderer reload (always resets to the terminal)

3 participants