fix(identity): Agent详情面板监听Rust身份更新事件刷新名称
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
问题: Rust端post_conversation_hook写回soul.md后emit Tauri事件, 但前端RightPanel未监听该事件,导致面板不刷新。 修复: RightPanel添加zclaw:agent-identity-updated事件监听, 收到后调用updateClone更新AgentConfig.name并刷新clone列表。
This commit is contained in:
@@ -9,6 +9,7 @@ import { toChatAgent, useChatStore, type CodeBlock } from '../store/chatStore';
|
|||||||
import { useConversationStore } from '../store/chat/conversationStore';
|
import { useConversationStore } from '../store/chat/conversationStore';
|
||||||
import { intelligenceClient, type IdentitySnapshot } from '../lib/intelligence-client';
|
import { intelligenceClient, type IdentitySnapshot } from '../lib/intelligence-client';
|
||||||
import { invoke } from '@tauri-apps/api/core';
|
import { invoke } from '@tauri-apps/api/core';
|
||||||
|
import { listen, type UnlistenFn } from '@tauri-apps/api/event';
|
||||||
import type { AgentInfo } from '../lib/kernel-types';
|
import type { AgentInfo } from '../lib/kernel-types';
|
||||||
import {
|
import {
|
||||||
Wifi, WifiOff, Bot, BarChart3, Plug, RefreshCw,
|
Wifi, WifiOff, Bot, BarChart3, Plug, RefreshCw,
|
||||||
@@ -195,6 +196,23 @@ export function RightPanel({ simpleMode = false }: RightPanelProps) {
|
|||||||
return () => window.removeEventListener('zclaw:agent-profile-updated', handler);
|
return () => window.removeEventListener('zclaw:agent-profile-updated', handler);
|
||||||
}, [currentAgent?.id]);
|
}, [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 = () => {
|
const handleReconnect = () => {
|
||||||
connect().catch(silentErrorHandler('RightPanel'));
|
connect().catch(silentErrorHandler('RightPanel'));
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user