diff --git a/desktop/src/components/RightPanel.tsx b/desktop/src/components/RightPanel.tsx index d753779..d2c85c5 100644 --- a/desktop/src/components/RightPanel.tsx +++ b/desktop/src/components/RightPanel.tsx @@ -8,6 +8,8 @@ import { useConfigStore } from '../store/configStore'; 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 type { AgentInfo } from '../lib/kernel-types'; import { Wifi, WifiOff, Bot, BarChart3, Plug, RefreshCw, MessageSquare, Cpu, FileText, User, Activity, Brain, @@ -143,6 +145,9 @@ export function RightPanel({ simpleMode = false }: RightPanelProps) { const [restoringSnapshotId, setRestoringSnapshotId] = useState(null); const [confirmRestoreId, setConfirmRestoreId] = useState(null); + // UserProfile from memory store (dynamic, learned from conversations) + const [userProfile, setUserProfile] = useState | null>(null); + const connected = connectionState === 'connected'; const selectedClone = useMemo( () => clones.find((clone) => clone.id === currentAgent?.id), @@ -166,6 +171,28 @@ export function RightPanel({ simpleMode = false }: RightPanelProps) { } }, [connected]); + // Fetch UserProfile from agent data (includes memory-learned profile) + useEffect(() => { + if (!currentAgent?.id) return; + invoke('agent_get', { agentId: currentAgent.id }) + .then(data => setUserProfile(data?.userProfile ?? null)) + .catch(() => setUserProfile(null)); + }, [currentAgent?.id]); + + // Listen for profile updates after conversations + useEffect(() => { + const handler = (e: Event) => { + const detail = (e as CustomEvent).detail; + if (detail?.agentId === currentAgent?.id && currentAgent?.id) { + invoke('agent_get', { agentId: currentAgent.id }) + .then(data => setUserProfile(data?.userProfile ?? null)) + .catch(() => {}); + } + }; + window.addEventListener('zclaw:agent-profile-updated', handler); + return () => window.removeEventListener('zclaw:agent-profile-updated', handler); + }, [currentAgent?.id]); + const handleReconnect = () => { connect().catch(silentErrorHandler('RightPanel')); }; @@ -552,6 +579,24 @@ export function RightPanel({ simpleMode = false }: RightPanelProps) { + {/* Dynamic: UserProfile data (from conversation learning) */} + {userProfile && ( +
+
对话中了解到的
+ {userProfile.industry ? ( + + ) : null} + {userProfile.role ? ( + + ) : null} + {userProfile.communicationStyle ? ( + + ) : null} + {Array.isArray(userProfile.recentTopics) && (userProfile.recentTopics as string[]).length > 0 ? ( + + ) : null} +
+ )} )} diff --git a/desktop/src/store/chat/streamStore.ts b/desktop/src/store/chat/streamStore.ts index 56a0f92..20fdf32 100644 --- a/desktop/src/store/chat/streamStore.ts +++ b/desktop/src/store/chat/streamStore.ts @@ -487,6 +487,12 @@ export const useStreamStore = create()( 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 } + })); + } intelligenceClient.reflection.recordConversation().catch(err => { log.warn('Recording conversation failed:', err); });