Skip to content

Provide one shared Windows session-ending signal and wire it for production use #1575

Open

Description

@petruslin

What

Three existing issues each guard a different call site that can start wsl.exe during a Windows session-end sequence:

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 the WM_QUERYENDSESSION / WM_ENDSESSION pair 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

  1. 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.
  2. 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.
  3. Substitutable in tests: forcing "ending" must not require shutting Windows down.
  4. Registering it must not change behaviour when no session end is in progress.
  5. Do not use Environment.HasShutdownStarted as the whole answer; on its own it is not reliable evidence that a session-end sequence is in progress.
  6. 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

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.26300 with OpenClaw Companion 2026.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.ps1 or the test projects. Someone else needs to verify.

Activity

  1. added
    P2
    clawsweeper:fix-shape-clear
    clawsweeper:queueable-fix
    impact:ux-friction
    issue-rating: 🌊 off-meta tidepool
    no-stale
    on Oct 1, 2026
  2. clawsweeper commented on Oct 1, 2026

    @clawsweeper

    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:

    • Canceled session-end requests need defined recovery semantics so a transient request cannot permanently suppress future reconnects.
    • Registration alone does not repair the consumer paths; those linked issues must retain their own zero-launch regressions.
    • The native popup race has not been independently reproduced, and the reporter's mid-session failures remain unattributed.

    Codex review notes: model internal, reasoning medium; reviewed against 2b7cfce17bb4.

    Label changes

    Label changes:

    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • remove 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:

    • ./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
    • Verify production host initialization observes session-ending notifications before background work and releases the subscription at its owned lifetime boundary.

    What I checked:

    Likely related people:

    • Barbara Kudiess: Raw commit 17a8b03 adds src/OpenClaw.Tray.WinUI/Services/AppShutdownCoordinator.cs:6 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 17a8b0363a82; files: src/OpenClaw.Tray.WinUI/Services/AppShutdownCoordinator.cs)
    How this review workflow works
    • 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; those execution lanes are retired.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

    Reviewed October 20, 2026, 7:29 PM ET / 23:29 UTC.

  3. clawsweeper commented on Oct 1, 2026

    @clawsweeper

    🦞🔧
    ClawSweeper is automatically building a fix for this issue.

    The issue review finished and no active implementation pull request was found.

    Automatic implementation progress:

  4. petruslin commented on Oct 1, 2026

    @petruslin
    Author

    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

    • intake run 36869053292 — its last step Dispatch repair worker succeeded at 13:32:26Z
    • worker run 36869423874 (repair cluster worker, job issue implementation jobs/openclaw/inbox/issue-openclaw-openclaw-windows-node-1575.md) — created 13:32:26Z, completed 13:33:40Z, conclusion: failure, run_attempt: 1
    • verbatim from the Run worker step (13:33:16Z → 13:33:27Z):
    {"type":"error","message":"Selected model is at capacity. Please try a different model."}
    {"type":"turn.failed","error":{"message":"Selected model is at capacity. Please try a different model."}}
    [ELIFECYCLE] Command failed with exit code 1.
    

    Why it still looks queued

    The failure happens inside Plan and review cluster, so Execute and apply cluster actions is skipped — and Publish automatic implementation completion status lives in that job, so it never runs. The State: Queued status 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_attempt is still 1 and there is no second run. Two other workers that failed today (162716 at 13:19:51Z, 162739 at 14:02:09Z) likewise have no second run, after 2h07m and 85 min.

    The ask: could someone with actions: write re-run 36869423874? 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 have pull on 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.

  5. added
    clawsweeper:intake:feature
    clawsweeper:source-repro
    issue-rating: 🦞 diamond lobster
    and removed
    issue-rating: 🌊 off-meta tidepool
    clawsweeper:intake:feature
    on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2clawsweeper:fix-shape-clearclawsweeper:queueable-fixclawsweeper:source-reproimpact:ux-frictionissue-rating: 🦞 diamond lobsterno-stale

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions