Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(conversations): restore background process selector for conversation list

Steven Enamakel5826bd9d5d42
diff --git a/app/src/features/conversations/selectors/backgroundProcesses.ts b/app/src/features/conversations/selectors/backgroundProcesses.ts
new file mode 100644
index 0000000000..414fe0d9af
--- /dev/null
+++ b/app/src/features/conversations/selectors/backgroundProcesses.ts
@@ -0,0 +1,53 @@
+import type { SubagentActivity, ToolTimelineEntry, ToolTimelineEntryStatus } from '../../../store/chatRuntimeSlice';
+
+/**
+ * A background process = a *detached* sub-agent spawned with
+ * `spawn_async_subagent` (a fire-and-forget tokio task that keeps running after
+ * the parent turn returns). The backend marks these with `mode: "async"` on the
+ * `SubagentSpawned` event (every blocking spawn emits `mode: "typed"`), and the
+ * frontend carries it through on {@link SubagentActivity.mode}. So the whole
+ * "is this truly in the background?" question reduces to `mode === 'async'`.
+ *
+ * Moved out of the (now-deleted) `BackgroundProcessesPanel.tsx` when that
+ * panel was replaced by the vendored `BackgroundInbox` element
+ * (`aui/BackgroundInboxCard.tsx`) — this selector and its `BackgroundProcess`
+ * type are unrelated to any one host component.
+ */
+export interface BackgroundProcess {
+ taskId: string;
+ name: string;
+ goal: string;
+ status: ToolTimelineEntryStatus;
+ toolCount: number;
+ iterations?: number;
+}
+
+const subagentName = (s: SubagentActivity): string =>
+ (s.displayName && s.displayName.trim()) || s.agentId || 'sub-agent';
+
+/**
+ * Pure selector: the detached background sub-agents spawned in a thread,
+ * newest-relevant first, deduped by spawn `taskId`. Driven off the same tool
+ * timeline the inline rows use, so a process opened here resolves to the
+ * exact same entry in the Agent Process Source panel.
+ */
+export function selectBackgroundProcesses(timeline: ToolTimelineEntry[]): BackgroundProcess[] {
+ const seen = new Set<string>();
+ const out: BackgroundProcess[] = [];
+ for (const entry of timeline) {
+ const sub = entry.subagent;
+ if (!sub || sub.mode !== 'async') continue;
+ if (seen.has(sub.taskId)) continue;
+ seen.add(sub.taskId);
+ out.push({
+ taskId: sub.taskId,
+ name: subagentName(sub),
+ goal: (sub.prompt ?? '').trim(),
+ status: entry.status,
+ toolCount: sub.toolCalls?.length ?? 0,
+ iterations: sub.iterations,
+ });
+ }
+ // Running first, so live work stays at the top of the list.
+ return out.sort((a, b) => Number(b.status === 'running') - Number(a.status === 'running'));
+}