Skip to content

Centralize terminal history/scrollback/buffer limits into config (no behavior change)#137

Merged
Ark0N merged 1 commit into
Ark0N:masterfrom
aakhter:cod-80-terminal-history-config
Jul 1, 2026
Merged

Centralize terminal history/scrollback/buffer limits into config (no behavior change)#137
Ark0N merged 1 commit into
Ark0N:masterfrom
aakhter:cod-80-terminal-history-config

Conversation

@aakhter

@aakhter aakhter commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

What

Introduces src/config/terminal-history.ts as the single source of truth for terminal history retention — terminal scrollback lines, tmux history-limit, and the server PTY buffer byte caps that were previously scattered as hardcoded literals across buffer-limits.ts, tmux-manager.ts, and session.ts.

Each value becomes overridable (env var or the settings object) and is bounds-clamped via a small pure resolveTerminalHistoryConfig().

Behavior-neutral

Defaults intentionally match the prior hardcoded values, so this PR changes no runtime behavior on its own:

value before this PR
tmux history-limit 50,000 50,000
terminal scrollback lines 50,000 (DEFAULT_SCROLLBACK) 50,000
PTY buffer max 2 MB 2 MB
PTY buffer trim 1.5 MB 1.5 MB

A follow-up PR (stacked on this one) raises these defaults; keeping the mechanism and the policy change separate so each can be reviewed on its own merits.

Wiring

  • buffer-limits.ts now sources MAX_TERMINAL_BUFFER_SIZE / TRIM_TERMINAL_TO from the resolver (env-override semantics preserved).
  • tmux-manager.ts uses DEFAULT_TMUX_HISTORY_LIMIT in place of the hardcoded history-limit 50000, and gains a setHistoryLimit() (mux-interface + impl) so a settings change applies to live sessions; also re-applied on respawnPane so the limit survives a respawn.
  • server.ts exposes getTerminalHistoryConfig() on the route ctx; system-routes.ts applies a changed tmuxHistoryLimit live.
  • session.ts threads a per-session tmuxHistoryLimit into the tmux spawn calls.
  • schemas.ts adds 4 optional, bounds-clamped settings keys (terminalScrollbackLines, tmuxHistoryLimit, terminalBufferMaxBytes, terminalBufferTrimBytes) with a trim <= max cross-check.

Tests

New test/terminal-history.test.ts (resolver defaults / clamping / trim<=max / non-number fallback) and test/terminal-history-schema.test.ts (settings-schema validation). tsc --noEmit, lint, the focused tests, and npm run build all pass.

Introduce src/config/terminal-history.ts: one place for terminal scrollback,
tmux history-limit, and PTY buffer byte caps, each overridable via env var or
the settings object and bounds-clamped via resolveTerminalHistoryConfig().
Defaults match the prior hardcoded values, so this is behavior-neutral. Wires
the resolver through buffer-limits, tmux-manager (incl. a setHistoryLimit so a
settings change applies live), session, server, system-routes, session-routes,
schemas, and the config port. Adds 4 optional settings keys (terminalScrollback
Lines, tmuxHistoryLimit, terminalBufferMaxBytes, terminalBufferTrimBytes) with
bounds + a trim<=max cross-check.
@Ark0N Ark0N merged commit 613eb25 into Ark0N:master Jul 1, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants