Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(main): end an open hang when the renderer dies

reviewab406f472b25
diff --git a/src/main/index.ts b/src/main/index.ts
index 3aad4fc25..68706cdfe 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -1413,6 +1413,8 @@ function createWindow(): BrowserWindow {
// The ring's only record that the page died — the reload below wipes the renderer's own console.
const gone = formatRenderProcessGone(details)
console[gone.level](`[process] ${gone.msg}`)
+ // A hang open on the dead page ends with it; the reloaded page's first hang is a new one.
+ hangs.reset()
ptyManager.dropClient(presenceId)
// A dead renderer sends no disarm and no focus-lost report. The reloaded page mounts no
// recorder and no terminal, so without this the user would come back to an app where ⌘W does
diff --git a/src/main/process-health-log.test.ts b/src/main/process-health-log.test.ts
index ce99ba7af..8b7b10aa9 100644
--- a/src/main/process-health-log.test.ts
+++ b/src/main/process-health-log.test.ts
@@ -73,6 +73,17 @@ describe('createHangTracker', () => {
expect(t.responsive(4000)).toBeNull()
})
+ it('a renderer that died while hung closes the hang: its successor\'s hang is a new one', () => {
+ const t = createHangTracker()
+ t.unresponsive(1000)
+ t.reset() // render-process-gone: the hung page is gone, and the reload is a fresh renderer
+ // No 'responsive' will ever answer the dead page; one that arrives is not its duration.
+ expect(t.responsive(9000)).toBeNull()
+ // The new page hanging is logged, not swallowed as a repeat of the dead page's hang.
+ expect(t.unresponsive(10_000)?.msg).toContain('hang #2')
+ expect(t.responsive(12_000)?.msg).toContain('after 2000 ms')
+ })
+
it('numbers successive hangs, and never reports a negative duration on a clock step back', () => {
const t = createHangTracker()
t.unresponsive(1000)
diff --git a/src/main/process-health-log.ts b/src/main/process-health-log.ts
index 716fb9610..3924a7f8b 100644
--- a/src/main/process-health-log.ts
+++ b/src/main/process-health-log.ts
@@ -68,6 +68,9 @@ export interface HangTracker {
unresponsive(now: number): HealthLine | null
/** BrowserWindow 'responsive'. Returns the line to log, or null if we never saw it hang. */
responsive(now: number): HealthLine | null
+ /** The renderer died ('render-process-gone'): an open hang ends unmeasured. The session's hang
+ * count is kept. */
+ reset(): void
}
/**
@@ -98,6 +101,12 @@ export function createHangTracker(): HangTracker {
level: 'warn',
msg: `window responsive again after ${ms} ms (counted from Electron's hang timeout, so the real stall was longer) — hang #${hangs}`
}
+ },
+ reset() {
+ // A hung page that dies never acks again, so without this the reloaded page's first hang
+ // would read as a repeat of the dead one, and its 'responsive' would report a duration
+ // spanning the crash.
+ since = null
}
}
}