Repository navigation
Description
What
Three existing issues each guard a different call site that can start wsl.exe during a Windows session-end sequence:
- Gate the managed-local provenance probe so it cannot start wsl.exe during Windows session teardown #1572 — the process-start boundary of the managed-local provenance probe
- Tray keep-alive can still start during Windows session end and its repair adapter ignores the cancellation token #1573 — the tray's keep-alive entry points
- Reconnect retry loop invokes reconnect authorization with no Windows session-ending check #1574 — the reconnect retry loop
All three need the same input: a reliable, injectable answer to "is a Windows session-end sequence in progress?". No such source exists in the repository today, and #1572 deliberately left the concrete Windows wiring out of its scope. As the reviews on #1573 and #1574 note, three independently-defined seams would be incompatible with each other, or would never be wired to anything real.
This issue owns that prerequisite: the abstraction, a concrete Windows source, and its production registration. It is the contract the other three implement against.
Where
- The contract must be consumable from
src/OpenClaw.Shared—WebSocketClientBase.cs(Reconnect retry loop invokes reconnect authorization with no Windows session-ending check #1574) lives there, and that assembly must not gain a Win32 or tray dependency. Put the abstraction in the shared layer; put the Windows implementation where the host can observe session events. - A concrete source is
Microsoft.Win32.SystemEvents.SessionEnding, or theWM_QUERYENDSESSION/WM_ENDSESSIONpair handled on the tray's own window. Either is acceptable; where a window already exists, prefer the message pair, because it lets the process act before the session ends rather than only observing that it is ending.
Required behaviour
- One injectable abstraction answering "is the Windows session ending?", consumed by all three call sites — a single source of truth, no per-call-site re-derivation of the state.
- A production implementation actually wired up in the tray host, not left as a null / always-false default in a released build. A seam that is never connected is worse than none: it looks fixed and is not.
- Substitutable in tests: forcing "ending" must not require shutting Windows down.
- Registering it must not change behaviour when no session end is in progress.
- Do not use
Environment.HasShutdownStartedas the whole answer; on its own it is not reliable evidence that a session-end sequence is in progress. - If the mechanism can observe the transition (a session end has been requested) and not merely a latched state, expose that. Reconnect retry loop invokes reconnect authorization with no Windows session-ending check #1574 needs to react to a session end that begins during an in-flight backoff wait, and Gate the managed-local provenance probe so it cannot start wsl.exe during Windows session teardown #1572 prefers to decline as early as possible.
Scope
- Add the abstraction, the Windows implementation and its registration. That is the whole of this issue.
- Do not change the three consumer call sites — Gate the managed-local provenance probe so it cannot start wsl.exe during Windows session teardown #1572, Tray keep-alive can still start during Windows session end and its repair adapter ignores the cancellation token #1573 and Reconnect retry loop invokes reconnect authorization with no Windows session-ending check #1574 own those, and each owns exactly one production file (plus, in Tray keep-alive can still start during Windows session end and its repair adapter ignores the cancellation token #1573's case, the keep-alive cancellation boundary under discussion there).
- Do not refactor
AppShutdownCoordinatoror the ordered-shutdown design recorded indocs/ARCHITECTURE.md. - Do not add a new user-facing setting.
This should stay a small change: one new contract, one new implementation, one registration. Keeping it that small is deliberate — a previous single issue covering all three spawn paths produced a fix artifact that spanned three subsystems and was rejected as too broad for autonomous execution.
Acceptance
./build.ps1
dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore
dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore
dotnet test ./tests/OpenClaw.Connection.Tests/OpenClaw.Connection.Tests.csproj --no-restore
Required regression test
- A test asserting the wiring is real: with the host configured as in production, the abstraction the consumers receive is the Windows implementation, not a default no-op. This is the failure mode that otherwise ships silently.
- A test asserting the substitutable path: an implementation reporting "ending" is observed as ending by a consumer, and one reporting "not ending" is observed as not ending — without any real session end.
- The test suite must not require an actual shutdown, a real
wsl.exe, or WSL to be installed.
Related
Prerequisite for #1572, #1573 and #1574 — they depend on this contract and should not be closed in favour of it. #1571 is the evidence umbrella for the underlying defect.
What I can and cannot contribute
- I can confirm the reported behaviour on Windows 11 Home China build
10.0.26300with OpenClaw Companion2026.9.4.0, including the Event 1074 → Event 26 ordering and tray-log excerpts during teardown. - I do not have a working build environment for this repository, so I cannot run
./build.ps1or the test projects. Someone else needs to verify.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsBacklog
Activity
clawsweeper commentedon Oct 1, 2026
Codex review: this still needs some work.
Summary
Keep open: current main still lacks the shared Windows session-ending signal and production wiring needed by the separately tracked consumer repairs.
Reproducibility: Current source establishes the missing shared observer and registration, plus the unguarded consumer boundaries; no build, tests, or live Windows shutdown reproduction ran in this read-only review.
Next step
Implement the shared Windows lifecycle source and establish failing production-wiring, transition, cancellation-recovery, and substitution regressions before opening a focused prerequisite PR.
Review details
Best possible solution:
Provide one host-owned Windows session lifecycle source with injectable state and transitions while preserving the existing ordered shutdown owner.
Do we have a high-confidence way to reproduce the issue?
Current source establishes the missing shared observer and registration, plus the unguarded consumer boundaries; no build, tests, or live Windows shutdown reproduction ran in this read-only review.
Is this the best way to solve the issue?
The proposed prerequisite is appropriately bounded if it registers a real observer before background work, exposes transitions safely, and handles canceled session-end requests without changing the three consumers.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning medium; reviewed against 2b7cfce17bb4.
Label changes
Label changes:
issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.clawsweeper:source-repro: Current issue advisory state selects this label.issue-rating: 🌊 off-meta tidepool: Current issue advisory state no longer selects this label.Label justifications:
P2: This bounded infrastructure prerequisite supports correction of reported shutdown-time error dialogs without evidence of lost data or an unusable core workflow.impact:ux-friction: The linked report describes alarming Windows application-error dialogs during shutdown, with successful gateway recovery on the next boot.Evidence reviewed
Acceptance criteria:
What I checked:
src/OpenClaw.Tray.WinUI/Services/AppShutdownCoordinator.cs:11, 2b7cfce17bb4)src/OpenClaw.Tray.WinUI/Presentation/AppServiceRegistration.cs:29, 2b7cfce17bb4)src/OpenClaw.Shared/WebSocketClientBase.cs:634, 2b7cfce17bb4)src/OpenClaw.Tray.WinUI/App.xaml.cs:967, 2b7cfce17bb4)wsl.exeduring session teardown, producing an "Application Error 0xc0000142" popup on every shutdown/restart #1571 (comment) distinguishes shutdown-associated failures from unexplained mid-session bursts; Tray spawnswsl.exeduring session teardown, producing an "Application Error 0xc0000142" popup on every shutdown/restart #1571 (comment) explicitly preserves separate consumer repairs.Likely related people:
src/OpenClaw.Tray.WinUI/Services/AppShutdownCoordinator.cs)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.Reviewed October 20, 2026, 7:29 PM ET / 23:29 UTC.
clawsweeper commentedon Oct 1, 2026
🦞🔧
ClawSweeper is automatically building a fix for this issue.
The issue review finished and no active implementation pull request was found.
Automatic implementation progress:
clawsweeper:manual-onlyorclawsweeper:human-review.petruslin commentedon Oct 1, 2026
The queued implementation worker died on a transient provider error — could someone re-run it?
Heads-up for a maintainer: this issue's Codex implementation worker was dispatched and did run. It failed on a provider capacity error, not on anything to do with this issue's content.
What happened
36869053292— its last stepDispatch repair workersucceeded at 13:32:26Z36869423874(repair cluster worker, jobissue implementation jobs/openclaw/inbox/issue-openclaw-openclaw-windows-node-1575.md) — created 13:32:26Z, completed 13:33:40Z,conclusion: failure,run_attempt: 1Run workerstep (13:33:16Z → 13:33:27Z):Why it still looks queued
The failure happens inside
Plan and review cluster, soExecute and apply cluster actionsisskipped— andPublish automatic implementation completion statuslives in that job, so it never runs. TheState: Queuedstatus comment above therefore stays frozen at its 13:32:17Z timestamp. From the issue side, a failed worker is indistinguishable from a queued one.No automatic retry followed. Checked at 15:27Z, ~2 h after the failure:
run_attemptis still 1 and there is no second run. Two other workers that failed today (162716at 13:19:51Z,162739at 14:02:09Z) likewise have no second run, after 2h07m and 85 min.The ask: could someone with
actions: writere-run36869423874? The durable job file already exists in the state repo, so a re-run should resume the same job rather than start over. I only havepullon both repos, so I cannot do it myself.Tagging @steipete and @RomneyDa, since you both commit to
openclaw/clawsweeper— happy to move this if there is a better channel for it.