From bbccfd9d4494ddca92da3e3666e70a3e5bab9050 Mon Sep 17 00:00:00 2001 From: Krasimir Kralev <263465593+KrasimirKralev@users.noreply.github.com> Date: Sun, 19 Apr 2026 02:51:07 +0300 Subject: [PATCH 1/2] fix(ai-provider): sweep sessions, show progress + green banner on switch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changing the primary AI provider in Settings (e.g. OpenAI → ClawBox AI) had three user-visible problems: 1. Chat kept responding as the OLD provider after the switch. The configure route updated agents.defaults.model.primary but left every existing session's per-session override pointing at the previous model. OpenClaw's resolver respected those sticky overrides on the next turn, so the chat stayed bound to the old provider until the user cleared the session — or refreshed the page and noticed it still answered wrong. 2. Chat 'froze' during the gateway restart. The chat popup only had skill-install-aware retry logic, so a provider-change gateway restart dropped the WS and the user saw no progress; only the bare retry loop slowly reconnected. 3. No affirmative 'switched to X' feedback — when reconnect finally landed, the chat looked identical to before. The dropdown already shows a green 'Switched chat to X' banner when switching models from within the chat pane (PR #73); provider changes via Settings deserved the same. Changes: - src/app/setup-api/ai-models/configure/route.ts: after 'agents.defaults.model.primary' is written, sweep per-session model overrides via applyModelOverrideToAllAgentSessions with source: 'user' so OpenClaw's resolver keeps the new primary bound across existing sessions. Mirrors the sweep in /setup-api/chat/model from PR #73. Only runs when this call actually set a new primary (skips local-only scopes). - src/components/ChatPopup.tsx: listens for the existing clawbox:primary-ai-configured event (dispatched by SettingsApp after provider configure succeeds) alongside clawbox-skill-installed. Reuses the reloadingSkill overlay + progress bar + quadrupled retry budget — makes the gateway restart visible instead of letting the chat look frozen. Banner label adapts ('Switching AI provider...' vs 'Reloading skills...') via a new reloadReason state; a matching reloadReasonRef escapes the frozen closure captured by the one-time WebSocket hello resolve callback. After reconnect on a provider change, the auto-'my skills were just updated' prompt is skipped (no skill changed, nothing to confirm) and a green 'Switched chat to