Skip to content

fix(desktop): hide raw renderer exceptions - #4459

Merged
Astro-Han merged 1 commit into
apache:mainfrom
orangeCatDeveloper:fix/desktop-error-boundary
Sep 1, 2026
Merged

Astro-Han merged 1 commit into
apache:mainfrom
orangeCatDeveloper:fix/desktop-error-boundary

Conversation

@orangeCatDeveloper

@orangeCatDeveloper orangeCatDeveloper commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Part of #2672

Summary

Unexpected renderer and startup failures show raw exception text as product copy: the crash surface renders the exception and component stack into the window, and native startup dialogs interpolate error.message into their detail text — unlocalized, unstable, and occasionally containing content that belongs only in a diagnostic report.

Raw exceptions are diagnostic data, not stable product copy. The crash surface and the native diagnostic dialogs now show fixed localized recovery guidance from typed catalogs (the reshaped errorBoundary group in shell-copy.ts, and a new main-process native-diagnostic-dialog-copy.ts), while the raw details keep flowing through the existing diagnostics channel — the copyable report still carries the full redacted stack. The last locale === ternary block in runtime-host-boot.ts moves into the catalog with the rest. The renderer copy deliberately stays in shell-copy.ts: the renderer architecture ratchet forbids new files in the AppShell closure, so the diff's renderer debt footprint is identical to main.

Scope note: this covers the generic surfaces only; expected-error localization by error code is a sibling PR, and the copy-boundary gate expansion for these files lands with the CLI ratchet PR.

Verification

Before (dialog detail carries the raw exception; fallback renders the stack)
runtime-host-boot.ts:  detail: isChinese ? `${input.error.message}\n\n你可以重试…` : `${input.error.message}\n\nRetry…`
error-boundary.tsx:    <pre className="maka-error-stack">{safeStack}</pre>

After (fixed localized guidance; raw error only in the diagnostic report)
native-diagnostic-dialog.test.js:
✔ keeps Default Runtime Host errors in diagnostics instead of dialog copy
    assert.doesNotMatch(JSON.stringify(recovery.options), /very-secret-token/u)
    assert.match(report, /Error: Authorization/u)
renderer-error-report.test.js:
✔ keeps raw exceptions out of the localized crash surface
ℹ tests 7  ℹ pass 7  ℹ fail 0

Workspace build, the touched suites, renderer/storybook typecheck, and Biome pass locally.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Claude Code implemented the migration, reviewed it for simplification (dead shell-copy group, catalog placement), and ran the listed checks.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@orangeCatDeveloper
orangeCatDeveloper force-pushed the fix/desktop-error-boundary branch from 7c994b9 to 2694b75 Compare September 1, 2026 10:23
@github-actions github-actions Bot added the effort/L Under 1000 readable lines label Sep 1, 2026
@orangeCatDeveloper
orangeCatDeveloper force-pushed the fix/desktop-error-boundary branch 2 times, most recently from 815660d to bfe48f1 Compare September 1, 2026 11:08
Unexpected exceptions are diagnostic data, not stable product copy. Keep details in the report and console while showing localized recovery guidance.

@Astro-Han Astro-Han 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.

Traced the diagnostics path end to end: handleCopyReport → formatRendererErrorDetails → renderer_crash keeps details, and the startup dialog's report already carried startupError.stack. Removed copy has no remaining references. Three non-blocking notes:

  • When the copy fails (copyState === 'failed'), the crash surface now shows nothing identifying — the old text pointed at the on-screen summary that no longer exists. Falling back to error.name there would keep a foothold.
  • The new third argument of showStartupDiagnosticDialog is the only place the stack reaches the report, and no test goes through it (the new test builds the input by hand).
  • native-diagnostic-dialog.ts:94 says the report stays English regardless of locale, but showStartupDiagnosticDialog feeds it the localized title/message.

One question, no action needed here: promptForDefaultRuntimeHostRecovery still resolves the system locale while desktopLocale is already constructed by then — intentional pre/post-settings boundary, or leftover?

@Astro-Han
Astro-Han merged commit 471aa1d into apache:main Sep 1, 2026
1 check passed
@orangeCatDeveloper
orangeCatDeveloper deleted the fix/desktop-error-boundary branch September 1, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/L Under 1000 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants