perf(server): make terminal history updates incremental - #9357
Closed
burnmandont wants to merge 1 commit into
Closed
perf(server): make terminal history updates incremental#9357burnmandont wants to merge 1 commit into
burnmandont wants to merge 1 commit into
Conversation
Contributor
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR changes the production terminal output hot path and persistence lifecycle through a new stateful buffering abstraction. Although the scope is focused and the external formats remain stable, the runtime impact is broad enough to merit human review. You can add or adjust custom eligibility rules. Learn more. |
This was referenced Sep 4, 2026
t3dotgg
added a commit
that referenced
this pull request
Sep 4, 2026
Append terminal history incrementally and materialize text for snapshots and coalesced disk writes. Clear evicted line references without changing retained output. Continues [#9357](#9357). The original contribution and author credit are preserved. The current line limit and wire format stay unchanged. A strict byte limit remains separate work. Created with GPT-6 Astra (preview) in Codex. Co-authored-by: will <will@moondiner.com>
Member
|
Superseded by #9703 (perf(server): stop rebuilding terminal history per chunk), which continues this work and has merged to main. Closing this PR in favor of that continuation. |
richardsolomou
added a commit
to richardsolomou/ras-code
that referenced
this pull request
Sep 5, 2026
* feat(server): measure provider turn token usage (#9132) (cherry picked from commit 1587f248dd81ed45e214d476451ebf16dbfadb1a) * chore(upstream): record the provider turn token measurement * chore(upstream): record the marketing motion skip * perf(server): avoid full patches for checkpoint summaries (#9694) (cherry picked from commit c163d502dd32b993c03d8c20a5fae55b159bd8dc) * chore(upstream): record the checkpoint summary change * perf(web): defer diff workers until a code view opens (#9692) (cherry picked from commit b3e1d88590489da2bb63b95c18a57e6f400b8b7f) * chore(upstream): record the deferred diff workers * chore(upstream): record the marketing font skip * perf(server): stop rebuilding terminal history per chunk (#9703) Append terminal history incrementally and materialize text for snapshots and coalesced disk writes. Clear evicted line references without changing retained output. Continues [#9357](pingdotgg/t3code#9357). The original contribution and author credit are preserved. The current line limit and wire format stay unchanged. A strict byte limit remains separate work. Created with GPT-6 Astra (preview) in Codex. Co-authored-by: will <will@moondiner.com> (cherry picked from commit 3bbbc1d9fd8b3d649c60ba0137c7dae93a6aab3f) * chore(upstream): record aligned changes through 3bbbc1d9f * perf(server): use one query for buffered provider events (#9706) (cherry picked from commit dffb4cd3b16dc6f41aced99922950ee3083082c6) * chore(upstream): record the buffered event query * perf(relay): avoid repeated activity decoding (#9708) (cherry picked from commit c75299ee2085a121bceb6df76796e971fe92b5b6) * chore(upstream): record aligned changes through c75299ee2 * perf(web): stop continuous chat status animations (#9709) (cherry picked from commit c7c1dfe4df99edf65a49d8a31b39ef1361f37f44) * chore(upstream): record the chat status animation change * fix(mobile): preserve saved work after storage read failures (#9710) (cherry picked from commit 7839140e5e93d3f401d7eb45b86cf1a234eb3609) * perf(web): stop replaying terminal buffers on rollover (#9707) Keep bounded, byte-counted terminal chunks and append only unread output. Use UTF-16 cursors so compaction preserves live terminal replies. Reset on lifecycle changes or a real retained-data gap. Keep the existing wire protocol, native buffer interface, and client retention limit. Native streaming and strict server replay byte bounds remain separate. Continue the client helpers from pingdotgg/t3code#9027 at source head 9391da2b48439d1d7a2b01d169e785682bf8abb8. Created with GPT-6 Astra (preview) in Codex. Co-Authored-By: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> (cherry picked from commit da7e46d08e85bcb07ecd78721a40f7b612fac2f2) * feat(web): preview pull request links (#9631) Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com> (cherry picked from commit 95103905f5f045523994213bf76bfb14acc31b27) * perf(client): reduce thread-list update work (#9716) (cherry picked from commit c66f15f39e61fda0a9a100578833ec12e7526859) * fix(server): settle inactive threads with open PRs (#9610) (cherry picked from commit d536b0580d044967dc644498d8c5a6e96464f767) * fix(server): bound slow-client event buffers (#9715) (cherry picked from commit 108f295cc3672716c3cb8291ce487846df5ce098) * test(server): allow either valid file-search match (#9720) (cherry picked from commit 8ccb933a8aae461b616b199ab287164c3311a755) * chore(upstream): record aligned changes through 8ccb933a8 * fix(web): match provider settings layout for disconnected devices (#9619) (cherry picked from commit 8357eef14cbd5ed063e4a64404c33d1bfbc78446) * chore(upstream): record the provider placeholder layout * fix(web): keep the slash menu above the composer when vertical space is short (#9625) (cherry picked from commit 120fab18d84f1eb993ecc7fa858a8dd212747079) * chore(upstream): record aligned changes through 120fab18d * fix(mobile): remove provider setup (#9721) (cherry picked from commit 9eb4d71681dc7d002082db2f8b4bacf7614412f4) * chore(upstream): record the mobile provider setup removal * perf(web): stop rendering hidden terminals (#9718) Stop post-construction terminal snapshots, canvas paint, and cursor timers while a drawer or right panel is hidden. Keep parsing output and answering VT queries, then render current state once on reveal. Cover delayed WASM initialization, selection behavior, zero-size mounts, and reveal with real-core headless tests. Keep the existing startup background fill. Continue the zero-size guard from source commit eb5b68103506b1bb5bd81c3b9e27f11e349743c9 in the terminal streaming contribution. Created with GPT-6 Astra (preview) in Codex. Co-Authored-By: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit 5eab021a5185e492b6b021f83564143d5263e8a6) * chore(upstream): record aligned changes through 5eab021a5 * fix(mobile): read file-backed image drafts before enabling them (#9713) Accept file-backed image drafts and v4 outbox records while keeping current inline image creation and v3 outbox writes. Retain image files during previews, uploads, and legacy inline reads. Preserve image MIME types and stop canceled sends after asynchronous reads. The later file-backed writers remain held until new native runtime fingerprints contain these readers and the storage guards. Continue Wout Stiens' mobile draft work with separate reader-only corrections. The original contribution remains unchanged. Created with GPT-6 Astra (preview) in Codex. Co-Authored-By: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> (cherry picked from commit c4353bc6b972fa527579b530f01cc8744b2407d2) * chore(upstream): record the image draft rebase * perf(server): replay only the selected thread (#9726) Read only the selected thread's events when resuming its detail stream. Measure bounded row counts and serialized payload bytes before replay, using the existing aggregate index and a captured authoritative head. Keep snapshot resets for oversized or invalid cursors. Reset recreated threads when a snapshot exists, and keep bounded replay for deleted threads whose snapshot is absent. Shell replay and the detail-event filter are unchanged. Created with GPT-6 Astra (preview) in Codex. (cherry picked from commit 50bfca43d76ced00f5d67cfbab8bc44c50eb0e53) * fix(web): mute composer helper text (#9654) (cherry picked from commit 7d5dc66c151a9ca7bfef45cffc9d3516842c5566) * feat(web): unpin threads from the sidebar multi-select menu (#9651) Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit c7bf3115f2223ede5cb2316613dc7369155dbeb1) * chore(upstream): record aligned changes through c7bf3115f * perf(web): reuse timeline rows while text streams (#9725) Reuse ordered timeline entries and raw rows for safe streaming text updates. Keep full derivation for structural, metadata, activity, and control changes. Preserve immutable attachment-preview objects when their current URLs are unchanged. Cover URL renewal/removal, completion, grouping, pagination, and earlier-row immutability. Continue extoci's ordered timeline projection work with separate integration and attachment corrections. The original contribution remains unchanged. Created with GPT-6 Astra (preview) in Codex. Co-Authored-By: extoci <hi@extoci.lol> (cherry picked from commit 19c1710a88a2c87c159d76269dacdf0b17ddd9f4) * chore(upstream): record the timeline row reuse * fix(relay): bound stalled push requests (#9734) Give HTTP sends and response-body reads ten seconds each. Keep the existing typed transport errors, delivery records, and queue policy. Abort stalled requests and let the next signed job run. JWT retrieval is outside these deadlines. Do not add retries for an uncertain response result. Created with GPT-6 Astra (preview) in Codex. (cherry picked from commit 088cc3f95599b7b933289d719fa1e9b0608cb4cd) * perf(server): stop caching unused OpenCode tool parts (#9738) Do not retain OpenCode tool parts after emitting their runtime events. The remaining cache readers need text, reasoning, or step-usage parts, not tool input and output. Keep tool lifecycle events, output bytes, late-role assistant text, and usage handling unchanged. Add focused lifecycle coverage and verify retained memory through the real adapter. Created with GPT-6 Astra (preview) in Codex. (cherry picked from commit c8f77e0d441264efb0acfac312e852c81ae3da83) * chore(upstream): record aligned changes through c8f77e0d4 * fix(web): fold single trailing activity (#9739) Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com> (cherry picked from commit cfc9bf34156ddcc4a98b7f5c67193adb5aedce06) * chore(upstream): record the trailing activity fold * fix(web): show project settings for new threads (#9743) (cherry picked from commit cbe93e8dfba68ff6fbe8c69e43a633fdc79db62d) * perf(mobile): bound the parsed review cache (#9749) Bound cached parsed review sections by eight entries and 4,194,304 full source characters. Evicted inactive parsed and native results can be collected. Raw patches, comments, and view state stay unchanged. Prewarm only nearby sections that fit beside the selected section. Use actual retained source weights for normalized cache hits, and skip oversized prewarms. Created with GPT-6 Astra (preview) in Codex. (cherry picked from commit d6e29dc9dee943b34d6b0d11441fa944c7bff7c9) * perf(web): avoid repeated terminal metadata scans (#9747) Build one ordered terminal metadata index per immutable snapshot. Reuse unchanged session wrappers and thread groups across consumers, with separate environment targets. Keep numeric ordering, picker ties, attach state, and subscription lifetimes unchanged. Let retired snapshots and groups be collected. Created with GPT-6 Astra (preview) in Codex. (cherry picked from commit fec606f9ae524277ef1f6886e614f32d9e15e36e) * 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> (cherry picked from commit cf9729d5ee9660c08556e823080d3bb19648ed28) * feat(web): link pull request authors to profiles (#9627) Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com> (cherry picked from commit a76b898b3aa4fd4081104b06a3b2c942bd4fecb7) * fix(web): refine server update notice (#9744) (cherry picked from commit 0de956ed2f92b8a6ead56e1566801db232d365dc) * perf(client): stop thread streams when unused (#9740) Close a thread's live detail stream when its last consumer leaves. Retain a registry-local completed state and replay cursor for five idle minutes. Keep warm lookup independent of collectible raw atom definitions. Preserve paging and deletion state, reject stale owners, and cache only completed data/cursor updates. Skip repeated saves of unchanged data while retaining dirty-data flushes and failed-write retries. Verify real GC/remount behavior and focused lifecycle cases. Created with GPT-6 Astra (preview) in Codex. (cherry picked from commit d7cf8aaa8d4fbcbdd523b4f4bc86fda5c47b4a70) * perf(mobile): defer file preview highlighter startup (#9752) (cherry picked from commit 77b655c47b82c9b2aad09e447117b7618a16e21d) * perf(server): skip history reads for metadata commands (#9758) (cherry picked from commit 6365919f2e5bcfb4fa4020b95e19af26ae40979f) * chore(upstream): record aligned changes through 6365919f2 * perf(web): defer image URL requests for thread history (#9760) (cherry picked from commit 15eda897d37aad232fca5089f5eb6ef7b726c31c) * fix(server): read thread history where the fork transcript needs it The metadata-command split moved turn dispatch onto the message-free shell read, which the fork and provider-handoff transcripts depend on, and left two fork-only call sites pointing at the removed resolveThread. * chore(upstream): record the deferred image URLs and the history-read split * docs(upstream): typecheck after each adopt-aligned run verify is the only check between its picks, so a removed export that only a fork file used survives to whichever later commit happens to typecheck. * fix(models): make GPT-6-Astra current (#9762) (cherry picked from commit bc03c3640d6d3bb44e5fb477bfd78d7484cd0e00) * fix(web): stop empty diffs replacing pull requests (#9753) (cherry picked from commit d115a96763b76d00f06b06272688cf68eebe8206) * fix(sidebar): mute background working threads (#9759) (cherry picked from commit 45bd3b631bf1e84520c90ebdfdd1b135871ced14) * fix(web): reset automatic pull to default (#9763) Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com> (cherry picked from commit f6db4206258b0ef30e8dd8949627acfd209bf338) * fix(web): restore file comment focus in editable preview (#9061) (cherry picked from commit 13427ecd8ba5bfa7892fc90d1e3f0ef59514870f) * chore(upstream): record aligned changes through 13427ecd8 * chore(upstream): defer the internal docs restructure * chore(upstream): defer the user docs restructure * fix(web): stop panel motion during navigation (#9766) (cherry picked from commit cd713679bbe06c435823bafc48e5bcfa3266a9aa) * chore(upstream): record the panel motion suppression * fix(web): open composer selectors below controls (#9767) (cherry picked from commit 8e056a0e5124775b9439751667bac483d7b5320a) * perf(server): skip unused Linux process detail reads (#9768) (cherry picked from commit 163d86a78430d23414abde323ca70d8379280c0b) * fix(server): remove retired Codex models after refresh (#9773) (cherry picked from commit bfef973d9ec64e580fff4197ac53085207471ffd) * chore(upstream): record aligned changes through bfef973d9 * test: stop path and platform tests depending on the host OS (#9564) Co-authored-by: Claude Code <noreply@anthropic.com> (cherry picked from commit cc60753aa2279722149e182fb942ca87f70ff804) * chore(upstream): record the host-independent path tests * test(server): skip posix executable fixtures on a Windows host (#9565) Co-authored-by: Claude Code <noreply@anthropic.com> (cherry picked from commit 4701041eef6339bbda0d9d9b00a929c4e9e18662) * chore(upstream): record the Windows fixture skip * test(mobile): assert cold-start highlighting per entry point Comparing the two entry points' token arrays assumes both resolve the same regex engine. Linux CI produced a different split for the same grammar and theme, so each path is checked for the behaviour the test names instead. --------- Co-authored-by: Theo Browne <me@t3.gg> Co-authored-by: maria <maria@kuuro.net> Co-authored-by: Guillermo Casanova <75276669+Gigioxx@users.noreply.github.com> Co-authored-by: oliver <97427849+flamboh@users.noreply.github.com> Co-authored-by: Igor Makowski <56691628+Mnigos@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: Jake Leventhal <jakeleventhal@me.com> Co-authored-by: Gianmarco <gianmarcosimone89@gmail.com> Co-authored-by: extoci <hi@extoci.lol> Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com> Co-authored-by: Shpetim <32248437+ShpetimA@users.noreply.github.com>
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 Changed
Why
Every PTY output chunk currently concatenates, splits, caps, and rejoins the entire retained history. Once the default 5,000-line buffer is full, sustained output repeatedly copies the whole buffer and makes callback cost proportional to retained history size.
The bounded buffer processes only newly received text during the hot path while keeping the existing wire format, persistence format, and terminal behavior unchanged.
A local Node 26.2 benchmark appended 50,000 representative one-line chunks while retaining 5,000 lines. The existing implementation took 7,342.5 ms; the incremental buffer took 5.5 ms (approximately 1,325x faster). Both produced byte-for-byte identical 230,000-byte output. These are machine-specific measurements rather than a product budget.
Verification
vp test run apps/server/src/terminal/Manager.test.ts— 55 tests passedvp run --filter t3 typecheck— passed (pre-existing Effect suggestions only)vp fmt --check apps/server/src/terminal/Manager.ts apps/server/src/terminal/Manager.test.ts docs/internals/terminal-runtime.md— passedChecklist
Created with GPT-5.6 in the Codex harness.
Note
Medium Risk
Touches core terminal output and persistence on every PTY chunk; behavior is heavily tested but regressions in line boundaries or capping would affect all integrated terminals.
Overview
Replaces per-chunk full-string history rebuild (concatenate, split, cap, rejoin) with an incremental
BoundedTerminalHistoryline buffer on the PTY output hot path. Sessions nowappendsanitized chunks and onlyvalue()materialize the full transcript for client snapshots and debounced disk writes.Clear, restart, and cwd/context resets use
history.clear()instead of assigning an empty string; the coalescing persist worker still receives the live buffer object and writeshistory.value()after debounce. Wire format and line-cap semantics stay the same, with a new test covering chunked partial lines, empty lines, and trailing newlines.Adds
docs/internals/terminal-runtime.mddocumenting the output path and the performance invariant that retained history must not be copied on every PTY callback.Reviewed by Cursor Bugbot for commit ed17b7d. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Make terminal history updates incremental in
TerminalManagerBoundedTerminalHistory) that caps retained lines and materializes the full string only on demandvalue()at write time, so debounced writes reflect the latest state instead of a snapshot string enqueued earlierBoundedTerminalHistoryhandles trailing-newline and partial-line state internally; any out-of-tree code reading thehistoryfield via snapshot will still get a string, but the value is now materialized throughBoundedTerminalHistory.value()rather than maintained eagerly📊 Macroscope summarized ed17b7d. 2 files reviewed, 1 issue evaluated, 1 issue filtered, 0 comments posted
🗂️ Filtered Issues
apps/server/src/terminal/Manager.ts — 0 comments posted, 1 evaluated, 1 filtered
appenddrops a newline-only chunk when the existing history already ends in a newline. For example, appending"\n"to retained"a\n"takes thethis.trailingNewlinebranch with an emptyappendedLinesarray, leaving the value"a\n"rather than"a\n\n". PTY chunk boundaries can split consecutive blank lines this way, so terminal history and persisted/snapshotted output silently lose empty lines. [ Out of scope (triage) ]