Conversation
SummaryReading const cached=_sessionHtmlCache.get(sid);
if(cached&&cached.msgCount===msgCount&&cached.renderWindowSize===renderWindowSize&&cached.signature===cacheSignature){
inner.innerHTML=cached.html;
_sessionHtmlCacheSid=sid;
...
}The store at One observation worth thinking about
const cacheEligible=!!(sid&&sid!==_sessionHtmlCacheSid&&!INFLIGHT[sid]&&!hasTransientTranscriptUi);
const cacheSignature=cacheEligible?_messageRenderCacheSignature(S.messages,renderWindowSize):null;Then guard the write-back at line 6381 with Tests
VerdictLGTM on the cache-correctness change. The signature inputs cover the cases that #963 left behind (edits, tool-result patches in place, compression-anchor reassignment, reasoning that appeared after an out-of-order patch). The 300KB + 8-session eviction bound at line 6382-6384 is unchanged so memory footprint stays the same. Worth a release-note line because the symptom — "old message reappears in wrong slot after switching sessions" — is exactly the kind of thing a user reports as data loss when it's actually just a stale render. |
|
Addressed the non-blocking perf observation by only computing the cache signature when the cache fast path is eligible. Validation: |
|
Thanks for the careful work on this! Superseded by #2692 (shipped in v0.51.104, Release CB / stage-397). Both PRs target the same root cause — the session render cache key was The shipped fix (#2692 by @ai-ag2026) folds a content signature into the cache key — including I reviewed both diffs side-by-side and either fix would have closed the underlying #2613 class. We ran #2692 first because it landed in the lowest-risk batch and its CHANGELOG accuracy passed Opus pre-merge review without code edits. Closing this as superseded — no work lost, the same fix is live in master. Happy to take follow-up PRs that further tighten the render cache contract if you've spotted additional cases (compression-anchor changes, sidecar reconciliation edges) that the shipped signature doesn't cover. Thanks again for the catch. |
Summary
Fixes a WebUI transcript rendering cache issue where session HTML could be reused after switching sessions when only
the message count and render window size matched. This could make the visible transcript stale, including recently
sent messages disappearing or old messages appearing in the wrong position after navigation or context compaction.
This is a follow-up to #963 and fixes the known limitation where the session render cache was keyed only by session
id, message count, and render window size.
Root Cause
renderMessages()instatic/ui.jsused a count-based cache guard. When two render states had the same messagecount and render window size, cached
innerHTMLcould be reused even if the message content, live/pending state,tool metadata, or compression anchor had changed.
Changes
truncation/window state, and compression anchor metadata in the cache key.
Validation
Combined result:
170 passed, 1 skippedlocally. The skipped test was environment-gated, not a failure.