fix: 添加 React Error Boundary 防止生产环境渲染崩溃

增强 SentryErrorBoundary 组件,捕获渲染错误时输出诊断信息
(错误消息 + component stack)到 stderr 和终端,而非静默返回
null。在 replLauncher 根节点和 Messages 组件层级包裹 Error
Boundary,防止 Ink 内部的 Error Boundary 直接终止进程。

Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
This commit is contained in:
claude-code-best
2026-05-09 22:02:04 +08:00
parent 0707284939
commit 2006ab25ff
4 changed files with 71 additions and 43 deletions

View File

@@ -18,11 +18,14 @@ export async function launchRepl(
renderAndRun: (root: Root, element: React.ReactNode) => Promise<void>,
): Promise<void> {
const { App } = await import('./components/App.js');
const { SentryErrorBoundary } = await import('./components/SentryErrorBoundary.js');
const { REPL } = await import('./screens/REPL.js');
await renderAndRun(
root,
<App {...appProps}>
<REPL {...replProps} />
</App>,
<SentryErrorBoundary name="RootREPLBoundary">
<App {...appProps}>
<REPL {...replProps} />
</App>
</SentryErrorBoundary>,
);
}