Skip to content

feat(ui): add global ErrorBoundary with navigation-aware auto-reset#1171

Merged
perber merged 2 commits into
mainfrom
fix/react-error
Jun 17, 2026
Merged

feat(ui): add global ErrorBoundary with navigation-aware auto-reset#1171
perber merged 2 commits into
mainfrom
fix/react-error

Conversation

@perber

@perber perber commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Replaces unhandled React render crashes (white screen) with a user-facing error screen offering reload and soft recovery. The boundary auto-resets on navigation via a resetKey prop tied to pathname — users are not stuck on the error screen when moving to a different page.

Placed at two levels:

  • App root: catches failures outside the router (e.g. RouterProvider crash)
  • Route wrappers (auth + read-only): catches per-page render errors; sits outside RequireAuth so auth errors are also covered

Fixes: error.stack already contains the message on V8, so the details panel no longer renders it twice.

Copilot AI review requested due to automatic review settings June 17, 2026 15:52

Copilot AI 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.

Pull request overview

Adds a reusable UI-level React ErrorBoundary to replace “white screen” render crashes with a recovery screen, and wires it into both the app root and route wrappers to improve resilience during navigation and auth/viewer flows.

Changes:

  • Introduces ui/leafwiki-ui/src/components/ErrorBoundary.tsx with reload + in-app recovery actions and an optional resetKey for auto-reset.
  • Wraps RouterProvider at the app root with the new ErrorBoundary.
  • Wraps auth + read-only router wrappers with ErrorBoundary resetKey={pathname} to reset on route changes.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ui/leafwiki-ui/src/layout/AppLayout.tsx Minor formatting change in the layout module.
ui/leafwiki-ui/src/features/router/RouterReadOnlyWrapper.tsx Wraps read-only routes with ErrorBoundary and navigation-based reset.
ui/leafwiki-ui/src/features/router/RouterAuthWrapper.tsx Wraps auth routes with ErrorBoundary (outside RequireAuth) and navigation-based reset.
ui/leafwiki-ui/src/components/ErrorBoundary.tsx New global error boundary UI with reload/recover actions and optional reset key.
ui/leafwiki-ui/src/App.tsx Wraps the router suspense tree with the new ErrorBoundary.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ui/leafwiki-ui/src/layout/AppLayout.tsx
Comment thread ui/leafwiki-ui/src/components/ErrorBoundary.tsx Outdated
Comment thread ui/leafwiki-ui/src/components/ErrorBoundary.tsx
Replaces unhandled React render crashes (white screen) with a user-facing
error screen offering reload and soft recovery. The boundary auto-resets
on navigation via a resetKey prop tied to pathname — users are not stuck
on the error screen when moving to a different page.

Placed at two levels:
- App root: catches failures outside the router (e.g. RouterProvider crash)
- Route wrappers (auth + read-only): catches per-page render errors; sits
  outside RequireAuth so auth errors are also covered

Fixes: error.stack already contains the message on V8, so the details panel
no longer renders it twice.
@perber
perber force-pushed the fix/react-error branch from 03d2a92 to 77d3df1 Compare June 17, 2026 15:57
@perber
perber merged commit 87104be into main Jun 17, 2026
9 checks passed
@perber
perber deleted the fix/react-error branch June 17, 2026 16:42
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.

2 participants