From e64a3ea9a39b344f93c0d9d59b8532d0a38c3972 Mon Sep 17 00:00:00 2001 From: iven Date: Thu, 23 Apr 2026 10:28:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(identity):=20Agent=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E7=9B=91=E5=90=ACRust=E8=BA=AB=E4=BB=BD?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=8B=E4=BB=B6=E5=88=B7=E6=96=B0=E5=90=8D?= =?UTF-8?q?=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题: Rust端post_conversation_hook写回soul.md后emit Tauri事件, 但前端RightPanel未监听该事件,导致面板不刷新。 修复: RightPanel添加zclaw:agent-identity-updated事件监听, 收到后调用updateClone更新AgentConfig.name并刷新clone列表。 --- desktop/src/components/RightPanel.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/desktop/src/components/RightPanel.tsx b/desktop/src/components/RightPanel.tsx index 514f68e..6b3f820 100644 --- a/desktop/src/components/RightPanel.tsx +++ b/desktop/src/components/RightPanel.tsx @@ -9,6 +9,7 @@ import { toChatAgent, useChatStore, type CodeBlock } from '../store/chatStore'; import { useConversationStore } from '../store/chat/conversationStore'; import { intelligenceClient, type IdentitySnapshot } from '../lib/intelligence-client'; import { invoke } from '@tauri-apps/api/core'; +import { listen, type UnlistenFn } from '@tauri-apps/api/event'; import type { AgentInfo } from '../lib/kernel-types'; import { Wifi, WifiOff, Bot, BarChart3, Plug, RefreshCw, @@ -195,6 +196,23 @@ export function RightPanel({ simpleMode = false }: RightPanelProps) { return () => window.removeEventListener('zclaw:agent-profile-updated', handler); }, [currentAgent?.id]); + // Listen for Tauri identity update events (from Rust post_conversation_hook) + // When agent name changes in soul.md, update AgentConfig.name and refresh panel + useEffect(() => { + let unlisten: UnlistenFn | undefined; + listen<{ agentId: string; agentName?: string }>('zclaw:agent-identity-updated', (event) => { + const { agentName } = event.payload; + if (agentName && currentAgent?.id) { + updateClone(currentAgent.id, { name: agentName }) + .then(() => loadClones()) + .catch(() => {}); + } + }) + .then(fn => { unlisten = fn; }) + .catch(() => {}); + return () => { unlisten?.(); }; + }, [currentAgent?.id]); + const handleReconnect = () => { connect().catch(silentErrorHandler('RightPanel')); };