Skip to content

fix: keep compaction in one persistent transcript marker - #136169

Merged
steipete merged 2 commits into
mainfrom
openclaw/inline-compaction-marker
Sep 2, 2026
Merged

steipete merged 2 commits into
mainfrom
openclaw/inline-compaction-marker

Conversation

@steipete

@steipete steipete commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users compacting a conversation see both a transient composer status and a separate “Context compacted” transcript message. The approved follow-up is one inline transcript element: animate while compacting, settle into a compacted marker, and retain that marker after history refresh or reload.

Related: #135988 — the original folding-line compaction animation. This is the maintainer-requested presentation and lifecycle follow-up, not a change to compaction policy.

Why This Change Was Made

The composer toast, slash-command success response, and persisted runtime activity had independent presentation paths. The transient row also lacked a stable identity connecting it to the stored boundary. Compaction producers now carry the same operation/item identity through lifecycle events and persistence; the shared transcript projection adopts the persisted boundary without replacing the live row. Rewriting old transcript boundaries preserves their recorded identity, including an unknown historical run.

Removed paths: compaction toast rendering and five-second completion clearing, successful /compact assistant text, and native compaction activity conversion into an assistant message. Cancellation, no-op and failure outcomes remain explicit. No settings, database schema version, model/provider routing, or compaction-policy changes.

User Impact

  • Chat and Home show the folding lines and soft shimmer inline, then retain the same row as a compacted marker.
  • History refresh and reload do not add another completion message; later compactions retain their own distinct markers.
  • Reduced-motion and forced-color treatments remain supported. Embedded compaction markers keep their checkpoint action.

Evidence

Behavior and regression coverage

inline-compaction-before-after.mp4

Before is left, after is right. Real isolated gateway/browser proof exercises /compact, observes the same DOM row transition from active to complete, asserts exactly one visible marker and no compaction toast, and reloads to confirm the persisted marker. Both source captures and the comparison's active/completed/reloaded frames were personally inspected. The video trims setup, crops surrounding chrome, preserves playback speed, and holds the final frame to align the two recordings. Baseline UI is 0b9cf4bf187; both use the same isolated gateway and synthetic observatory notes. The existing generic command queue row is not a compaction toast and disappears when /compact finishes.

Focused regression coverage includes manual and automatic compaction identity, cancellation, transcript replay, native activity projection, matching persisted-row adoption, active-leaf refresh, repeated compactions, session/reset boundaries, and browser accessibility/motion. The history-handoff and historical-identity regressions failed before their fixes.

The late ClawSweeper sequence-order finding and both Rank-up moves are addressed: compaction and terminal lifecycle events reuse the existing per-run Gateway sequence fence. Delayed start/success/cancel/retry events cannot replace a newer active item, and stale lifecycle completion cannot finish a newer retry. Five regression cases failed before this correction; the corrected lifecycle/transcript suites pass 207 tests across six files. Different runs still accept their own sequence numbering. No extra state or cleanup path was added. The attached nominal-flow recording predates this ordering-only correction; the correction is proven at the real event-handler boundary in the reported order and does not change the visual treatment.

Dependency contract inspected directly: sibling Codex codex-rs/core/src/compact.rs:252 creates one compaction item for start; compact.rs:379 persists compacted history before completing that same item at compact.rs:392. OpenClaw preserves this identity rather than inferring completion from timing.

Validation

  • node scripts/run-vitest.mjs src/agents/embedded-agent-runner/transcript-rewrite.test.ts src/agents/sessions/agent-session-compaction-correlation.test.ts src/agents/sessions/agent-session-compaction.test.ts ui/src/pages/chat/history-merge.test.ts ui/src/pages/chat/components/chat-transcript-render.test.ts — 87 tests passed across five files.
  • Browser compaction/motion suite — 4 tests passed; broader UI and producer/projection suites were also run during development.
  • After rebasing, node scripts/run-vitest.mjs ui/src/pages/chat/chat-thread.test.ts ui/src/pages/chat/components/chat-transcript-render.test.ts ui/src/pages/chat/history-merge.test.ts — 297 tests passed across three files, including the upstream reasoning-grouping changes.
  • pnpm ui:build and node --import ./scripts/tsx.mjs scripts/build-all.mts qaRuntime passed, including UI budgets and runtime bundle/import guards.
  • Fresh post-rebase independent autoreview completed scoped-clean. Changed-file guards, core/UI/plugin and test typechecks, and dead-export scans passed. The combined check caught one metadata-access lint error; it was corrected, then the full core lint shard and all remaining selected style/plugin/schema/import/security gates passed. Exact-head CI is recorded in the pre-merge verification comment.
  • After the sequence-order correction: focused lifecycle/transcript tests (207), fresh UI build and independent autoreview passed; final changed-file checks and exact-head CI are tracked in the verification comment.

