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.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
feat(renderer): offscreen-dispose policy + offscreenTerminalMinutes setting
enesd34e11e34c02
diff --git a/src/renderer/terminal/offscreen-policy.test.ts b/src/renderer/terminal/offscreen-policy.test.tsnew file mode 100644index 000000000..5b5aa83b9--- /dev/null+++ b/src/renderer/terminal/offscreen-policy.test.ts@@ -0,0 +1,19 @@+import { describe, it, expect } from 'vitest'+import { OFFSCREEN_DISPOSE_MS_DEFAULT, offscreenDisposeMs, mayDisposeOffscreen } from './offscreen-policy'++describe('offscreen dispose policy', () => {+ it('default is 10 minutes; 0 disables; undefined falls back to default', () => {+ expect(OFFSCREEN_DISPOSE_MS_DEFAULT).toBe(600_000)+ expect(offscreenDisposeMs(undefined)).toBe(600_000)+ expect(offscreenDisposeMs(10)).toBe(600_000)+ expect(offscreenDisposeMs(0)).toBeNull()+ expect(offscreenDisposeMs(-3)).toBeNull()+ expect(offscreenDisposeMs(2)).toBe(120_000)+ })+ it('never disposes a visible, selected, or remote terminal', () => {+ expect(mayDisposeOffscreen({ visible: false, remote: false, selected: false })).toBe(true)+ expect(mayDisposeOffscreen({ visible: true, remote: false, selected: false })).toBe(false)+ expect(mayDisposeOffscreen({ visible: false, remote: true, selected: false })).toBe(false)+ expect(mayDisposeOffscreen({ visible: false, remote: false, selected: true })).toBe(false)+ })+})diff --git a/src/renderer/terminal/offscreen-policy.ts b/src/renderer/terminal/offscreen-policy.tsnew file mode 100644index 000000000..48d76f9a4--- /dev/null+++ b/src/renderer/terminal/offscreen-policy.ts@@ -0,0 +1,27 @@+/**+ * When to tear down an OFFSCREEN terminal's xterm+PTY client in place (node stays mounted; the+ * tmux session keeps running and re-attach redraws — same contract as the Refresh action and the+ * post-park remount). cmux's renderer-realization idea taken one level deeper: past this window+ * nobody has looked at the node for so long that reattach-redraw fidelity is indistinguishable+ * from park fidelity, and the buffer (up to ~16 MB full) is pure cost.+ *+ * REMOTE (SSH) nodes are excluded in v1: their spawn path runs the requireRemote/offline+ * machinery and a re-spawn while the ControlMaster is down would surface the offline overlay for+ * a node the user never touched. Follow-up once demand exists.+ */+export const OFFSCREEN_DISPOSE_MS_DEFAULT = 10 * 60_000++/** Setting is in minutes; 0 or negative = feature off; undefined = default. */+export function offscreenDisposeMs(settingMinutes: number | undefined): number | null {+ if (settingMinutes === undefined) return OFFSCREEN_DISPOSE_MS_DEFAULT+ if (!(settingMinutes > 0)) return null+ return Math.round(settingMinutes * 60_000)+}++export function mayDisposeOffscreen(i: {+ visible: boolean+ remote: boolean+ selected: boolean+}): boolean {+ return !i.visible && !i.remote && !i.selected+}diff --git a/src/shared/types.ts b/src/shared/types.tsindex 82f6205c7..6d516e00b 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -850,6 +850,9 @@ export interface Settings {* renderer. See `resolveTerminalRenderer` (shared/webgl.ts) for the full history. */terminalGpuRendering: 'auto' | 'on' | 'off' | 'shared'tmuxScrollback: number+ /** Minutes a terminal may sit fully offscreen before its xterm+PTY client is torn down in+ * place (tmux keeps the session; re-approach reattaches and redraws). 0 = never. */+ offscreenTerminalMinutes: number/** AI commit message agent: a local coding-agent CLI run read-only. */commitAgent: 'claude' | 'codex' | 'custom'/** For commitAgent='custom': command template; {prompt} placeholder optional (else stdin). */@@ -988,6 +991,7 @@ export const DEFAULT_SETTINGS: Settings = {tmuxEnabled: true,terminalGpuRendering: 'auto',tmuxScrollback: 50000,+ offscreenTerminalMinutes: 10,commitAgent: 'claude',commitAgentCommand: '',commitExtraPrompt: '',