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.

Merge origin/main; gate the quit dialog behind a Behavior toggle, drop the CI matrix change

enes18197f2962a6
diff --cc src/main/index.ts
index ecb80c113,be7e09513..b1e875966
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@@ -361,39 -471,9 +471,44 @@@ let activeRemote: { cwd: string; ref: G
// True from the first before-quit on: lets window close-events through (see hide-on-close).
let quitting = false
+// Confirm-before-quit gate. Set once the user has answered "Quit" in the dialog below, or when
+// a quit is app-initiated rather than user-initiated (auto-update restart) and should not be
+// interrupted by a prompt for a decision already made. `pending` dedupes concurrent triggers
+// (shortcut + menu + window-close firing in the same tick) into a single dialog.
+let quitConfirmed = false
+let skipQuitConfirmation = false
+let quitConfirmationPending = false
+
+/** Resolves true once quitting may proceed. Shows a native confirm dialog (all platforms) on
- * first call; a Quit answer is remembered so the re-issued app.quit() below is not re-prompted. */
++ * first call; a Quit answer is remembered so the re-issued app.quit() below is not re-prompted.
++ * Read at ASK TIME, not captured: the Settings toggle must apply to the very next ⌘Q. */
+function confirmQuit(parentWin: BrowserWindow | null): Promise<boolean> {
++ if (!settingsStore.get().confirmBeforeQuit) return Promise.resolve(true)
+ if (quitConfirmed || skipQuitConfirmation) return Promise.resolve(true)
+ if (quitConfirmationPending) return Promise.resolve(false)
+ quitConfirmationPending = true
+ const opts = {
+ type: 'question' as const,
+ buttons: ['Cancel', 'Quit'],
+ defaultId: 0,
+ cancelId: 0,
+ title: 'Quit nodeterm?',
+ message: 'Quit nodeterm?',
+ detail: 'Terminal sessions keep running in the background and will still be here next time you open nodeterm.'
+ }
+ const p =
+ parentWin && !parentWin.isDestroyed() ? dialog.showMessageBox(parentWin, opts) : dialog.showMessageBox(opts)
+ return p.then(({ response }) => {
+ quitConfirmationPending = false
+ const confirmed = response === 1
+ if (confirmed) quitConfirmed = true
+ return confirmed
+ })
+}
+
+ // Keep-awake tracker (created in whenReady next to the notch HUD, disposed in before-quit).
+ let keepAwake: KeepAwakeTracker | undefined
+
// Browser <webview> guest webContents id → the browser node (and which of its two surfaces) it
// belongs to. Used today for new-window capture; every entry is proven to BE a <webview> before it
// lands here — see `registerBrowserGuest`.
@@@ -2747,18 -3259,13 +3312,23 @@@ app.on('window-all-closed', () =>
// the quit just long enough for them to land, capped so a hung tmux can never block quit.
let quitFlushed = false
app.on('before-quit', (e) => {
+ // Menu Quit / Cmd+Q / Ctrl+Q reach here directly (no window-close event first), so the confirm
+ // gate is repeated here for that path. quitConfirmed short-circuits this on the re-issued
+ // app.quit() below once the user has answered, and on the win.close() gate's own re-issue.
+ if (!quitConfirmed && !skipQuitConfirmation) {
+ e.preventDefault()
+ void confirmQuit(getMainWindow() as unknown as BrowserWindow | null).then((ok) => {
+ if (ok) app.quit()
+ })
+ return
+ }
quitting = true // from here on, window close-events must NOT be turned into hide
destroyNotchHud()
+ // Electron releases power assertions at exit anyway; disposing keeps the hold/release log
+ // honest. Clearing the ref too keeps a hook edge that lands during the quit flush (the pty
+ // teardown window below) from re-holding an assertion nothing will ever release.
+ keepAwake?.dispose()
+ keepAwake = undefined
workspaceWatcher.dispose()
if (quitFlushed) {
// Second pass (the deferred app.quit() below): the flush had its chance — drop the masters.
diff --cc src/renderer/components/settings/sections/BehaviorSection.tsx
index 0dc88f3eb,aac27a732..026be981d
--- a/src/renderer/components/settings/sections/BehaviorSection.tsx
+++ b/src/renderer/components/settings/sections/BehaviorSection.tsx
@@@ -51,6 -51,10 +51,14 @@@ const ROWS =
browserSaver: {
title: 'Browser memory saver',
keywords: ['browser', 'memory', 'saver', 'ram', 'webview', 'discard', 'page', 'web']
+ },
+ keepAwake: {
+ title: 'Keep awake while agents work',
+ keywords: ['sleep', 'awake', 'power', 'battery', 'suspend', 'run']
++ },
++ confirmQuit: {
++ title: 'Confirm before quitting',
++ keywords: ['quit', 'exit', 'close', 'confirm', 'dialog', 'ask']
}
}
const ENTRIES = Object.values(ROWS)
@@@ -269,6 -273,19 +277,32 @@@ export function BehaviorSection({ isAct
}
/>
</SearchableRow>
+ <SearchableRow {...ROWS.keepAwake}>
+ <FieldRow
+ label="Keep awake while agents work"
+ description="Holds off idle sleep while a local agent is running. A closed lid still sleeps the machine."
+ control={
+ <Switch
+ checked={settings.keepAwakeWhileAgentsWork}
+ onChange={(v) => update({ keepAwakeWhileAgentsWork: v })}
+ ariaLabel="Keep awake while agents work"
+ />
+ }
+ />
+ </SearchableRow>
++ <SearchableRow {...ROWS.confirmQuit}>
++ <FieldRow
++ label="Confirm before quitting"
++ description="Ask before the app quits (⌘Q / Ctrl+Q or the title-bar close). Terminal sessions survive a quit either way."
++ control={
++ <Switch
++ checked={settings.confirmBeforeQuit}
++ onChange={(v) => update({ confirmBeforeQuit: v })}
++ ariaLabel="Confirm before quitting"
++ />
++ }
++ />
++ </SearchableRow>
</SettingsSection>
)
}
diff --cc src/shared/types.ts
index 6918c54b6,50f9dcbd1..de7692585
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@@ -1154,6 -1185,10 +1185,14 @@@ export interface Settings
* hook holds briefly for a phone/canvas Approve/Deny before falling through to the normal
* interactive prompt. Off ⇒ the env var is absent ⇒ exact legacy behavior. Claude-only. */
hookReplyApprovals: boolean
+ /** Hold an idle-sleep power assertion while a LOCAL agent node is working, so long runs
+ * survive an unattended laptop. Released when the last one stops (or goes stale). Cannot
+ * hold through a closed lid. Asked in the setup tour; Settings → Behavior. */
+ keepAwakeWhileAgentsWork: boolean
++ /** Ask before the app actually quits (⌘/Ctrl+Q, menu Quit, or the Windows/Linux title-bar ×).
++ * The auto-update "Restart to update" flow never asks — that decision was already made.
++ * Settings → Behavior. */
++ confirmBeforeQuit: boolean
/** macOS Notch HUD (docs/notch-hud.md): a transparent always-on-top strip by the notch showing
* walking agent mascots while agents work, expanding into a mini session panel. Default on;
* macOS + desktop only (ignored on other platforms / Server Edition). */
@@@ -1265,6 -1317,9 +1321,12 @@@ export const DEFAULT_SETTINGS: Setting
// Deterministic hook-reply approvals default ON (existing users pick it up on hydrate). Only
// affects Claude terminal sessions; off reproduces the pre-feature launch bit-for-bit.
hookReplyApprovals: true,
+ // Keep-awake-while-agents-work default ON (existing users pick it up on hydrate — deliberate,
+ // same note style as hookReplyApprovals). Held only while a local agent is actually working.
+ keepAwakeWhileAgentsWork: true,
++ // Confirm-before-quit default ON: sessions survive a quit anyway, but an accidental ⌘Q
++ // tears down every window at once; the toggle is one switch away for who finds it noisy.
++ confirmBeforeQuit: true,
// macOS Notch HUD default ON (guarded to darwin at runtime; a no-op elsewhere).
notchHud: true,
notchWidth: 168,