Scope and known proof limitation

Production delta: +263 / -163, net +100 lines. This adds the missing operation-to-persisted-marker identity boundary and persistent inline presentation while removing competing toast/message paths. The late sequence fix contributes net +9 by extending the existing fence instead of adding state. Tests/support: +477 / -262, net +215. Assertion baseline: -1, recording a removed assertion. No proof assets are committed.

The existing native active-writer conflict reproduced in both baseline and candidate immediately after creating a fresh session. It is separately tracked by #135441 — native compaction writer coordination. Successful capture uses the existing synthetic session after restarting only the isolated test gateway; the operator gateway and live state are untouched.

@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling extensions: codex size: XL maintainer Maintainer-authored PR labels Sep 2, 2026
@steipete
steipete marked this pull request as ready for review September 2, 2026 08:32
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 2, 2026
@steipete

steipete commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Pre-merge verification

Current head: 0c120abfd4059ffa3a45ddd67abe4ac21c189203.
This exact head passed CI run 33611403128, attempt 2, completed successfully at 09:41:07 UTC on September 2. Repository-native preparation and merge remain required. The earlier head c5a2f1e876ac86675a3a359668f426bcc30e4d8a passed CI (https://github.com/openclaw/openclaw/actions/runs/33609233611) and native preparation, but a late review finding was addressed before merging. That earlier green run is not being substituted for the new head's checks.

The compaction producer/persistence owner now carries one operation identity to the shared Chat/Home transcript row. Removed the competing compaction toast, delayed clearing, successful /compact assistant response, and native activity-to-assistant presentation. The same inline DOM row animates, completes and remains; a reload retains exactly one marker. Cancellation, no-op, error and checkpoint behavior are preserved. Production +263/-163 (net +100) supplies the missing identity boundary, persistent rendering and sequence fencing; tests/support +477/-262 (net +215), assertion baseline -1.

Late ClawSweeper finding and Rank-up moves

Addressed the sequence-order finding and both Rank-up moves. Compaction and terminal lifecycle events now reuse acceptActivityEvent and its existing per-run sequence map. No parallel state or cleanup owner was added; the correction adds net nine production lines. Delayed old start/success/cancel/retry events cannot replace the newer active item, and a stale lifecycle end cannot complete a newer retry. Gateway sequence ownership was checked directly at src/infra/agent-events.ts:260.

Five cases failed before the correction for the reported ordering defect. node scripts/run-vitest.mjs ui/src/pages/chat/tool-stream-fallback.node.test.ts ui/src/pages/chat/tool-stream.node.test.ts ui/src/pages/chat/tool-stream.usage.node.test.ts ui/src/pages/chat/tool-stream.startup.node.test.ts ui/src/pages/chat/chat-state.test.ts ui/src/pages/chat/components/chat-transcript-render.test.ts now passes 207 tests in six files, including independent run sequence numbering and active timeout cleanup. Fresh UI build and independent autoreview --mode uncommitted pass. node scripts/check-changed.mjs -- ui/src/pages/chat/tool-stream.ts ui/src/pages/chat/tool-stream-fallback.node.test.ts passed all selected formatting, guard, typecheck, dead-export and lint gates. The nominal live recording below predates this ordering-only correction; it remains representative of the unchanged rendering, with the fault proven at the actual UI event boundary in the reported order.

Local verification

  • node scripts/run-vitest.mjs src/agents/embedded-agent-runner/transcript-rewrite.test.ts src/agents/sessions/agent-session-compaction-correlation.test.ts src/agents/sessions/agent-session-compaction.test.ts ui/src/pages/chat/history-merge.test.ts ui/src/pages/chat/components/chat-transcript-render.test.ts — 87 passed.
  • node scripts/run-vitest.mjs ui/src/pages/chat/chat-thread.test.ts ui/src/pages/chat/components/chat-transcript-render.test.ts ui/src/pages/chat/history-merge.test.ts — 297 passed after rebase.
  • Browser compaction/motion suite — 4 passed; producer/projection and broader UI suites passed during development.
  • pnpm ui:build and node --import ./scripts/tsx.mjs scripts/build-all.mts qaRuntime — passed, including bundle/import guards and UI budgets.
  • Changed-file guards, core/UI/plugin/test typechecks and dead-export scans passed. The combined checker caught one metadata-access lint error, which was corrected. node --import ./scripts/tsx.mjs scripts/run-oxlint-shards.mts --only=core then passed; changed style/plugin lint plus selected native-schema, database-first, media, sidecar, cycle, webhook/pairing guards and UI typecheck passed.
  • Fresh independent post-rebase autoreview (--mode uncommitted) completed scoped-clean, followed by another clean review of the sequence correction. Native review artifacts were refreshed and validated against the current head before preparation.

Browser CI investigation

CI run 33611403128, attempt 1, failed only browser shard 5/14 and its dependent rollup. chat-transcript-disclosure-anchor.e2e.test.ts:476 observed a second jump-to-bottom stopping 576 px short after interrupted scrolling and recovered text. The failed test and its scroll/virtualizer owners are unchanged by this PR. The failure screenshot and diagnostic artifact were inspected; no page errors were recorded.

The focused four interrupted-scroll cases pass locally, and the original CI shard command, OPENCLAW_UI_E2E_SKIP_REAL_GATEWAY=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner --shard 5/13, passes all 123 tests in 27 files. No assertions, timeouts, scroll implementation, or CI requirements were weakened. One exact-head failed-job rerun passed browser job 100196013343 at 09:35:14 UTC. This does not establish that its timing cause has been repaired. Named follow-up: instrument interrupted-scroll recovery if the original 576 px shortfall recurs; preserve the failure artifacts and original execution order rather than weaken the assertion or make a speculative scroll change.

The refreshed ClawSweeper review at 09:05:44 UTC reports no actionable correctness finding. Its remaining maintainer risk asks that historical compaction entries without identity metadata remain completed markers. That optional shape is retained: producer correlation is added to new operations, not required to render old transcript boundaries. Existing historical-metadata, repeated-operation, delayed-event, and live reload evidence cover the decision; no schema migration or configuration change is introduced.

Personally inspected real-flow proof

inline-compaction-before-after.mp4

Before left, after right; synthetic conversation, real isolated gateway and browser. Active, completed and reloaded frames were inspected. The recorder asserted stable DOM identity and one marker without a compaction toast. Setup was trimmed, surrounding chrome cropped, speed unchanged, final frame held for alignment. Direct Codex contract inspection: codex-rs/core/src/compact.rs:252, :379, :392 confirms one started/completed item with history persistence before completion.

Known limitation: the pre-existing native fresh-session active-writer conflict reproduced in baseline and candidate; open PR #135441 — native compaction writer coordination — tracks it. Successful recordings use the existing synthetic session after restarting only the owned isolated gateway. Test gateway and temporary authentication copy are cleaned up; operator state is untouched.

The latest ClawSweeper review is fresh and its actionable finding, merge-risk repetitions and both Rank-up moves are addressed above. Production growth is justified by the requested persistent-marker identity capability; the ordering repair extends the existing owner instead of introducing another state path. No related duplicate issue was found in the scoped search. The latest review will be checked again before repository-native preparation and merge, without bypassing gates.

@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 2, 2026, 5:04 AM ET / 09:04 UTC.

ClawSweeper review

What this changes

The PR gives each compaction operation a persistent identity so Control UI progress becomes one durable transcript marker instead of a separate completion message.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

No blocking correctness finding. The branch carries one compaction identity from the producer into persisted transcript entries and the Control UI, and it addresses the prior sequence-order finding; it remains an active maintainer-authored PR with an unmerged change.

Priority: P2
Reviewed head: 0c120abfd4059ffa3a45ddd67abe4ac21c189203

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A solid cross-boundary repair with focused source-level regression coverage and no blocking defect found.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied isolated gateway/browser recording and focused regression claims are supplemental evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied isolated gateway/browser recording and focused regression claims are supplemental evidence.
Evidence reviewed 5 items Producer and persistence owner: The session compaction owner creates an item ID before start, passes it into compaction work, and stores it on the compaction transcript boundary; the session guard adds the owning run ID without replacing recorded replay identity.
UI consumer and ordering fence: The UI matches persisted markers by run/item identity, renders the matching live row in place, and rejects lower-sequence compaction or terminal lifecycle events for the same run before status handling.
Boundary regression coverage: The added ordering cases send an older compaction event after a newer same-run start and assert that the newer marker remains active; transcript rendering coverage also exercises live-to-persisted adoption and repeated same-run compactions.
Findings None None.
Security None None.

How this fits together

Compaction events originate in the agent/runtime layer, are persisted in a session transcript, and are projected into Control UI chat history. This change links the live event and persisted boundary so one row transitions from active to completed across refreshes.

flowchart LR
  A[Agent compaction] --> B[Compaction event]
  B --> C[Session transcript]
  C --> D[Gateway projection]
  D --> E[Chat history]
  B --> F[Live chat state]
  F --> E
Loading

Before merge

  • Resolve merge risk (P1) - Compaction identity now travels through persisted session transcript entries and live UI adoption; a mismatched run/item identity could suppress or duplicate a marker after refresh, although the branch covers historical metadata, repeated operations, and delayed lower-sequence events.
Agent review details

Security

None.

PR surface

Source +114, Tests +201, Other -1. Total +314 across 50 files.

View PR surface stats
Area Files Added Removed Net
Source 33 277 163 +114
Tests 16 463 262 +201
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 50 740 426 +314

Review metrics

Metric Value Why it matters
Production versus test delta production +263/-163; tests/support +477/-262 The production growth crosses the agent, persisted-transcript, gateway, and UI ownership boundary; the larger test change covers identity and ordering regressions.

Merge-risk options

Maintainer options:

  1. Retain migration-free transcript compatibility (recommended)
    Land only with the optional identity shape so historical compaction boundaries without metadata remain valid completed markers.

Technical review

Best possible solution:

Keep the producer-generated run/item identity optional for historical transcripts and use it as the single matching key for live-to-persisted marker adoption.

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible: the prior independent transient and persisted presentation paths are replaced by producer-to-transcript identity matching, with focused ordering and refresh regressions in the branch. This read-only review did not execute the supplied harness.

Is this the best way to solve the issue?

Yes. Recording identity at the compaction producer and preserving it through transcript projection is preferable to inferring completion from timing or independently rendered UI paths; the inspected Codex contract uses the same single-item lifecycle.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against a359864ed5cc.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied isolated gateway/browser recording and focused regression claims are supplemental evidence.
  • remove proof: sufficient: Current real behavior proof status is not_applicable, not sufficient.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded session-transcript and Control UI behavior repair with limited blast radius.
  • merge-risk: 🚨 session-state: The PR changes persisted compaction metadata and its live/history reconciliation behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied isolated gateway/browser recording and focused regression claims are supplemental evidence.

Evidence

What I checked:

  • Producer and persistence owner: The session compaction owner creates an item ID before start, passes it into compaction work, and stores it on the compaction transcript boundary; the session guard adds the owning run ID without replacing recorded replay identity. (src/agents/sessions/agent-session-compaction.ts:109, 0c120abfd405)
  • UI consumer and ordering fence: The UI matches persisted markers by run/item identity, renders the matching live row in place, and rejects lower-sequence compaction or terminal lifecycle events for the same run before status handling. (ui/src/pages/chat/tool-stream.ts:280, 0c120abfd405)
  • Boundary regression coverage: The added ordering cases send an older compaction event after a newer same-run start and assert that the newer marker remains active; transcript rendering coverage also exercises live-to-persisted adoption and repeated same-run compactions. (ui/src/pages/chat/tool-stream-fallback.node.test.ts:652, 0c120abfd405)
  • Codex compaction contract: Directly inspected sibling Codex source: it creates one context-compaction item, persists compacted history, then completes that same item. The local checkout is configured through a cache remote, so repository ownership is left unverified. (codex-rs/core/src/compact.rs:252, 78c290807ce710180111df227df3b7a4fe845452)
  • PR and release provenance: The PR head is not contained by local main and no tag contains it, so the requested behavior is neither implemented on current main by this commit nor shipped in a release. (0c120abfd405)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Shakker: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-02T08:41:19.980Z sha c5a2f1e :: found issues before merge. :: [P2] Fence compaction events by Gateway sequence

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 2, 2026
@steipete
steipete merged commit 107b259 into main Sep 2, 2026
530 of 534 checks passed
@steipete
steipete deleted the openclaw/inline-compaction-marker branch September 2, 2026 09:49
@steipete

steipete commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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 extensions: codex gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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