perf(server): bound terminal history by bytes (#9748)

Keep at most 5,000 lines and 8 MiB of retained UTF-8 terminal history. Discard the oldest text at either limit while preserving complete live output.

Track bytes and newlines in small chunks. Join split surrogates before eviction. Restore only the needed file tail, handle short reads, and close the file before rewriting current or legacy history.

Created with GPT-6 Astra (preview) in Codex.

Co-authored-by: will <will@moondiner.com>
cf9729d5eeTheo Browne committed on 9/4/2026, 6:49:15 PM· committed by GitHubparentfec606f
4 files changedLine totals unavailable