perf(transcript): bound streamed projection work (cmux#34383)
Fix the long transcript replay's per-token O(rows) projection work by carrying the earliest changed row alongside each ordered snapshot and reusing the already-shaped prefix. Structural rebuilds conservatively invalidate the prefix; filtered permission views keep their existing full-projection path.
Leo asked for this parity work after seeing streaming degrade under contention: “It should just never, ever, ever, ever be acceptable for there to be linear time growth degradation in performance just because the app somehow has tons of workspaces, thousands, whatever workspace... you’re only seeing at any given point one screen at a time... important bits get extreme priority and everything else goes by the wayside.”
This also addresses the replay-harness finding in cmux#34383: the 600-turn transcript costs O(rows) per streamed token.
Performance
| Replay metric (600 turns, shared transcript-replay harness) | Before (cmux#34382 baseline) | After |
|---|---|---|
| streamed token p95 main-thread time | 7.64 ms | pending exact-head CI run |
| token slope per 1,000 existing rows | 0.70 ms | pending exact-head CI run |
| streamed tool-output p95 | 11.13 ms | pending exact-head CI run |
The benchmark remains advisory in CI; it is not a runtime default or feature flag.
Tests: bun test webviews/src/agent-session/acpmux/conversation/thoughts.test.ts (6 pass). The ordered-row performance test runs in the managed CI environment because this lane lacks its optional local dependency.
agent-identity footer --repo manaflow-ai/cmux
🤖 Generated with Codex
Agent session: agent session
![Autofix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png)
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.
Summary by cubic
Fixes the long transcript replay's per-token O(rows) projection work by tracking the first changed row in each ordered snapshot and reusing the already-shaped prefix.
OrderedRowsrecords the first changed index and publishes it with each snapshot, so a token update shapes only the streaming tail.- The transcript pane reuses the shaped prefix across snapshots; filtered permission views and structural rebuilds fall back to the full projection.