Skip to content

feat: handle lifecycle slash commands natively in Windows chat - #1036

Merged
shanselman merged 7 commits into
openclaw:mainfrom
calebeden:calebeden-slash-command-parity
Jul 21, 2026
Merged

shanselman merged 7 commits into
openclaw:mainfrom
calebeden:calebeden-slash-command-parity

Conversation

@calebeden

@calebeden calebeden commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor
Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.

What Problem This Solves

Resolves a problem where users entering /new, /reset, or /compact in the Windows chat surface would see those lifecycle commands sent as ordinary chat messages instead of receiving the native behavior and structured presentation available in other first-party clients (i.e., gateway-hosted web UI and Mac app).

Why This Change Was Made

Exact, attachment-free lifecycle commands now use dedicated gateway RPCs while argument-bearing commands, attachments, and all other slash commands continue through chat.send. /new runs immediately without disturbing work in the source session, /reset confirms before immediately clearing that session, and /compact is an ordered typed queue operation that never falls through to chat.send. The implementation safely supports older gateways when creating parallel sessions and reloads authoritative history after model-backed compaction.

User Impact

Windows users can create, reset, and compact sessions without command or acknowledgement bubbles. Compaction boundaries are durable, localized, accessible timeline dividers. A queued /compact waits for active and earlier work, blocks later messages until completion, can be canceled while pending, and cannot deadlock the queue after failure. Newer composer edits and attachments survive awaited operations, and ambiguous /new timeouts advise users to check the session list before retrying.

Evidence

  • Current-head full repository build and required Shared/Tray suites pass.
  • Current-head focused coverage verifies lifecycle protocol behavior, ordered compaction, cancellation and failure handling, reset supersession, and composer preservation.
  • A dual-model Hanselman adversarial review of current HEAD found no actionable correctness, security, race, data-loss, or protocol issues.
  • Existing live WinUI proof demonstrates model-backed /compact, durable compaction-divider rendering after restart, safe /new creation against an older gateway, and /reset cancellation preserving input.

Before: compaction appeared as an ordinary chat exchange

Before this change, Windows sent /compact through chat.send, so the command
and its acknowledgement appeared as chat bubbles rather than the structured
compaction event shown by the gateway web UI.

Screenshot 2026-07-20 164900 Screenshot 2026-07-20 164921

In this example, /compact was used twice in the web dashboard and once through the Windows app.

After: compaction is a structured timeline event

Windows now invokes model-backed compaction directly, creates no command or
acknowledgement bubbles, and renders the durable structured boundary as an
accessible timeline divider. This now more closely models the behavior observed through
the gateway's web UI.

image

Here, /compact was invoked, and the compaction divider appears without rendering a chat bubble for the command.

Video: /new and /reset lifecycle behavior

The recording shows /new creating and selecting a distinct empty session while preserving the original session and its history. It then demonstrates the /reset confirmation flow: canceling preserves the command and transcript, while confirming clears the selected session after the gateway accepts the reset. Neither lifecycle command produces a command or acknowledgement bubble.

new_reset.mp4

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Validation

  • .\build.ps1
    • Passed: Shared, CLI, WinNode CLI, Setup Engine, and WinUI.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore
    • Passed: 3,089; skipped: 31; failed: 0.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore
    • Passed: 1,884; skipped: 0; failed: 0.
  • Focused Shared gateway/protocol/client tests
    • Passed: 211; failed: 0.
  • Focused Tray provider/composer tests
    • Passed: 280; failed: 0.
  • Dual-model Hanselman adversarial review
    • Current HEAD has no actionable findings.

Real Behavior Proof

  • Environment tested: Windows ARM64, .NET SDK 10.0.301, WinUI target net10.0-windows10.0.22621.0\win-arm64.
  • PR head or commit tested: Automated validation and adversarial review at 997a6a1f8b00a89f7f75e11ff734e1b277339ae0.
  • Exact steps or command run: Ran the full build and required Shared/Tray test commands above. Existing live proof entered exact /compact, /new, and /reset commands in a safe WinUI chat session and restarted the app after compaction to verify durable history rendering.
  • Evidence after fix: Current-head tests cover ordered typed compaction without chat.send, pending cancellation, failed compaction queue recovery, reset superseding an in-flight compaction, source-session preservation for /new, and composer revision/attachment preservation. Existing live proof shows the structured divider and lifecycle command UX.
  • Observed result: Lifecycle commands use native RPC behavior while argument-bearing variants remain ordinary chat commands. /compact preserves queue ordering and later work cannot race ahead of it.
  • Screenshot or artifact links verified? (Yes/No/N/A): Yes
  • Not verified or blocked: Current-head UI automation was not rerun because it was explicitly deferred. The retained screenshots and video predate the final queue-ordering policy; current-head behavior is covered by focused and full automated validation.

