Skip to content

fix(desktop): prevent blank screen during session restore - #134

Merged
ruru-m07 merged 1 commit into
devfrom
ruru/fix-blank-startup
Sep 25, 2026
Merged

ruru-m07 merged 1 commit into
devfrom
ruru/fix-blank-startup

Conversation

@ruru-m07

@ruru-m07 ruru-m07 commented Sep 20, 2026 •

Copy link
Copy Markdown
Owner

What

  • replace pre-mount asynchronous router navigation with synchronous history replacement and flushing
  • keep React mounting resilient when persisted session restoration fails
  • add regression coverage for pending restoration, invalid state, host routes, onboarding, and embedded runtimes

Why

A production cold start with last-page set to /app awaited router.navigate before RouterProvider mounted. The URL changed, but the navigation promise could not settle, so createRoot was never reached and the window stayed blank.

The tauri_runtime_wry web content process terminated debug line was a misleading signal; WebContent remained alive and bundled assets loaded normally.

How

Startup restoration now replaces and flushes TanStack history synchronously. RouterProvider then owns the initial route load, while the bootstrap boundary catches malformed persisted state so first paint still proceeds.

Validation

  • make verify: 86 frontend tests, lint, type checks, production frontend build, Rust formatting, Clippy, and 291 Rust tests
  • make build-tauri: app, DMG, updater archive, and updater signature generated successfully
  • production cold start with persisted last-page=/app reached /app with a populated React root and rendered host UI

Compatibility note

Draft PR #133 also edits apps/desktop/src/main.tsx in the startup block and may need a small rebase depending on merge order.

Summary by CodeRabbit

  • Bug Fixes

    • Improved desktop startup and session restoration, including more reliable redirects to the previously open page.
    • Corrected routing for app-shell and workspace URLs while preserving embedded runtime locations.
    • Startup now continues gracefully if restoring the previous session encounters an error.
  • Tests

    • Added coverage for startup behavior, session restoration, route handling, embedded runtimes, and error recovery.

@coderabbitai

coderabbitai Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 5b311af6-74f8-4bd2-95af-7761e3298518

📥 Commits

Reviewing files that changed from the base of the PR and between a0da433 and 1fafdd2.

📒 Files selected for processing (4)
  • apps/desktop/src/bootstrap/session-restore.ts
  • apps/desktop/src/main.tsx
  • apps/desktop/tests/main-startup.test.tsx
  • apps/desktop/tests/session-restore.test.ts

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

Desktop session restoration now uses synchronous history replacement and router flushing. Startup catches restoration errors, logs them, and continues mounting. Tests cover route restoration, embedded-runtime no-ops, pending restoration, and thrown errors.

Changes

Desktop session restoration

Layer / File(s) Summary
Startup location restoration
apps/desktop/src/bootstrap/session-restore.ts, apps/desktop/tests/session-restore.test.ts
redirectToLastPage now replaces startup history entries, flushes the router, and preserves existing route checks. Tests cover host redirects, workspace canonicalization, non-workspace routes, and embedded-runtime no-ops.
Synchronous startup integration
apps/desktop/src/main.tsx, apps/desktop/tests/main-startup.test.tsx
Startup invokes restoration synchronously. It logs "Failed to restore the last page" when restoration throws. Tests verify mounting and query-bridge initialization during pending or failed restoration.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant main.tsx
  participant redirectToLastPage
  participant RouterHistory
  participant QueryBridge
  main.tsx->>redirectToLastPage: invoke synchronously
  redirectToLastPage->>RouterHistory: replace startup location
  redirectToLastPage->>RouterHistory: flush router
  main.tsx->>QueryBridge: initialize query bridge
  main.tsx-->>main.tsx: log restoration error if thrown
Loading

Merge Risk: ⚪ Minimal · up to 1fafd

No concrete outstanding risk remains from the session-restoration changes; the test mocks are reset between cases as configured.

🚥 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: preventing a blank desktop screen during session restoration.
Description check ✅ Passed The description includes complete What, Why, and How sections. It explains the failure mode, implementation, validation, and compatibility note. It does not include a linked issue under Fixes #, but t…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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

A rabbit hops through startup light
History settles, routes align
The router flushes, paths grow clear
Errors whisper; mounts proceed
Query bridges wake with cheer

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

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying gitru with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1fafdd2
Status: ✅  Deploy successful!
Preview URL: https://feae391d.gitru.pages.dev
Branch Preview URL: https://ruru-fix-blank-startup.gitru.pages.dev

View logs

@ruru-m07 ruru-m07 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

catstare_thumbsup

@ruru-m07
ruru-m07 merged commit 58cab7d into dev Sep 25, 2026
15 checks passed
@ruru-m07
ruru-m07 deleted the ruru/fix-blank-startup branch September 25, 2026 13:19
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.

1 participant