fix(desktop): harden renderer error boundaries and recovery
What & why
Related to #7648 (Machine resources). CDP reproduced a real chart-hover crash: the tooltip converted the configured series label to a timestamp, producing RangeError: Invalid time value. Read and validate the sample timestamp from the tooltip payload instead. The secondary Lingui null-destructuring failure was subsequently reproduced with the release entry/error/chart source in production mode; details below.
When a desktop route fallback failed (including a missing Lingui context), TanStack's global boundary could display its raw error UI underneath the native title bar. Move baseline providers and the emergency boundary into RendererLayout, disable the built-in global fallback, and share title-bar-safe layout styles across route errors, 404s, and startup failures.
Keep dashboard and Settings crashes contained to the content pane, reset that boundary when navigation commits, and keep recovery actions ahead of long diagnostics. Add automated architecture guards for provider dependencies and fallback registrations, real-Lingui integration coverage, and safe formatting for unusual thrown values. No separate CDP suite or production fault-injection hooks are added.
How I tested it
-
Settings containment: shared
ContentBoundarynow wraps both Settings outlet layouts and dashboard content. Reproduced the known chart crash by temporarily restoring its old source: before, the whole window was replaced; after, Settings sidebar/chrome stayed visible and clicking Appearance recovered without reloading. The fixed chart source was restored after verification. Boundary integration tests, outlet-placement architecture tests, desktop TypeScript, changed-file Biome, and strict i18n checks passed. -
Reported Lingui failure reproduced without fault injection: the earlier baseline already contained #7603, so it could not reproduce the release's missing provider. Restored the relevant renderer files from
desktop-v1.29.0and repeated the real Machine resources chart interaction. In production mode it displaysCannot destructure property '_' of '_useLingui(...)' as it is null.fromErrorPage, followed by TanStack's raw global fallback. This establishes the tooltip invalid-date → missing-provider error-page → Lingui failure chain. The compiler-generated hook alias differs from the report only by a leading underscore. -
Matching after-check: restoring PR source passes 20 real refresh clicks and 20 cursor moves after 15 seconds of sampling, with no captured console errors or fallback. Screenshots captured and inspected. This used release-source reconstruction with installed dependencies and a production-mode Vite renderer in the real Electron window, not the distributed release binary. Full setup and artifact paths are documented in
docs/desktop-error-cdp-verification.md. -
#7648 before/after, no fault injection: Settings → Usage → Machine resources, 15 seconds of sampling, then cursor movement across charts and manual refresh. Both pre-PR renderer source (
29ed948df3) and initial PR (31440ef780) crashed after the first refresh/cursor sequence. With the tooltip fix, the same sequence completed 20 refresh clicks and 20 cursor moves without captured console errors or an error screen. Before/after screenshots were captured and visually inspected at 1100×760. This verifies this chart failure, not every intermittent cause or the released 1.29.0 binary. -
Tooltip regression tests, desktop TypeScript, focused boundary tests, changed-file Biome checks, and strict i18n checks passed after the fix.
-
Focused Bun tests: architecture guards, real-macro error/recovery integration, and arbitrary diagnostic values passed.
-
Desktop
bun run typecheck, changed-file Biome checks,bun run check:i18n, andgit diff --checkpassed. -
Real Electron CDP verification: 24 settings sections and main dashboard navigation; supplementary smoke checks covered all 59 route templates. Injected root, loader, provider, nested-boundary, fallback, and boot failures; checked French translations, 404 recovery, and long diagnostics at 400×400.
-
Before/after measurements: raw global error heading at y=8; shared full-window content starts at y=48. Long dashboard diagnostics previously pushed recovery offscreen; heading now starts at y=80 with recovery visible at 400×400. Screenshots captured and inspected locally; detailed coverage and limitations are in
docs/desktop-error-cdp-verification.md. -
Final targeted CDP recheck passed dashboard containment, fallback escalation, long diagnostics, and real Go-home recovery. The sibling-navigation regression is covered by the production-boundary integration test.
Full monorepo checks were not run. Cloud access and plugin success states were unavailable in the local environment; first-run onboarding, destructive operations, and every permission/feature-flag combination were not exercised. If a rich fallback throws before committing, emergency reporting captures the secondary exception; its original reporting effect may not run.
Checklist
- PR title follows conventional commits (
type(scope): subject) -
bun run lintandbun run typecheckpass (scoped checks above passed; full monorepo checks left to CI) - "Allow edits from maintainers" is checked on fork PRs (same-repository PR)
Summary by cubic
Harden the desktop renderer's error boundaries so route fallback failures show a styled full-window screen instead of TanStack's raw error UI, dashboard and Settings crashes stay contained to the content pane, and recovery stays visible with long diagnostics. Fixes #7648: an invalid timestamp in ResourceSparkline's tooltip crashed the whole renderer window, which in release source also triggered the reported Lingui failure.
Bug Fixes
- Lingui context and the emergency boundary moved into
RendererLayout, and TanStack's global catch boundary is disabled so fallback errors reach the desktop screen. - Dashboard and Settings outlets share
ContentBoundary, which resets on the router's navigation commit marker instead of the URL, fixing a race that retried the stale outlet. - Recovery actions render before diagnostics, and long diagnostics scroll within bounded regions; the pre-React boot fallback also gained a Reload button.
- Resource tooltips read the sample timestamp from the payload and validate it, so invalid labels no longer crash the renderer.
Refactors
BootErrorBoundarybecameRendererErrorBoundarywith generic copy, shared Sentry reporting, and a non-throwing diagnostic formatter for arbitrary thrown values.- Route errors, 404s, and the boot fallback share
FailureLayoutstyles that reserve the title-bar drag region. - Architecture tests audit emergency UI dependencies, router roots, and fallback registrations; integration fixtures use real Lingui macros.
Summary by CodeRabbit
-
New Features
- Added consistent full-window failure screens with reload actions, improved diagnostics, scrolling, and title-bar spacing.
- Added localized content-level error screens with navigation and app reload options.
- Dashboard and Settings errors can recover during navigation while preserving surrounding layout elements.
- Resource usage chart tooltips now show accurate sample timestamps.
-
Bug Fixes
- Improved handling of unexpected and malformed errors without causing additional failures.
- Prevented chart tooltip crashes caused by invalid resource samples.
-
Documentation
- Added desktop error-handling guidance and verification results.