Centralize terminal history/scrollback/buffer limits into config (no behavior change)#137
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Introduces
src/config/terminal-history.tsas the single source of truth for terminal history retention — terminal scrollback lines, tmuxhistory-limit, and the server PTY buffer byte caps that were previously scattered as hardcoded literals acrossbuffer-limits.ts,tmux-manager.ts, andsession.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:
DEFAULT_SCROLLBACK)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.tsnow sourcesMAX_TERMINAL_BUFFER_SIZE/TRIM_TERMINAL_TOfrom the resolver (env-override semantics preserved).tmux-manager.tsusesDEFAULT_TMUX_HISTORY_LIMITin place of the hardcodedhistory-limit 50000, and gains asetHistoryLimit()(mux-interface + impl) so a settings change applies to live sessions; also re-applied onrespawnPaneso the limit survives a respawn.server.tsexposesgetTerminalHistoryConfig()on the route ctx;system-routes.tsapplies a changedtmuxHistoryLimitlive.session.tsthreads a per-sessiontmuxHistoryLimitinto the tmux spawn calls.schemas.tsadds 4 optional, bounds-clamped settings keys (terminalScrollbackLines,tmuxHistoryLimit,terminalBufferMaxBytes,terminalBufferTrimBytes) with atrim <= maxcross-check.Tests
New
test/terminal-history.test.ts(resolver defaults / clamping / trim<=max / non-number fallback) andtest/terminal-history-schema.test.ts(settings-schema validation).tsc --noEmit, lint, the focused tests, andnpm run buildall pass.