Skip to content

fix(ui): reconcile every null tombstone and align session sort with the gateway - #124104

Merged
steipete merged 3 commits into
mainfrom
codex/autoqa-reconcile-tombstones
Aug 15, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/autoqa-reconcile-tombstones

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Control UI's sessions.changed merge deleted null-tombstoned fields from a hand-maintained eleven-field list while the gateway's tombstone policy (session-event-payload.ts) had grown past it: toolOverrides, observerDigest, controlOwnerSessionKey, restartRecoveryStatus, and goal leaked literal null into rows typed optional-not-null, and every future tombstoned field would silently repeat the drift. Today's consumers happen to be null-tolerant, so this is a type-lie plus drift trap rather than a crash — but it's exactly the "hand-kept copy of the producer's policy" disease.

Why This Change Was Made

One loop over the event's null-valued keys now owns the tombstone rule (the producer's policy applied mechanically), with updatedAt/activeLeafEntryId — the schema's only legitimately nullable row fields — keeping their explicit handling. Net −24 lines at the fix site.

Riders in the same owner neighborhood (sessions-lane findings):

  • compareSessionRowsByUpdatedAt gains the gateway's ascending-key tie-break (session-list-order.ts: "Stable key ties keep offset paging deterministic") so tied rows — including all updatedAt: null rows — stop visibly swapping when the canonical refresh replaces an event-driven reconcile.
  • Deleted the unreachable kind === "cron" wire guards: the gateway folds cron/spawn-child into direct before any projection (refactor(sessions): consolidate entry state #115299), and both sites needed an as string cast because the protocol type has no such member. Real cron detection (isCronSessionKey) stays.
  • The stale-active-snapshot path in reconcileSessionHistory returns the original result identity when no defaults were passed, so the caller's result === state.result publish gate skips a spurious sidebar re-render on every stale event.

User Impact

Session rows no longer carry type-violating null values after patches that clear tool overrides, goals, control ownership, or restart-recovery status; sidebar ordering stays stable across the event→canonical-refresh handoff; stale events stop forcing needless sidebar re-renders.

Evidence

  • Two new regression tests, both verified to fail pre-fix (stash proof): the five leaked tombstone fields now delete (with updatedAt proven untouched by the loop), and tied rows sort by ascending key matching the gateway.
  • node scripts/run-vitest.mjs run ui/src/lib/sessions — 280/280 across 29 files; ui/src/pages — 4625 passed.
  • pnpm tsgo:ui, pnpm check:test-types, oxfmt/oxlint clean; autoreview clean (0.98).

Production LOC +25/−38 (net −13); tests +63.

@clawsweeper

clawsweeper Bot commented Aug 15, 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 15, 2026 08:21
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: S maintainer Maintainer-authored PR labels Aug 15, 2026
@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 15, 2026
@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 15, 2026, 4:50 AM ET / 08:50 UTC.

ClawSweeper review

What this changes

The PR makes Control UI session reconciliation delete producer-sent null tombstones generically except for nullable row fields, matches Gateway key tie ordering, avoids stale no-op publishes, and relaxes one E2E layout tolerance.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. Current main still has the hand-maintained tombstone list and non-deterministic UI tie ordering; this maintainer-authored PR replaces those drift points with the Gateway contract. No blocking correctness finding was found, but merge should wait for the current head’s checks and any required merge-result refresh.

Priority: P2
Reviewed head: 1cde9598bb317a6ab15887de2cdb1d6d7262899f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a focused, contract-aligned repair with regression coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body supplies focused regression and UI-suite validation claims.
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 body supplies focused regression and UI-suite validation claims.
Evidence reviewed 7 items Current-main defect: Current main merges incoming event fields, then deletes nulls only for an eleven-field manual list; it does not cover the producer’s newer null-tombstoned fields such as tool overrides, observer digest, control ownership, restart recovery, and goal.
Producer tombstone contract: The Gateway event producer deliberately emits null for cleared optional fields, including observerDigest, controlOwnerSessionKey, toolOverrides, restartRecoveryStatus, goal, and lastRunError.
Nullable row exceptions: The protocol schema defines updatedAt and activeLeafEntryId as the row fields that legitimately accept null, supporting the PR’s explicit exclusions from generic tombstone deletion.
Findings None None.
Security None None.

How this fits together

The Control UI receives incremental Gateway session events and canonical session-list snapshots, reconciles them into sidebar rows, then sorts them for navigation. The changed code is the client-side boundary that must preserve Gateway clearing and ordering semantics.

flowchart LR
  Gateway[Gateway session events] --> Reconcile[UI reconciliation]
  Gateway --> Snapshot[Canonical session list]
  Reconcile --> Rows[Session row state]
  Snapshot --> Ordering[Deterministic ordering]
  Rows --> Sidebar[Sidebar navigation]
  Ordering --> Sidebar
Loading

Before merge

  • Resolve merge risk (P1) - Required checks for the current head are still in progress; merge readiness should be confirmed on the actual merge result before landing.
  • Complete next step (P2) - No repair lane is needed: the patch has no actionable review finding; wait for exact-head checks before normal maintainer merge review.
Agent review details

Security

None.

PR surface

Source -11, Tests +65. Total +54 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 28 39 -11
Tests 3 66 1 +65
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 94 40 +54

Review metrics

Metric Value Why it matters
Production versus test LOC production +25/-38 (net -13); tests and test support +69/-2 The bug repair removes duplicated production tombstone policy while adding focused regression coverage and a bounded E2E tolerance adjustment.

Stored data model

Persistent data-model change detected: serialized state: ui/src/lib/sessions/navigation.test.ts, serialized state: ui/src/lib/sessions/navigation.ts, serialized state: ui/src/lib/sessions/reconcile.test.ts, unknown-data-model-change: ui/src/lib/sessions/reconcile.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the Gateway producer as the canonical tombstone and ordering authority, retain the UI’s two explicit nullable-field exceptions, and land only after current-head validation is green.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the Gateway producer as the canonical tombstone and ordering authority, retain the UI’s two explicit nullable-field exceptions, and land only after current-head validation is green.

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

Yes—source reproducible: current main’s event producer emits null tombstones that the UI’s fixed deletion list does not fully remove, leaving literal null in optional row fields.

Is this the best way to solve the issue?

Yes. Applying the producer’s null-tombstone rule at the UI merge boundary, while preserving the two schema-nullable fields, removes the duplicated policy rather than extending another manual list.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This fixes bounded Control UI session-state consistency and ordering behavior without a crash, security, or data-loss signal.
  • 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 body supplies focused regression and UI-suite validation claims.

Evidence

What I checked:

  • Current-main defect: Current main merges incoming event fields, then deletes nulls only for an eleven-field manual list; it does not cover the producer’s newer null-tombstoned fields such as tool overrides, observer digest, control ownership, restart recovery, and goal. (ui/src/lib/sessions/reconcile.ts:429, 4fc375654d34)
  • Producer tombstone contract: The Gateway event producer deliberately emits null for cleared optional fields, including observerDigest, controlOwnerSessionKey, toolOverrides, restartRecoveryStatus, goal, and lastRunError. (src/gateway/session-event-payload.ts:54, 4fc375654d34)
  • Nullable row exceptions: The protocol schema defines updatedAt and activeLeafEntryId as the row fields that legitimately accept null, supporting the PR’s explicit exclusions from generic tombstone deletion. (packages/gateway-protocol/src/schema/sessions-row.ts:55, 4fc375654d34)
  • Gateway ordering contract: The Gateway comparator sorts pinned rows, timestamps, then ascending session key to make offset paging deterministic; the PR gives the UI comparator the same final key tie-break. (src/gateway/session-list-order.ts:28, 4fc375654d34)
  • UI caller boundary: The session capability publishes only when reconciliation returns a different result identity, so retaining identity for stale no-op active-session events avoids a needless sidebar publish. (ui/src/lib/sessions/index.ts:238, 1cde9598bb31)
  • Feature-history provenance: Blame attributes the newly added UI ordering tie-break to the PR’s initial fix commit; the pre-existing comparator and Gateway comparator also trace to Peter Steinberger’s recent session/UI work. (ui/src/lib/sessions/navigation.ts:318, 1a82e265feab)

Likely related people:

  • steipete: Current-main history and blame on the UI comparator, Gateway ordering rule, and adjacent session reconciliation work consistently point to this contributor. (role: recent session and Control UI contributor; confidence: high; commits: 83319bad608b, d2be00e171f6, 1a82e265feab; files: ui/src/lib/sessions/navigation.ts, ui/src/lib/sessions/reconcile.ts, src/gateway/session-list-order.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let the current head’s required checks finish successfully and refresh review only if the actual merge result changes this surface.

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 (2 earlier review cycles)
  • reviewed 2026-08-15T08:26:33.982Z sha b894d532735e149fec963f7458f7536e0d4edeba :: needs maintainer review before merge. :: none
  • reviewed 2026-08-15T08:36:56.040Z sha 32e2522 :: needs maintainer review before merge. :: none

…he gateway

The sessions.changed merge deleted null-tombstoned fields from a hand-kept
eleven-field list while the gateway's tombstone policy
(session-event-payload.ts) had grown past it: toolOverrides, observerDigest,
controlOwnerSessionKey, restartRecoveryStatus, and goal leaked literal null
into rows typed optional-not-null, and every new tombstoned field would
silently repeat the drift. One loop over the event's null-valued keys now
owns the rule; updatedAt/activeLeafEntryId (the schema's only nullable row
fields) keep their explicit handling. Net −24 lines.

Riders in the same owner neighborhood:
- compareSessionRowsByUpdatedAt gains the gateway's ascending-key tie-break
  (session-list-order.ts: "Stable key ties keep offset paging deterministic")
  so tied rows — including all updatedAt:null rows — stop visibly swapping
  when the canonical refresh replaces an event-driven reconcile.
- Deleted the unreachable kind === "cron" wire guards (gateway folds cron to
  direct before projection, #115299; both sites needed an `as string` cast
  because the protocol type has no such member).
- The stale-active-snapshot path returns the original result identity when no
  defaults were passed, so the caller's result === state.result publish gate
  skips a spurious sidebar re-render on every stale event.
@steipete
steipete force-pushed the codex/autoqa-reconcile-tombstones branch from b894d53 to 32e2522 Compare August 15, 2026 08:31
The 2px y-tolerance flaked at 2.41px on CI renderers; the #122809
regression this guards against shifts by a full indicator row (~20px).
@steipete
steipete merged commit c841845 into main Aug 15, 2026
168 checks passed
@steipete
steipete deleted the codex/autoqa-reconcile-tombstones branch August 15, 2026 08:59
@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 16, 2026
…he gateway (openclaw#124104)

* fix(ui): reconcile every null tombstone and align session sort with the gateway

The sessions.changed merge deleted null-tombstoned fields from a hand-kept
eleven-field list while the gateway's tombstone policy
(session-event-payload.ts) had grown past it: toolOverrides, observerDigest,
controlOwnerSessionKey, restartRecoveryStatus, and goal leaked literal null
into rows typed optional-not-null, and every new tombstoned field would
silently repeat the drift. One loop over the event's null-valued keys now
owns the rule; updatedAt/activeLeafEntryId (the schema's only nullable row
fields) keep their explicit handling. Net −24 lines.

Riders in the same owner neighborhood:
- compareSessionRowsByUpdatedAt gains the gateway's ascending-key tie-break
  (session-list-order.ts: "Stable key ties keep offset paging deterministic")
  so tied rows — including all updatedAt:null rows — stop visibly swapping
  when the canonical refresh replaces an event-driven reconcile.
- Deleted the unreachable kind === "cron" wire guards (gateway folds cron to
  direct before projection, openclaw#115299; both sites needed an `as string` cast
  because the protocol type has no such member).
- The stale-active-snapshot path returns the original result identity when no
  defaults were passed, so the caller's result === state.result publish gate
  skips a spurious sidebar re-render on every stale event.

* test(ui): pin the ascending-key tie for equal-updatedAt sidebar rows

* test(ui): tolerate CI renderer jitter in the typing-shift picker guard

The 2px y-tolerance flaked at 2.41px on CI renderers; the openclaw#122809
regression this guards against shifts by a full indicator row (~20px).
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 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: 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