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 remote-tracking branch 'origin/main' into keepawake-push

enes08b2b1ebad6f
diff --cc src/main/index.ts
index 8f16e7fb8,0cee368be..519500402
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@@ -63,14 -99,18 +99,20 @@@ import
sessionNameSweepEntries,
nodeState,
nodeSessionName,
- workingNodeIds
+ workingNodes
} from '../core/agent-status-mirror'
+ import { paneOwnerProject } from '../core/agents/pane-ownership'
import { createPushNotify, createLiveUpdatePush } from '../core/push-notify'
- import { createGrantsAccessor } from '../core/push-grants'
+ import { createGrantsAccessor, type PushGrant } from '../core/push-grants'
+ import { createRemoteGrantsCache } from '../core/remote-push-grants'
import { createAckSweeper } from '../core/ack-sweep'
import { createSessionReaper } from '../core/session-budget'
+import { initKeepAwake } from './keep-awake'
+import type { KeepAwakeTracker } from '../core/keep-awake'
+ import { startSessionMemoryService, sshScopePredicate } from '../core/session-memory-service'
+ import { createMemoryPressureMonitor } from '../core/memory-pressure'
+ import { createPtyPressureMonitor } from '../core/pty-pressure'
+ import { registerPtmxLimitHandler } from './ptmx-limit'
import { getDeviceId } from '../core/device-id'
import { initRemoteStatusPush } from './remote-ssh/remote-status-push'
import { initCanvasSync } from '../core/canvas-sync'
@@@ -296,11 -361,10 +363,13 @@@ 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
+// Keep-awake tracker (created in whenReady next to the notch HUD, disposed in before-quit).
+let keepAwake: KeepAwakeTracker | undefined
+
- // Browser <webview> guest webContents id → its browser node id (for new-window capture).
- const browserGuests = new Map<number, string>()
+ // 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`.
+ const browserGuests = new Map<number, BrowserGuest>()
// Node → live tail bookkeeping, so closing a node (× → pty:destroy) releases its file tailers.
// Without this, a node closed mid-run never emits SessionEnd/PostToolUse, so context-tail (1s
@@@ -896,26 -1309,14 +1314,34 @@@ app.whenReady().then(async () =>
initNotchHud({ getNodeTitle: displayTitleFor }, notchTunables())
if (win.isVisible()) startNotchHud()
else win.once('show', startNotchHud)
- settingsStore.onChange(() => applyNotchHudSettings(notchTunables()))
+ buildAppMenu(win)
+ // Rebuild the native menu on every settings change so the View → Snap to Grid checkmark (and
+ // any future live label) tracks the renderer's setting. The renderer is the sole settings
+ // writer; a change persists through `settingsStore`, which fires this hook. No reverse IPC.
++ // Keep-awake re-reads its enable flag on the same edge.
+ settingsStore.onChange(() => {
+ applyNotchHudSettings(notchTunables())
+ buildAppMenu(win)
++ keepAwake?.refresh()
++ })
+ // Keep awake while agents work (docs/superpowers/specs/2026-08-18-keep-awake-design.md): hold an
+ // idle-sleep power assertion while a LOCAL agent node is working, released the moment the last
+ // one stops. Folds the same mirror edges the notch does; the stale sweep's synthetic end
+ // (WORKING_STALE_MS) is the leak backstop for exits that never send their own edge.
+ keepAwake = initKeepAwake({
+ enabled: () => settingsStore.get().keepAwakeWhileAgentsWork,
+ // SSH-homed nodes work on the remote host — they must not pin THIS machine awake.
+ isRemoteNode: (nodeId) => workspaceStore.sshProjectIdForNode(nodeId) !== undefined
})
+ onNodeStateChange((c) => keepAwake?.onChange(c))
- settingsStore.onChange(() => keepAwake?.refresh())
+ // Seed from the restored mirror: an app relaunch (auto-update, crash) does not stop a
+ // tmux-backed run, and loadPersisted deliberately restores its `working` entry WITHOUT firing
+ // edges — so without this the machine would go unprotected until the run's next turn boundary.
+ // The tracker applies the same isRemoteNode/enabled gates as a live edge, and an entry that is
+ // in fact gone is released by the stale sweep's synthetic end within its next tick.
- for (const nodeId of workingNodeIds()) {
++ for (const { nodeId } of workingNodes()) {
+ keepAwake.onChange({ nodeId, event: 'start', state: 'working' })
+ }
// Advertise launch settings to the mobile companion through the mirror. The provider is
// consulted at every flush (heartbeat ≤60s), so a settings change propagates without extra
// plumbing. Caps arrive async: re-flush once the memoized probe answers.
diff --cc src/renderer/components/settings/sections/BehaviorSection.tsx
index 9b0435c8b,0dc88f3eb..aac27a732
--- a/src/renderer/components/settings/sections/BehaviorSection.tsx
+++ b/src/renderer/components/settings/sections/BehaviorSection.tsx
@@@ -29,9 -48,9 +48,13 @@@ const ROWS =
title: 'Canvas left-drag',
keywords: ['pan', 'drag', 'select', 'canvas', 'mouse', 'grab', 'figma', 'miro']
},
+ 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']
}
}
const ENTRIES = Object.values(ROWS)
@@@ -175,19 -256,19 +260,32 @@@ export function BehaviorSection({ isAct
}
/>
</SearchableRow>
+ <SearchableRow {...ROWS.browserSaver}>
+ <FieldRow
+ label="Browser memory saver"
+ description="Free a hidden browser page's memory after 5 minutes; it reloads when shown. Each page is a whole Chromium process."
+ control={
+ <Switch
+ checked={settings.browserMemorySaver}
+ onChange={(v) => update({ browserMemorySaver: v })}
+ ariaLabel="Browser memory saver"
+ />
+ }
+ />
+ </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>
</SettingsSection>
)
}