Skip to content

[codex] fix settings page error fallback - #1291

Closed
ZhuLinsen wants to merge 1 commit into
mainfrom
codex/fix-settings-error-boundary
Closed

[codex] fix settings page error fallback#1291
ZhuLinsen wants to merge 1 commit into
mainfrom
codex/fix-settings-error-boundary

Conversation

@ZhuLinsen

Copy link
Copy Markdown
Owner

Summary

Fixes #1287.

  • Add a reusable page-level error boundary.
  • Wrap /settings so settings runtime errors render a diagnostic fallback instead of a blank page.
  • Include a desktop-specific hint asking for logs/desktop.log and the failing settings category.

Root Cause

The original Windows portable black-screen report still needs release/version logs to identify the exact failing settings branch. However, the settings route had no page error boundary, so any runtime render exception could collapse the page into a blank state.

Validation

  • cd apps/dsa-web && npm ci
  • cd apps/dsa-web && npm run test -- PageErrorBoundary.test.tsx (2 passed)
  • cd apps/dsa-web && npm run lint
  • cd apps/dsa-web && npm run build

Note: npm ci reported existing dependency audit findings: 10 vulnerabilities (4 moderate, 6 high). No new dependencies were added.

Risk

This prevents black-screen UX and improves diagnostics, but it does not prove the original Windows portable root cause. The follow-up still needs release version and desktop.log from an affected machine.

Rollback

Revert this PR to remove the settings page error boundary.

@github-actions github-actions Bot added documentation Improvements or additions to documentation size/M testing labels May 13, 2026
@github-actions

github-actions Bot commented May 13, 2026

Copy link
Copy Markdown

🤖 自动审查报告

项目 结果
📊 变更文件 5 个
➕ 新增行数 146 行
➖ 删除行数 2 行
🔍 静态检查 ✅ 通过
🧠 AI 审查 ✅ 已完成

📁 修改的文件

  • 📝 apps/dsa-web/src/App.tsx (+13/-2)
  • 🆕 apps/dsa-web/src/components/common/PageErrorBoundary.tsx (+84/-0)
  • 🆕 apps/dsa-web/src/components/common/__tests__/PageErrorBoundary.test.tsx (+47/-0)
  • 📝 apps/dsa-web/src/components/common/index.ts (+1/-0)
  • 📝 docs/CHANGELOG.md (+1/-0)

🧠 AI 代码审查意见

结论: Ready to Merge

结构化审查结果

  • 必要性: 通过

  • 关联性: 通过

  • 类型: fix

    • 建议类型: 变更内容(修复设置页黑屏问题)与 PR 标题和描述(fix settings page error fallback)高度匹配,属于 fix 类型。
  • 描述完整性: 完整

    • 背景: 描述了问题的根源是设置页缺少页面级错误边界。
    • 范围: 明确了通过添加可复用的页面级错误边界并包裹 /settings 路由来解决问题。
    • 验证命令与结果: 提供了详细的前端验证步骤(npm ci, npm run test, npm run lint, npm run build)及测试结果(2 passed),且 CI 检查状态显示静态检查通过。
    • 兼容性风险: 评估了风险,指出虽然改善了 UX 和诊断,但尚未完全证明原始 Windows 问题的根本原因。
    • 回滚方案: 提供了清晰的回滚方案(Revert this PR)。
  • 风险级别:

    • 关键风险: 引入了一个标准 React 错误边界组件,并应用于一个特定路由。此变更主要是增加了一个错误处理机制,预期不会引入新的功能性 bug,反而提高了系统的健壮性。已包含单元测试确保其基本功能。

必改项 (0 条)

无。

建议项 (1 条)

  1. docs/CHANGELOG.md: 当前 CHANGELOG.md[3.17.0] 下有两条关于设置页修复的条目:
    • - [修复] Web 设置页为通知测试与 Agent/通知配置区域增加局部运行时错误兜底,异常时提示提供 Windows 桌面端 \desktop.log`,避免整页黑屏。`
    • - [修复] 设置页增加错误边界,避免桌面端进入通知或 Agent 设置时因运行时异常直接黑屏。
      第二条是本次 PR 新增的。如果第一条描述的是其他已经存在的局部错误边界,则两项独立无问题。如果第一条也涵盖了本次 PR 的意图,可以考虑将两条合并为一条更全面且精确的描述,以避免潜在的重复或歧义。但这不影响功能正确性,仅为文档风格建议。

