Skip to content

fix(gateway): mark a terminal restart-safe admission unread - #159285

Closed
wangmiao0668000666 wants to merge 15 commits into
openclaw:mainfrom
wangmiao0668000666:fix/restart-recovery-unread
Closed

wangmiao0668000666 wants to merge 15 commits into
openclaw:mainfrom
wangmiao0668000666:fix/restart-recovery-unread

Conversation

@wangmiao0668000666

@wangmiao0668000666 wangmiao0668000666 commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Refs #160003 (still open; this PR is closed without merging)

What Problem This Solves

A Control-UI chat send that a restart-safe admission terminalizes is persisted terminal without an unread marker, even though the reply never reached the user. #155690 advances lastActivityAt only for terminal writes that carry controlUiVisible (src/gateway/session-lifecycle-state.ts:224), and terminalizeRestartSafeChatAdmission synthesizes its own terminal event (src/gateway/server-methods/chat-restart-recovery.ts:427) without that field. The row keeps lastActivityAt undefined, deriveSessionUnread stays false, and the session list never shows the failure the user still has to read.

Precedent: #155690 (the gate this completes — same owner, same "a visible terminal advances activity" invariant).

Why This Change Was Made

A restart-safe request is not the same thing as a visible turn. createRestartSafeChatRequest returns a fingerprint for Goal work before it checks browser eligibility (chat-restart-recovery.ts:121), because internal start/resume must survive a restart too. So the terminal write cannot infer visibility from the admission's existence.

The admission now records the decision its caller already made and carries it to the write:

  • createRestartSafeChatRequest takes controlUiVisible and returns it on every branch, including the Goal branch.
  • RestartSafeChatAdmission and terminalizeRestartSafeChatAdmission take the same field, and the synthetic terminal event stamps controlUiVisible: params.controlUiVisible instead of a literal true.
  • chat-send-session.ts supplies the browser-client fact, isBrowserOperatorUiClient(request.clientInfo). Visibility is deliberately not the whole eligible conjunction: the remaining terms (no attachments, no reconnect resume, no timeout override, …) describe restart safety, not visibility.

Production LOC is +25/-1 across three files. Tests are +262/-1 plus two one-line call-site updates, plus the CI inventory line and its doc bullet. No new option, configuration, validator, or persistence surface: the fact lives in memory on the admission.

CI cost also moves with it: the ~33 s real-Gateway tour is registered in RELEASE_ONLY_RUNTIME_TEST_FILES, so ordinary PRs and pushes keep the fast owner contract instead of paying for the full composition (+1 inventory line, +1 doc bullet, no case or assertion removed).

Classification: behavior-completing

User Impact

  • A Control-UI turn that a restart left terminal as failed/killed now reads as unread in the session list, so the user sees there is something to read instead of losing the failure silently.
  • Internal Goal start/resume work that ends terminal stays quiet: it no longer acquires an unread marker for a turn the Control UI never showed.
  • Non-Control-UI lifecycle writes are untouched: they still default visibility through the existing agent-bus path.
  • Ordinary PR and push CI no longer pays ~33 s for the live tour; the fast owner contract still runs on every PR that touches it, and a directly edited tour file is still selected on its own PR.

Evidence

Rebase note (2026-10-11)

This revision's head is b499d8deca9c1e6ff21cf1c5dd4d0e5bbbb9a0ef, rebased onto main @ ea576bd11d8 because the previous base (dfa25c723a340f18aa39cbac0cd2012f63f412c5) predated a material amount of merged work. The rebase replayed the same commits with no conflicts; the patch is +508/-8 across 19 files (git diff --stat origin/main...HEAD). The extra +6/-1 is one follow-up commit, refactor(gateway): narrow the transcript-state admission to the facts it reads, which repairs a typecheck break our required controlUiVisible admission field introduced for the recovery fixture that main added in #167080 after this branch was cut: the transcript-state serializer now declares exactly the three facts it reads (priorTerminalSourceRunId, requestFingerprint, retryExpectedState) instead of demanding a visibility claim it never consumes. The proof receipts below were captured on the pre-rebase head and were not re-run on this base; CI re-runs on this head.

