COD-80 raise terminal history/scrollback/buffer defaults

Bump the centralized terminal-history defaults: tmux scrollback 50k->100k and
PTY buffer cap 2MB->32MB (trim 1.5MB->24MB). Both remain env/settings overridable
and bounds-clamped. Worst-case 20-session buffer budget rises 40MB->640MB.
Stacked on the terminal-history config commit.
This commit is contained in:
Aamer Akhter
2026-07-01 13:00:08 -04:00
parent 1fa88cd187
commit ad71a92f29
3 changed files with 18 additions and 19 deletions
+1 -2
View File
@@ -6,10 +6,9 @@
* it easy to tune memory usage.
*
* Memory Budget Rationale (for 20 concurrent sessions):
* - Terminal buffer: 2MB max × 20 = 40MB worst case
* - Terminal buffer: 32MB max × 20 = 640MB worst case
* - Text output: 1MB max × 20 = 20MB worst case
* - Messages: ~1KB each × 1000 × 20 = 20MB worst case
* - Total buffer overhead: ~80MB (acceptable for a long-running server)
*
* @module config/buffer-limits
*/
+9 -9
View File
@@ -1,19 +1,19 @@
/**
* Defaults, bounds, and resolution for terminal history retention.
*
* Centralizes the terminal scrollback, tmux history-limit, and server PTY buffer
* byte caps that were previously scattered as hardcoded literals. Each value is
* overridable (env var or the settings object) and clamped to a sane range via
* resolveTerminalHistoryConfig(). Defaults intentionally match the prior
* hardcoded values, so introducing this module is behavior-neutral.
* Defaults are sized to retain a full default scrollback for replay:
* - browser/tmux scrollback: 50,000 -> 100,000 lines
* - server PTY buffer cap: 2MB -> 32MB (room for 100k normal-width lines + ANSI)
* All values remain env- and settings-overridable and bounds-clamped via
* resolveTerminalHistoryConfig().
*/
export const DEFAULT_TERMINAL_SCROLLBACK_LINES = 50_000;
export const DEFAULT_TMUX_HISTORY_LIMIT = 50_000;
export const DEFAULT_TERMINAL_SCROLLBACK_LINES = 100_000;
export const DEFAULT_TMUX_HISTORY_LIMIT = 100_000;
export const DEFAULT_TERMINAL_BUFFER_MAX_BYTES =
parseInt(process.env.CODEMAN_MAX_TERMINAL_BUFFER || '', 10) || 2 * 1024 * 1024;
parseInt(process.env.CODEMAN_MAX_TERMINAL_BUFFER || '', 10) || 32 * 1024 * 1024;
export const DEFAULT_TERMINAL_BUFFER_TRIM_BYTES =
parseInt(process.env.CODEMAN_TRIM_TERMINAL_TO || '', 10) || 1.5 * 1024 * 1024;
parseInt(process.env.CODEMAN_TRIM_TERMINAL_TO || '', 10) || 24 * 1024 * 1024;
export const MIN_TERMINAL_SCROLLBACK_LINES = 1_000;
export const MAX_TERMINAL_SCROLLBACK_LINES = 1_000_000;
+8 -8
View File
@@ -22,11 +22,11 @@ describe('resolveTerminalHistoryConfig', () => {
});
});
it('defaults match the prior hardcoded values (behavior-neutral)', () => {
expect(DEFAULT_TMUX_HISTORY_LIMIT).toBe(50_000);
expect(DEFAULT_TERMINAL_SCROLLBACK_LINES).toBe(50_000);
expect(DEFAULT_TERMINAL_BUFFER_MAX_BYTES).toBe(2 * 1024 * 1024);
expect(DEFAULT_TERMINAL_BUFFER_TRIM_BYTES).toBe(1.5 * 1024 * 1024);
it('defaults raise tmux scrollback to 100k and terminal buffer cap to 32MB', () => {
expect(DEFAULT_TMUX_HISTORY_LIMIT).toBe(100_000);
expect(DEFAULT_TERMINAL_SCROLLBACK_LINES).toBe(100_000);
expect(DEFAULT_TERMINAL_BUFFER_MAX_BYTES).toBe(32 * 1024 * 1024);
expect(DEFAULT_TERMINAL_BUFFER_TRIM_BYTES).toBe(24 * 1024 * 1024);
});
it('passes valid in-range values through unchanged', () => {
@@ -80,9 +80,9 @@ describe('resolveTerminalHistoryConfig', () => {
});
it('caps the default trim to a lowered max', () => {
// Default trim (1.5MB) exceeds a 1MB max → trim must fall to the max.
const cfg = resolveTerminalHistoryConfig({ terminalBufferMaxBytes: 1 * 1024 * 1024 });
expect(cfg.terminalBufferTrimBytes).toBe(1 * 1024 * 1024);
// Default trim (24MB) exceeds a 2MB max → trim must fall to the max.
const cfg = resolveTerminalHistoryConfig({ terminalBufferMaxBytes: 2 * 1024 * 1024 });
expect(cfg.terminalBufferTrimBytes).toBe(2 * 1024 * 1024);
});
it('truncates fractional inputs to integers', () => {