Skip to content

fix: show unread activity on never-opened sessions - #128986

Merged
roboclaw-bot merged 1 commit into
mainfrom
openclaw/read-and-unread-status-bug
Aug 25, 2026
Merged

roboclaw-bot merged 1 commit into
mainfrom
openclaw/read-and-unread-status-bug

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #100739

What Problem This Solves

Fixes an issue where users could see every session as read even when a never-opened session had received new activity. Modern sessions without a lastReadAt timestamp were projected as read, so the Control UI sidebar and other clients never received an unread state for their first background activity.

Why This Change Was Made

The Gateway now uses the session's immutable creation timestamp as the initial unread baseline until an actual read timestamp exists. Rows that predate durable creation provenance keep the upgrade-safe legacy behavior, so old installs do not light up historical sessions.

This repairs the unread invariant at the canonical session-row projection used by list responses and live events. It does not add client-side inference or a second read-state path.

User Impact

Never-opened modern sessions now show an unread indicator after new activity and remain unread until the user opens or explicitly marks them read. Existing legacy rows without creation provenance remain unchanged.

Evidence

  • Real Gateway + Control UI before: isolated Gateway, real sessions.list, and Chromium showed the Background research row without an unread dot under the pre-fix projection.
  • Real Gateway + Control UI after: the identical state showed the red unread dot after the fix. Both capture runs passed and their screenshots plus the inspected post-fix WebM are attached below.

Before

Before: Background research has no unread indicator

After

After: Background research has a red unread indicator

Post-fix recording

read-unread-after.webm
  • OPENCLAW_READ_UNREAD_PROOF_STATE=before node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/read-unread-status-proof.capture.e2e.test.ts — passed (temporary capture-only test removed before commit).
  • OPENCLAW_READ_UNREAD_PROOF_STATE=after node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/read-unread-status-proof.capture.e2e.test.ts — passed (temporary capture-only test removed before commit).
  • node scripts/run-vitest.mjs --configLoader runner src/gateway/session-utils.test.ts -t "derives unread state" — passed after rebase; 7 table-driven cases cover modern first activity, explicit unread, read/activity ordering, and legacy rows.
  • node scripts/check-changed.mjs -- src/gateway/session-utils-core.ts src/gateway/session-utils.test.ts — passed.
  • .agents/skills/autoreview/scripts/autoreview --mode uncommitted --stream-engine-output — clean; no accepted/actionable findings, correctness 0.99.

Production LOC: +6/-3 (net +3) | Tests: +10/-0. The production growth is the creation-baseline owner fix plus the compatibility invariant comment; no fallback path or persistence change was added.

Regression provenance: the original unread contract was introduced by @steipete in #100814 and intentionally treated sessions without any read timestamp as read for upgrade safety. Durable createdAt provenance now lets modern rows distinguish “new session, never read” from legacy unknown state. The hidden retained-pane bug fixed in #123247 was separate.

AI-assisted by Roboclaw; behavior, code, tests, and visual proof were reviewed before publication.

Use creation time as the initial unread baseline for modern session rows while leaving legacy rows unchanged.

Co-authored-by: Tak Hoffman <[email protected]>
@clawsweeper

clawsweeper Bot commented Aug 25, 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 gateway Gateway runtime size: XS maintainer Maintainer-authored PR labels Aug 25, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review August 25, 2026 03:41
@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 12:22 AM ET / 04:22 UTC.

ClawSweeper review

What this changes

This PR makes a never-opened session show unread activity when its durable creation time predates recorded activity, while retaining legacy behavior for rows without creation provenance.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

No blocking code findings. This is still-needed, focused Gateway repair; it remains open because it is an active maintainer-labeled PR, not because it is superseded or already on current main.