Exact-head proof receipt

  • Product head SHA: 6afe925fe687061695e4cb3087933006d46f3931 (fix 4714841a3e9, CI tier df07e0e393a, live readback 0a2f6b8e524, test split f0a85cd2a2e, two test-fixture type fixes, the rendered proof 6504a8158a9, then its package.json registration)
  • Unmodified base: 2871aef000c (the three production files are byte-identical to current main 6ff787d0509; branch merges cleanly with it — git merge-tree --write-tree origin/main HEAD reports no conflicts)
  • Production entry: the real restart-safe terminal owner, terminalizeRestartSafeChatAdmission, driven into a real session store created by withOpenClawTestState
  • Canonical owner exercised: deriveGatewaySessionLifecycleSnapshot inside terminalizeRestartSafeChatAdmission (chat-restart-recovery.ts:427)
  • Decision surface: the persisted row's lastActivityAt and the projected unread field, read back through the real loadSessionEntry, the real deriveSessionUnread, and a real sessions.list RPC
  • Recorder/readback boundary: deriveSessionUnread(loadSessionEntry(target)) — the same predicate behind session-utils-row.ts unread — plus the identical value through the Control UI's own sessions.list call
  • Acceptance RED: on unchanged production the same scenario leaves lastActivityAt undefined and deriveSessionUnread false after a successful terminalization (status: "failed", delivery claim released)
  • Acceptance GREEN: on this exact head the same scenario reads true, locally and through sessions.list
  • Legal control: rows start unread false before terminalization, so the assertions cannot pass trivially, and the hidden Goal case asserts the write still terminalizes while visibility stays false
  • Cleanup: each case uses its own withOpenClawTestState state/config; no production Gateway, session, channel, token, or configuration was touched

Inspectable RED -> GREEN terminal traces

Node v24.18.0.

# RED — new unit cases, production reverted to the unmodified base (2871aef000c)
$ node scripts/run-vitest.mjs run src/gateway/server-methods/chat-restart-recovery.unread.test.ts
 × counts a terminal restart-safe admission as unread activity
   AssertionError: expected false to be true // Object.is equality
 × keeps a hidden Goal admission quiet when it ends terminal
   AssertionError: expected true to be false // Object.is equality
      Tests  2 failed (2)
# RED — the same two cases against this PR's *previous* revision (1711343bdde),
# which stamped the literal `controlUiVisible: true` for every restart-safe admission
$ git checkout 1711343bdde -- src/gateway/server-methods/chat-restart-recovery.ts
$ node scripts/run-vitest.mjs run src/gateway/server-methods/chat-restart-recovery.unread.test.ts
 ✓ counts a terminal restart-safe admission as unread activity
 × carries the browser visibility fact on a hidden Goal request
   AssertionError: expected { Object (fingerprint) } to deeply equal { controlUiVisible: false, …(1) }
 × keeps a hidden Goal admission quiet when it ends terminal
   AssertionError: expected true to be false // Object.is equality
      Tests  2 failed | 1 passed (3)
# GREEN — same command on this head
$ node scripts/run-vitest.mjs run src/gateway/server-methods/chat-restart-recovery.unread.test.ts
 ✓ counts a terminal restart-safe admission as unread activity
 ✓ carries the browser visibility fact on a hidden Goal request
 ✓ keeps a hidden Goal admission quiet when it ends terminal
      Test Files  1 passed (1)
      Tests  3 passed (3)
# GREEN — the sibling contracts on this head
$ node scripts/run-vitest.mjs run \
    src/gateway/server-methods/chat-restart-recovery.unread.test.ts \
    src/gateway/server-methods/chat-send-dispatch-errors.test.ts \
    src/gateway/server.chat.orphaned-recovery.test.ts --maxWorkers=1
      Test Files  3 passed (3)
      Tests  22 passed (22)

Live end-to-end proof (real Gateway, real RPC, real projection)

