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(conversations): handle missing transcript in map display items
Steven Enamakeld39854629be3
diff --git a/app/src/features/conversations/derived/mapDisplayItems.ts b/app/src/features/conversations/derived/mapDisplayItems.tsindex 09a371534c..5290eed84e 100644--- a/app/src/features/conversations/derived/mapDisplayItems.ts+++ b/app/src/features/conversations/derived/mapDisplayItems.ts@@ -32,6 +32,8 @@ import type {} from '../../../store/chatRuntimeSlice';import type {DerivedDisplayItem,+ DerivedSubagent,+ DerivedSubagentStatus,DerivedToolCall,DerivedToolCallStatus,DerivedToolFailure,@@ -138,7 +140,8 @@ function stringifyArgs(args: unknown): string | undefined {* projects onto the sub-agent transcript (`thinking` / `text` / `tool`) plus a* flat `toolCalls` list — exactly what the assistant-ui delegation card reads.*/-function buildSubagentActivity(id: string, items: DerivedDisplayItem[]): SubagentActivity {+function buildSubagentActivity(item: DerivedSubagent): SubagentActivity {+ const { items } = item;const toolCalls: SubagentToolCallEntry[] = [];const transcript: SubagentTranscriptItem[] = [];@@ -183,7 +186,43 @@ function buildSubagentActivity(id: string, items: DerivedDisplayItem[]): Subagen}}- return { taskId: id, agentId: id, status: 'completed', toolCalls, transcript };+ return {+ taskId: item.taskId ?? item.id,+ agentId: item.agentId ?? item.id,+ status: subagentActivityStatus(item.status),+ toolCalls,+ transcript,+ };+}++/** The delegation card's activity status for a settled sub-agent run. An+ * older core sent no status; it only ever reported finished runs. */+function subagentActivityStatus(status: DerivedSubagentStatus | undefined): string {+ switch (status) {+ case 'failed':+ return 'failed';+ case 'interrupted':+ case 'running':+ return status;+ case 'completed':+ default:+ return 'completed';+ }+}++/** The timeline row status for a settled sub-agent run — the same settling+ * rule as a tool row: a run with no terminal record is `cancelled`. */+function subagentEntryStatus(status: DerivedSubagentStatus | undefined): ToolTimelineEntryStatus {+ switch (status) {+ case 'failed':+ return 'error';+ case 'interrupted':+ case 'running':+ return 'cancelled';+ case 'completed':+ default:+ return 'success';+ }}/** Mutable per-turn accumulator. */@@ -268,6 +307,10 @@ export function mapDisplayItems(}if (!item.text.trim()) break;const turn = ensureTurn(turns, currentRequestId);+ // Reasoning is projected *before* the message of its step, so the+ // round must come from the reasoning itself — waiting for the+ // following assistantMessage filed it under the previous step.+ if (item.iteration !== undefined) turn.round = item.iteration;turn.transcript.push({kind: 'thinking',round: turn.round,@@ -283,27 +326,34 @@ export function mapDisplayItems(break;}const turn = ensureTurn(turns, currentRequestId);+ // A step with no visible narration emits no assistantMessage, so the+ // call carries its own step number.+ if (item.iteration !== undefined) turn.round = item.iteration;pushToolCall(turn, item);break;}case 'subagent': {- // Anchor to the turn the sub-agent was spawned in (core-derived- // `requestId`), not the current cursor — sub-agent items are appended- // after all root items, so the cursor is the last turn by then.+ // The core places a sub-agent right after its spawning call (or at the+ // end of its turn), so it arrives in order; its own `requestId` still+ // wins over the cursor for payloads from an older core, which+ // appended every sub-agent after all root items.const anchorRequestId = item.requestId ?? currentRequestId;if (!anchorRequestId || skip.has(anchorRequestId)) {if (anchorRequestId) skipped.add(anchorRequestId);break;}const turn = ensureTurn(turns, anchorRequestId);- const activity = buildSubagentActivity(item.id, item.items);+ const activity = buildSubagentActivity(item);+ const agentId = activity.agentId;turn.entries.push({+ // `item.id` is unique per run (task id), so two runs of one agent+ // in a turn no longer collide on `subagent:<agent>`.id: `subagent:${item.id}`,- name: `subagent:${item.id}`,+ name: `subagent:${agentId}`,round: turn.round,seq: turn.seq++,- status: 'success',+ status: subagentEntryStatus(item.status),subagent: activity,});break;diff --git a/app/src/types/derivedTranscript.ts b/app/src/types/derivedTranscript.tsindex 3df032b9af..1426c39f04 100644--- a/app/src/types/derivedTranscript.ts+++ b/app/src/types/derivedTranscript.ts@@ -62,10 +62,15 @@ export interface DerivedAssistantMessage {iteration?: number;}-/** The model's reasoning/thinking that preceded an assistant message. */+/**+ * The model's reasoning/thinking that preceded an assistant message.+ * `iteration` is the model call it belongs to — the same value as the message+ * and tool calls that follow it.+ */export interface DerivedReasoning {kind: 'reasoning';text: string;+ iteration?: number;}/**@@ -84,6 +89,8 @@ export interface DerivedToolCall {kind: 'toolCall';callId: string;name: string;+ /** The model call (1-based, within the turn) that issued this call. */+ iteration?: number;args?: unknown;result?: string;status: DerivedToolCallStatus;@@ -91,15 +98,25 @@ export interface DerivedToolCall {failure?: DerivedToolFailure;}+/** Terminal state of a projected sub-agent run (Rust `SubagentStatus`). */+export type DerivedSubagentStatus = 'completed' | 'failed' | 'interrupted' | 'running';+/**- * A delegated sub-agent run, with its own nested projected items. `requestId`- * anchors the whole trail to the parent turn that spawned it (derived core-side- * from the sub-agent's spawn timestamp vs. the parent turns' timestamp ranges);- * absent for legacy/CLI transcripts with no `requestId`.+ * A delegated sub-agent run, with its own nested projected items. The core+ * places it directly after the tool call that spawned it (`callId`) when that+ * call can be correlated, else at the end of its turn. `requestId` anchors the+ * trail to the parent turn that spawned it; absent for legacy/CLI transcripts+ * with no `requestId`. `id` is unique per run (the spawn task id when+ * recorded), never the agent name.*/export interface DerivedSubagent {kind: 'subagent';id: string;+ agentId?: string;+ taskId?: string;+ callId?: string;+ /** Absent only on payloads from a core that predates the field. */+ status?: DerivedSubagentStatus;requestId?: string;items: DerivedDisplayItem[];}