fix: 迭代计数修复 — stateChange 也携带迭代号,双通道同步
- IPC handler 将 stateChange 事件转发到渲染进程 - useAgentStream 同时监听 streamEvent 和 stateChange 更新迭代 - 切换会话/发消息时重置 currentIteration 为 0 - 添加 console.log 诊断日志
This commit is contained in:
@@ -84,9 +84,13 @@ export function registerAllIPCHandlers(
|
||||
}
|
||||
};
|
||||
|
||||
const onStateChange = (data: { previous: string; current: string }) => {
|
||||
const onStateChange = (data: { previous?: string; current?: string; sessionId?: string; iteration?: number; state?: string }) => {
|
||||
// AGENT 层:记录状态转换
|
||||
log.info(`[AGENT] State: ${data.previous} → ${data.current}`);
|
||||
if (data.previous) log.info(`[AGENT] State: ${data.previous} → ${data.current}`);
|
||||
// 转发到渲染进程(携带迭代号)
|
||||
if (!mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('agent:stateChange', data);
|
||||
}
|
||||
};
|
||||
|
||||
agentLoop.on('streamEvent', onStreamEvent);
|
||||
|
||||
Reference in New Issue
Block a user