src/gateway/server.chat.live-restart-unread.test.ts boots a real in-process Gateway (startGatewayWithClient, real loopback listener, Control-UI origin allowed), seeds an idle session row, and drives a real chat.send RPC from a browser Control-UI client (GATEWAY_CLIENT_NAMES.CONTROL_UI, mode WEBCHAT, origin http://localhost:18789), so the request genuinely qualifies for a restart-safe admission. It then reads the row back three ways: the real loadSessionEntry, the real deriveSessionUnread, and the Gateway's own sessions.list RPC — the exact response the Control UI renders the marker from.

The failure trigger is deterministic and needs no timing race: the seeded row carries pendingProjectGitUrl: "not a repository url", which prepareSessionWorkspace (chat-send-agent-dispatch.ts:273 → session-create-project.ts:241-246) cannot normalize, so dispatch throws before the agent run starts or takes over terminal persistence. The Gateway's own writer (chat-send-dispatch-errors.ts:282 → terminalizeRestartSafeChatAdmission) therefore terminalizes the claim — exactly the write this PR fixes.

# RED — live case against unmodified base production (2871aef000c)
LIVE_RESTART_UNREAD status=failed claim=live-restart-unread-run unread=false \
  lastActivityAt=undefined lastInteractionAt=undefined lastReadAt=undefined createdAt=1790477588844
 → expect(row?.lastActivityAt).toBeGreaterThan(baselineAt)
   TypeError: actual value must be number or bigint, received "undefined"
      Tests  1 failed (1)     29.5s
# GREEN — same command on this head
LIVE_RESTART_UNREAD status=failed claim=live-restart-unread-run unread=true \
  lastActivityAt=1790476242625 lastInteractionAt=undefined lastReadAt=undefined createdAt=1790476178529
 ✓ LIVE: a terminal restart-safe admission marks the Control UI session unread
      Tests  1 passed (1)

The row is terminal in both runs (status=failed, claim released), so terminalization itself is not what changes — only the activity fact the #155690 gate reads. chat-send-dispatch-errors.ts sets its generic lifecycle patch only when !restartSafeDispatchFailureTerminalized, so once the restart-safe claim terminalizes, lastActivityAt on base can only be undefined because terminalizeRestartSafeChatAdmission wrote the row without controlUiVisible.

Rendered marker (before / after)

Real Control UI bundle, real Chromium (Playwright), synthetic session and message text only. Reproduce with node --import ./scripts/tsx.mjs scripts/capture-restart-unread-marker-mock-proof.mts --out <file.png> --mode before|after:

Before (no marker) After (marker)
before after
locator: openclaw-app-sidebar [data-session-key="agent:main:dashboard:synthetic-restart-unread"]
before:  dot=0 badge=0   → no marker
after:   dot=0 badge=1   → .sidebar-session-indicator .session-glyph__badge--unread
after row: <div class="sidebar-recent-session … sidebar-recent-session--attention-danger" data-session-key="…">

What this capture does and does not prove. It varies only the projected unread fact, so it proves the render binding in the shipped UI — row.unread → the sidebar marker — and nothing about how the fact is produced. The producing half is proven separately above, through a real Gateway: real chat.send, the restart-safe terminal write, and a real sessions.list whose row reports unread: true. The seam the two halves leave untested is the row delivery between the Gateway and a mounted UI, which is unchanged shared infrastructure and is exercised by the existing Control UI suites.

Why there is no single-flow real capture. A real-Gateway Control UI capture was built and booted on this host (createQaGatewayChild + createControlUiE2eSuite: real Gateway, hello-ok, server build f0a85cd2a2e, the seeded row rendered in the real sidebar), but it cannot be driven to a composer send here: the session pane's first chat.startup retries indefinitely with UNAVAILABLE: session changed while reading history; reload the conversation for a row seeded outside the pane, so the composer parks the message and no chat.send frame ever reaches the Gateway (reproduced without a browser via gateway.call("chat.startup", …)). Driving that send from a Control UI identity inside the same harness also fails: the harness client is gateway-client/backend and would not set controlUiVisible, a fresh openclaw-control-ui client closes pre-hello, and replaying the page's own handshake in-browser fails DEVICE_AUTH_NONCE_MISMATCH. The live case above therefore drives the same real flow through the real chat.send RPC rather than the rendered composer.

CI routing proof

src/gateway/server.chat.live-restart-unread.test.ts is now in RELEASE_ONLY_RUNTIME_TEST_FILES (scripts/lib/ci-proof-test-inventory.mts), the same tier as src/gateway/gateway.chat-redaction.test.ts and the session-row-projection.keyed-marks.benchmark.test.ts deferral in 1dc005c7cb3. The filter only narrows plan includePatterns: the file keeps its canonical test/vitest/vitest.gateway-server.config.ts owner, its assertions, and its agentic-control-plane-agent-chat shard, and a directly edited test file is still re-admitted to its own PR.

  • test/scripts/ci-node-test-plan.test.ts — passes with the new release-inventory entry; its expectations are derived from the inventory itself, so a wrong tier fails it.
  • All five check-test-types-core-* lanes pass at this head. Two test fixtures construct the request/admission literal directly and had to follow the new required field: chat-send-dispatch-errors.test.ts (late-rejection terminal) and chat-send-pre-admission.test.ts (durable-fingerprint restartSafeRequest).
  • CI at this head: 174 pass, 0 fail, 0 pending (the only non-passing entries are skipped optional lanes).
  • One unrelated flake hit this PR once: checks-node-changed-compact-large-40 / shard agentic-plugin-sdk-hosted-2 failed in src/plugin-sdk/session-store-runtime.conversation.test.ts with TestTeardownError: … AggregateError: Agent database resource drainage failed … SqliteWorkerError: Shared-state admission requires the host broker. The same shard, same file, same error also failed on PR fix(gateway): keep the typed state-contention Stop outcome on sessions.abort #159282 in the same time window, and the lane passes on this head now — a host-level SQLite teardown flake, not a diff-caused failure.
  • test/scripts/ci-changed-node-test-plan.integration.test.ts — 2 cases time out at the file's own 120 s budget on this host ("keeps precise first-signin targets under exclusive Gateway admission", "keeps boundary coverage when only a deferred proof helper changes"). Proven unrelated: reverting this PR's inventory line and re-running the same case in isolation still times out (142.6 s vs 139.9 s).

Verification

  • chat-restart-recovery.unread.test.ts (3 cases) — 1 file / 3 passed; RED 2/2 on unmodified production, RED 2/2 against the previous revision of this fix, GREEN 3/3 on this head
  • chat-restart-recovery.unread.test.ts + chat-send-dispatch-errors.test.ts + server.chat.orphaned-recovery.test.ts — 3 files / 22 passed
  • server.chat.live-restart-unread.test.ts — 1 passed (~33 s warm, real Gateway boot); RED on unmodified production, GREEN on this head
  • agent-runner-required-maintenance.pending-input.test.ts — 2 passed (the call site that now passes the visibility fact)
  • oxfmt --check on every changed file — clean
  • Not tested: the mandatory remote proof lane (10.54.159.54) is powered off and has no out-of-band power interface, so every run above is on this Linux host (Node v24.18.0) rather than the remote Docker lane. The live case exercises the dispatch-error terminalization site (chat-send-dispatch-errors.ts:282); the setup-error site (:103) and the in-flight restart abort (chat-send-handler.ts:219, reachable only through a real process restart) are not covered, and the failure trigger is an unnormalizable saved-repo URL rather than a provider failure. No live channel or credential was exercised.
  • Also not covered: the sibling synthetic terminal at chat-send-dispatch-errors.ts:424-431 (persistGatewaySessionLifecycleEvent with a synthetic data: { phase: "error" } event) has the same literal omission for non-restart-safe Control-UI sends. Whether that path may stamp visibility depends on its own reachability, so it is deliberately left out rather than stamped blind.
  • Known proof seam: the rendered capture above comes from the mocked-Gateway Control UI lane, and the real failed-turn flow is proven at the projection boundary (sessions.list). No single run on this host drives the rendered composer through the real restart-safe terminal write; the concrete blockers are listed in that section.

Scope and risk

File Change Risk
src/gateway/server-methods/chat-restart-recovery.ts carry controlUiVisible on the request, the admission, and the synthetic terminal event; stamp the passed value instead of a literal true only affects this restart-safe terminal write; every other field of the snapshot is unchanged; the Goal branch keeps its early return
src/gateway/server-methods/chat-send-session.ts pass the browser-client visibility fact into the request one added field, no change to the eligible conjunction
src/gateway/server-methods/chat-send-handler.ts pass the admitted visibility into the terminalizer reads an undefined-safe optional and defaults to false (quiet)
src/gateway/server-methods/chat-restart-recovery.unread.test.ts fast contract for both directions (visible ⇒ unread, hidden ⇒ quiet) test-only
src/gateway/server.chat.live-restart-unread.test.ts live Gateway flow (boot + chat.send + real terminalization + loadSessionEntry/deriveSessionUnread/sessions.list readback) test-only; ~33 s warm, now deferred from ordinary PR/push plans
src/gateway/server-methods/chat-send-dispatch-errors.test.ts, src/gateway/server.chat.orphaned-recovery.test.ts, src/auto-reply/reply/agent-runner-required-maintenance.pending-input.test.ts, src/gateway/server-methods/chat-send-pre-admission.test.ts call-site and fixture updates for the new required field test-only, one line each
scripts/lib/ci-proof-test-inventory.mts, docs/ci/scope-and-routing/node-test-lanes.md register the tour in the release-only runtime inventory and document it routing only; no case or assertion removed
scripts/capture-restart-unread-marker-mock-proof.mts, package.json (ui:proof:restart-unread-marker), .github/pr-proof/restart-safe-unread-marker/{before,after}.png the rendered before/after capture, the script that reproduces it, and its executable-root registration proof-only; not run by CI, requires a Chromium binary and a manual invocation

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Sep 27, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 27, 2026
@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR carries browser visibility through restart-safe chat admission so visible terminal failures can mark the session unread.

Example: A browser sends run live-restart-unread-run to agent:main:dashboard:live-restart-unread, and workspace preparation fails before agent execution.

  • Before: The session becomes failed but sessions.list reports unread: false.
  • After: The terminal write advances lastActivityAt and sessions.list reports unread: true.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused repair has no identified introduced bug, but the supplied harness and mocked rendering evidence do not satisfy the required shipped-behavior proof gate.
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 browser chat turn can remain marked read, leaving the user unaware of its terminal outcome.
Reason: The patch completes the existing visible-terminal contract without adding settings, storage, or a competing owner.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: current main still has the reported visibility omission, and this PR provides a focused repair with meaningful unique work.

Priority: P2
Reviewed head: b499d8deca90a5300fcecbd348f94b3e9119dd32

Before merge

  • Add real behavior proof - The supplied chat.send-to-sessions.list trace runs through an in-process Gateway test, and inspected badge screenshots use mocked session rows. These support the repair but do not exercise it through a shipped entry point under this review's proof gate, despite the earlier sufficient-proof assessment. Provide terminal output, logs, or a recording of the failed-turn scenario through a running candidate Gateway; redact IPs, keys, phone numbers, and non-public endpoints. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Findings

None.

Tests

  • Missing end-to-end proof: Supply a redacted shipped Gateway run showing a browser restart-safe send reaching terminal failure and sessions.list returning unread: true, with hidden internal Goal work remaining quiet.
Agent review details

How this fits together

Gateway chat admission retains request facts through dispatch settlement; the existing lifecycle writer stores activity timestamps that sessions.list projects into the Control UI unread badge.

flowchart LR
A[Browser chat send] --> B[Request preparation]
B --> C[Restart safe admission]
C --> D[Terminal settlement]
D --> E[Session lifecycle writer]
E --> F[Sessions list projection]
F --> G[Control UI unread badge]
Loading

Technical review

Best possible solution:

Complete the existing visibility contract at the restart-safe terminal owner while preserving quiet internal work and current claim settlement.

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

Current-main source exposes the missing visibility field and its unread consequence, supported by supplied RED/GREEN traces; this read-only review ran no target code.

Is this the best way to solve the issue?

Carrying the caller's visibility decision into the existing terminal writer fixes the producer without duplicating unread policy or assuming all Goal admissions are visible.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4f3eb4f25466.

Provenance checked

  • Restart-safe admission and terminal settlement keeps the original intent (bafabba: Accepted Control UI turns must survive restarts through durable claims, with terminal outcomes retained to prevent replay.)
  • Visible-terminal unread activity keeps the original intent (359a8a3: Visible completed sessions should become unread while hidden work and heartbeats remain quiet.)
  • Retained worker-backed terminal settlement keeps the original intent (c6698b1: Exceptional cleanup retains accepted admission and physical source facts while preserving settlement ordering.)
  • Release-only runtime test inventory keeps the original intent (1b6ba2c: Expensive compositions retain complete release coverage and direct-edit selection while focused owner tests serve routine PRs.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit a872abc adds src/gateway/server-methods/chat-restart-recovery.ts:432 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a872abc97829; files: src/gateway/server-methods/chat-restart-recovery.ts)

PR surface

Source +32, Tests +310, Docs +1, Config +1, Other +156. Total +500 across 19 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 4 36 4 +32
Tests 9 314 4 +310
Docs 1 1 0 +1
Config 3 1 0 +1
Generated 0 0 0 0
Other 2 156 0 +156
Total 19 508 8 +500

Review metrics

Metric Value Why it matters
Runtime versus regression growth Runtime +36/-4 lines; tests +314/-4 lines The runtime growth carries one fact through existing owners; tests cover visible and hidden settlement plus the real Gateway RPC composition.

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.
  • remove proof: sufficient: Current real behavior proof status is mock_only, not sufficient.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: 📣 needs proof.

Label justifications:

  • P2: Failed browser turns can miss an unread notification, with limited impact on session discoverability rather than message durability or core availability.
  • 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.

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 (11 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-27T03:01:03.421Z sha f0a85cd2a2ebbd912de9b0f3b6b7cc86065d9814 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-27T03:24:50.016Z sha e06dcaa4bff9933a19ae0ca8f1d5a48538a49a71 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-27T04:43:03.916Z sha 6504a8158a930c7076aece60718c41c4d331fb79 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-27T04:57:44.171Z sha 6afe925fe687061695e4cb3087933006d46f3931 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-28T01:14:14.847Z sha 6afe925fe687061695e4cb3087933006d46f3931 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-08T12:58:50.870Z sha 6f18e35ab87f93be1fc5e11589680861ac7a2b8a :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-09T06:00:57.024Z sha dfa25c723a340f18aa39cbac0cd2012f63f412c5 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-09T06:09:49.509Z sha dfa25c723a340f18aa39cbac0cd2012f63f412c5 :: needs maintainer review before merge. :: none

Reviewed October 11, 2026, 11:57 AM ET / 15:57 UTC (Revision 12).

@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 27, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: M and removed size: S labels Sep 27, 2026
@clawsweeper clawsweeper Bot added 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. and removed merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 27, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 28, 2026
@wangmiao0668000666
wangmiao0668000666 force-pushed the fix/restart-recovery-unread branch from 6afe925 to 6f18e35 Compare October 8, 2026 12:50
@clawsweeper clawsweeper Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Oct 8, 2026
@clawsweeper clawsweeper Bot added 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 9, 2026
wangmiao0668000666 and others added 14 commits October 11, 2026 23:28
openclaw#155690 advances lastActivityAt only for terminal writes that carry
controlUiVisible, so a Control-UI chat send that a restart-safe admission
terminalizes after a Gateway restart is persisted terminal with no activity
advance and the session list never shows the unread marker, even though the
reply never reached the user.

terminalizeRestartSafeChatAdmission synthesizes its own terminal event, and that
admission only exists for the browser Control UI (restartRecoverySourceIngress is
hardcoded "control-ui" and eligibility is isBrowserOperatorUiClient), so the
event now stamps controlUiVisible: true.
Boots a real Gateway, sends a real chat.send from a browser Control-UI client,
and terminalizes the restart-safe claim through the Gateway's own dispatch-error
writer. On the unfixed base the row is terminal with lastActivityAt undefined and
deriveSessionUnread false; with the fix it advances activity and reads unread.
Deterministic: no timing race, 3/3 red and 4/4 green locally.
…ion store

The rebased branch lands on a main whose session store is SQLite-backed
and whose running state lives in the lifecycle snapshot, so the terminal
write now goes through the captured target/read-source contract and the
fixtures no longer seed a legacy running status.

Co-Authored-By: Claude Code <[email protected]>
…tures

The restart-safe admission type now carries controlUiVisible; the worker
settlement, close-settlement and dispatch-error fixtures that terminalize
an admission directly pass the fact explicitly.

Co-Authored-By: Claude Code <[email protected]>
…ture

Main rejects legacy agents.entries default markers at gateway startup;
the canonical roster shape carries the single main entry without one.

Co-Authored-By: Claude Code <[email protected]>
@wangmiao0668000666
wangmiao0668000666 force-pushed the fix/restart-recovery-unread branch from dfa25c7 to 26568e6 Compare October 11, 2026 15:29
@wangmiao0668000666
wangmiao0668000666 force-pushed the fix/restart-recovery-unread branch from 96a7ecc to b499d8d Compare October 11, 2026 15:47
@clawsweeper clawsweeper Bot added 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. labels Oct 11, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

Closing without merging — handoff

Closing this PR instead of carrying it further. The repair is understood and small; what is missing is the shipped-behavior proof the review now requires (a failed browser turn demonstrated through a running candidate Gateway), and this environment cannot produce a candidate build (see the last section).

The defect is still live on main. #160003 stays open. A Control-UI chat send that a restart-safe admission terminalizes is persisted terminal without an unread marker, because terminalizeRestartSafeChatAdmission synthesizes its own terminal event (src/gateway/server-methods/chat-restart-recovery.ts:427) without the controlUiVisible fact that #155690 requires before advancing lastActivityAt (src/gateway/session-lifecycle-state.ts:224).

Branch state at close — wangmiao0668000666:fix/restart-recovery-unread @ b499d8deca9, 19 files, +508/-8:

  • production: carry browser visibility through the restart-safe admission (chat-restart-recovery.ts, chat-send-handler.ts, chat-send-session.ts, chat-send-work-admission.ts);
  • on this head check-prod-types, check-test-types-core-1..5, check-lint-core-1..5, build-artifacts and the node lanes were green; the only red left was an inherited extension/UI e2e lane failure, recorded in the body;
  • review verdict: needs-human, hold=proof, findings=0 — the requested item is real behavior proof, nothing else.

Proof recipe for whoever revives this (all steps need a build made from this head):

  1. Runtime dist: OPENCLAW_RUN_NODE_SKIP_DTS_BUILD=1 node --import ./scripts/tsx.mjs scripts/build-all.mts. Needs the workspace package dists plus the canvas A2UI bundle; @openclaw/fs-safe must be at the version package.json pins.
  2. Isolated Gateway: node dist/index.js gateway run --port 18789 --token <token> with OPENCLAW_STATE_DIR / OPENCLAW_CONFIG_PATH on a scratch directory, and gateway.controlUi.allowedOrigins matching the WebSocket origin.
  3. Seed one session with pendingProjectGitUrl: "not a repository url" and createdAt = now - 60s (fixture shape: src/gateway/server.chat.live-restart-unread.test.ts:70-78).
  4. Connect as the Control UI with the existing out-of-process device-auth driver — scripts/lib/gateway-bench-control-ui-driver.ts:170-230 (buildDeviceAuthPayloadV3, client.id = "openclaw-control-ui") — then send a valid chat.send with idempotencyKey and deliver: false. Dispatch fails in src/gateway/server-methods/session-create-project.ts:304-309 before any agent run, and the Gateway's own writer terminalizes the restart-safe claim.
  5. Read back through openclaw gateway call sessions.list --params '{"includeGlobal":true,"limit":200}' --port <port> --token <token> --json: the session must report unread: true.
  6. Control case: the same flow with intent: {"kind":"session-goal-start","version":1,"issuedAtMs":<now>} sent by a CLI client (controlUiVisible: false) must still terminalize while staying unread: false.

The proof receipts in the body were captured before the last rebase; the "Rebase note" section states which head they belong to.

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

Labels

docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: L 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.

1 participant