Security Impact

  • New permissions or capabilities? (Yes/No): No
  • Secrets or tokens handling changed? (Yes/No): No
  • New or changed network calls? (Yes/No): Yes
  • Command or tool execution surface changed? (Yes/No): No
  • Data access scope changed? (Yes/No): No
  • If any answer is Yes, explain the risk and mitigation: Exact lifecycle commands now invoke existing authenticated sessions.create, sessions.reset, and sessions.compact gateway RPCs. Matching is deliberately restricted to exact, attachment-free commands; failures preserve local state and are surfaced visibly.

Compatibility and Migration

  • Backward compatible? (Yes/No): Yes
  • Config or environment changes? (Yes/No): No
  • Migration needed? (Yes/No): No
  • If yes, list the exact upgrade steps: N/A

Older gateways that reject succeedsParent are retried with an unlinked parallel-session request, preventing legacy parent rollover. Gateways without sessions.create show a visible unsupported error and do not reset or mutate the current session as a fallback.

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

Handle exact /new, /reset, and /compact commands through lifecycle RPCs, preserve structured compaction boundaries, and retain safe compatibility behavior for older gateways.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: c41e789a-73e3-41ae-ac62-1ff5287599c0
Preserve explicit session selection and failed composer sends, retain live entries during authoritative reloads, widen compaction metrics, and clarify lifecycle timeout recovery.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: c41e789a-73e3-41ae-ac62-1ff5287599c0
@calebeden
calebeden marked this pull request as ready for review July 21, 2026 03:43
@calebeden
calebeden marked this pull request as draft July 21, 2026 04:22
calebeden and others added 2 commits July 20, 2026 21:28
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: c41e789a-73e3-41ae-ac62-1ff5287599c0
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: c41e789a-73e3-41ae-ac62-1ff5287599c0
@calebeden
calebeden marked this pull request as ready for review July 21, 2026 17:38
Integrate openclaw#1040 demand-loaded history (LoadHistoryCoreAsync split, generation
CTS, connection version guards) with PR openclaw#1036 authoritative reload path.

Resolve provider conflicts preserving both connection-versioned history
flights and authoritative reload pending queue.

Address review findings:
- Replace hardcoded 'New session' with localized Chat_PendingNewSessionTitle
  across all 5 locales (en-us, fr-fr, nl-nl, zh-cn, zh-tw)
- Fix authoritative reload dropping valid live entries without OpenClawSeq
  when gateway clock skews behind local time: entries with no seq are now
  preserved since history coverage cannot be determined
- Add post-timeout session list reconciliation for /new failures so user
  can see potentially-created sessions (protocol has no idempotency key;
  guidance message retained by design)
- Add behavioral composer submission policy tests (reference equality,
  identity preservation, edit-during-send)
- Add behavioral pending selection survival test for stale snapshots

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: d2982ca8-bb56-4728-85bd-29542ce9d554
@clawsweeper

clawsweeper Bot commented Jul 21, 2026

Copy link
Copy Markdown

ClawSweeper status: review started.

I am starting a fresh review of this pull request: feat: handle lifecycle slash commands natively in Windows chat This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

shanselman and others added 2 commits July 21, 2026 15:20
The _authoritativeHistoryReloadPending flag was consumed in
LoadHistoryCoreAsync's finally block without checking whether the
completing request belonged to the current connection generation.
A stale old-generation completion after disconnect/reconnect could
consume the flag and trigger an unintended authoritative reload
in the newer generation.

Fix:
- Only consume/schedule the pending authoritative reload when
  requestConnectionVersion == _historyConnectionVersion (same
  guard as _historyInFlight removal)
- Clear _authoritativeHistoryReloadPending in
  AdvanceHistoryGenerationLocked so generation advances invalidate
  stale pending flags
- Add deterministic regression test:
  StaleGenerationAuthoritativeReload_DoesNotReloadInNewGeneration

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: d2982ca8-bb56-4728-85bd-29542ce9d554
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 4f0e93ff-d320-454d-b00a-865dac727d0c
@clawsweeper

clawsweeper Bot commented Jul 21, 2026

Copy link
Copy Markdown

ClawSweeper status: review started.

I am starting a fresh review of this pull request: feat: handle lifecycle slash commands natively in Windows chat This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants