From 28684abbfb0931da9c4e8746a0bacd035626d989 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 8 Jun 2026 01:54:28 +0000 Subject: [PATCH] fix(setup): cancel wizard session before disconnect to prevent stale-session retry errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When wizard.next timed out (e.g. Teams channel selection hanging), EnterWizardErrorAsync called DisconnectAsync which nulled _client, then showed "Start wizard again" / "Skip wizard" buttons. CancelCurrentSessionAsync checked _client != null and skipped the wizard.cancel call — leaving the server-side session active. Subsequent "Start wizard again" clicks then hit a gateway "wizard already running" error. Fix: replace await DisconnectAsync() with await CancelCurrentSessionAsync() in both EnterWizardErrorAsync and StartWizardAsync. CancelCurrentSessionAsync sends wizard.cancel (best-effort, catch ignored) then calls DisconnectAsync, so the disconnect still happens. The session cancel is a no-op when _client is already null or _sessionId is empty, so the first-start path is unaffected. Closes #709 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/OpenClaw.SetupEngine.UI/Pages/WizardPage.xaml.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/OpenClaw.SetupEngine.UI/Pages/WizardPage.xaml.cs b/src/OpenClaw.SetupEngine.UI/Pages/WizardPage.xaml.cs index 95fbca19..93a67480 100644 --- a/src/OpenClaw.SetupEngine.UI/Pages/WizardPage.xaml.cs +++ b/src/OpenClaw.SetupEngine.UI/Pages/WizardPage.xaml.cs @@ -56,7 +56,10 @@ private async Task StartWizardAsync() { _errorState = false; HideRecoveryActions(); - await DisconnectAsync(); + // Cancel any in-progress server-side wizard session before starting a + // fresh one, so the gateway doesn't reject wizard.start with "wizard + // already running" when recovering from a previous error. + await CancelCurrentSessionAsync(); ClearConsoleBanner(); _sessionId = ""; _wizardStepCount = 0; @@ -757,7 +760,10 @@ private async Task EnterWizardErrorAsync(string detail) return; _errorState = true; - await DisconnectAsync(); + // Cancel the server-side wizard session before disconnecting so that + // subsequent retries (Start wizard again / Skip wizard) don't hit a + // "wizard already running" error from a lingering gateway session. + await CancelCurrentSessionAsync(); ShowError(detail); }