From b5ef8a93ca134f1b9861ce17c572c6b252c866eb Mon Sep 17 00:00:00 2001 From: icarus Date: Fri, 19 Sep 2025 15:24:33 +0800 Subject: [PATCH] refactor(useAgent): simplify mutate call in agent update The previous implementation unnecessarily spread the previous state when only the result is needed. This simplifies the mutation logic while maintaining the same behavior. --- src/renderer/src/hooks/agents/useAgent.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/renderer/src/hooks/agents/useAgent.ts b/src/renderer/src/hooks/agents/useAgent.ts index 9bc2258635..cff8d24a6a 100644 --- a/src/renderer/src/hooks/agents/useAgent.ts +++ b/src/renderer/src/hooks/agents/useAgent.ts @@ -24,10 +24,7 @@ export const useAgent = (id: string | null) => { try { // may change to optimistic update const result = await client.updateAgent(form) - mutate((prev) => ({ - ...prev, - ...result - })) + mutate(result) window.toast.success(t('common.update_success')) } catch (error) { window.toast.error(formatErrorMessageWithPrefix(error, t('agent.update.error.failed')))