Priority: P2
Reviewed head: 85b9923b2c74c8b4df9b6c74286e59a58b3ea88a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with regression coverage and real before/after evidence; the documented session-state transition is the remaining merge consideration.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (recording): The PR provides linked isolated real-Gateway and Chromium before/after captures plus a post-fix recording showing the unread indicator; reviewer-side DNS prevented downloading the attachments but does not invalidate the supplied evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (recording): The PR provides linked isolated real-Gateway and Chromium before/after captures plus a post-fix recording showing the unread indicator; reviewer-side DNS prevented downloading the attachments but does not invalidate the supplied evidence.
Evidence reviewed 5 items Canonical unread owner: The changed helper uses the session creation timestamp only when no explicit read timestamp exists, preserving no-provenance rows as read.
Projection caller: Every session-list row derives unread state through the changed helper, and the event payload forwards that row state to clients.
Regression coverage: The focused table includes legacy activity without creation provenance and activity after creation before first read.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs --configLoader runner src/gateway/session-utils.test.ts -t "derives unread state"

Result: PASS (completed)

node scripts/run-vitest.mjs --configLoader runner src/gateway/session-utils.test.ts -t "derives unread state"
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128986-CEbjwa/target$ node scripts/run-vitest.mjs --configLoader runner src/gateway/session-utils.test.ts -t "d
erives unread state"
node scripts/run-vitest.mjs --configLoader runner src/gateway/session-utils.test.ts -t "derives unread state"
[test] starting test/vitest/vitest.gateway.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128986-CEbjwa/target

 ✓  gateway-core  ../../src/gateway/session-utils.test.ts (194 tests | 187 skipped) 2139ms
     ✓ derives unread state for 'never read'  953ms

 Test Files  1 passed (1)
      Tests  7 passed | 187 skipped (194)
   Start at  04:23:41
   Duration  12.89s (transform 8.43s, setup 972ms, import 9.46s, tests 2.14s, environment 0ms)

[test] passed 1 Vitest shard in 19.62s


































Assertions:

  • PASS expect_output: derives unread state

How this fits together

The Gateway converts persisted session metadata into session-list rows and live event payloads consumed by the Control UI and other clients. Read markers and activity timestamps become the unread indicator rendered by those clients.

flowchart LR
A[Session creation] --> B[Persisted session row]
C[Agent activity] --> B
B --> D[Gateway unread projection]
E[Read or unread action] --> D
D --> F[Session list and events]
F --> G[Control UI and clients]
Loading

Before merge

  • Resolve merge risk (P1) - Merging intentionally reclassifies existing creation-provenance rows with no read marker and later activity as unread; the PR discussion records acceptance of that visible session-state transition.
Agent review details

Security

None.

PR surface

Source +3, Tests +10. Total +13 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 6 3 +3
Tests 1 10 0 +10
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 16 3 +13

Review metrics

Metric Value Why it matters
Production versus regression coverage production +6/-3 (net +3); tests +10/-0 The small production increase is the canonical creation-baseline rule and its invariant comment; the added cases cover the modern and legacy boundary.

Stored data model

Persistent data-model change detected: serialized state: src/gateway/session-utils.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Land the documented transition (recommended)
    Accept the recorded behavior that creation-provenance sessions with prior activity become unread until explicitly read, while legacy no-provenance rows stay unchanged.
  2. Pause for a different upgrade policy
    Keep the PR open only if maintainers want a narrower persisted cutoff or a migration policy instead of the recorded creation-provenance boundary.

Technical review

Best possible solution:

Keep the unread rule in the canonical Gateway row projection and land it with the recorded legacy-row and upgrade behavior intact.

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

Yes, from source: a row with createdAt 10 and lastActivityAt 11 was previously projected read and is now projected unread; the PR also supplies isolated Gateway and Chromium before/after evidence.

Is this the best way to solve the issue?

Yes. The Gateway row projection is the single source for both session lists and live payloads, so a client-side inference path would duplicate read-state policy.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This fixes a bounded but user-visible session-state indicator defect without data loss, security impact, or availability loss.
  • add merge-risk: 🚨 session-state: The merge intentionally changes unread state for existing durable-creation session rows that have activity but no recorded read marker.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR provides linked isolated real-Gateway and Chromium before/after captures plus a post-fix recording showing the unread indicator; reviewer-side DNS prevented downloading the attachments but does not invalidate the supplied evidence.
  • add proof: 🎥 video: Contributor real behavior proof includes video or recording evidence. The PR provides linked isolated real-Gateway and Chromium before/after captures plus a post-fix recording showing the unread indicator; reviewer-side DNS prevented downloading the attachments but does not invalidate the supplied evidence.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (recording): The PR provides linked isolated real-Gateway and Chromium before/after captures plus a post-fix recording showing the unread indicator; reviewer-side DNS prevented downloading the attachments but does not invalidate the supplied evidence.

