fix(ui): Agent 面板信息不随对话更新 — 事件时序 + clones 刷新
Some checks are pending
CI / Lint & TypeCheck (push) Waiting to run
CI / Unit Tests (push) Waiting to run
CI / Build Frontend (push) Waiting to run
CI / Rust Check (push) Waiting to run
CI / Security Scan (push) Waiting to run
CI / E2E Tests (push) Blocked by required conditions
Some checks are pending
CI / Lint & TypeCheck (push) Waiting to run
CI / Unit Tests (push) Waiting to run
CI / Build Frontend (push) Waiting to run
CI / Rust Check (push) Waiting to run
CI / Security Scan (push) Waiting to run
CI / E2E Tests (push) Blocked by required conditions
- 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));
|
||||
}, [currentAgent?.id]);
|
||||
|
||||
// Listen for profile updates after conversations
|
||||
// Listen for profile updates after conversations (fired after memory extraction completes)
|
||||
useEffect(() => {
|
||||
const handler = (e: Event) => {
|
||||
const detail = (e as CustomEvent).detail;
|
||||
@@ -187,6 +187,8 @@ export function RightPanel({ simpleMode = false }: RightPanelProps) {
|
||||
invoke<AgentInfo | null>('agent_get', { agentId: currentAgent.id })
|
||||
.then(data => setUserProfile(data?.userProfile ?? null))
|
||||
.catch(() => {});
|
||||
// Refresh clones data so selectedClone (name, role, nickname, etc.) stays current
|
||||
loadClones();
|
||||
}
|
||||
};
|
||||
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 filtered = msgs
|
||||
.filter(m => m.role === 'user' || m.role === 'assistant')
|
||||
.map(m => ({ role: m.role, content: m.content }));
|
||||
const convId = useConversationStore.getState().currentConversationId;
|
||||
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 }
|
||||
}));
|
||||
}
|
||||
getMemoryExtractor().extractFromConversation(filtered, agentId, convId ?? undefined)
|
||||
.then(() => {
|
||||
// Notify RightPanel to refresh UserProfile after memory extraction completes
|
||||
if (typeof window !== 'undefined') {
|
||||
window.dispatchEvent(new CustomEvent('zclaw:agent-profile-updated', {
|
||||
detail: { agentId }
|
||||
}));
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
log.warn('Memory extraction failed:', err);
|
||||
});
|
||||
intelligenceClient.reflection.recordConversation().catch(err => {
|
||||
log.warn('Recording conversation failed:', err);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user