fix: keep compression banner attached to the compaction marker - #2182
3 commits merged into
Conversation
|
Reading the diff against Case 1: anchor index outside the render window (
|
|
Hi, I found during usage another related on compression error and I appended a new commit into the current PR and re-edited the PR content to reflect this. Please review again if needed. |
f5be6e3
fix: keep compression banner attached to the compaction marker (LumenYoung)
fix: keep compression banner attached to the compaction marker (LumenYoung)
fix: keep compression banner attached to the compaction marker (LumenYoung)
Summary
Fixes several related cases where the context compression banner can appear to drift away from the actual compaction boundary in long WebUI conversations.
Case 1: windowed transcript rendering
The compression anchor is stored as an index into the full visible transcript, but
renderMessages()renders only a slicedrenderVisWithIdxwindow. When the anchor key cannot be matched, the previous code passed the full visible index directly into the rendered-window array. For long sessions this index is usually outside the current render window, so the compression card falls back toinner.appendChild(node)and appears near the newest messages instead of near the compression boundary.Case 2: persisted compaction reference messages
Some sessions already contain a persisted
[CONTEXT COMPACTION — REFERENCE ONLY]message in the transcript. That message can be a stronger placement signal than anchor metadata, because it preserves the raw transcript position where compaction happened.Case 3: stale / multiple compaction markers
Long sessions can contain multiple older persisted compaction reference messages. The banner should not blindly attach to the first or latest marker. A persisted marker is only authoritative when its content matches the current
compression_anchor_summary; otherwise placement falls back to the current anchor metadata.This prevents a new compression banner from attaching to an older compaction marker in the same transcript.
This change also keeps anchor matching tolerant of older persisted anchor keys that do not include a timestamp. Some existing sessions have
compression_anchor_message_key.ts = null, while the corresponding message later has_ts/timestampstamped. Strict timestamp comparison makes those anchors fail to match.Fix
visWithIdxlist, not the sliced render window.renderVisWithIdxwindow before inserting the compression card.compression_anchor_summary, insert the banner relative to that message's raw transcript position.Why this is correct
There are now three levels of placement fidelity, in descending priority:
This keeps the banner stable across normal long-session windowing, partially damaged sidecars, and transcripts that contain multiple older compaction markers.
Tests
Added / updated coverage for:
Tested with: