Skip to content

fix: show one divider after a compaction in Control UI chat - #204029

Merged
obviyus merged 1 commit into
mainfrom
fix/compaction-divider-once
Nov 23, 2026
Merged

obviyus merged 1 commit into
mainfrom
fix/compaction-divider-once

Conversation

@obviyus

@obviyus obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

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 #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):

Before: two Context compacted dividers

After (head):

After: one Context compacted divider with metric

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.

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]>
@clawsweeper

clawsweeper Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui agents Agent runtime and tooling size: S labels Nov 23, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 23, 2026
@clawsweeper

clawsweeper Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The 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.

  • Before: Two Context compacted dividers appear, including one bare divider.
  • After: One divider appears with saved 3.9k tokens (67.5%).

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A minimal owner-level repair with relevant persistence coverage, inspected visual proof, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): The inspected screenshots and accompanying reproduction exercise composer /compact through a built Gateway and local provider, showing the duplicate divider replaced by one divider with its metric.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A completed compaction appears twice in Control UI chat while live status remains visible.
Reason: The maintainer-authored direction restores the existing single-divider contract with a narrowly scoped change.

Regression provenance

Possible 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
Reviewed head: f016ec440cfe58014077638d538253dfc169f7fa

Before merge

None.

Findings

None.

Agent review details

How this fits together

Prepared 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]
Loading

Technical review

Best 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

  • Prepared compaction persistence keeps the original intent (777fc99: Reduce complete-history retention on the Gateway thread while preserving summary, retained-context, and persistence behavior.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +1, Tests +54. Total +55 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 2 1 +1
Tests 2 54 0 +54
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 56 1 +55

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P3: The duplicate divider is recoverable visual confusion; compaction and saved-token reporting still work.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: The duplicate divider is recoverable visual confusion; compaction and saved-token reporting still work.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 23, 2026, 5:30 AM ET / 10:30 UTC.

@obviyus
obviyus merged commit cef769b into main Nov 23, 2026
137 checks passed
@obviyus
obviyus deleted the fix/compaction-divider-once branch November 23, 2026 10:31
@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in cef769b.

  • Bug: prepared compactions (Control UI /compact, recovery) persisted their entry without the run id their progress announced, so chat showed a second bare "Context compacted" divider.
  • Fix: the prepared path persists {runId, itemId}.
  • Proof: real-transcript regression test red on base / green on head; UI contract test; Control UI E2E on a real Gateway shows two dividers on base and one with the metric on head.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 24, 2026
…#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):

![Before: two Context compacted dividers](https://github.com/user-attachments/assets/bf6e542f-ec29-4d3d-af8a-512151ccfa20)

After (head):

![After: one Context compacted divider with metric](https://github.com/user-attachments/assets/63bb297e-f190-41ed-8cce-cf30b1768c63)

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant