The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(chat): route late rows with no turn live; reach frozen cards' progress
M3gA-Mind4e7c2d9e8034
diff --git a/app/src/store/__tests__/chatRuntimeSlice.liveParity.test.ts b/app/src/store/__tests__/chatRuntimeSlice.liveParity.test.tsindex fe204a7e9a..b423f1ac9c 100644--- a/app/src/store/__tests__/chatRuntimeSlice.liveParity.test.ts+++ b/app/src/store/__tests__/chatRuntimeSlice.liveParity.test.ts@@ -11,10 +11,13 @@ import reducer, {beginInferenceTurn,liveTurnStarted,markInferenceTurnStreaming,+ recordSubagentTranscriptTool,registerParallelRequest,+ resolveSubagentTranscriptTool,setInferenceStatusForThread,setToolTimelineForThread,streamDeltaReceived,+ subagentIterationStarted,subagentSpawned,toolArgsDeltaReceived,toolCallReceived,@@ -261,6 +264,9 @@ describe('turnSettled', () => {);expect(settled.toolTimelineRequestByThread[T]).toBe('req-1');expect(settled.settledTurnsByThread[T]?.['bgdeliver-1']).toBeUndefined();+ // The live timeline is still req-1's own rows, so its late row joins+ // them: the background-process panel reads the live timeline.+ expect(settled.toolTimelineByThread[T]).toHaveLength(2);}});@@ -323,6 +329,74 @@ describe('turnSettled', () => {]);});+ it("with no turn live, a late row of an earlier turn joins its own trail, not the last turn's rows", () => {+ // req-1 and req-2 both settled; the live timeline still holds req-2's+ // rows. A late req-1 row appended there (and claiming) would hand req-2's+ // whole timeline to req-1.+ const settled = run(+ [+ turnSettled({ threadId: T, requestId: 'req-1' }),+ setToolTimelineForThread({ threadId: T, entries: [] }),+ liveTurnStarted({ threadId: T, requestId: 'req-2' }),+ toolCallReceived({+ threadId: T,+ requestId: 'req-2',+ round: 1,+ toolName: 'shell',+ toolCallId: 'call-b',+ }),+ turnSettled({ threadId: T, requestId: 'req-2' }),+ toolCallReceived({+ threadId: T,+ requestId: 'req-1',+ round: 2,+ toolName: 'shell',+ toolCallId: 'call-late',+ }),+ ],+ live()+ );+ expect(settled.toolTimelineByThread[T]?.map(row => row.id)).toEqual(['call-b']);+ expect(settled.toolTimelineRequestByThread[T]).toBe('req-2');+ expect(settled.settledTurnsByThread[T]?.['req-1']?.timeline.map(row => row.id)).toEqual([+ 'call-a',+ 'call-late',+ ]);+ });++ it("a detached child's progress reaches its card in a frozen trail", () => {+ const rowId = `${T}:subagent:sub-9:researcher`;+ const settled = run(+ [+ turnSettled({ threadId: T, requestId: 'req-1' }),+ setToolTimelineForThread({ threadId: T, entries: [] }),+ liveTurnStarted({ threadId: T, requestId: 'req-2' }),+ subagentSpawned({+ threadId: T,+ requestId: 'req-1',+ round: 2,+ rowId,+ taskId: 'sub-9',+ agentId: 'researcher',+ }),+ subagentIterationStarted({ threadId: T, rowId, childIteration: 3, childMaxIterations: 9 }),+ recordSubagentTranscriptTool({+ threadId: T,+ rowId,+ callId: 'child-1',+ toolName: 'web_search',+ }),+ resolveSubagentTranscriptTool({ threadId: T, rowId, callId: 'child-1', success: true }),+ ],+ live()+ );+ const card = settled.settledTurnsByThread[T]?.['req-1']?.timeline.find(row => row.id === rowId);+ expect([card?.subagent?.childIteration, card?.subagent?.childMaxIterations]).toEqual([3, 9]);+ expect(+ card?.subagent?.transcript?.map(item => (item.kind === 'tool' ? item.status : item.kind))+ ).toEqual(['success']);+ });+it('a late row of a turn this session never froze is left to the core projection', () => {const settled = run([diff --git a/app/src/store/chatRuntimeSlice.ts b/app/src/store/chatRuntimeSlice.tsindex a26dc356a5..2612ceedb6 100644--- a/app/src/store/chatRuntimeSlice.ts+++ b/app/src/store/chatRuntimeSlice.ts@@ -1013,10 +1013,9 @@ function claimTimelineForLiveTurn(requestId: string | undefined): void {if (requestId && state.parallelRequestThreads[requestId] !== undefined) return;- const live = state.liveRequestIdByThread[threadId];- // Another turn's row never reaches the live timeline (see `rowTarget`).- if (live && requestId && requestId !== live) return;- const claim = requestId ?? live;+ // A row `rowTarget` kept off the live timeline never claims it.+ if (foreignTrail(state, threadId, requestId) !== undefined) return;+ const claim = requestId ?? state.liveRequestIdByThread[threadId];if (claim) state.toolTimelineRequestByThread[threadId] = claim;else delete state.toolTimelineRequestByThread[threadId];}@@ -1052,14 +1051,20 @@ function foreignTrail(threadId: string,requestId: string | undefined): { timeline: ToolTimelineEntry[]; transcript: ProcessingTranscriptItem[] } | null | undefined {+ if (requestId === undefined || state.parallelRequestThreads[requestId] !== undefined) {+ return undefined;+ }const live = state.liveRequestIdByThread[threadId];- const foreign =- requestId !== undefined &&- live !== undefined &&- requestId !== live &&- state.parallelRequestThreads[requestId] === undefined;- if (!foreign) return undefined;- return state.settledTurnsByThread[threadId]?.[requestId] ?? null;+ const frozen = state.settledTurnsByThread[threadId]?.[requestId];+ if (live !== undefined) return requestId === live ? undefined : (frozen ?? null);+ // No turn is live. The live timeline still holds the last settled turn's+ // rows: a late row of THAT turn keeps joining them (they are its rows, and+ // the background-process panel reads them), but a late row of an earlier+ // turn that has its own frozen trail goes there — appending it would hand+ // it, and by claiming, the whole timeline, to the wrong turn. Without a+ // trail (a missed `inference_start`) it joins the live timeline as before.+ const owner = state.toolTimelineRequestByThread[threadId];+ return frozen && owner !== requestId ? frozen : undefined;}function subagentRows(@@ -2150,10 +2155,15 @@ const chatRuntimeSlice = createSlice({}>) => {const { threadId, rowId, childIteration, childMaxIterations } = action.payload;- const entry = state.toolTimelineByThread[threadId]?.find(e => e.id === rowId);- if (!entry?.subagent) return;- if (childIteration !== undefined) entry.subagent.childIteration = childIteration;- if (childMaxIterations !== undefined) entry.subagent.childMaxIterations = childMaxIterations;+ // Live and frozen rows alike, as `subagentToolCallReceived`: a detached+ // child keeps reporting after its turn settled (or its row was routed+ // to that turn's frozen trail by `rowTarget`).+ for (const entry of subagentRows(state, threadId, e => e.id === rowId)) {+ if (!entry.subagent) continue;+ if (childIteration !== undefined) entry.subagent.childIteration = childIteration;+ if (childMaxIterations !== undefined)+ entry.subagent.childMaxIterations = childMaxIterations;+ }},subagentToolCallReceived: (state,@@ -2307,20 +2317,22 @@ const chatRuntimeSlice = createSlice({) => {const { threadId, rowId, callId, toolName, iteration, args, displayName, detail } =action.payload;- const entry = state.toolTimelineByThread[threadId]?.find(e => e.id === rowId);- if (!entry?.subagent) return;- const transcript = (entry.subagent.transcript ??= []);- if (transcript.some(i => i.kind === 'tool' && i.callId === callId)) return;- transcript.push({- kind: 'tool',- iteration,- callId,- toolName,- status: 'running',- args,- displayName,- detail,- });+ // Live and frozen rows alike; see `subagentIterationStarted`.+ for (const entry of subagentRows(state, threadId, e => e.id === rowId)) {+ if (!entry.subagent) continue;+ const transcript = (entry.subagent.transcript ??= []);+ if (transcript.some(i => i.kind === 'tool' && i.callId === callId)) continue;+ transcript.push({+ kind: 'tool',+ iteration,+ callId,+ toolName,+ status: 'running',+ args,+ displayName,+ detail,+ });+ }},/*** Flip a transcript `tool` item to its terminal status when the child@@ -2342,16 +2354,20 @@ const chatRuntimeSlice = createSlice({) => {const { threadId, rowId, callId, success, elapsedMs, outputChars, result, failure } =action.payload;- const entry = state.toolTimelineByThread[threadId]?.find(e => e.id === rowId);- const item = entry?.subagent?.transcript?.find(i => i.kind === 'tool' && i.callId === callId);- if (!item || item.kind !== 'tool') return;- item.status = success ? 'success' : 'error';- if (elapsedMs != null) item.elapsedMs = elapsedMs;- if (outputChars != null) item.outputChars = outputChars;- if (result != null) item.result = result;- // Carry the structured why/next onto the rendered transcript item; a- // successful result clears any stale failure (#4459).- item.failure = success ? undefined : failure;+ // Live and frozen rows alike; see `subagentIterationStarted`.+ for (const entry of subagentRows(state, threadId, e => e.id === rowId)) {+ const item = entry.subagent?.transcript?.find(+ i => i.kind === 'tool' && i.callId === callId+ );+ if (!item || item.kind !== 'tool') continue;+ item.status = success ? 'success' : 'error';+ if (elapsedMs != null) item.elapsedMs = elapsedMs;+ if (outputChars != null) item.outputChars = outputChars;+ if (result != null) item.result = result;+ // Carry the structured why/next onto the rendered transcript item; a+ // successful result clears any stale failure (#4459).+ item.failure = success ? undefined : failure;+ }},setPendingApprovalForThread: (state,