fix(desktop): recover from main Renderer loss - #3495
Conversation
cad4a13 to
edb2d38
Compare
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
edb2d38 to
94b689b
Compare
jackwener
left a comment
There was a problem hiding this comment.
Independent review of 94b689b20.
-
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.
-
Solution.
observeMainRendererProcessGoneis a one-shot onwebContents. It ignoresclean-exitand anything afterbefore-quitaborts the window-creation signal (that abort happens before Electron closes windows, so shutdown-inducedkilled/crasheddoes not open the dialog). Unexpected loss shows the existing diagnostic dialog: Relaunch/Exit are the decisions, Copy Diagnostics is the extra button.hostTarget: 'none'socopyDesktopDiagnosticReportnever callsresolveActiveRuntimeHost/resolveRuntimeHost(the test fails those resolvers on purpose). Window load failure is a different path:onWindowCreationErrorlogs, no recovery dialog. -
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.
#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
Summary
English
Detect unexpected termination of the main BrowserWindow Renderer while the Electron main process remains alive.
中文
当 Electron 主进程仍存活、主 BrowserWindow 的 Renderer 意外终止时提供可恢复的诊断入口。
Fixes #3490
Refs #3463
Verification
English
npm --workspace @maka/desktop test— 1152 passednpm run buildnpm run typechecknpm run lintnpm run format:checknpx knip --workspace apps/desktopFocused tests cover the actual
render-process-goneobservation 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:
Tool(s) and scope: Codex implemented and validated the change under human direction. The commit includes the required
Generated-by: Codextrailer.Checklist
Does this PR entail a change in behavior?