Skip to content

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

feat(chat): wire run queue events into the chat runtime provider

Steven Enamakel7cfaad3f0b02
diff --git a/app/src/components/assistant-ui/elements/subagent-list.tsx b/app/src/components/assistant-ui/elements/subagent-list.tsx
new file mode 100644
index 0000000000..df548dc379
--- /dev/null
+++ b/app/src/components/assistant-ui/elements/subagent-list.tsx
@@ -0,0 +1,105 @@
+'use client';
+
+/**
+ * Vendored from the assistant-ui `elements-subagent-list` registry item
+ * (https://r.assistant-ui.com/styles/base-nova/elements-subagent-list.json).
+ * Changes from upstream:
+ * - `cn` import path (`@/components/assistant-ui/lib/utils`).
+ * - `../utils/range` -> `@/components/assistant-ui/utils/range`.
+ * No hard-coded user-facing copy — `agent.name`/`agent.model` are
+ * caller-supplied props, so there is nothing to route through `useT()` here.
+ */
+import type { ComponentProps } from 'react';
+import { CheckIcon, Loader2Icon } from 'lucide-react';
+
+import { cn } from '@/components/assistant-ui/lib/utils';
+import { pct } from '@/components/assistant-ui/utils/range';
+
+import { mono, paper } from './surfaces';
+
+export interface SubagentItem {
+ name: string;
+ model: string;
+}
+
+export function SubagentList({
+ agents,
+ completedCount,
+ progress,
+ showSummary,
+ summaryAgent,
+ className,
+ ...props
+}: Omit<
+ ComponentProps<'div'>,
+ 'children' | 'agents' | 'completedCount' | 'progress' | 'showSummary' | 'summaryAgent'
+> & {
+ agents: readonly SubagentItem[];
+ completedCount: number;
+ progress: readonly number[];
+ showSummary: boolean;
+ summaryAgent: SubagentItem;
+}) {
+ return (
+ <div
+ data-slot="subagent-list"
+ className={cn('flex min-h-[14.5rem] w-full max-w-xs flex-col gap-2', className)}
+ {...props}>
+ {agents.map((agent, index) => {
+ const done = index < completedCount;
+ const width = progress[index] ?? 0;
+ const percentage = pct(width, 100);
+
+ return (
+ <div key={agent.name} className={cn(paper, 'flex flex-col gap-2 rounded-2xl px-3.5 py-2.5')}>
+ <div className="flex items-center gap-2">
+ {done ? (
+ <CheckIcon className="fade-in zoom-in-90 animate-in size-3.5 shrink-0 text-emerald-500 duration-200" />
+ ) : (
+ <Loader2Icon className="text-foreground/35 size-3.5 shrink-0 animate-spin motion-reduce:animate-none" />
+ )}
+ <span className="flex-1 truncate text-[13.5px]">{agent.name}</span>
+ <span className={cn(mono, 'text-foreground/35')}>{agent.model}</span>
+ </div>
+ <span
+ role="progressbar"
+ aria-label={`${agent.name} progress`}
+ aria-valuemin={0}
+ aria-valuemax={100}
+ aria-valuenow={percentage}
+ className="bg-foreground/[0.06] h-[3px] w-full overflow-hidden rounded-full">
+ <span
+ className={cn(
+ 'block h-full rounded-full transition-[width] duration-700',
+ done ? 'bg-emerald-500/70' : 'bg-foreground/60'
+ )}
+ style={{ width: `${percentage}%` }}
+ />
+ </span>
+ </div>
+ );
+ })}
+ {showSummary && (
+ <div
+ className={cn(
+ paper,
+ 'fade-in slide-in-from-bottom-2 animate-in flex flex-col gap-2 rounded-2xl px-3.5 py-2.5 duration-300'
+ )}>
+ <div className="flex items-center gap-2">
+ <Loader2Icon className="text-foreground/35 size-3.5 shrink-0 animate-spin motion-reduce:animate-none" />
+ <span className="flex-1 truncate text-[13.5px]">{summaryAgent.name}</span>
+ <span className={cn(mono, 'text-foreground/35')}>{summaryAgent.model}</span>
+ </div>
+ <span
+ role="progressbar"
+ aria-label={`${summaryAgent.name} progress`}
+ aria-valuemin={0}
+ aria-valuemax={100}
+ className="bg-foreground/[0.06] h-[3px] w-full overflow-hidden rounded-full">
+ <span className="shimmer shimmer-bg block h-full w-full rounded-full motion-reduce:animate-none" />
+ </span>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/app/src/providers/ChatRuntimeProvider.tsx b/app/src/providers/ChatRuntimeProvider.tsx
index 716ff38ee5..b3550d40da 100644
--- a/app/src/providers/ChatRuntimeProvider.tsx
+++ b/app/src/providers/ChatRuntimeProvider.tsx
@@ -1,6 +1,7 @@
import debug from 'debug';
import { useCallback, useEffect, useRef } from 'react';
+import { useRunQueueEvents } from '../features/conversations/aui/useRunQueueEvents';
import { requestUsageRefresh } from '../hooks/usageRefresh';
import { useRefetchSnapshotOnTurnEnd } from '../hooks/useRefetchSnapshotOnTurnEnd';
import {
@@ -347,6 +348,8 @@ const ChatRuntimeProvider = ({ children }: { children: React.ReactNode }) => {
const dispatch = useAppDispatch();
const { refetch: refetchSnapshot } = useRefetchSnapshotOnTurnEnd();
const socketStatus = useAppSelector(selectSocketStatus);
+ // The core's run queue (`queue_item_*`) → `queueSlice` → the composer queue.
+ useRunQueueEvents(socketStatus === 'connected');
const toolTimelineByThread = useAppSelector(state => state.chatRuntime.toolTimelineByThread);
const inferenceStatusByThread = useAppSelector(
state => state.chatRuntime.inferenceStatusByThread
@@ -552,7 +555,7 @@ const ChatRuntimeProvider = ({ children }: { children: React.ReactNode }) => {
// user → assistant → queued follow-up. Without this the queued prompts are
// lost on reload and the dispatched answer has no visible user message.
const flushQueuedFollowups = async (threadId: string) => {
- const queued = store.getState().chatRuntime.queuedFollowupsByThread[threadId] ?? [];
+ const queued = store.getState().queue.pendingFollowupsByThread[threadId] ?? [];
// Persist sequentially so the queued prompts land in the append-log in the
// order the user queued them (concurrent dispatches would race), and
// surface failures instead of dropping them silently. The stored message