Skip to content

fix(gateway): record visible activity on chat setup failures - #186448

Open
moonbow0407 wants to merge 3 commits into
openclaw:mainfrom
moonbow0407:fix/160003-restart-safe-unread
Open

moonbow0407 wants to merge 3 commits into
openclaw:mainfrom
moonbow0407:fix/160003-restart-safe-unread

Conversation

@moonbow0407

@moonbow0407 moonbow0407 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Related: #160003

What Problem This Solves

When an accepted chat fails during setup or dispatch before its run starts, the terminal failure can be recorded without advancing session activity. A user who has already marked the session read can therefore miss that failure.

The restart-safe recovery path originally addressed by this PR was removed by #185730. This revision targets the remaining setup and dispatch failure paths in the current architecture. It does not claim that the removed mechanism still exists or that every symptom in #160003 is resolved.

Change

Carry the existing run and RPC-source visibility into terminal lifecycle persistence. Visible failures advance activity; hidden work remains quiet. Lifecycle ownership and the unread predicate are unchanged.

Thanks @wangmiao0668000666 for the original investigation in #159285.

Evidence

  • On upstream main 4e472c7eda03fe91631ee666ca79e08b40206ae7, the new isolated SQLite regressions fail for visible setup and unstarted dispatch failures because lastActivityAt does not advance. The hidden setup control passes.
  • On the candidate, node scripts/run-vitest.mjs src/gateway/server-methods/chat-send-dispatch-errors.test.ts --maxWorkers=1 passed 25/25 on Windows with Node 24.22.1 using isolated SQLite state. Targeted lint, formatting, git diff --check, and the test-line ratchet against that upstream snapshot passed. The separate allocation covers 61 net regression-test lines for both terminal paths and hidden controls.
  • Independent source review found no actionable defects. This exercises the lifecycle owner, not a browser-rendering or live Gateway flow.
  • The updated head 278ccf6b9159efcdcb8d8c08e187cd82538857a8 has a successful openclaw/ci-gate status. Consult its checks for details.

The prior PR evidence and old-head CI concerned the removed recovery path and are not validation of this revision.

@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Oct 28, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR advances session activity when visible chat setup or dispatch fails while preserving quiet hidden work.

Example: A session has lastActivityAt 1000 and lastReadAt 1500 when a visible chat fails at 2000.

  • Before: The failure is stored, but activity remains 1000 and the session stays read.
  • After: Activity advances to 2000 and the existing unread predicate reports the session unread.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation is focused and source-consistent, but supplied product evidence does not exercise the revised behavior; existing persisted fields and formats require no migration.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A failed visible chat can leave a previously read session without an unread indicator.
Reason: The focused change restores the established visible-terminal activity contract; the description appropriately uses Related for the historical issue.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this PR repairs a current visibility omission through the existing lifecycle owner, with no actionable code defects found.

Priority: P2
Reviewed head: 278ccf6b9159efcdcb8d8c08e187cd82538857a8

Before merge

  • Add real behavior proof - The revised setup and dispatch owners have reported SQLite regression coverage, but the inspected screenshots cover historical paths and the body explicitly disclaims live Gateway validation of this revision; the contributor should provide candidate Gateway logs, live output, or a recording demonstrating visible failure activity and the hidden control, with credentials and private endpoints redacted. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

None.

Tests

  • Missing end-to-end proof: Show both revised failure paths through a running candidate Gateway, with a read baseline becoming unread for visible work and remaining quiet for hidden work.
Agent review details

How this fits together

Chat setup and detached dispatch feed terminal events into the shared session lifecycle writer, whose persisted activity timestamps drive session unread indicators.

flowchart TD
  A[Chat send admission] --> B[Setup or dispatch failure]
  B --> C[Run and source visibility]
  C --> D[Session lifecycle writer]
  D --> E[Persisted session activity]
  E --> F[Session unread indicator]
Loading

Technical review

Best possible solution:

Carry the existing visibility facts into both terminal events while retaining the shared lifecycle writer and unread predicate.

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

Current main demonstrably omits the visibility fact required to advance activity on both failure paths; the contributor reports matching base failures, but this review ran no target code.

Is this the best way to solve the issue?

This is the smallest complete repair for the stated scope: it supplies missing metadata at the producers and preserves lifecycle ownership, hidden-work behavior, and unread derivation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1ae91fa20263.

Provenance checked

  • Hidden-work projection keeps the original intent (ddb31b3: Progress-card refresh work must avoid creating visible chat activity.)
  • Setup and dispatch terminal persistence keeps the original intent (9344233: The restart refactor retired competing recovery machinery and retained ordinary chat lifecycle ownership.)
  • Visible terminal activity keeps the original intent (359a8a3: Visible completed sessions should become unread while hidden and internal work remains quiet.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +9, Tests +61, Other +2. Total +72 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 11 2 +9
Tests 1 62 1 +61
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 3 75 3 +72

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The repair prevents missed failure activity on bounded chat failure paths without establishing message loss or runtime unavailability.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rank-up moves

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

  • Provide running-Gateway evidence for visible and hidden setup and dispatch failures on the revised candidate.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-28T02:41:23.860Z sha 5b20a6a :: needs changes before merge. :: [P2] Preserve synchronous retry preparation when no worker read is needed
  • reviewed 2026-10-28T03:06:40.543Z sha f68aca6 :: needs maintainer review before merge. :: none

Reviewed October 29, 2026, 9:28 PM ET / October 30, 2026, 01:28 UTC (Revision 3).

Copy link
Copy Markdown
Contributor Author

Restored the original conditional retry await from #164682 in f68aca61056b89318731e89d023896cf022798f7 and removed the mock forwarding assertion. The pending-Stop case now passes, and all 158 tests across the six affected suites pass. The English PR body now records the correction, proof reuse, and the remaining CI attribution gaps.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 28, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor

Thanks for picking this up, @moonbow0407 — and for the credit on my withdrawn #159285. The visibility-through-admission fix with the current terminal owner is the right shape; happy to see it landed on the existing custody rather than adding a new state owner. Since this Closes #160003, I will leave that issue open for the merge to resolve it. If you want a second pair of eyes on the retry-await correction or the CI attribution while it waits on maintainer review, happy to help.

Preserve session activity when visible chat setup or dispatch fails before the run starts. Keep hidden work quiet. The test line allocation covers persistence regressions for both paths.
@moonbow0407 moonbow0407 changed the title fix(gateway): mark failed restart-safe browser chats unread fix(gateway): record visible activity on chat setup failures Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The previous restart-safe recovery path was removed by #185730. The updated PR targets the remaining setup and dispatch failure paths; the description now records the changed scope and current evidence.

@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Oct 30, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants