Skip to content

feat(ui): session-reset dividers + boundary markers for DB-backed sessions - #122222

Merged
steipete merged 2 commits into
mainfrom
steipete/session-reset-divider
Aug 11, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/session-reset-divider

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Two related gaps in the system-notice family that #122144 established:

  1. Session resets were invisible. /reset writes a type:"reset" boundary into the transcript and the projection silently drops everything before it — the operator sees content vanish with only a transient command ack. After a reload (or from another client) there is no recorded explanation at all. Worst-bug-class material: an action whose durable outcome is nothing.
  2. Boundary markers never reached clients on DB-backed sessions. Live testing this change surfaced a real shipped regression: the SQLite transcript projection (readSessionTranscriptMessageEvents family) selects only message events, so the existing compaction divider never rendered for DB-backed sessions — the marker synthesis only existed in the legacy file-based reader (session-utils.fs.ts). Every mocked/unit proof injected history directly, which is why this was never caught.

Why This Change Was Made

  • Reset becomes a first-class transcript fact: both storage backends project type:"reset" boundaries as the same synthetic marker message shape (__openclaw:{kind:"reset", id, seq}) already documented for compaction, and the Control UI renders it through the landed minimal divider family ("Session reset · The earlier conversation was cleared.", rotateCcw icon).
  • Marker synthesis now has one owner: src/gateway/session-transcript-message.ts, consumed by both the SQLite and file-based readers. The new session-accessor.sqlite-history-events.ts projects messages + boundaries across all client read shapes (full, recent tail, paged, count, by-id, anchor) and reuses the existing reset-window truncation owner; message-only readers remain for usage/title extraction where markers don't belong.
  • Additive protocol only — the marker envelope in docs/gateway/clients.md gains the kind:"reset" sibling paragraph; compaction shape untouched.

Config-reload was considered as a third divider kind and deliberately skipped: no producer records a per-session transcript fact for it (restart-sentinel already covers config-recovery restarts as a class-A notice).

User Impact

  • /reset leaves a durable, visible "Session reset" divider at the boundary — including after reloads and from other clients — with kept turns visible above it.
  • Compaction dividers now actually appear for live (DB-backed) sessions — restoring the shipped feature this family is built on.

Rendering (mocked fixture: restart-recovery notice + compaction + reset)

system notices

Evidence

  • Live end-to-end proof on an isolated dev gateway (fresh OPENCLAW_STATE_DIR, port 19822, built dist): real chat turn (anthropic Haiku), real /compact → compaction divider rendered live on the DB-backed session (it did not before this fix); real /reset → "SESSION RESET" divider rendered between kept turns and post-reset content, with the projection's kept-entries retention visible.
  • Pre-fix failing proof: DB-reader tests written first showed both markers omitted (2 expected failures), then passed post-fix.
  • Focused suites: gateway 117/117, SQLite accessor 12/12, UI 416/416; table-driven marker cases across full/recent/page/count/by-id/anchor reads; reset-window ordering cases (reset-with-kept-entries, compaction↔reset orderings).
  • pnpm ui:i18n:baseline clean; deadcode exports scan clean; git diff --check clean; Codex autoreview clean on the final bundle.
  • Production LOC +~390 net: dominated by the new SQLite history projection — capability growth fixing the DB-backed marker regression across every read shape, not consolidation debt. Tests +~300.

…backed sessions

/reset now leaves a durable 'Session reset' divider at the transcript
boundary in the Control UI. Root-cause fix underneath: the SQLite
transcript projection only selected message events, so compaction (and
now reset) markers never reached clients for DB-backed sessions; marker
synthesis now has one owner (session-transcript-message.ts) consumed by
both storage backends across full/recent/paged/by-id/anchor reads.
Additive __openclaw marker kind 'reset' documented in clients.md.
@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 11, 2026 19:13
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Aug 11, 2026
…ix CI gates

Direct imports for the sqlite history readers (the session-accessor barrel
is SDK-reachable via session-transcript-lock-runtime); reset marker added
to the kept-tail chat.history expectation; lint naming fixes; marker tests
split into session-transcript-readers.markers.test.ts.
@steipete
steipete merged commit a1846db into main Aug 11, 2026
197 of 199 checks passed
@steipete
steipete deleted the steipete/session-reset-divider branch August 11, 2026 19:59
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Aug 11, 2026
@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 11, 2026, 3:58 PM ET / 19:58 UTC.

ClawSweeper review

What this changes

The PR makes SQLite-backed chat histories carry reset and compaction boundaries and renders reset boundaries as persistent Control UI dividers.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for normal maintainer review: current main demonstrably omits SQLite transcript boundaries, and the PR repairs the shared display projection without a blocking defect found in review.

