openclaw-windows-node icon indicating copy to clipboard operation
openclaw-windows-node copied to clipboard

Fix chat session routing from Sessions page and toast notifications

Open QQSHI13 opened this issue 6 months ago • 8 comments

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:

  1. Gateway → Notification: OpenClawNotification had no SessionKey property, so chat toasts couldn't carry the source session.
  2. Toast → App: ToastActivationRouter.OpenChat was Action (no parameters), so the toast's sessionKey argument was ignored.
  3. App → ChatPage: ShowWebChat didn't accept or forward a session key. ChatPage only checked _hub?.PendingChatSessionKey, which is null when the HubWindow doesn't exist (background notifications, closed window).
  4. ChatPage (FunctionalUI): The pendingSessionKey is not null guard treated "" as a valid key, and the provider fallback to _mountedThreadId could return a stale default.
  5. 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: Add SessionKey property.
  • OpenClawGatewayClient.EmitChatNotification: Accept sessionKey parameter (from HandleChatEvent payload) and set it on the notification.

Commit 2: Fix chat session routing from Sessions page and toast notifications

  • App.PendingChatSessionKey: New fallback property when HubWindow doesn't exist. Consumed (cleared) by ChatPage.
  • App.ShowWebChat(string? sessionKey): Accepts session key, stashes it on both App and HubWindow so ChatPage can pick it up after navigation.
  • ToastActivationRouter: OpenChat changed from Action → Action<string?>. Reads sessionKey from toast arguments and passes it through.
  • App.OnGatewayNotificationReceived: Embeds sessionKey in chat toast body arguments and the "Open Chat" toast button.
  • ChatPage (FunctionalUI):
    • Consumes pending key from _hub?.PendingChatSessionKey and (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
  • ChatPage (WebView):
    • New _pendingWebViewSessionKey field
    • ShowWebViewSurface: consumes pending key from HubWindow or App fallbacks
    • NavigateWebViewToCurrentChatUrl: appends &session={key} to the URL (deduping any existing session param)
    • InitializeWebViewAsync: passes _pendingWebViewSessionKey through GatewayChatHelper.TryBuildChatUrl
  • SessionsPage.OnOpenChat: Writes key to CurrentApp.PendingChatSessionKey (fallback) in addition to hub.PendingChatSessionKey.
  • Tests: Updated ToastActivationRouterTests and AppRefactorContractTests for the new Action<string?> contract. Added Route_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

  1. Open the tray app, connect to a gateway with multiple sessions.
  2. Sessions tab: Click "Open chat" on a non-default session — should open that specific session.
  3. Toast notification: Trigger an assistant response in a non-default session, click the toast — should open that specific session.
  4. WebView mode: Enable "Use standard Gateway Chat interface" in Settings, repeat steps 2–3 — the WebView should navigate to ?token=...&session={key}.

QQSHI13 avatar May 31 '26 11:05 QQSHI13

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:

  1. 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.
  2. 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:

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-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.
  • 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 explain to ask for more context, or @clawsweeper stop to stop active automation.

clawsweeper[bot] avatar May 31 '26 11:05 clawsweeper[bot]

@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

  1. Opened the tray Hub, navigated to Sessions tab.
  2. Clicked "Open chat" on a non-default session (agent:main:scratch).
  3. Chat page opened with the correct session selected in the composer dropdown.
  4. 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

  1. Triggered an assistant response in a non-default session from another client.
  2. Clicked the toast notification when it appeared.
  3. Chat page opened with the source session selected (not the default/main session).
  4. 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.

QQSHI13 avatar May 31 '26 13:05 QQSHI13

🦞🧹 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[bot] avatar May 31 '26 13:05 clawsweeper[bot]

@clawsweeper re-review

QQSHI13 avatar May 31 '26 13:05 QQSHI13

🦞👀 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[bot] avatar May 31 '26 13:05 clawsweeper[bot]

@clawsweeper re-review

QQSHI13 avatar Jun 05 '26 10:06 QQSHI13

🦞👀 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[bot] avatar Jun 05 '26 10:06 clawsweeper[bot]

@clawsweeper re-review

QQSHI13 avatar Jun 14 '26 01:06 QQSHI13