perf(web): reuse work log rows during streaming - #8006
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Skipped Macroscope did not run approvability analysis for this PR. Macroscope could not determine whether this PR modifies its approvability configuration, so the PR was not approved automatically. A PR that may change the rules that govern approval is never approved automatically. |
Long threads rebuild their full work log for every streamed activity update. That reparsed unchanged activity payloads, cloned every output row, and changed row identities even when the source activities had not changed.
This change caches each immutable activity's derived work-log entry in a
WeakMap, keeps collapse metadata private with a symbol, and returns collapsed entries without a second cloning pass. Unchanged activity rows now keep stable identities across append updates.Benchmark
Verification
pnpm --filter @t3tools/web typecheckvp lint apps/web/src/session-logic.ts apps/web/src/session-logic.test.ts --report-unused-disable-directivesvp fmt --check apps/web/src/session-logic.ts apps/web/src/session-logic.test.tsvp test run src/session-logic.test.ts --project unit(77 tests)vp test run src/components/chat/MessagesTimeline.logic.test.ts src/components/chat/MessagesTimeline.test.tsx --project unit(77 tests)Created with GPT-5.6 in the Codex harness through T3 Code.
Note
Memoize
DerivedWorkLogEntryvia WeakMap to reuse work log rows during streamingtoDerivedWorkLogEntryin a module-levelWeakMapkeyed by activity object, so repeated derivations for the same activity return the same entry instancecollapseKeyto a symbol-keyed property[workLogCollapseKey], eliminating the final mapping step inderiveWorkLogEntriesthat previously stripped internal fieldsactivityKindtosourceActivityKindonDerivedWorkLogEntry; updates all readers intoolLifecycleCollapseMapKey,collapseDerivedWorkLogEntries,shouldCollapseToolLifecycleEntries, andderiveToolLifecycleCollapseKeyDerivedWorkLogEntryno longer exposesactivityKindorcollapseKey; any external reader of these fields must switch tosourceActivityKindand[workLogCollapseKey]Macroscope summarized 647e760.