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) {