Skip to content

fix(desktop): recover from main Renderer loss - #3495

Merged
jackwener merged 3 commits into
mainfrom
fix/main-renderer-process-diagnostics
Aug 22, 2026
Merged

fix(desktop): recover from main Renderer loss#3495
jackwener merged 3 commits into
mainfrom
fix/main-renderer-process-diagnostics

Conversation

@M4n5ter

@M4n5ter M4n5ter commented Aug 22, 2026

Copy link
Copy Markdown
Member

Summary

English

Detect unexpected termination of the main BrowserWindow Renderer while the Electron main process remains alive.

  • Ignore clean exits and app shutdown.
  • Capture the bounded reason and exit code in existing main-process diagnostics.
  • Present a native recovery dialog where Copy Diagnostics remains auxiliary to Relaunch or Exit.
  • Keep the report Desktop-only instead of inferring Runtime Host authority.
中文

当 Electron 主进程仍存活、主 BrowserWindow 的 Renderer 意外终止时提供可恢复的诊断入口。

  • 忽略正常退出和应用关闭流程。
  • 将限长后的退出原因与退出码记录到既有主进程诊断中。
  • 通过原生恢复弹窗提供复制诊断信息,同时保留重新启动或退出决策。
  • 报告仅归因于 Desktop,不推断 Runtime Host。

Fixes #3490
Refs #3463

Verification

English
  • npm --workspace @maka/desktop test — 1152 passed
  • npm run build
  • npm run typecheck
  • npm run lint
  • npm run format:check
  • npx knip --workspace apps/desktop

Focused tests cover the actual render-process-gone observation boundary, shutdown filtering, rejected window loads, and the Copy Diagnostics → Relaunch decision path.

中文

上述检查均通过;聚焦测试覆盖真实的 render-process-gone 事件边界、关闭流程过滤、窗口加载失败,以及“复制诊断信息后仍可重新启动”的决策路径。

Review focus

English

Please verify that the lifecycle filter reports only unexpected loss of the main Renderer and that the native report remains within the existing Desktop diagnostic authority.

中文

请重点确认生命周期过滤仅报告主 Renderer 的意外终止,并且原生报告仍遵循既有 Desktop 诊断权限边界。

AI use

Select exactly one:

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

Tool(s) and scope: Codex implemented and validated the change under human direction. The commit includes the required Generated-by: Codex trailer.

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

@M4n5ter
M4n5ter force-pushed the fix/main-renderer-process-diagnostics branch from cad4a13 to edb2d38 Compare August 22, 2026 13:19
Observe unexpected termination of the main BrowserWindow renderer while the Electron main process is still alive. Reuse the native diagnostic dialog and existing report formatter so users can copy bounded Desktop evidence before choosing to relaunch or exit, without querying an unrelated Runtime Host.

Generated-by: Codex
Route every window creation through the quit coordinator so rejected initial loads are reported instead of escaping as unhandled rejections. Test the real render-process-gone observation boundary while preserving the existing native recovery decision flow.

Generated-by: Codex
Route Renderer-loss copying through the existing Desktop diagnostic authority so collection, Host attribution, redaction, and clipboard behavior keep one owner. Align the shutdown regression test with the production register-then-abort lifecycle.

Generated-by: Codex
@M4n5ter
M4n5ter force-pushed the fix/main-renderer-process-diagnostics branch from edb2d38 to 94b689b Compare August 22, 2026 13:46
@M4n5ter
M4n5ter marked this pull request as ready for review August 22, 2026 13:52

@jackwener jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Independent review of 94b689b20.

  1. Problem. Main process can outlive the main BrowserWindow Renderer. Without a filter, shutdown looks like a crash; without a native path, there is no recovery once the UI is gone.

  2. Solution. observeMainRendererProcessGone is a one-shot on webContents. It ignores clean-exit and anything after before-quit aborts the window-creation signal (that abort happens before Electron closes windows, so shutdown-induced killed/crashed does not open the dialog). Unexpected loss shows the existing diagnostic dialog: Relaunch/Exit are the decisions, Copy Diagnostics is the extra button. hostTarget: 'none' so copyDesktopDiagnosticReport never calls resolveActiveRuntimeHost / resolveRuntimeHost (the test fails those resolvers on purpose). Window load failure is a different path: onWindowCreationError logs, no recovery dialog.

  3. Occam. Observer is ~19 lines. Dialog reuses showMessageBoxWithDiagnostics. Diagnostic fields reuse the native helper. Quit coordinator now owns initial window creation and rejected loads. Not extra domain.

Approve.

@jackwener
jackwener merged commit 9a661a1 into main Aug 22, 2026
2 checks passed
@jackwener
jackwener deleted the fix/main-renderer-process-diagnostics branch August 22, 2026 13:57
jackwener pushed a commit that referenced this pull request Aug 22, 2026
#3495 branched before #3397 landed, so its two new files arrived without the
ASF header and its CI predates the `audit` job. `check:asf-headers` runs in
`ci.yml`, so main is currently failing that check and every open PR inherits
the failure.

`npm run write:asf-headers` produced this; nothing else was touched.

Generated-by: Claude Code
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.

feat(desktop): expose diagnostics when the main Renderer process disappears

2 participants