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