Repository navigation
[PR] fix(web): avoid full-text arrays for message previews - #6593
Merged
ranxianglei merged 1 commit intoNov 14, 2026
Merged
Conversation
Owner
|
Superseded by #6677 (merged as Landed into master via the real merge commit The fix for #6590 is now in master. Closing this PR as superseded — thanks for the careful, well-tested fix. |
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.
Fixes #6590
Problem
Opening a session's compression tree converts every character of each tool result into an array just to display a 110-code-point preview. Large retained results impose avoidable synchronous CPU and allocation in the proxy process.
Change
Stop after at most 111 code points of the existing normalized string. Keep whitespace collapse and trim, the 110-code-point limit and ellipsis rule, astral characters, combining sequences, existing lone-surrogate behavior, and the original retained text. This is a display-only host change; it does not alter kernel, wire, persistence or configuration behavior.
The whitespace normalization still scans the full text. This removes the full-text character array; it does not claim constant work for the entire preview pipeline.
Measurement
The included
scripts/bench-web-message-preview.tsinvokes the realbuildSessionDetailwith one compressed block and one retained tool result. On Node 24.22.1/Linux, three fresh process pairs each ran two warmups and five timed renders. Median of per-process medians:For 8 MiB, median whole-process peak RSS was 186,940 KiB before and 117,476 KiB after (about 67.8 MiB lower). Every complete response hash matched:
854de61ce4d75e2964f560b50961afc576e4ae2ed8b71c32b80a02c611cd83b5. The benchmark pins the ledger generation clock for byte-for-byte output comparison while measuring elapsed time with the monotonic clock.These are renderer measurements on a synthetic workload, not production HTTP latency. The small-input control was slightly slower in this sample; the material improvement is removal of the large array for large results.
Verification
git diff --checkpass.e1f31ad9d5b47500362699a9867819b861c7de96(current master at submission). The remote Git tree exactly matches the tested local tree.The linked issue contains reproduction, triage and all-state duplicate screening.