Repository navigation
Conversation
- One rule decides unread activity: an appended user or assistant row the chat renders with something to read advances lastActivityAt and ends a snooze. - Applied by the append owners: transcript turns, SessionManager appends and the in-memory actor. NO_REPLY, quiet heartbeats, wakes and hidden turns no longer mark a session unread. - Removed the run-end lifecycle stamp, agent-command touchActivity and its coordination special case, and the inbound/background-result stamps. Co-authored-by: obviyus <[email protected]> Fixes #204164
|
🦞👀 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: blocked before merge. What this changesThis PR advances unread activity and clears snooze when visible transcript messages are appended instead of when runs finish. Example: A chat has lastActivityAt=1000 and lastReadAt=1500; a quiet wake ends at 1800 with NO_REPLY.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 6 items remain Keep open: this addresses a real false-unread bug, but missed failure notices, reset regressions, and broken wrapper extraction block merge. Priority: P2 Before merge
Findings
Provenance
Tests
Agent review detailsHow this fits togetherSession transcript writers persist messages and session metadata; Gateway projections turn those committed facts into unread indicators and snooze state for clients. flowchart LR
A[Transcript append] --> B[Display visibility projection]
B --> C[Atomic activity and snooze update]
C --> D[Gateway session projection]
D --> E[Client unread indicator]
F[Run lifecycle] --> D
Technical reviewBest possible solution: Keep the shared append-time visibility rule, cover visible failure reports, preserve reset behavior, and complete the affected wrapper and consumer cutover. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the silent-completion mismatch, and the inspected base/head browser screenshots corroborate it; no target code was executed during this review. Is this the best way to solve the issue? Append-time activity uses the right existing owners and removes competing stamps, but the cutover must include visible report events and consumers that depend on transcript-only writes. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a1a7893689ac. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +28, Tests -53, Docs 0. Total -25 across 21 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, 3:06 PM ET / 20:06 UTC. |
…unread state - A visible row writes the session entry only when it makes a read session unread or ends a snooze; appends to an already-unread chat stay transcript-only, keeping streaming previews off the row rematerialize path. - Cover a real sessions_send coordination reply through the run writer's display projection. - Add the projection modules to the PR wrapper import inventory. Co-authored-by: obviyus <[email protected]>
…ad baseline - A visible row ends a snooze set before it, independent of the unread baseline, so legacy rows without createdAt/lastReadAt still wake. - Drop the deleted snooze test from the database-worker test inventory. Co-authored-by: obviyus <[email protected]>
|
Rejected review findings:
(The round 2 finding, a snoozed legacy session not waking, was fixed in 854cdb3.) |
|
Status: not ready to land.
Same class as the earlier reds on this branch: an entry write inside a SessionManager append breaks transcript-owned contracts (row preview rematerialization, turn postimages, reset boundary, now the PostgreSQL run). Next step (separate design change): stop writing the entry in the SessionManager append path. Keep the content fact on the transcript side (the window's row-transcript projection already records the latest display-visible assistant row) and let the run-end writer, which already writes the entry, consume it. Turn-path stamping ( |
|
Superseded by #204281: the run end reads the transcript's newest visible reply instead of writing the entry in the transcript append path, which broke the PostgreSQL cron run here. |
…e reply (#204281) Closes #204164. Replaces #204209. ## Problem A session went unread with nothing new to read. Example (synthetic): a heartbeat or child-end wake runs in a chat, the model answers `NO_REPLY` (or `HEARTBEAT_OK`), the chat shows no new row, and the sidebar still lights its unread dot. Cause: the run end stamped unread activity per run, not per content. - The Gateway's run-end lifecycle projection set `lastActivityAt = endedAt` for every Control UI–visible run (`controlUiVisible`). - Agent-command post-run set `lastActivityAt = now` for every run without internal events (`touchActivity`), with a special case for a child's `sessions_send` turns (#204143). Neither knew whether the run added anything a person can see. ## Change The run end now reads what the run added. Both run-end writers ask the transcript for its newest visible assistant row (`lastAssistantMessage`, the same row projection that feeds the sidebar preview) and advance `lastActivityAt` to that row's time only when it is newer. Silent replies (`NO_REPLY`), heartbeat acknowledgements and hidden coordination replies (`display: false`) are not visible rows, so a run that ends in one of them leaves unread alone. - One read: `readVisibleSessionActivityAt` (`src/gateway/session-row-transcript-backfill.ts`), a thin wrapper over the existing bounded row-transcript read (`backfillSessionRowTranscriptFields`). - Gateway run end: `persistPreparedGatewaySessionLifecycleEvent` passes the time into the lifecycle patch (`visibleActivityAt`); `projectSessionLifecyclePatch` applies it on terminal events. - Agent-command run end (Gateway `agent` runs and `openclaw agent --local`): `updateSessionStoreAfterAgentRun` reads the same fact; a visible reply also ends a snooze, as before. - Nothing is written in the transcript append path. - Channel inbound messages and background/cron results keep their existing stamping (they add a visible row themselves). Removed: - the run-end `controlUiVisible` stamp and `controlUiVisible` on lifecycle events, which only fed it; - agent-command `touchActivity`, its internal-event and coordination special cases; - the lifecycle-event unread recomputation in `buildGatewaySessionSnapshot`; - `session-store.snooze.test.ts`, which asserted the removed `touchActivity` parameter (snooze is covered in `session-unread.test.ts`). Production line delta (excluding tests, docs and test inventories): **+44 / −27 (net +17)**. The read is one helper with two call sites; the per-run special cases it replaces were smaller than the read and its plumbing. ## What the user sees - A turn that ends in `NO_REPLY`, a quiet heartbeat, an internal wake, or a parent answering its child's `sessions_send` no longer lights the unread dot. - A visible reply, a channel message, or a delivered cron/background result still does. A visible reply still wakes a snoozed session. ## Accepted edge cases - Incognito sessions: their transcripts stay in the Gateway process, so the run end has no stored row to read and their replies no longer mark them unread. You are usually in an incognito chat while it runs. - A reply that is only an image (no text) has no row preview, so it does not mark the chat unread. - CLI-backend runs (`claude-cli` and similar) persist their transcript after the agent-command run end, so `openclaw agent --local` with a CLI backend does not mark unread from that writer. I did not verify whether the Gateway lifecycle run end sees a Gateway CLI run's reply. - A visible reply whose stored event is over 64 KiB has no row preview, so it does not mark the chat unread (the preview read is size-bounded so it can run at every run end). - The run end adds one bounded transcript read per terminal run (the same read the sidebar row owner already does). ## Evidence - `src/shared/session-unread.test.ts` (rewritten) appends real rows to a SQLite transcript and runs the real agent-command run end: - stays read and snoozed after a `NO_REPLY` wake turn, a quiet heartbeat, and a parent's reply to a child's `sessions_send` (built through the run writer's display projection). **Red on base** (base stamps every run). - turns unread and ends the snooze after a visible reply; - inbound channel message unread, internal wake read (unchanged from #204143). - `src/gateway/session-lifecycle-state.test.ts`: a visible run that ends without a new visible reply leaves `lastActivityAt` alone. **Red on base.** - `src/cron/isolated-agent/destination-completion.test.ts` (unchanged): a delivered cron result still stamps the destination. - PostgreSQL conformance, full suite, locally against PostgreSQL 16 (pgvector pg16 image from CI): `server-database-engine-cron.postgres.test.ts`, which failed on #204209, passes. `client-credential-update.test.ts` and `git-backup.postgres.test.ts` fail locally the same way on the merge base (local environment, not this change). - `pnpm check:changed`: typecheck, lint and guards pass. The dead-export scan fails on three exports this PR does not touch (also on `main`). - Real-Gateway Control UI E2E (throwaway, not committed; only the model provider is scripted; dist build): two chats each get an `agent` turn with a hidden heartbeat input while the browser shows a third chat. The first reply is `NO_REPLY`, the second visible. - Base: **fails**, the `NO_REPLY` chat shows an unread dot. - Head: **passes**, the `NO_REPLY` chat stays read; the visible-reply chat shows a dot. Screenshots in a PR comment. Co-authored-by: Ayaan Zaidi <[email protected]>
…e reply (openclaw#204281) Closes openclaw#204164. Replaces openclaw#204209. ## Problem A session went unread with nothing new to read. Example (synthetic): a heartbeat or child-end wake runs in a chat, the model answers `NO_REPLY` (or `HEARTBEAT_OK`), the chat shows no new row, and the sidebar still lights its unread dot. Cause: the run end stamped unread activity per run, not per content. - The Gateway's run-end lifecycle projection set `lastActivityAt = endedAt` for every Control UI–visible run (`controlUiVisible`). - Agent-command post-run set `lastActivityAt = now` for every run without internal events (`touchActivity`), with a special case for a child's `sessions_send` turns (openclaw#204143). Neither knew whether the run added anything a person can see. ## Change The run end now reads what the run added. Both run-end writers ask the transcript for its newest visible assistant row (`lastAssistantMessage`, the same row projection that feeds the sidebar preview) and advance `lastActivityAt` to that row's time only when it is newer. Silent replies (`NO_REPLY`), heartbeat acknowledgements and hidden coordination replies (`display: false`) are not visible rows, so a run that ends in one of them leaves unread alone. - One read: `readVisibleSessionActivityAt` (`src/gateway/session-row-transcript-backfill.ts`), a thin wrapper over the existing bounded row-transcript read (`backfillSessionRowTranscriptFields`). - Gateway run end: `persistPreparedGatewaySessionLifecycleEvent` passes the time into the lifecycle patch (`visibleActivityAt`); `projectSessionLifecyclePatch` applies it on terminal events. - Agent-command run end (Gateway `agent` runs and `openclaw agent --local`): `updateSessionStoreAfterAgentRun` reads the same fact; a visible reply also ends a snooze, as before. - Nothing is written in the transcript append path. - Channel inbound messages and background/cron results keep their existing stamping (they add a visible row themselves). Removed: - the run-end `controlUiVisible` stamp and `controlUiVisible` on lifecycle events, which only fed it; - agent-command `touchActivity`, its internal-event and coordination special cases; - the lifecycle-event unread recomputation in `buildGatewaySessionSnapshot`; - `session-store.snooze.test.ts`, which asserted the removed `touchActivity` parameter (snooze is covered in `session-unread.test.ts`). Production line delta (excluding tests, docs and test inventories): **+44 / −27 (net +17)**. The read is one helper with two call sites; the per-run special cases it replaces were smaller than the read and its plumbing. ## What the user sees - A turn that ends in `NO_REPLY`, a quiet heartbeat, an internal wake, or a parent answering its child's `sessions_send` no longer lights the unread dot. - A visible reply, a channel message, or a delivered cron/background result still does. A visible reply still wakes a snoozed session. ## Accepted edge cases - Incognito sessions: their transcripts stay in the Gateway process, so the run end has no stored row to read and their replies no longer mark them unread. You are usually in an incognito chat while it runs. - A reply that is only an image (no text) has no row preview, so it does not mark the chat unread. - CLI-backend runs (`claude-cli` and similar) persist their transcript after the agent-command run end, so `openclaw agent --local` with a CLI backend does not mark unread from that writer. I did not verify whether the Gateway lifecycle run end sees a Gateway CLI run's reply. - A visible reply whose stored event is over 64 KiB has no row preview, so it does not mark the chat unread (the preview read is size-bounded so it can run at every run end). - The run end adds one bounded transcript read per terminal run (the same read the sidebar row owner already does). ## Evidence - `src/shared/session-unread.test.ts` (rewritten) appends real rows to a SQLite transcript and runs the real agent-command run end: - stays read and snoozed after a `NO_REPLY` wake turn, a quiet heartbeat, and a parent's reply to a child's `sessions_send` (built through the run writer's display projection). **Red on base** (base stamps every run). - turns unread and ends the snooze after a visible reply; - inbound channel message unread, internal wake read (unchanged from openclaw#204143). - `src/gateway/session-lifecycle-state.test.ts`: a visible run that ends without a new visible reply leaves `lastActivityAt` alone. **Red on base.** - `src/cron/isolated-agent/destination-completion.test.ts` (unchanged): a delivered cron result still stamps the destination. - PostgreSQL conformance, full suite, locally against PostgreSQL 16 (pgvector pg16 image from CI): `server-database-engine-cron.postgres.test.ts`, which failed on openclaw#204209, passes. `client-credential-update.test.ts` and `git-backup.postgres.test.ts` fail locally the same way on the merge base (local environment, not this change). - `pnpm check:changed`: typecheck, lint and guards pass. The dead-export scan fails on three exports this PR does not touch (also on `main`). - Real-Gateway Control UI E2E (throwaway, not committed; only the model provider is scripted; dist build): two chats each get an `agent` turn with a hidden heartbeat input while the browser shows a third chat. The first reply is `NO_REPLY`, the second visible. - Base: **fails**, the `NO_REPLY` chat shows an unread dot. - Head: **passes**, the `NO_REPLY` chat stays read; the visible-reply chat shows a dot. Screenshots in a PR comment. Co-authored-by: Ayaan Zaidi <[email protected]>



Closes #204164.
Problem
A session went unread with nothing new to read. Example (synthetic): a heartbeat or child-end wake runs in a chat, the model answers
NO_REPLY(orHEARTBEAT_OK), and the chat shows no new row, but the sidebar lights its unread dot.Cause: unread was stamped per run, not per content.
lastActivityAt = endedAtfor every Control UI–visible run (controlUiVisible).lastActivityAt = nowfor every run without internal events (touchActivity), with a special case for subagent coordination turns (fix(sessions): exclude hidden coordination and failed children from unread #204143).initSessionStateandcommitBackgroundResultToSessionstamped it separately for inbound messages and background/cron results.None of these knew whether the run added anything a person can see.
Change
One rule, applied where rows are appended: a session becomes unread (and a snooze ends) only when an appended user or assistant row is one the chat renders with something to read. The decision is
projectVisibleSessionActivity(src/config/sessions/session-visible-activity.ts). It uses the Control UI's own per-message projection (projectChatDisplayMessage). Silent replies, heartbeat prompts and acknowledgements, wake inputs,display: falsecoordination rows, tool calls and reasoning do not count.The rule writes the entry only when it changes something: when a visible row makes a read session unread, or ends a snooze. Appends to a chat that is already unread stay transcript-only writes, so streaming previews keep their no-rematerialize path.
It is applied by the existing append owners, in the same transaction as the append:
buildExpectedTranscriptTurnSessionPatch: chat sends, channel inbound, chat inject, background and cron results);appendTranscriptMessageSnapshotSync: embedded run replies, includingopenclaw agent --local);Removed:
lastActivityAtstamp, andcontrolUiVisibleon lifecycle events, which only fed it;touchActivity, its coordination special case, and its snooze clearing;initSessionStateand background-resultlastActivityAtstamps, andlastActivityAtin the turn lifecycle patch type;buildGatewaySessionSnapshot.Channel inbound messages, background/cron results and
--localreplies still mark unread, because each appends a visible row.scripts/pr-lib/wrapper-components.txtgains the projection modules that the session writer now imports (the PR-wrapper import inventory test lists them).Production line delta (excluding tests, docs and the wrapper/test inventories): +86 / −43 (net +43). The add is the one decision function and its three appliers; the per-run stamps it replaces were smaller.
What the user sees
NO_REPLY, a quiet heartbeat, or an internal wake no longer lights the unread dot.Accepted edge cases
lastActivityAtnow marks the visible row that made the session unread. Further rows in a chat that is already unread do not move it. Row order useslastInteractionAt/updatedAtas before. Chat prefetch keys onlastActivityAt, so it does not re-warm an already-unread chat for each later row; opening the chat still loads its history.createdAtorlastReadAtwere never unread and still are not; a visible row still wakes them from a snooze.Review notes
Rejected review findings:comment. Round 2 (a snoozed legacy session would not wake) is fixed.model-selection.configured.test.tsfails onmaintoo (ci-triage: MAIN-ALSO). Our reds were fixed: per-append entry writes broke the streaming-preview row contract (now only unread transitions write), the wrapper import inventory, and a stale test inventory entry for the deleted snooze test.Evidence
src/shared/session-unread.test.ts(rewritten) drives real SQLite appends throughSessionManagerandpersistSessionTranscriptTurn:sessions_send(snooze kept);src/gateway/session-lifecycle-state.test.ts: a visible run's end no longer moveslastActivityAt. Red on base, green on head.src/cron/isolated-agent/destination-completion.test.ts: a delivered cron result marks a read destination unread.agentturn with a hidden heartbeat input while the browser shows a third chat. The first reply isNO_REPLY, the second visible.NO_REPLYchat shows an unread dot.NO_REPLYchat stays read and the visible-reply chat shows a dot. Screenshots in the PR comment.src/shared/session-unread.test.tsalso covers a snoozed legacy row (no read baseline) waking on a visible reply.pnpm check:changedon the first head: typecheck, lint, guards and import cycles pass. The PostgreSQL turn-count conformance lane was not run locally (no PostgreSQL); the SQLite turn-count budget is unchanged.