Repository navigation
fix(sessions): exclude hidden coordination and failed children from unread - #204143
Conversation
Unread reads lastActivityAt only. A parent answering its child's sessions_send no longer lights the dot. Drop the post-run lastActivityAt write that ignored coordination provenance; the run-end lifecycle projection gated on controlUiVisible is the one run writer. The flag keeps only its snooze job (touchActivity -> clearSnooze). Auto-reply stamps lastActivityAt for inbound non-system messages so channel sessions still go unread. Opening a parent acknowledges failed and timed-out hidden runs too, so they no longer hold the parent's unread count. Co-authored-by: obviyus <[email protected]>
|
🦞👀 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. |
…ination Restore the post-run lastActivityAt write: `openclaw agent --local` has no Gateway lifecycle persister, so visible replies from that path must still stamp activity. Gate it on subagent coordination provenance, the same check the run-end lifecycle writer applies via controlUiVisible, so a child's sessions_send to its requester neither stamps activity nor clears a snooze. Co-authored-by: obviyus <[email protected]>
|
Codex review: blocked before merge. What this changesThis PR makes unread indicators follow visible activity and lets opening a parent acknowledge failed hidden runs. Example: A child sends its parent 15 progress messages through sessions_send, with replies visible only to the child.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep this maintainer-authored PR open: it addresses a real unread-state bug, but dropping the interaction-clock fallback misses accepted chat input that fails before reply initialization. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherSession admission and run completion persist activity timestamps; shared unread derivation feeds Gateway rows and Control UI indicators, while parent-read actions acknowledge folded hidden runs. flowchart TD
A[Incoming chat or coordination] --> B[Session admission]
B --> C[Agent execution]
B --> D[Persisted session timestamps]
C --> D
D --> E[Shared unread derivation]
E --> F[Gateway session rows]
F --> G[Control UI sidebar and parent reads]
Technical reviewBest possible solution: Stamp visible accepted input through its existing persistence owner before removing the idle-clock fallback, while preserving hidden coordination suppression and standalone agent activity. Do we have a high-confidence way to reproduce the issue? The original hidden-turn defect is supported by source and inspected author-supplied before/after screenshots; the missed accepted-input failure path is source-reproducible, and no target code was executed during this review. Is this the best way to solve the issue? Separating idle activity from unread activity is sound, but the cutover must include visible input acceptance rather than relying on reply initialization to run successfully. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e5dcfa009663. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +2, Tests +103, Docs +2. Total +107 across 8 files. Added test files: 1. 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, 12:02 PM ET / 17:02 UTC. |
Leave failed and timed-out hidden runs unacknowledged so their failure stays on the child card, and stop counting them toward the parent's unread state instead. Background and scheduled results committed into a conversation stamp lastActivityAt with the message timestamp, so they still mark the destination unread. Co-authored-by: obviyus <[email protected]>
|
Landed. A parent that only answers its child's |
…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]>
…nread (openclaw#204143) ## Problem A session went unread with nothing new to read. Example (synthetic): a subagent sends its parent 15 progress messages with `sessions_send`. Each one starts a hidden parent turn that answers only the child. Nothing appears in the parent chat, but every turn lights the parent's unread dot. Cause: `deriveSessionUnread` compared `lastReadAt` with `max(lastInteractionAt, lastActivityAt)`. - `lastInteractionAt` is the idle-reset clock. Every non-system turn moves it, hidden turns included. - Agent-command post-run moved `lastActivityAt` on every non-internal-event run. Unlike the run-end lifecycle writer, it did not skip hidden subagent coordination turns. Second problem: failed or timed-out hidden subagent runs stayed unread for good. Opening the parent acknowledged its hidden runs but skipped failed ones, and hidden runs have no row of their own to open. ## Change - `deriveSessionUnread` reads only `lastActivityAt` (plus the manual `markedUnreadAt`). It no longer reads the idle clock. - Post-run `touchActivity` now also skips subagent coordination provenance (`isSubagentCoordinationInputProvenance`), the same check the run-end lifecycle writer already applies through `controlUiVisible`. A hidden coordination turn no longer stamps activity, and it no longer clears a snooze. - Auto-reply `initSessionState` stamps `lastActivityAt` for an inbound non-system message, with the same value as the existing `lastInteractionAt` stamp. Channel sessions (for example Telegram) depended on the idle clock for unread, so they still go unread when a message arrives. Internal wakes do not. - Background and scheduled results committed into a conversation (`commitBackgroundResultToSession`, used by confirmed cross-conversation messages and cron results) stamp `lastActivityAt` with the same message timestamp as `lastInteractionAt`. - The sidebar tree counts a hidden subagent run toward its parent's unread count only while reading the parent can acknowledge it (`isAcknowledgeableHiddenRun`). Failed and timed-out hidden runs no longer hold the parent dot. They are not acknowledged, so their failure stays on the child card. - Docs: `docs/web/control-ui/sessions-and-sidebar.md`. Production line delta (excluding tests and docs): **+27 / −15 (net +12)**. ## What the user sees - A parent that only answers its child's `sessions_send` stays read. - A visible reply, or a channel message arriving, still marks the session unread. - Failed hidden child runs no longer keep a parent's dot or count lit after you open the parent. ## Review notes - Round 2 found (both fixed): (a) background and scheduled results stamped only the idle clock, so they would stop marking the destination unread; (b) the first head acknowledged failed hidden runs when the parent opened, which stamps `lastReadAt` and hides the failure on the child card. Now failed runs stay unacknowledged and are left out of the parent count instead. - Local ClawSweeper round 1 found that `openclaw agent --local` has no Gateway lifecycle persister. The first head deleted the post-run `lastActivityAt` write, so visible replies from that path stopped marking unread. Fixed by keeping the write and gating it on coordination provenance instead. ## Not done here (original scope, unfinished) The goal was that unread follows visible content: a turn that appends nothing visible never marks the session unread. This PR covers hidden coordination turns and failed hidden children only. Unread still follows run visibility, not appended content, so a Control UI–visible run that ends in `NO_REPLY` or a quiet heartbeat still marks the session unread. Fixing that needs one owner that decides from transcript content (the run end has no visible-output fact today). Tracked in openclaw#204164. ## Evidence - `src/shared/session-unread.test.ts` (new) drives the real run-end lifecycle patch and `initSessionState` through `deriveSessionUnread`: - hidden turn (idle clock moved, run not visible) → read; visible run end → unread. **Red on base, green on head.** - inbound channel message → unread; internal wake → read. Green on both (guards the auto-reply stamp). - `src/agents/agent-command.live-model-switch.test.ts`: through `agentCommand`, an operator turn stamps activity and a child's `sessions_send` to its requester does not. **Red on base, green on head.** - `ui/src/components/app-sidebar-session-tree.test.ts`: an unread finished hidden run counts toward its parent; failed and timed-out ones do not. **Red on base, green on head.** - `src/cron/isolated-agent/destination-completion.test.ts`: a delivered cron result stamps `lastActivityAt` on the destination. **Red on base, green on head.** - Real-Gateway Control UI E2E (throwaway; only the model provider is scripted, while Gateway, `sessions_spawn`, `sessions_send` and sidebar are real): a parent spawns a visible child; the operator moves to another session; the child sends the parent a progress message with `sessions_send`; the parent's hidden turn replies only to the child (the child stays running, so no completion wake). Assertion: the parent sidebar row has no unread dot. - Base: **fails**, 1 dot. Head: **passes**, 0 dots. Screenshots in the 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]>


Problem
A session went unread with nothing new to read. Example (synthetic): a subagent sends its parent 15 progress messages with
sessions_send. Each one starts a hidden parent turn that answers only the child. Nothing appears in the parent chat, but every turn lights the parent's unread dot.Cause:
deriveSessionUnreadcomparedlastReadAtwithmax(lastInteractionAt, lastActivityAt).lastInteractionAtis the idle-reset clock. Every non-system turn moves it, hidden turns included.lastActivityAton every non-internal-event run. Unlike the run-end lifecycle writer, it did not skip hidden subagent coordination turns.Second problem: failed or timed-out hidden subagent runs stayed unread for good. Opening the parent acknowledged its hidden runs but skipped failed ones, and hidden runs have no row of their own to open.
Change
deriveSessionUnreadreads onlylastActivityAt(plus the manualmarkedUnreadAt). It no longer reads the idle clock.touchActivitynow also skips subagent coordination provenance (isSubagentCoordinationInputProvenance), the same check the run-end lifecycle writer already applies throughcontrolUiVisible. A hidden coordination turn no longer stamps activity, and it no longer clears a snooze.initSessionStatestampslastActivityAtfor an inbound non-system message, with the same value as the existinglastInteractionAtstamp. Channel sessions (for example Telegram) depended on the idle clock for unread, so they still go unread when a message arrives. Internal wakes do not.commitBackgroundResultToSession, used by confirmed cross-conversation messages and cron results) stamplastActivityAtwith the same message timestamp aslastInteractionAt.isAcknowledgeableHiddenRun). Failed and timed-out hidden runs no longer hold the parent dot. They are not acknowledged, so their failure stays on the child card.docs/web/control-ui/sessions-and-sidebar.md.Production line delta (excluding tests and docs): +27 / −15 (net +12).
What the user sees
sessions_sendstays read.Review notes
lastReadAtand hides the failure on the child card. Now failed runs stay unacknowledged and are left out of the parent count instead.openclaw agent --localhas no Gateway lifecycle persister. The first head deleted the post-runlastActivityAtwrite, so visible replies from that path stopped marking unread. Fixed by keeping the write and gating it on coordination provenance instead.Not done here (original scope, unfinished)
The goal was that unread follows visible content: a turn that appends nothing visible never marks the session unread. This PR covers hidden coordination turns and failed hidden children only. Unread still follows run visibility, not appended content, so a Control UI–visible run that ends in
NO_REPLYor a quiet heartbeat still marks the session unread. Fixing that needs one owner that decides from transcript content (the run end has no visible-output fact today). Tracked in #204164.Evidence
src/shared/session-unread.test.ts(new) drives the real run-end lifecycle patch andinitSessionStatethroughderiveSessionUnread:src/agents/agent-command.live-model-switch.test.ts: throughagentCommand, an operator turn stamps activity and a child'ssessions_sendto its requester does not. Red on base, green on head.ui/src/components/app-sidebar-session-tree.test.ts: an unread finished hidden run counts toward its parent; failed and timed-out ones do not. Red on base, green on head.src/cron/isolated-agent/destination-completion.test.ts: a delivered cron result stampslastActivityAton the destination. Red on base, green on head.sessions_spawn,sessions_sendand sidebar are real): a parent spawns a visible child; the operator moves to another session; the child sends the parent a progress message withsessions_send; the parent's hidden turn replies only to the child (the child stays running, so no completion wake). Assertion: the parent sidebar row has no unread dot.