Skip to content

fix(app): show a recovery screen instead of a blank window when a render throws - #4697

Merged
yomgui merged 3 commits into
devfrom
fix/app-root-error-boundary-v2
Sep 9, 2026
Merged

yomgui merged 3 commits into
devfrom
fix/app-root-error-boundary-v2

Conversation

@yomgui

@yomgui yomgui commented Sep 9, 2026

Copy link
Copy Markdown
Member

Summary

Last-resort React error boundary around the whole desktop/web app. A throw during render — including inside AppProviders or the activation gate — now shows a recovery screen instead of an empty #root.

Supersedes #3402 by @pranshu26 (rebased onto current dev, boundary and test kept; recovery actions and journey proof added). Co-authored-by trailer is on the commit.

Why

React unmounts the entire tree when a render throws. Until now the only boundaries were LexicalErrorBoundary and the tool-part boundary in components/chat/message-list.tsx; nothing sat above the routes. A pre-activation crash in an enterprise install is also invisible to telemetry by design (desktop Sentry only sends after a signed-in user/org), so the recovery screen must work with no network and no providers mounted. The provider-composition bug that surfaced this is fixed separately in #4606; this PR changes what any such crash looks like, not the individual cause.

What changed

  • apps/app/src/react-app/shell/app-error-boundary.tsx — the boundary and its recovery screen. Sits above every provider in index.react.tsx, reads no React context, no t() (locale init has itself been a startup failure), no network.
    • Shows the thrown message and stack (non-Error throws are stringified).
    • Copy details → clipboard: OpenWork <version> (<deployment>, <flavor>), message, stack.
    • Open logs folder → reveals the server log via the existing openworkServerInfo + __revealItemInDir bridge. Hidden on the web and before enterprise activation, where the bridge refuses the call (and no server log exists yet).
    • Reload.
  • apps/app/src/index.react.tsx — wrap the tree inside StrictMode, outside QueryClientProvider.
  • apps/app/src/react-app/shell/app-root.tsx — dev-only eval.app.render_throw control action (gated on import.meta.env.DEV, next to eval.app.relaunch) so a journey spec can make the real app throw during render.
  • apps/app/tests/app-error-boundary.test.tsx — unit coverage for the state transition, fallback markup, non-Error throws, and the exact copy payload.
  • evals/specs/app-render-crash-recovery.e2e.test.ts + renderCrashWorld in evals/worlds/first-run.ts — journey spec.

Proof

Journey spec: pnpm evals:e2e app-render-crash-recovery — placement: daytona (daytona CLI authenticated), checkout 9e9ad071dffc, 1 passed / 0 failed / 0 skipped, verdict passed. Steps: app healthy with no recovery screen → eval.app.render_throw lands on the recovery screen showing the message, a stack naming the throwing component, Reload / Copy details / Open logs folder → Copy details flips to "Copied" and the clipboard holds OpenWork <version> (desktop, public|enterprise), the message, and the stack → Reload restores the app and the recovery screen is gone.

Also: pnpm --filter @openwork/app typecheck exit 0; bun test --isolate tests/app-error-boundary.test.tsx 7 pass / 0 fail; boundary and channel ratchets report nothing for the new spec.

Evidence comment follows via pnpm evals:e2e --publish.

Rollback

Revert the commit — remove the wrapper in index.react.tsx, the eval hook in app-root.tsx, and the new files. Nothing else imports the boundary.

pranshu26 and others added 3 commits September 9, 2026 16:37
…der throws