Priority: P2
Reviewed head: 2b6f80f48521b51289504640744fc46b71d23b25

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-proven repair with coherent shared ownership and broad read-shape coverage; no actionable patch defect was found.
Proof confidence 🌊 off-meta tidepool Not applicable: The PR is repository-member authored, so the external-contributor proof gate does not apply; the body nevertheless records a claimed isolated live Gateway run and exact-head CI is green.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The PR is repository-member authored, so the external-contributor proof gate does not apply; the body nevertheless records a claimed isolated live Gateway run and exact-head CI is green.
Evidence reviewed 6 items Current-main defect: SQLite history reads select only events with a message position, excluding reset and compaction boundary records before Gateway can project them.
Owner-boundary repair: The PR adds one boundary-aware SQLite history projection and reuses it for full, recent, paged, count, by-id, and anchored display reads while retaining message-only readers for usage and previews.
Sibling reader parity: The legacy file reader now retains reset boundaries and delegates synthetic marker construction to the same shared projection helper.
Findings None None.
Security None None.

How this fits together

Transcript events are stored in SQLite or legacy files, projected into Gateway chat-history rows, and rendered by the Control UI. Reset and compaction boundaries must survive that projection so operators can understand why history changed.

flowchart LR
  A[Transcript events] --> B[SQLite or file reader]
  B --> C[History projection]
  C --> D[Gateway chat history]
  D --> E[Control UI chat]
  E --> F[Boundary dividers]
Loading

Before merge

  • Resolve merge risk (P1) - Production code grows by about 383 net lines for a bug fix; the added projection is justified by five display-read contracts, but it should remain the sole boundary-aware owner.
  • Resolve merge risk (P1) - Focused local tests could not be rerun because Corepack attempted to create a cache on the read-only filesystem; the supplied exact-head CI is green.
  • Complete next step (P2) - This member-authored, maintainer-labeled PR needs normal exact-head maintainer review; no mechanical repair is identified.
Agent review details

Security

None.

PR surface

Source +383, Tests +345, Docs +3. Total +731 across 16 files.

View PR surface stats
Area Files Added Removed Net
Source 10 504 121 +383
Tests 5 372 27 +345
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 16 879 148 +731

Review metrics

Metric Value Why it matters
Production versus test LOC production +504/-121 (net +383); tests +372/-27 (net +345); docs +3 The runtime growth is concentrated in the single SQLite history projection and replaces duplicated file-reader marker mapping.

Stored data model

Persistent data-model change detected: serialized state: src/config/sessions/session-accessor.sqlite-history-events.ts, serialized state: src/gateway/session-transcript-anchor-reader.ts, serialized state: src/gateway/session-transcript-message.ts, serialized state: src/gateway/session-transcript-readers.markers.test.ts, serialized state: src/gateway/session-transcript-readers.ts, serialized state: src/gateway/session-utils.fs.test.ts, and 7 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the shared boundary-aware history projection after ordinary exact-head maintainer review; retain message-only readers for usage and previews rather than duplicating marker placement in callers.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the shared boundary-aware history projection after ordinary exact-head maintainer review; retain message-only readers for usage and previews rather than duplicating marker placement in callers.

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

Yes, from source: current SQLite history selection excludes boundary rows with no message position, while the file reader already has a synthetic compaction path. A local execution was not possible in this read-only environment.

Is this the best way to solve the issue?

Yes. A shared boundary-aware history projection is preferable to UI-side inference or changing the low-level message-only readers used for usage and preview extraction.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This repairs persisted chat-history visibility with bounded impact on Gateway and Control UI session reads.
  • 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: The PR is repository-member authored, so the external-contributor proof gate does not apply; the body nevertheless records a claimed isolated live Gateway run and exact-head CI is green.

Label justifications:

  • P2: This repairs persisted chat-history visibility with bounded impact on Gateway and Control UI session reads.
  • 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: The PR is repository-member authored, so the external-contributor proof gate does not apply; the body nevertheless records a claimed isolated live Gateway run and exact-head CI is green.

Evidence

What I checked:

Likely related people:

  • steipete: Recent history attributes the system-notice consumer and adjacent transcript-reader refactors to Peter Steinberger; this PR continues that same boundary. (role: recent area contributor and UI feature owner; confidence: high; commits: eef860d972f8, ebb2770000d1; files: src/gateway/session-transcript-readers.ts, ui/src/pages/chat/chat-thread-build.ts)

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.

@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 12, 2026
…sions (openclaw#122222)

* feat(ui): show session-reset dividers and fix boundary markers on DB-backed sessions

/reset now leaves a durable 'Session reset' divider at the transcript
boundary in the Control UI. Root-cause fix underneath: the SQLite
transcript projection only selected message events, so compaction (and
now reset) markers never reached clients for DB-backed sessions; marker
synthesis now has one owner (session-transcript-message.ts) consumed by
both storage backends across full/recent/paged/by-id/anchor reads.
Additive __openclaw marker kind 'reset' documented in clients.md.

* fix(gateway): keep history readers out of the plugin SDK barrel and fix CI gates

Direct imports for the sqlite history readers (the session-accessor barrel
is SDK-reachable via session-transcript-lock-runtime); reset marker added
to the kept-tail chat.history expectation; lint naming fixes; marker tests
split into session-transcript-readers.markers.test.ts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR 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