From fcdd1629f6a84d5bdaefd2a1fae956725a552ef7 Mon Sep 17 00:00:00 2001 From: thzxx Date: Sat, 27 Jun 2026 22:17:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Agent=20=E8=BF=AD=E4=BB=A3=E6=95=B0?= =?UTF-8?q?=E4=BB=8E=E6=9C=AA=E6=9B=B4=E6=96=B0=EF=BC=8C=E5=A7=8B=E7=BB=88?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=200/N?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useAgentStream.ts | 5 +++++ src/stores/agent-store.ts | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/hooks/useAgentStream.ts b/src/hooks/useAgentStream.ts index 6721241..4a08357 100644 --- a/src/hooks/useAgentStream.ts +++ b/src/hooks/useAgentStream.ts @@ -38,6 +38,11 @@ export function useAgentStream(): void { const store = useAgentStore.getState(); + // 每次收到迭代号时同步更新 + if (data.iteration != null) { + store.setCurrentIteration(data.iteration); + } + switch (data.type) { // 思考开始 case 'thinking_start': diff --git a/src/stores/agent-store.ts b/src/stores/agent-store.ts index 17c81b1..663e76b 100644 --- a/src/stores/agent-store.ts +++ b/src/stores/agent-store.ts @@ -105,6 +105,7 @@ interface AgentState { updateTokenUsage: (usage: Partial) => void; setProvider: (provider: string, model: string) => void; setMaxIterations: (max: number) => void; + setCurrentIteration: (n: number) => void; saveTraceData: () => void; clearMessages: () => void; abort: () => void; @@ -305,6 +306,8 @@ export const useAgentStore = create((set, get) => ({ setMaxIterations: (max) => set({ maxIterations: max }), + setCurrentIteration: (currentIteration) => set({ currentIteration }), + saveTraceData: () => { const { currentSessionId, traceSteps, tokenUsage } = get(); if (currentSessionId && window.metona?.sessions?.saveTrace) {