From 1309101a942a3b2bdc01e6ed8e3e2a0b19c01d24 Mon Sep 17 00:00:00 2001 From: iven Date: Thu, 16 Apr 2026 22:57:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(ui):=20Agent=20=E9=9D=A2=E6=9D=BF=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E4=B8=8D=E9=9A=8F=E5=AF=B9=E8=AF=9D=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=20=E2=80=94=20=E4=BA=8B=E4=BB=B6=E6=97=B6=E5=BA=8F=20+=20clone?= =?UTF-8?q?s=20=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - streamStore: zclaw:agent-profile-updated 事件从记忆提取前改为 .then() 后触发 - RightPanel: profile 更新事件中新增 loadClones() 刷新 selectedClone 数据 --- desktop/src/components/RightPanel.tsx | 4 +++- desktop/src/store/chat/streamStore.ts | 23 +++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/desktop/src/components/RightPanel.tsx b/desktop/src/components/RightPanel.tsx index 51cc828..0e2d776 100644 --- a/desktop/src/components/RightPanel.tsx +++ b/desktop/src/components/RightPanel.tsx @@ -179,7 +179,7 @@ export function RightPanel({ simpleMode = false }: RightPanelProps) { .catch(() => setUserProfile(null)); }, [currentAgent?.id]); - // Listen for profile updates after conversations + // Listen for profile updates after conversations (fired after memory extraction completes) useEffect(() => { const handler = (e: Event) => { const detail = (e as CustomEvent).detail; @@ -187,6 +187,8 @@ export function RightPanel({ simpleMode = false }: RightPanelProps) { invoke('agent_get', { agentId: currentAgent.id }) .then(data => setUserProfile(data?.userProfile ?? null)) .catch(() => {}); + // Refresh clones data so selectedClone (name, role, nickname, etc.) stays current + loadClones(); } }; window.addEventListener('zclaw:agent-profile-updated', handler); diff --git a/desktop/src/store/chat/streamStore.ts b/desktop/src/store/chat/streamStore.ts index 05fd157..710dadc 100644 --- a/desktop/src/store/chat/streamStore.ts +++ b/desktop/src/store/chat/streamStore.ts @@ -521,21 +521,24 @@ export const useStreamStore = create()( }); } - // Async memory extraction + // Async memory extraction — dispatch update event AFTER extraction completes const msgs = _chat?.getMessages() || []; const filtered = msgs .filter(m => m.role === 'user' || m.role === 'assistant') .map(m => ({ role: m.role, content: m.content })); const convId = useConversationStore.getState().currentConversationId; - getMemoryExtractor().extractFromConversation(filtered, agentId, convId ?? undefined).catch(err => { - log.warn('Memory extraction failed:', err); - }); - // Notify RightPanel to refresh UserProfile after memory extraction - if (typeof window !== 'undefined') { - window.dispatchEvent(new CustomEvent('zclaw:agent-profile-updated', { - detail: { agentId } - })); - } + getMemoryExtractor().extractFromConversation(filtered, agentId, convId ?? undefined) + .then(() => { + // Notify RightPanel to refresh UserProfile after memory extraction completes + if (typeof window !== 'undefined') { + window.dispatchEvent(new CustomEvent('zclaw:agent-profile-updated', { + detail: { agentId } + })); + } + }) + .catch(err => { + log.warn('Memory extraction failed:', err); + }); intelligenceClient.reflection.recordConversation().catch(err => { log.warn('Recording conversation failed:', err); });