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): auto-reload the window after a renderer crash

enes24791977916d
diff --git a/src/main/index.ts b/src/main/index.ts
index 8091e78d7..0fc8cc08b 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -32,7 +32,7 @@ import {
isValidPendingId,
syntheticAnsweredEvent
} from '../core/agents/pending-approvals'
-import { setMainWindow, getMainWindow, sendToMain, shouldHideOnClose } from './main-window'
+import { setMainWindow, getMainWindow, sendToMain, shouldHideOnClose, createCrashReloadPolicy } from './main-window'
import {
initNotchHud,
applyNotchHudSettings,
@@ -409,7 +409,32 @@ function createWindow(): BrowserWindow {
})
// A crashed/killed renderer is the same story, minus the window: drop its subscriptions so the
// reloaded renderer reattaches to live sessions instead of inheriting the dead one's state.
- win.webContents.on('render-process-gone', () => ptyManager.dropClient(presenceId))
+ // And actually reload — a dead renderer otherwise leaves the window a permanent blank page
+ // (both projects, every terminal). Bounded by the policy so a boot-path crash can't loop;
+ // past the budget the user decides. The tmux sessions all live in this process, so a reload
+ // costs nothing but the canvas re-hydrating from the workspace store.
+ const crashReload = createCrashReloadPolicy()
+ win.webContents.on('render-process-gone', (_event, details) => {
+ ptyManager.dropClient(presenceId)
+ if (quitting || win.isDestroyed()) return
+ const action = crashReload(details.reason, Date.now())
+ if (action === 'reload') {
+ win.webContents.reload()
+ } else if (action === 'give-up') {
+ void dialog
+ .showMessageBox(win, {
+ type: 'error',
+ message: 'The window keeps crashing',
+ detail: `The interface process died repeatedly (${details.reason}). Your terminal sessions are still running.`,
+ buttons: ['Reload', 'Not Now'],
+ defaultId: 0,
+ cancelId: 1
+ })
+ .then(({ response }) => {
+ if (response === 0 && !win.isDestroyed()) win.webContents.reload()
+ })
+ }
+ })
win.on('ready-to-show', () => win.show())
// The main window is a regular app window; establishing its Dock presence explicitly means the
diff --git a/src/main/main-window.test.ts b/src/main/main-window.test.ts
index 49aa146df..fa99cc754 100644
--- a/src/main/main-window.test.ts
+++ b/src/main/main-window.test.ts
@@ -5,6 +5,7 @@ import {
sendToMain,
mainWindowClientIds,
shouldHideOnClose,
+ createCrashReloadPolicy,
type MainWindowLike
} from './main-window'
@@ -110,6 +111,41 @@ describe('main-window tracking', () => {
})
})
+// Field bug (2026-08-10): a dead renderer left the window permanently blank — the
+// render-process-gone handler dropped pty clients but nothing ever reloaded the page.
+describe('createCrashReloadPolicy', () => {
+ it('reloads after a crashed renderer', () => {
+ const onCrash = createCrashReloadPolicy()
+ expect(onCrash('crashed', 0)).toBe('reload')
+ })
+
+ it('reloads after an OOM kill', () => {
+ const onCrash = createCrashReloadPolicy()
+ expect(onCrash('oom', 0)).toBe('reload')
+ })
+
+ it('ignores a clean exit and spends no reload budget on it', () => {
+ const onCrash = createCrashReloadPolicy({ maxReloads: 1 })
+ expect(onCrash('clean-exit', 0)).toBe('ignore')
+ expect(onCrash('crashed', 1)).toBe('reload') // budget untouched
+ })
+
+ it('gives up when crashes keep coming inside the window (no reload loop)', () => {
+ const onCrash = createCrashReloadPolicy({ maxReloads: 2, windowMs: 60_000 })
+ expect(onCrash('crashed', 0)).toBe('reload')
+ expect(onCrash('crashed', 1_000)).toBe('reload')
+ expect(onCrash('crashed', 2_000)).toBe('give-up')
+ })
+
+ it('restores the budget once earlier reloads age out of the window', () => {
+ const onCrash = createCrashReloadPolicy({ maxReloads: 2, windowMs: 60_000 })
+ onCrash('crashed', 0)
+ onCrash('crashed', 1_000)
+ expect(onCrash('crashed', 2_000)).toBe('give-up')
+ expect(onCrash('crashed', 61_500)).toBe('reload') // both grants aged out
+ })
+})
+
describe('shouldHideOnClose', () => {
it('hides instead of closing on macOS while the app is not quitting', () => {
expect(shouldHideOnClose('darwin', false)).toBe(true)
diff --git a/src/main/main-window.ts b/src/main/main-window.ts
index ba8518667..d5271d0da 100644
--- a/src/main/main-window.ts
+++ b/src/main/main-window.ts
@@ -45,6 +45,28 @@ export function mainWindowClientIds(): number[] {
return typeof id === 'number' ? [id] : []
}
+export type CrashReloadAction = 'reload' | 'give-up' | 'ignore'
+
+// A dead renderer leaves the (single) window a permanent blank page — nothing in Electron
+// reloads it. Reload automatically, but bounded: a crash on the boot path would otherwise
+// reload forever. 'clean-exit' is a deliberate teardown (window close, navigation), never
+// reloaded; everything else — crashed, oom, abnormal-exit, launch-failed, and 'killed'
+// (macOS memory-pressure jetsam included) — deserves an attempt.
+export function createCrashReloadPolicy(
+ opts?: { maxReloads?: number; windowMs?: number }
+): (reason: string, now: number) => CrashReloadAction {
+ const maxReloads = opts?.maxReloads ?? 2
+ const windowMs = opts?.windowMs ?? 60_000
+ let granted: number[] = []
+ return (reason, now) => {
+ if (reason === 'clean-exit') return 'ignore'
+ granted = granted.filter((t) => now - t < windowMs)
+ if (granted.length >= maxReloads) return 'give-up'
+ granted.push(now)
+ return 'reload'
+ }
+}
+
// macOS convention: closing the window hides it (the app — and its tmux sessions,
// hook server, updater, license watchers — keeps running); a real close only happens
// on quit. Other platforms quit on window close, so never intercept there.