Fix chat session routing from Sessions page and toast notifications
Problem
Clicking a session entry in the Sessions tab, or clicking a chat toast notification, always opened the default/main session instead of the specific session that was selected or that produced the notification.
Root Cause
The session routing path had gaps at every hand-off point:
- Gateway → Notification:
OpenClawNotificationhad noSessionKeyproperty, so chat toasts couldn't carry the source session. - Toast → App:
ToastActivationRouter.OpenChatwasAction(no parameters), so the toast'ssessionKeyargument was ignored. - App → ChatPage:
ShowWebChatdidn't accept or forward a session key.ChatPageonly checked_hub?.PendingChatSessionKey, which isnullwhen the HubWindow doesn't exist (background notifications, closed window). - ChatPage (FunctionalUI): The
pendingSessionKey is not nullguard treated""as a valid key, and the provider fallback to_mountedThreadIdcould return a stale default. - ChatPage (WebView): The WebView path never appended
&session={key}to the chat URL — it always navigated to the bare gateway root.
Changes
Commit 1: Thread session key through chat notifications
OpenClawNotification: AddSessionKeyproperty.OpenClawGatewayClient.EmitChatNotification: AcceptsessionKeyparameter (fromHandleChatEventpayload) and set it on the notification.
Commit 2: Fix chat session routing from Sessions page and toast notifications
App.PendingChatSessionKey: New fallback property whenHubWindowdoesn't exist. Consumed (cleared) byChatPage.App.ShowWebChat(string? sessionKey): Accepts session key, stashes it on bothAppandHubWindowsoChatPagecan pick it up after navigation.ToastActivationRouter:OpenChatchanged fromAction→Action<string?>. ReadssessionKeyfrom toast arguments and passes it through.App.OnGatewayNotificationReceived: EmbedssessionKeyin chat toast body arguments and the "Open Chat" toast button.ChatPage(FunctionalUI):- Consumes pending key from
_hub?.PendingChatSessionKeyand(App.Current as App)?.PendingChatSessionKey !string.IsNullOrEmpty()guard so""is treated as null- Clears both sources after consumption
forceRemount = !string.IsNullOrEmpty(pendingSessionKey)ensures a remount when a key arrives
- Consumes pending key from
ChatPage(WebView):- New
_pendingWebViewSessionKeyfield ShowWebViewSurface: consumes pending key fromHubWindoworAppfallbacksNavigateWebViewToCurrentChatUrl: appends&session={key}to the URL (deduping any existingsessionparam)InitializeWebViewAsync: passes_pendingWebViewSessionKeythroughGatewayChatHelper.TryBuildChatUrl
- New
SessionsPage.OnOpenChat: Writes key toCurrentApp.PendingChatSessionKey(fallback) in addition tohub.PendingChatSessionKey.- Tests: Updated
ToastActivationRouterTestsandAppRefactorContractTestsfor the newAction<string?>contract. AddedRoute_OpenChat_PassesSessionKeyArgument.
Test Results
dotnet test tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj
Passed! - Failed: 0, Passed: 871, Skipped: 2, Total: 873
Verification Steps
- Open the tray app, connect to a gateway with multiple sessions.
- Sessions tab: Click "Open chat" on a non-default session — should open that specific session.
- Toast notification: Trigger an assistant response in a non-default session, click the toast — should open that specific session.
- WebView mode: Enable "Use standard Gateway Chat interface" in Settings, repeat steps 2–3 — the WebView should navigate to
?token=...&session={key}.
Codex review: needs real behavior proof before merge. Reviewed June 13, 2026, 11:37 PM ET / 03:37 UTC.
Summary Threads chat session keys from gateway chat events through notifications, toast activation, App/Hub pending state, SessionsPage, native ChatPage, WebView URL routing, and tray tests.
Reproducibility: yes. by source inspection: current main drops the session key before notification/toast activation and ChatPage only consumes HubWindow pending state. I did not run the Windows UI flow in this read-only review.
Review metrics: 3 noteworthy metrics.
- Changed surface: 7 runtime files, 2 test files. The fix depends on several handoff points staying consistent across shared gateway code and WinUI chat surfaces.
- Diff size: +110/-27 across 9 files. The patch is moderate, but the behavior is stateful and crosses notification, navigation, and chat mounting boundaries.
- Inspectable proof artifacts: 0 attached. External PR real behavior proof remains a merge gate for this visible Windows routing change.
Merge readiness Overall: 🦪 silver shellfish Proof: 🦪 silver shellfish Patch quality: 🐚 platinum hermit Result: blocked until stronger real behavior proof is added.
Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.
Rank-up moves:
- [P1] Add redacted screenshot, recording, terminal/live output, linked artifact, or logs showing non-default Sessions and toast routing in native chat and WebView mode.
- Update the PR body after adding proof so ClawSweeper re-reviews automatically; if that does not happen, ask a maintainer to comment
@clawsweeper re-review. - [P1] Make the repo-required build, shared tests, and tray tests visible for the latest head before merge.
Proof guidance:
- [P1] Needs stronger real behavior proof before merge: The comment reports the Windows flows, but no inspectable screenshot, recording, terminal/live output, linked artifact, or redacted log is attached; the contributor should add proof and update the PR body to trigger re-review.
Mantis proof suggestion A short desktop proof would directly show whether Sessions-page and toast activation select the intended non-default session in both chat surfaces. A maintainer can ask Mantis to capture proof by posting a new PR comment that starts with the OpenClaw Mantis account mention, followed by:
visual task: verify that Sessions-page Open chat and chat-toast activation open a non-default session in native chat and WebView mode, with private gateway details redacted.
Risk before merge
- [P1] The routing change spans shared gateway events, Windows toast arguments, App/Hub pending state, native chat remounting, and WebView URL construction, so a missed handoff could still open the wrong session.
- [P1] The current proof is a text report without inspectable media, logs, live output, or linked artifacts, so reviewers cannot independently confirm the native/WebView Sessions and toast flows.
Maintainer options:
- Require redacted route proof (recommended)
Have the contributor add a screenshot, recording, terminal/live output, linked artifact, or redacted log showing non-default Sessions and toast activation in native chat and WebView mode before merge. - Accept source-only routing risk
Maintainers can merge based on source review and the text report, but then own any missed real toast or WebView session-routing edge case.
Next step before merge
- [P1] Needs contributor or maintainer follow-up for inspectable Windows behavior proof and normal merge validation; automation cannot supply the contributor's real setup proof.
Security Cleared: No concrete security or supply-chain issue was found; the diff adds no dependencies, downloads, permission changes, or credential persistence changes.
Review details
Best possible solution:
Land the session-key handoff after redacted inspectable Windows proof covers Sessions and toast routing in native and WebView modes, with the repo-required build and tests visible for the latest head.
Do we have a high-confidence way to reproduce the issue?
Yes, by source inspection: current main drops the session key before notification/toast activation and ChatPage only consumes HubWindow pending state. I did not run the Windows UI flow in this read-only review.
Is this the best way to solve the issue?
Yes, the patch uses the existing notification, toast router, App/Hub pending-state, and ChatPage handoff points rather than adding a parallel routing system. It still needs inspectable behavior proof before merge.
AGENTS.md: found and applied where relevant.
Codex review notes: model internal, reasoning high; reviewed against cb68abf8e75e.
Label changes
Label justifications:
P2: This is a normal-priority user-visible bug fix for wrong chat session routing with limited blast radius.merge-risk: 🚨 session-state: The PR changes how pending chat session keys are carried and consumed, so a merge mistake could open or preserve the wrong chat session.rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The comment reports the Windows flows, but no inspectable screenshot, recording, terminal/live output, linked artifact, or redacted log is attached; the contributor should add proof and update the PR body to trigger re-review.
Evidence reviewed
What I checked:
- Repository policy read: AGENTS.md was read in full; its tray-action and validation guidance applies because this PR changes chat/tray navigation behavior and reports validation. (
AGENTS.md:1, cb68abf8e75e) - Current main notification model lacks session routing metadata: OpenClawNotification on current main has chat/category metadata but no SessionKey property for toast activation to consume. (
src/OpenClaw.Shared/Models.cs:97, cb68abf8e75e) - Current main drops the chat session before toast creation: HandleChatEvent extracts sessionKey but calls EmitChatNotification(text) without passing it for both new and legacy assistant events. (
src/OpenClaw.Shared/OpenClawGatewayClient.cs:3013, cb68abf8e75e) - Current main toast activation cannot pass a session key: Toast activation wires OpenChat to ShowWebChat with no parameter, and ToastActivationRouter calls actions.OpenChat() for open_chat. (
src/OpenClaw.Tray.WinUI/App.ToastActivation.cs:31, cb68abf8e75e) - Current main Sessions-page handoff is HubWindow-only: SessionsPage stores the selected key only on ActiveHubWindow, and ChatPage consumes only _hub?.PendingChatSessionKey. (
src/OpenClaw.Tray.WinUI/Pages/SessionsPage.xaml.cs:242, cb68abf8e75e) - PR diff implements the intended handoff chain: The PR adds OpenClawNotification.SessionKey, passes it from HandleChatEvent into notifications, threads it through ToastActivationRouter, stores App.PendingChatSessionKey, and consumes it in native and WebView ChatPage paths. (
src/OpenClaw.Tray.WinUI/Pages/ChatPage.xaml.cs:224, ffdec51c5315)
Likely related people:
- bkudiess: GitHub commit metadata for dea331f80d7c links the Sessions page redesign to the current HubWindow.PendingChatSessionKey handoff consumed by ChatPage. (role: introduced Sessions-page handoff; confidence: high; commits: dea331f80d7c; files:
src/OpenClaw.Tray.WinUI/Pages/SessionsPage.xaml.cs,src/OpenClaw.Tray.WinUI/Pages/ChatPage.xaml.cs,src/OpenClaw.Tray.WinUI/Windows/HubWindow.xaml.cs) - shanselman: git log -S and GitHub commit metadata tie the current chat notification emission and toast activation router surfaces to commits authored by Scott Hanselman. (role: introduced notification and toast routing; confidence: high; commits: 57b929ce599b, 0d4fcbd50ad5; files:
src/OpenClaw.Shared/OpenClawGatewayClient.cs,src/OpenClaw.Tray.WinUI/App.xaml.cs,src/OpenClaw.Tray.WinUI/App.ToastActivation.cs) - RBrid: Recent current-main chat event/session work touches OpenClawGatewayClient near the session-key notification path this PR changes. (role: recent adjacent contributor; confidence: medium; commits: 3fdfbfad837f; files:
src/OpenClaw.Shared/OpenClawGatewayClient.cs,tests/OpenClaw.Tray.Tests/OpenClawChatDataProviderTests.cs)
What the crustacean ranks mean
- 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
- 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
- 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
- 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
- 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
- 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
- 🌊 off-meta tidepool: rating does not apply to this item.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.
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-reviewcomments, 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-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only. - Maintainers can also comment
@clawsweeper reviewto request a fresh review only. - Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
- Maintainer-only repair and merge flows require explicit commands such as
@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review. - Maintainers can comment
@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.
@clawsweeper Re-review requested — live behavior proof added below.
Live behavior proof
Tested from Windows build of the tray app (working tree copied from WSL to %TEMP%\openclaw-build\, built and run via run-app-local.ps1).
Sessions tab → specific session
- Opened the tray Hub, navigated to Sessions tab.
- Clicked "Open chat" on a non-default session (
agent:main:scratch). - Chat page opened with the correct session selected in the composer dropdown.
- Confirmed this works in both:
- Native chat (default FunctionalUI surface)
- WebView mode (enabled "Use standard Gateway Chat interface" in Settings; URL carried
&session=agent%3Amain%3Ascratch)
Toast notification → specific session
- Triggered an assistant response in a non-default session from another client.
- Clicked the toast notification when it appeared.
- Chat page opened with the source session selected (not the default/main session).
- Verified in both native and WebView modes.
Full validation
./build.ps1 → Build succeeded
dotnet test tests/OpenClaw.Shared.Tests → Passed
dotnet test tests/OpenClaw.Tray.Tests → 871 passed, 0 failed, 2 skipped
Ready for re-review.
🦞🧹 ClawSweeper re-review requested.
I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.
Re-review progress:
- State: Complete
- Detail: The targeted re-review finished, the durable review comment was updated, and the synced verdict was routed.
- Run: https://github.com/openclaw/clawsweeper/actions/runs/27484459574
- Updated: 2026-06-14T01:20:42.369Z
@clawsweeper re-review
🦞👀 ClawSweeper picked this up.
Command router queued. I will update this comment with the next step.
Re-review progress:
- State: Failed
- Detail: The targeted re-review did not finish cleanly. Check the workflow run for details.
- Run: https://github.com/openclaw/clawsweeper/actions/runs/26713472917
- Updated: 2026-05-31T13:08:40.474Z
@clawsweeper re-review
🦞👀 ClawSweeper picked this up.
Command router queued. I will update this comment with the next step.
Re-review progress:
- State: Failed
- Detail: The targeted re-review did not finish cleanly. Check the workflow run for details.
- Run: https://github.com/openclaw/clawsweeper/actions/runs/27010816463
- Updated: 2026-06-05T10:56:20.318Z
@clawsweeper re-review