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(app): let the run ledger settle a detached row whose child died
M3gA-Mind03a3e36f80af
diff --git a/app/src/store/__tests__/chatRuntimeSlice.test.ts b/app/src/store/__tests__/chatRuntimeSlice.test.tsindex bfa8d3e064..acbc4fc2ea 100644--- a/app/src/store/__tests__/chatRuntimeSlice.test.ts+++ b/app/src/store/__tests__/chatRuntimeSlice.test.ts@@ -412,6 +412,87 @@ describe('chatRuntimeSlice', () => {expect(row.subagent?.transcript).toEqual([]);});+ /**+ * The detached-row keep-alive above is only truthful while the child lives.+ * If the core dies after the parent turn completes, the snapshot stays+ * `completed` and no `subagent_completed` is ever coming, so the row would+ * read "Running" forever. The run ledger is the independent authority:+ * startup stamps orphaned runs `interrupted`. A terminal ledger status must+ * settle a detached row still shown running, and a `running` one must not.+ */+ describe('ledger reconciliation of a detached async row kept alive past its parent', () => {+ const keptAlive = () =>+ reducer(+ undefined,+ hydrateRuntimeFromSnapshot({+ snapshot: {+ threadId: 'thread-detached',+ requestId: 'req-detached',+ lifecycle: 'completed',+ iteration: 1,+ maxIterations: 25,+ streamingText: '',+ thinking: '',+ toolTimeline: [+ {+ id: 'subagent:sub-detached',+ name: 'subagent:researcher',+ round: 1,+ status: 'running',+ subagent: {+ taskId: 'sub-detached',+ agentId: 'researcher',+ status: 'running',+ mode: 'async',+ toolCalls: [],+ },+ },+ ],+ startedAt: '2026-09-22T00:00:00Z',+ updatedAt: '2026-09-22T00:00:09Z',+ },+ })+ );+ const ledgerSays = (status: 'interrupted' | 'running') =>+ hydrateRuntimeFromRunLedger({+ threadId: 'thread-detached',+ runs: [+ {+ id: 'sub-detached',+ kind: 'subagent',+ parentThreadId: 'thread-detached',+ agentId: 'researcher',+ status,+ metadata: { mode: 'async' },+ startedAt: '2026-09-22T00:00:00Z',+ updatedAt: '2026-09-22T00:05:00Z',+ },+ ],+ });++ it('settles the row when the ledger reports the child orphaned by a restart', () => {+ const before = keptAlive();+ expect(before.toolTimelineByThread['thread-detached'][0].status).toBe('running');++ const rows = reducer(before, ledgerSays('interrupted')).toolTimelineByThread[+ 'thread-detached'+ ];++ expect(rows).toHaveLength(1);+ expect(rows[0].status).toBe('cancelled');+ expect(rows[0].subagent?.status).toBe('interrupted');+ });++ it('leaves the row running while the ledger says the child is still alive', () => {+ const rows = reducer(keptAlive(), ledgerSays('running')).toolTimelineByThread[+ 'thread-detached'+ ];++ expect(rows).toHaveLength(1);+ expect(rows[0].status).toBe('running');+ });+ });+it('maps durable run ledger status, kind, and optional metadata into timeline rows', () => {const next = reducer(undefined,diff --git a/app/src/store/chatRuntimeSlice.ts b/app/src/store/chatRuntimeSlice.tsindex 70a95575d9..63ea6d3e4f 100644--- a/app/src/store/chatRuntimeSlice.ts+++ b/app/src/store/chatRuntimeSlice.ts@@ -2368,7 +2368,32 @@ const chatRuntimeSlice = createSlice({// get a stable, monotonically increasing `seq` for sorting.const seq = state.toolTimelineSeqByThread[threadId] ?? 0;const entry = timelineEntryFromRun(run, seq);- if (!entry || byId.has(entry.id) || liveTaskIds.has(run.id)) continue;+ if (liveTaskIds.has(run.id)) {+ // A detached `async` row is kept `running` past its parent's+ // `completed` snapshot (see `settleOrphanedTimelineEntry`), which+ // is only truthful while the child is alive. If the core died+ // first, no `subagent_completed` is ever coming, and the snapshot+ // stays `completed` — so without this the row would read+ // "Running" forever. The ledger is the independent authority on+ // the child: startup stamps orphaned runs `interrupted`+ // (`interrupt_orphaned_agent_runs`). Let a terminal ledger status+ // settle a row that is still shown running.+ const live = existing.find(e => e.subagent?.taskId === run.id);+ const settled = timelineStatusFromRun(run.status);+ if (+ live?.status === 'running' &&+ live.subagent?.mode === 'async' &&+ settled !== 'running'+ ) {+ byId.set(live.id, {+ ...live,+ status: settled,+ subagent: live.subagent && { ...live.subagent, status: run.status },+ });+ }+ continue;+ }+ if (!entry || byId.has(entry.id)) continue;state.toolTimelineSeqByThread[threadId] = seq + 1;byId.set(entry.id, entry);}