Label justifications:

  • P2: This fixes a bounded but user-visible session-state indicator defect without data loss, security impact, or availability loss.
  • merge-risk: 🚨 session-state: The merge intentionally changes unread state for existing durable-creation session rows that have activity but no recorded read marker.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (recording): The PR provides linked isolated real-Gateway and Chromium before/after captures plus a post-fix recording showing the unread indicator; reviewer-side DNS prevented downloading the attachments but does not invalidate the supplied evidence.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR provides linked isolated real-Gateway and Chromium before/after captures plus a post-fix recording showing the unread indicator; reviewer-side DNS prevented downloading the attachments but does not invalidate the supplied evidence.
  • proof: 🎥 video: Contributor real behavior proof includes video or recording evidence. The PR provides linked isolated real-Gateway and Chromium before/after captures plus a post-fix recording showing the unread indicator; reviewer-side DNS prevented downloading the attachments but does not invalidate the supplied evidence.

Evidence

What I checked:

  • Canonical unread owner: The changed helper uses the session creation timestamp only when no explicit read timestamp exists, preserving no-provenance rows as read. (src/gateway/session-utils-core.ts:88, 85b9923b2c74)
  • Projection caller: Every session-list row derives unread state through the changed helper, and the event payload forwards that row state to clients. (src/gateway/session-utils-row.ts:599, 85b9923b2c74)
  • Regression coverage: The focused table includes legacy activity without creation provenance and activity after creation before first read. (src/gateway/session-utils.test.ts:319, 85b9923b2c74)
  • Feature history: History identifies the original merged unread-session feature and the later creation-provenance work; the latter supplies the durable discriminator used here. (src/config/sessions/session-entry-provenance.ts:66, 099d6351b360)
  • Current-main and release status: The PR head is not an ancestor of current main, and no local release tag contains it; GitHub context reports it open and cleanly mergeable. The partial clone could not materialize the current-main file tree because network DNS was unavailable, so this review does not claim a direct source comparison to current main. (935c555c98d6)

Likely related people:

  • steipete: Authored the merged unread-session feature and the subsequent creation-provenance work that establishes the distinction this repair relies on. (role: feature owner and recent area contributor; confidence: high; commits: 88f1ec38d4a5, 099d6351b360; files: src/gateway/session-utils-core.ts, src/config/sessions/session-entry-provenance.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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-25T03:41:17.083Z sha 85b9923 :: needs maintainer review before merge. :: none

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Maintainer decision: accept the documented upgrade behavior. Existing modern sessions with durable createdAt, no lastReadAt, and later recorded activity may become unread immediately after upgrade; legacy rows without creation provenance remain unchanged.

ClawSweeper rank-up move: satisfied. This PR is ready for review, the owner decision above resolves the session-state merge risk, and exact-head validation is green.

Land-ready proof for 85b9923b2c74c8b4df9b6c74286e59a58b3ea88a:

  • Focused regression: node scripts/run-vitest.mjs --configLoader runner src/gateway/session-utils.test.ts -t "derives unread state" — passed after rebase (7 unread cases).
  • Changed gate: node scripts/check-changed.mjs -- src/gateway/session-utils-core.ts src/gateway/session-utils.test.ts — passed.
  • Real behavior: isolated real Gateway + Chromium before/after captures passed; before, after, and post-fix recording.
  • Autoreview: clean, no accepted/actionable findings, correctness 0.99.
  • Exact-head CI: run 32806117781 completed successfully.
  • ClawSweeper: no code findings; the only before-merge item was the owner decision recorded above.

Known proof gaps: none for this bounded deterministic Gateway projection change.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 25, 2026
@roboclaw-bot
roboclaw-bot merged commit b454497 into main Aug 25, 2026
317 of 318 checks passed
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

@roboclaw-bot
roboclaw-bot deleted the openclaw/read-and-unread-status-bug branch August 25, 2026 04:44
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 26, 2026
Use creation time as the initial unread baseline for modern session rows while leaving legacy rows unchanged.

Co-authored-by: roboclaw-bot <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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