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
This commit is contained in:
w-sss 2026-03-17 21:39:09 +08:00
parent 8135ddd566
commit 445328622c
5 changed files with 9 additions and 1 deletions

View File

@ -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);
}

View File

@ -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),

View File

@ -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;

View File

@ -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;

View File

@ -12,4 +12,5 @@ export type ChannelsState = {
whatsappLoginQrDataUrl: string | null;
whatsappLoginConnected: boolean | null;
whatsappBusy: boolean;
configSaveError: string | null;
};