fix(mobile): fold subagent lifecycle rows into one batch per spawn #10211
Mergedjuliusmarmingemerged 2 commits into
t3code/mobile-work-row-expand-only-with-extra fromrefs/pull/10211/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/mobile/src/lib/threadActivity.ts line 749Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -604,4 +712,14 @@604712 entry.sourceActivityKind === "task.completed" ||605713 entry.sourceActivityKind === "task.updated");606714 if (isTaskRow && entry.taskId !== undefined) {607- const existingIndex = taskRowIndex.get(entry.taskId);715+ if (entry.isBackgroundTask) {716+ const existingIndex = taskRowIndex.get(entry.taskId);717+ if (existingIndex !== undefined) {718+ collapsed[existingIndex] = mergeDerivedWorkLogEntries(collapsed[existingIndex]!, entry);719+ continue;720+ }721+ taskRowIndex.set(entry.taskId, collapsed.length);722+ collapsed.push(entry);723+ continue;724+ }725+ const groupKey = spawnGroupByTaskId.get(entry.taskId) ?? agentSpawnGroupKey(entry);apps/mobile/src/lib/threadActivity.ts line 671Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -591,0 +627,21 @@627+}628+629+/**630+ * The batch row keeps the group's anchor identity (id, createdAt, turnId,631+ * label) so it renders where the run launched instead of drifting to the632+ * newest progress tick, and gains each member's latest lifecycle state.633+ */634+function agentSpawnRow(635+ anchor: DerivedWorkLogEntry,636+ workflowId: string | null,637+ agentTaskIds: ReadonlyArray<string>,638+ agents: NonNullable<WorkLogEntry["agentSpawn"]>["agents"],639+): DerivedWorkLogEntry {640+ const agentSpawn = { workflowId, agentTaskIds, agents };641+ // The batch row has no detail of its own: its body lists the members.642+ const { detail: _detail, ...anchorWithoutDetail } = anchor;643+ return {644+ ...anchorWithoutDetail,645+ // The row's own lifecycle is the batch's: live while any member is, then646+ // the worst terminal state, so the group summary and shimmer follow it.647+ toolLifecycleStatus: agentSpawnLifecycleStatus(agents),apps/mobile/src/lib/threadActivity.ts line 712Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -591,0 +668,21 @@668+ const taskId = entry.taskId ?? "";669+ const memberIndex = spawn.agentTaskIds.indexOf(taskId);670+ if (memberIndex === -1) {671+ return agentSpawnRow(672+ existing,673+ spawn.workflowId,674+ [...spawn.agentTaskIds, taskId],675+ [...spawn.agents, agentSpawnMember(entry)],676+ );677+ }678+ const agents = spawn.agents.map((agent, index) =>679+ index === memberIndex ? agentSpawnMember(entry, agent) : agent,680+ );681+ return agentSpawnRow(existing, spawn.workflowId, spawn.agentTaskIds, agents);682+}683+684+function agentSpawnLifecycleStatus(685+ agents: NonNullable<WorkLogEntry["agentSpawn"]>["agents"],686+): WorkLogToolLifecycleStatus {687+ const statuses = agents.map((agent) => agent.status);688+ if (statuses.some((status) => status === undefined || status === "inProgress")) {
juliusmarminge merged this579a775
juliusmarminge closed this
Sign in to join this conversation.

Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Baseline: unavailable · PR result:
a83379d· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.