Skip to content

[PR] fix(web): avoid full-text arrays for message previews - #6593

Merged
ranxianglei merged 1 commit into
ranxianglei:masterfrom
Afloat16:2026-11-13_bounded-message-previews
Nov 14, 2026
Merged

ranxianglei merged 1 commit into
ranxianglei:masterfrom
Afloat16:2026-11-13_bounded-message-previews

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

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.ts invokes the real buildSessionDetail with 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:

Tool result Master This change
1 KiB ASCII control 0.230 ms 0.277 ms
8 MiB ASCII 62.822 ms 0.704 ms

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

  • Twelve new compatibility controls pass on both unchanged master and this branch: ASCII/astral exact and over-limit boundaries, mixed astral boundary, combining code points, Unicode whitespace, whitespace-only tail, collapsed boundary, existing lone surrogate and unchanged retained source.
  • Related compression-tree, session endpoint and storage-fallback suites: 63 pass, 0 fail across three files. Existing live, stored and frozen-snapshot preview paths remain covered.
  • Typecheck, complete build, unused-export check, test-import-graph check and git diff --check pass.
  • Base: e1f31ad9d5b47500362699a9867819b861c7de96 (current master at submission). The remote Git tree exactly matches the tested local tree.
  • Full regression is the pushed-head hosted CI verdict; upstream [PR] test: unpin legacy envelope suites from the storage baseline #6561 tracks separate base-wide storage-test failures.

The linked issue contains reproduction, triage and all-state duplicate screening.

@ranxianglei ranxianglei changed the title fix(web): avoid full-text arrays for message previews [PR] fix(web): avoid full-text arrays for message previews Nov 13, 2026
@ranxianglei
ranxianglei merged commit de54a2c into ranxianglei:master Nov 14, 2026
43 of 48 checks passed
@ranxianglei

Copy link
Copy Markdown
Owner

Superseded by #6677 (merged as 3858b6956, 2026-11-14).

Landed into master via the real merge commit de54a2c2329 (Merge Afloat16/2026-11-13_bounded-message-previews (PR #6593)), so your original commits are preserved verbatim in master history — only hashes of the batch wrapper changed, your authorship and commit messages are intact.

The fix for #6590 is now in master. Closing this PR as superseded — thanks for the careful, well-tested fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session detail allocates a full character array for each 110-character preview

2 participants