💡 提示: 请确保代码已通过本地测试,并遵循项目代码规范。

@ZhuLinsen
ZhuLinsen marked this pull request as ready for review May 13, 2026 15:02
Copilot AI review requested due to automatic review settings May 13, 2026 15:02

Copilot AI 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.

Pull request overview

This PR addresses the /settings blank/black-screen failure mode by adding a reusable React page-level error boundary and wrapping the settings route so runtime render exceptions show a diagnostic fallback (including a desktop log collection hint) instead of collapsing the page.

Changes:

  • Added PageErrorBoundary component that renders a user-facing fallback with optional diagnostics and a reload action.
  • Wrapped the /settings route in App.tsx with PageErrorBoundary and provided desktop-specific support hints.
  • Added unit tests for the new error boundary and documented the change in docs/CHANGELOG.md.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
docs/CHANGELOG.md Adds an Unreleased fix entry describing the settings-page error boundary.
apps/dsa-web/src/components/common/PageErrorBoundary.tsx Introduces a reusable page-level React error boundary with fallback UI and reload/reset behavior.
apps/dsa-web/src/components/common/index.ts Re-exports PageErrorBoundary from the common components barrel.
apps/dsa-web/src/components/common/tests/PageErrorBoundary.test.tsx Adds tests verifying normal rendering and fallback rendering/reset callback behavior.
apps/dsa-web/src/App.tsx Wraps the /settings route with PageErrorBoundary and provides diagnostic/support text.

Comment on lines +36 to +42
private handleReset = () => {
if (this.props.onReset) {
this.props.onReset();
return;
}
window.location.reload();
};

@ZhuLinsen ZhuLinsen left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

评审结论

  • 必要性:通过,关联 Windows 桌面端设置页黑屏/空白页诊断问题,增加路由级错误边界有实际修复价值。
  • 是否有对应 issue:有,Fixes #1287
  • PR 类型:fix,主要修复 /settings 运行时异常导致页面崩溃为黑屏的问题。
  • description 完整性:完整,已包含 Summary、Root Cause、Validation、Risk 和 Rollback,且说明了未完全证明原 Windows portable 根因。
  • 是否可直接合入:可,当前 CI 为 success,改动范围聚焦 Web 设置页错误兜底与测试;mergeable_state=blocked 更像分支保护状态,不单独构成阻断。

主要问题

  1. [Nice to have] apps/dsa-web/src/components/common/PageErrorBoundary.tsx 新增了 onReset 可选 API,但 handleReset 在调用 onReset 后不会清空 hasError/message,因此后续复用该组件并传入 onReset 时,fallback 可能一直停留在错误状态,除非父组件强制卸载或改 key。当前 /settings 路径未传 onReset,主修复路径不受影响;建议补充清状态逻辑或移除暂未使用的 API,并把测试从“只验证回调被调用”扩展到“reset 后可恢复渲染”的行为验证。

🤖 此回复由 OpenReview Bot 自动生成,仅供参考。如有疑问请 @维护者。

@ZhuLinsen
ZhuLinsen force-pushed the codex/fix-settings-error-boundary branch from 6441481 to a1c350d Compare May 15, 2026 12:35
@ZhuLinsen ZhuLinsen closed this May 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a1c350d47d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


{this.state.message ? (
<pre className="max-h-32 overflow-auto rounded-xl border border-danger/20 bg-danger/5 px-3 py-2 text-xs leading-5 text-danger">
{this.state.message}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Redact fallback error messages before display

When a settings child outside the existing panel boundary throws an Error whose message includes config-derived values such as a webhook URL, Authorization header, or API key, this page-level fallback renders that message verbatim in the UI. The existing SettingsPanelErrorBoundary already sanitizes and truncates these summaries, but this new boundary catches broader settings-page failures and can expose secrets in screenshots/support reports; please apply the same redaction/truncation before displaying the message.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/M testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Windows 免安装桌面端进入通知/Agent 设置可能黑屏

2 participants