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.

feat(terminal): raise default park cap 12 -> 20 (#886)

reviewb894163fc9b0
diff --git a/CLAUDE.md b/CLAUDE.md
index 67b63627b..bee94b3b3 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -586,7 +586,7 @@ Lifecycle, by intent:
teardown: `kill()` detaches the PTY client; the tmux session keeps running. **Window and cap
are settings (issue #886)**: `settings.terminalParkMinutes` (default 5; **0 = until app quit** —
`parkWindowMs` returns `null` and NO timer is armed, never `Infinity`, which `setTimeout` clamps
- to ~1 ms and would dispose every park at once) and `settings.terminalParkMax` (default 12), both
+ to ~1 ms and would dispose every park at once) and `settings.terminalParkMax` (default **20**, raised from 12), both
re-validated at park time. The LRU cap evicts **local parks before remote ones**
(`planParkEviction`'s `isRemote`): a local re-adopt miss is a warm reattach in ms, an SSH one is
a new client per terminal paced 4-per-master, plus a login if the master idled out
diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsx
index 118db4fb5..58e6ef0f9 100644
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@ -509,7 +509,7 @@ interface ParkedTerminal {
}
const parkedTerminals = new Map<string, ParkedTerminal>()
// The park window is `settings.terminalParkMinutes` (default 5 = the historical TERM_PARK_MS; 0 =
-// until the app quits) and the count cap `settings.terminalParkMax` (default PARK_MAX = 12), both
+// until the app quits) and the count cap `settings.terminalParkMax` (default PARK_MAX = 20), both
// read at PARK time through their validators (`parkWindowMs` / `parkCap`), so a change applies to
// the next switch-away without touching entries already parked. Issue #886.
diff --git a/src/renderer/terminal/park-budget.test.ts b/src/renderer/terminal/park-budget.test.ts
index 2476ad680..41bc4a668 100644
--- a/src/renderer/terminal/park-budget.test.ts
+++ b/src/renderer/terminal/park-budget.test.ts
@@ -24,9 +24,9 @@ describe('planParkEviction', () => {
it('evicts the oldest entries beyond the cap, oldest first', () => {
expect(planParkEviction(['a', 'b', 'c', 'd'], 2)).toEqual(['a', 'b'])
})
- it('default cap is 12', () => {
- expect(PARK_MAX).toBe(12)
- const keys = Array.from({ length: 13 }, (_, i) => `k${i}`)
+ it('default cap is 20', () => {
+ expect(PARK_MAX).toBe(20)
+ const keys = Array.from({ length: 21 }, (_, i) => `k${i}`)
expect(planParkEviction(keys, PARK_MAX)).toEqual(['k0'])
})
it('skips protected parks and takes the next disposable one instead', () => {
@@ -91,7 +91,7 @@ describe('a parked plain-shell agent survives the departure clear (#126)', () =>
park('victim', { tmuxBacked: false, parkedAgentState: 'working', liveAgentState: 'working' })
departureClear('victim')
for (let i = 0; i < PARK_MAX; i++) park(`other${i}`, { tmuxBacked: true })
- // 13 parks against a cap of 12, oldest ('victim') first — the exact >PARK_MAX project switch.
+ // PARK_MAX+1 parks against the cap, oldest ('victim') first — the exact >PARK_MAX project switch.
const plan = planParkEviction([...registry.keys()], PARK_MAX, disposable)
expect(plan).not.toContain('victim')
expect(plan).toEqual(['other0']) // the cap still holds, paid by the next-oldest disposable park
diff --git a/src/renderer/terminal/park-budget.ts b/src/renderer/terminal/park-budget.ts
index 70a143851..02de8a4c4 100644
--- a/src/renderer/terminal/park-budget.ts
+++ b/src/renderer/terminal/park-budget.ts
@@ -14,9 +14,14 @@ import type { AgentState } from '@shared/agents/normalize'
* park just means the next remount is a warm tmux reattach (tmux redraws), the same path every
* remount after the 5-minute window already takes.
*
- * 12 ≈ one busy project's worth of terminals; the same order of magnitude as WEBGL_BUDGET.
+ * 20 (raised from 12 in issue #886): with several SSH projects open, 12 was hit long before the
+ * park window and turned ordinary project cycling into seconds-long remote reattaches. A parked
+ * tmux-backed terminal measured ≈ 2 MB (headless xterm, 200×50), so the raise costs ≈ 16 MB more
+ * in the common case; a plain shell with a full scrollback (≈ 27 MB) is the expensive exception,
+ * and the memory-pressure lever still drops every disposable park. User-tunable via
+ * `settings.terminalParkMax`.
*/
-export const PARK_MAX = 12
+export const PARK_MAX = 20
/** Default park window in minutes (`settings.terminalParkMinutes`) — the historical
* `TERM_PARK_MS` of 5 minutes, unchanged for everyone who never touches the setting. */
diff --git a/src/shared/types.ts b/src/shared/types.ts
index 8fe1fae24..83388065e 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -1610,7 +1610,7 @@ export interface Settings {
* Default 5. Hand-editable; re-validated at the use site (`parkWindowMs`). Issue #886. */
terminalParkMinutes: number
/** Max parked terminals across all projects before the oldest (local first, then remote) are
- * released early. Default 12. Re-validated at the use site (`parkCap`). Issue #886. */
+ * released early. Default 20. Re-validated at the use site (`parkCap`). Issue #886. */
terminalParkMax: number
/** AI commit message agent: a local coding-agent CLI run read-only. */
commitAgent: 'claude' | 'codex' | 'custom'
@@ -1886,7 +1886,7 @@ export const DEFAULT_SETTINGS: Settings = {
tmuxLeadPaneWidth: 0,
offscreenTerminalMinutes: 10,
terminalParkMinutes: 5,
- terminalParkMax: 12,
+ terminalParkMax: 20,
commitAgent: 'claude',
commitAgentCommand: '',
commitExtraPrompt: '',