From 445328622cbf2ad35429e40be7e06f2b0658c96a Mon Sep 17 00:00:00 2001 From: w-sss <1598099293@qq.com> Date: Tue, 17 Mar 2026 21:39:09 +0800 Subject: [PATCH] fix(ui): use dedicated configSaveError state instead of global lastError - Add configSaveError field to ChannelsState and AppViewState - Clear configSaveError before save/reload operations - Set configSaveError only when config save fails - Fixes Codex P2 feedback about global error pollution - Channel config callouts now only show save-specific errors --- ui/src/ui/app-channels.ts | 5 +++++ ui/src/ui/app-render.ts | 2 +- ui/src/ui/app-view-state.ts | 1 + ui/src/ui/app.ts | 1 + ui/src/ui/controllers/channels.types.ts | 1 + 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ui/src/ui/app-channels.ts b/ui/src/ui/app-channels.ts index eb05e83e81b..ff9aa5787fc 100644 --- a/ui/src/ui/app-channels.ts +++ b/ui/src/ui/app-channels.ts @@ -25,12 +25,17 @@ export async function handleWhatsAppLogout(host: OpenClawApp) { } export async function handleChannelConfigSave(host: OpenClawApp) { + host.configSaveError = null; await saveConfig(host); + if (host.lastError) { + host.configSaveError = host.lastError; + } await loadConfig(host); await loadChannels(host, true); } export async function handleChannelConfigReload(host: OpenClawApp) { + host.configSaveError = null; await loadConfig(host); await loadChannels(host, true); } diff --git a/ui/src/ui/app-render.ts b/ui/src/ui/app-render.ts index 786a85b0757..540e65b0342 100644 --- a/ui/src/ui/app-render.ts +++ b/ui/src/ui/app-render.ts @@ -680,7 +680,7 @@ export function renderApp(state: AppViewState) { configUiHints: state.configUiHints, configSaving: state.configSaving, configFormDirty: state.configFormDirty, - configSaveError: state.lastError, + configSaveError: state.configSaveError, nostrProfileFormState: state.nostrProfileFormState, nostrProfileAccountId: state.nostrProfileAccountId, onRefresh: (probe) => loadChannels(state, probe), diff --git a/ui/src/ui/app-view-state.ts b/ui/src/ui/app-view-state.ts index 375faa43137..75459ca5cbf 100644 --- a/ui/src/ui/app-view-state.ts +++ b/ui/src/ui/app-view-state.ts @@ -145,6 +145,7 @@ export type AppViewState = { channelsSnapshot: ChannelsStatusSnapshot | null; channelsError: string | null; channelsLastSuccess: number | null; + configSaveError: string | null; whatsappLoginMessage: string | null; whatsappLoginQrDataUrl: string | null; whatsappLoginConnected: boolean | null; diff --git a/ui/src/ui/app.ts b/ui/src/ui/app.ts index af0d0cb9c96..2c85ce883c9 100644 --- a/ui/src/ui/app.ts +++ b/ui/src/ui/app.ts @@ -240,6 +240,7 @@ export class OpenClawApp extends LitElement { @state() channelsSnapshot: ChannelsStatusSnapshot | null = null; @state() channelsError: string | null = null; @state() channelsLastSuccess: number | null = null; + @state() configSaveError: string | null = null; @state() whatsappLoginMessage: string | null = null; @state() whatsappLoginQrDataUrl: string | null = null; @state() whatsappLoginConnected: boolean | null = null; diff --git a/ui/src/ui/controllers/channels.types.ts b/ui/src/ui/controllers/channels.types.ts index 4fb8e6bc510..f30a674ca2e 100644 --- a/ui/src/ui/controllers/channels.types.ts +++ b/ui/src/ui/controllers/channels.types.ts @@ -12,4 +12,5 @@ export type ChannelsState = { whatsappLoginQrDataUrl: string | null; whatsappLoginConnected: boolean | null; whatsappBusy: boolean; + configSaveError: string | null; };