fix(ui): Agent 面板信息不随对话更新 — 事件时序 + clones 刷新
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
- streamStore: zclaw:agent-profile-updated 事件从记忆提取前改为 .then() 后触发 - RightPanel: profile 更新事件中新增 loadClones() 刷新 selectedClone 数据
This commit is contained in:
@@ -179,7 +179,7 @@ export function RightPanel({ simpleMode = false }: RightPanelProps) {
|
|||||||
.catch(() => setUserProfile(null));
|
.catch(() => setUserProfile(null));
|
||||||
}, [currentAgent?.id]);
|
}, [currentAgent?.id]);
|
||||||
|
|
||||||
// Listen for profile updates after conversations
|
// Listen for profile updates after conversations (fired after memory extraction completes)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handler = (e: Event) => {
|
const handler = (e: Event) => {
|
||||||
const detail = (e as CustomEvent).detail;
|
const detail = (e as CustomEvent).detail;
|
||||||
@@ -187,6 +187,8 @@ export function RightPanel({ simpleMode = false }: RightPanelProps) {
|
|||||||
invoke<AgentInfo | null>('agent_get', { agentId: currentAgent.id })
|
invoke<AgentInfo | null>('agent_get', { agentId: currentAgent.id })
|
||||||
.then(data => setUserProfile(data?.userProfile ?? null))
|
.then(data => setUserProfile(data?.userProfile ?? null))
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
|
// Refresh clones data so selectedClone (name, role, nickname, etc.) stays current
|
||||||
|
loadClones();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
window.addEventListener('zclaw:agent-profile-updated', handler);
|
window.addEventListener('zclaw:agent-profile-updated', handler);
|
||||||
|
|||||||
@@ -521,21 +521,24 @@ export const useStreamStore = create<StreamState>()(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Async memory extraction
|
// Async memory extraction — dispatch update event AFTER extraction completes
|
||||||
const msgs = _chat?.getMessages() || [];
|
const msgs = _chat?.getMessages() || [];
|
||||||
const filtered = msgs
|
const filtered = msgs
|
||||||
.filter(m => m.role === 'user' || m.role === 'assistant')
|
.filter(m => m.role === 'user' || m.role === 'assistant')
|
||||||
.map(m => ({ role: m.role, content: m.content }));
|
.map(m => ({ role: m.role, content: m.content }));
|
||||||
const convId = useConversationStore.getState().currentConversationId;
|
const convId = useConversationStore.getState().currentConversationId;
|
||||||
getMemoryExtractor().extractFromConversation(filtered, agentId, convId ?? undefined).catch(err => {
|
getMemoryExtractor().extractFromConversation(filtered, agentId, convId ?? undefined)
|
||||||
log.warn('Memory extraction failed:', err);
|
.then(() => {
|
||||||
});
|
// Notify RightPanel to refresh UserProfile after memory extraction completes
|
||||||
// Notify RightPanel to refresh UserProfile after memory extraction
|
if (typeof window !== 'undefined') {
|
||||||
if (typeof window !== 'undefined') {
|
window.dispatchEvent(new CustomEvent('zclaw:agent-profile-updated', {
|
||||||
window.dispatchEvent(new CustomEvent('zclaw:agent-profile-updated', {
|
detail: { agentId }
|
||||||
detail: { agentId }
|
}));
|
||||||
}));
|
}
|
||||||
}
|
})
|
||||||
|
.catch(err => {
|
||||||
|
log.warn('Memory extraction failed:', err);
|
||||||
|
});
|
||||||
intelligenceClient.reflection.recordConversation().catch(err => {
|
intelligenceClient.reflection.recordConversation().catch(err => {
|
||||||
log.warn('Recording conversation failed:', err);
|
log.warn('Recording conversation failed:', err);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user