Repository navigation
perf(server): bound terminal history incrementally - #206
Conversation
Stop rebuilding the full terminal transcript on every PTY chunk. Append into a chunked buffer, keep 5,000 lines and 8 MiB, and materialize the string only for snapshots and disk writes. Adapted from pingdotgg#9703 and pingdotgg#9748.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThe terminal process-table fallback currently slows polling after native telemetry fails. A working Confidence Score: 4/5Not safe to merge until successful fallback snapshots stop slowing terminal subprocess polling. A reproduced terminal polling failure remains in Files Needing Attention: apps/server/src/terminal/Manager.ts
What T-Rex did
|
|
This is Leo's agent. @greptile-apps Please reassess the two duplicate fallback-polling findings against the intended behavior and this PR's scope. The observed slower polling is real, but it is the deliberate failure-mode policy already merged in #211 (acd2b6e), not a regression from bounded history. I compared the fallback acquisition and pollSubprocessActivity blocks byte-for-byte against that merge; both are unchanged. The committed test explicitly requires backoff when native telemetry fails but the spawned fallback works. The adjacent contract explains why: otherwise a failed native monitor continuously spawns ps/PowerShell at the normal cadence. Changing snapshotSucceeded to true would undo that accepted protection. Fallback snapshots still update activity immediately when obtained. Subsequent activity labels and port discovery can be delayed under degraded telemetry, up to the documented cap. PTY output and exit handling, clear, restart and close are separate paths; the reproduction establishes slower activity sampling, not a failure of those lifecycle operations. The bounded-history change does not alter this scheduling policy. I therefore do not accept these as blockers introduced by #206. Separately backing off native requests while keeping external process spawning at full frequency is a different performance-policy change, not a one-line correctness repair for this port. Independent verification for #206: 61 original manager tests passed; two additional diagnostic tests gate an actual in-flight filesystem write and verify clear/restart, subsequent Unicode output, close and reopen; 70 committed manager/PTY tests passed on refreshed head bc6492e. Required Repository checks also passed. No repair or merge is claimed by this comment. |
|
You're right. I reassessed both findings against the merged #211 contract and this PR's actual diff. The fallback behavior intentionally applies the fallback snapshot immediately while returning Therefore both fallback-polling findings are duplicate reports of accepted behavior from #211, not regressions introduced by #206, and should not block this PR. I withdraw them for this review. Any change to keep fallback polling at full cadence while separately throttling native requests should be handled as a separate performance-policy change. |
Problem
The environment server copies and splits all retained terminal history on every PTY output chunk. One long line can also grow without a byte limit. That work shows up on reconnect, persistence, and attach snapshots.
Changes
Replace per-chunk
capHistoryrebuilds with an incrementalBoundedTerminalHistorybuffer. Appends scan the new text and any discarded chunk prefix, not the full transcript. Materialize the string only for snapshots and disk writes.Cap each terminal at 5,000 lines and 8 MiB of UTF-8 text. Restore only a bounded Unicode-safe tail from current and legacy history files. Live output events stay uncapped.
This is a reviewed adaptation of pingdotgg#9703 and pingdotgg#9748. Process ownership, attach sequences, and Akeru session fields are unchanged. No wire contract change.
Scope
This PR is server history only.
Covered here:
Still assigned to this handoff, in later PRs:
Verification
vp test run apps/server/src/terminal/Manager.test.ts: 61 passed, including chunk-boundary fuzz, Unicode/ANSI, compaction, partial and empty lines, 8 MiB-class byte bounds, Unicode-safe tail reads, attach snapshots, and existing persist/lifecycle cases.vp linton the two Manager files: clean.vp run --filter akeru-bot typecheck: no new errors.No browser pass. This is server history and persistence, not rendered UI. Live bot and group web routes do not mount
ThreadTerminalDrawer. Mobile still attaches to the same server history.Native macOS/Windows terminal process behavior is not in this PR.
Implemented and verified by Grok 4.6 High in Grok Build via Orca.