React unmounts the whole tree when a render throws, and the renderer had no
boundary above the routes — only LexicalErrorBoundary in the composer and the
tool-part boundary in components/chat/message-list.tsx. That second one already
documents this failure mode in its own comment ("without this boundary a single
bad part unmounts the entire app (white screen). Seen in production on v0.15.3").

The same shape reaches the whole app from route-level render work. #3372 is a
current example: a local MCP server configured with a string `command` throws
`config.command?.some is not a function` inside a `useMemo` in settings-route,
and the user gets a blank window with nothing to report.

This adds a last-resort boundary around the tree that shows the error, its
stack, a Reload button, and Copy details. It renders plain elements and does not
call `t()` on purpose: locale init runs before the tree mounts and has itself
been a startup failure (#2767), so the screen that reports a crash must not
depend on it.

This does not fix any individual crash — it stops them presenting as a blank
window.

Co-Authored-By: Claude <[email protected]>
…throws

Extend the app-level error boundary from #3402 so a render throw above the
routes (including inside providers or the activation gate) shows a recovery
screen instead of an empty #root. The boundary wraps every provider in
index.react.tsx and reads no React context.

- Show the thrown message and stack.
- Copy details puts message, stack, app version and distribution flavor on
  the clipboard; nothing is sent over the network.
- Open logs folder reveals the server log through the existing
  __revealItemInDir bridge; hidden on the web and before activation where the
  bridge refuses the call.
- Reload.
- Dev-only eval.app.render_throw control action and a journey spec that
  drives the real desktop through the crash and back.

Co-authored-by: pranshu26 <[email protected]>
@vercel

vercel Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
openwork-app Ready Ready Preview Sep 9, 2026 8:41pm UTC
openwork-den Ready Ready Preview Sep 9, 2026 8:41pm UTC
openwork-diagnostics Ready Ready Preview Sep 9, 2026 8:41pm UTC
openwork-landing Ready Ready Preview, v0 Sep 9, 2026 8:41pm UTC

@yomgui

yomgui commented Sep 9, 2026 •

Copy link
Copy Markdown
Member Author

Passed · 1/1 tests · 2/2 assertions · 0 images

Commit 9e9ad071dffc1c1168b00797e145a49ba64a2d1b · selected evidence

Open review report

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Warden review summary — Clear

Native findings: 0. Blocking policy matches before consolidation: 0. Full finding text remains in Warden's native checks and review threads. This comment retains only native IDs, severity, skill attribution, and safe locations. Analysis run

Reported trigger coverage (not proof of complete repository or context coverage): diff-security-review (35277 ms), confidentiality-review (49150 ms), spec-provenance-review (52466 ms), desktop-den-sync-review (55216 ms).

Blockers

  • None.

Advisories

  • None.

Needs recheck

  • None.

Observed review-thread metrics

  • Unique observed run attempts in retained window: 1
  • Distinct heads in retained window: 1
  • Current unresolved Warden threads: 0 of 0 observed
  • Observed resolved/unresolved transitions in retained snapshots: 0 / 0
  • First observed resolved/unresolved (state at first collection, not event time): 0 / 0
  • Precision: unavailable (no adjudications; no TP/FP values are inferred)
  • Observation window: 1/20 run attempts retained; truncated: false
  • Transition snapshot: 0/0 current attributed threads retained (limit 500); truncated: false

Thread states are read-only collection snapshots. These metrics are neither lifetime totals nor exact resolution times, and this summary is not clearance authority.

@diff-warden diff-warden 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.

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (9e9ad071dffc1c1168b00797e145a49ba64a2d1b). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@yomgui
yomgui merged commit 61b4190 into dev Sep 9, 2026
27 checks passed
yomgui added a commit that referenced this pull request Sep 9, 2026
Match the disclosure shape used by session error cards and the boot-failure screen: headline, plain guidance and Reload first; the raw message, stack, Copy details and Open logs folder open on demand. Follow-up to #4697.
yomgui added a commit that referenced this pull request Sep 9, 2026
…catches the crash (#4699)

#4697 mounted a root error boundary, so a first-launch render crash now
renders "OpenWork hit an unexpected error" instead of unmounting the tree.
React reports caught errors through console.error, not
Runtime.exceptionThrown, so packaged-first-launch no longer stopped on the
crash: it waited the full 60 s for the gate heading and failed with a
timeout whose message buried the cause in the last-value dump.

Treat the recovery heading as a terminal state, assert it is absent by
name, and check for it instead of the stale "Something went wrong" text.

Local lane, macOS arm64, electron-builder.enterprise.yml --mac --dir:
- dev: passed (11.2 s)
- dev with providers.tsx reverted to pre-#4696: failed in 8.0 s,
  "the root error boundary caught a first-launch render crash ...
  Local context is missing" (before this change: failed after 65.8 s
  with "Timed out waiting for enterprise first-launch gate")

This branch was successfully deployed

4 active deployments
Preview – openwork-landing — 9e9ad071 Deployed Sep 9, 2026 by vercel[bot]
Preview – openwork-app — 9e9ad071 Deployed Sep 9, 2026 by vercel[bot]
Preview – openwork-den — 9e9ad071 Deployed Sep 9, 2026 by vercel[bot]
Preview – openwork-diagnostics — 9e9ad071 Deployed Sep 9, 2026 by vercel[bot]
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