fix(openclaw): update button state and toast message after switch

Add cache invalidation for openclawLiveProviderIds in useSwitchProviderMutation
to ensure button state updates correctly after adding/removing providers.

Also fix toast message to show "已添加到配置" for OpenClaw (same as OpenCode).
This commit is contained in:
Jason
2026-02-05 22:58:05 +08:00
parent 46ab15f9f6
commit c431a86064
2 changed files with 15 additions and 7 deletions
+6
View File
@@ -174,6 +174,7 @@ export const useSwitchProviderMutation = (appId: AppId) => {
onSuccess: async () => {
await queryClient.invalidateQueries({ queryKey: ["providers", appId] });
// OpenCode/OpenClaw: also invalidate live provider IDs cache to update button state
if (appId === "opencode") {
await queryClient.invalidateQueries({
queryKey: ["opencodeLiveProviderIds"],
@@ -182,6 +183,11 @@ export const useSwitchProviderMutation = (appId: AppId) => {
queryKey: ["omo", "current-provider-id"],
});
}
if (appId === "openclaw") {
await queryClient.invalidateQueries({
queryKey: ["openclawLiveProviderIds"],
});
}
try {
await providersApi.updateTrayMenu();