#10898: fix(mac): adopt canonical session key and add reset triggers
app: macos
stale
## Summary
- **Bug fix**: The Mac app chat was silently dropping all gateway push events because the ViewModel kept the short session key alias (`"main"`) while the gateway emits events with the canonical key (`"agent:main:main"`). After loading history we now adopt the canonical key returned by `chat.history` so event filtering matches correctly.
- **Feature**: Adds `/new`, `/reset`, `/clear` trigger support to the native Mac chat UI — the same reset triggers already available on messaging channels (WhatsApp, Telegram, etc.) — by intercepting them in `performSend()` and calling `sessions.reset` on the gateway.
## Changes
- `ChatViewModel.swift`: Adopt canonical session key from gateway response in `bootstrap()`; intercept reset triggers in `performSend()`; add `performReset()` method
- `ChatTransport.swift`: Add `resetSession(sessionKey:)` to the `OpenClawChatTransport` protocol with a default throwing implementation
- `WebChatSwiftUI.swift`: Implement `resetSession` in `MacGatewayChatTransport` using the `sessions.reset` gateway RPC
## Test plan
- [x] Built and launched Mac app — verified chat events now display correctly (session key match)
- [x] Tested `/new` in Mac app chat — session resets and history clears
- [ ] Verify no regression on iOS (default protocol extension throws, same as before)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
- Updates the macOS chat ViewModel to adopt the gateway’s canonical session key from `chat.history`, aiming to prevent push events from being filtered out when aliases like `"main"` are used.
- Adds `/new`, `/reset`, and `/clear` trigger handling in the native macOS chat UI by resetting the session via the transport instead of sending the command as a message.
- Extends `OpenClawChatTransport` with a `resetSession(sessionKey:)` API and implements it for the macOS gateway transport using the `sessions.reset` RPC.
<h3>Confidence Score: 3/5</h3>
- This PR is close to safe to merge, but has a functional gap that can still leave macOS push events filtered out after canonicalization.
- The change to adopt the canonical session key is sensible, but the current code sets the active session key before canonicalization and never re-applies it, so the intended fix may not take effect depending on how the transport/gateway filters events. Reset-trigger handling and the transport extension look straightforward otherwise.
- apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel.swift
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#3182: fix(gateway): use canonical session key in chat.send
by chrisherold · 2026-01-28
80.0%
#14309: fix(ui): resolve chat event session key mismatch
by justonlyforyou · 2026-02-11
79.1%
#18694: fix(ui): reset session key to main after /new in webchat
by Phineas1500 · 2026-02-17
78.1%
#19343: Refactor chat state management: reset chat messages and queue on se...
by saurav470 · 2026-02-17
76.7%
#9218: Fix Control UI chat resync on gaps and terminal events
by figitaki · 2026-02-05
75.9%
#4567: Webchat: canonicalize main session key for /new (fix #4446)
by selfboot · 2026-01-30
75.0%
#16767: fix: auto-resync webchat on reconnect and prevent message flicker o...
by alewcock · 2026-02-15
74.0%
#22458: Codex/macos chat corner clip
by apethree · 2026-02-21
74.0%
#3474: fix(macos): menu bar activity badge not showing during agent work
by elektricM · 2026-01-28
73.9%
#5693: fix(chat): display error messages when LLM requests fail
by niemesrw · 2026-01-31
73.6%