Repository navigation
fix: show one divider after a compaction in Control UI chat - #204029
Conversation
Prepared compaction persisted only the item id, so the Control UI could not match the stored entry to the live status that announced it and rendered a second bare divider. Persist the run id the progress events carried too. Co-authored-by: obviyus <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThe prepared compaction writer saves the run ID alongside the item ID so Control UI can reconcile persisted and live compaction dividers. Example: A user types /compact in Control UI after three conversation turns.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review This PR fixes a confirmed compaction-marker mismatch with a minimal producer-side change; no actionable findings remain, and the CI gate is pending. Priority: P3 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherPrepared compaction consumes session history and summary results, persists a compaction marker, and exposes its identity through chat history for reconciliation with live progress. flowchart LR
A[Manual or recovery compaction] --> B[Prepared compaction runtime]
B --> C[Progress events]
B --> D[Compaction transcript writer]
D --> E[Chat history]
C --> F[Control UI reconciliation]
E --> F
F --> G[Single compaction divider]
Technical reviewBest possible solution: Persist the existing run and item identities at the prepared compaction writer and retain the existing UI matcher. Do we have a high-confidence way to reproduce the issue? The current-main writer and unchanged matcher establish the mismatch, supported by supplied before/after Gateway screenshots; this read-only review ran no target code. Is this the best way to solve the issue? This is the smallest complete repair: restore missing metadata at its producer without weakening matching or introducing another rendering path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6f2bd815fecb. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +1, Tests +54. Total +55 across 3 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 23, 2026, 5:30 AM ET / 10:30 UTC. |
|
Landed in cef769b.
|
…#204029) ## What Problem This Solves After a compaction, the Control UI chat shows two "Context compacted" dividers: one with the saved-token metric, and a second bare one below it. This happens for every compaction that runs through the prepared compaction path: `/compact` from the Control UI (`sessions.compact`) and recovery compactions (overflow, budget, timeout). ## User Impact New compactions render one divider, with its "saved … tokens" metric. Sessions that already have an affected compaction keep the extra bare divider only until the live compaction status clears (reload, session switch, or the status timeout); stored transcript rows are not rewritten. ## Why This Change Was Made The UI hides its live compaction divider when the persisted compaction entry carries the same `{runId, itemId}` that its progress events announced. Since openclaw#201304, the prepared compaction path persisted only `itemId` and dropped `runId`, so the UI never matched the two and rendered both. The prepared path now persists `{ runId, itemId }` from the same run id and diag id that its callers use for progress events (recovery: the run id and `diagId`; `sessions.compact`: the operation id). The UI matcher is unchanged. ## Evidence - Regression test through the real queued compaction, native session, and SQLite transcript (`compact.summary-fallback.test.ts`, recovery and `sessions.compact` preflight cases): the persisted entry's `__openclaw` equals the caller's `{runId, itemId}`. Red on base (`[{ itemId: "cmp-…" }]`, no `runId`), green on head. - UI contract test (`chat-thread-live-final.test.ts`): a persisted marker plus a matching complete compaction status renders exactly one divider with the metric. - Control UI E2E against a real built Gateway, real agent, and a local OpenAI-compatible fixture provider: three turns, then `/compact` typed in the composer. - Base: two dividers; `chat.history` marker has `itemId` only. - Head: one divider with "saved 3.9k tokens (67.5%)"; marker has `runId` and `itemId`. Before (base):  After (head):  Merge danger: two-way door. A revert restores the old entry shape; no schema, protocol, or stored-row change. Blast radius: new compaction entries written by the prepared path gain a `runId` field already defined on `CompactionEntry["__openclaw"]` and already projected by `chat.history`. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
After a compaction, the Control UI chat shows two "Context compacted" dividers: one with the saved-token metric, and a second bare one below it. This happens for every compaction that runs through the prepared compaction path:
/compactfrom the Control UI (sessions.compact) and recovery compactions (overflow, budget, timeout).User Impact
New compactions render one divider, with its "saved … tokens" metric. Sessions that already have an affected compaction keep the extra bare divider only until the live compaction status clears (reload, session switch, or the status timeout); stored transcript rows are not rewritten.
Why This Change Was Made
The UI hides its live compaction divider when the persisted compaction entry carries the same
{runId, itemId}that its progress events announced. Since #201304, the prepared compaction path persisted onlyitemIdand droppedrunId, so the UI never matched the two and rendered both. The prepared path now persists{ runId, itemId }from the same run id and diag id that its callers use for progress events (recovery: the run id anddiagId;sessions.compact: the operation id). The UI matcher is unchanged.Evidence
compact.summary-fallback.test.ts, recovery andsessions.compactpreflight cases): the persisted entry's__openclawequals the caller's{runId, itemId}. Red on base ([{ itemId: "cmp-…" }], norunId), green on head.chat-thread-live-final.test.ts): a persisted marker plus a matching complete compaction status renders exactly one divider with the metric./compacttyped in the composer.chat.historymarker hasitemIdonly.runIdanditemId.Before (base):
After (head):
Merge danger: two-way door. A revert restores the old entry shape; no schema, protocol, or stored-row change. Blast radius: new compaction entries written by the prepared path gain a
runIdfield already defined onCompactionEntry["__openclaw"]and already projected bychat.history.