fix(desktop): preserve translation context for route errors
What & why
When a root route fails, its error screen replaces the layout containing the language provider. The error screen then crashes in useLingui(), hiding the original exception and preventing its Sentry reporting effect from running.
Wrap the router in a Lingui provider backed by the shared i18n instance. Root error and not-found screens keep translation context and the active language even after the normal layout unmounts. Add an isolated regression test using real Lingui hooks and compiled macros, bypassing the desktop test suite's translation mocks.
This fixes the secondary crash shown in the report. The original trigger for the affected user is still unknown; their Sentry event, logs, or reproduction steps are needed to diagnose it.
How I tested it
- Passed
bun run lint,bun run typecheck, andbun run check:plugins. - Passed all six targeted RendererRouter and LanguageAwareI18nProvider tests.
- Regression coverage exercises root-layout exceptions, loader failures, and 404s; checks French translations, original error details, the Sentry capture call, and Go home recovery from loader errors and 404s.
- Removing the outer provider makes the regression test fail with a missing-I18nProvider error.
bun run testfailed: host-service tests and one desktop Git test report an unaccepted Xcode license; a desktop node-pty native symbol check also returns empty output. Desktop results: 3,928 passed, 2 failed. These failures are outside the changed renderer code.- Verification is synthetic; no live-app before/after screenshots were captured, and the other user's exact journey was not reproduced.
Checklist
- PR title follows conventional commits (
type(scope): subject) -
bun run lintandbun run typecheckpass (CI fails on lint warnings too) - "Allow edits from maintainers" is checked on fork PRs (same-repository branch)
Summary by cubic
Desktop route error and not-found screens now retain the shared Lingui context instead of crashing in useLingui() after the normal layout unmounts. This keeps the original exception available for its Sentry report; the affected user's initial failure remains unidentified.
- Covers layout exceptions, loader failures, and 404s with real Lingui hooks and compiled macros, including localized fallback text and navigation recovery.
- 404 screens remain unreported as crashes, while exception screens show the original error details.
- Lint, type checking, and plugin checks pass; full-suite failures remain limited to unrelated Xcode-license and
node-ptyissues. - Verification is synthetic and still needs the affected user's Sentry event, logs, or reproduction steps.
Summary by CodeRabbit
- Bug Fixes
- Improved route error handling so fallback screens retain the correct translation context.
- Error details now display the original failure while preserving localized headings.
- Not-found and other route failures recover correctly, allowing navigation back to the home screen.
- Improved error reporting for unexpected route failures without affecting not-found handling.
- Prevented translation-related errors from obscuring the original route failure.