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(chat): surface inference phase, round and active tool on assistant-ui
M3gA-Mindee3e54c55c36
diff --git a/app/src/components/assistant-ui/thread.tsx b/app/src/components/assistant-ui/thread.tsxindex a5f44f7931..7cc6cd488a 100644--- a/app/src/components/assistant-ui/thread.tsx+++ b/app/src/components/assistant-ui/thread.tsx@@ -100,6 +100,17 @@ export type ThreadComponents = {ComposerExtras?: ComponentType | undefined;/** Full-width host content immediately above the composer shell. */ComposerHeader?: ComponentType | undefined;+ /**+ * Host-owned progress line for the turn in flight, rendered under the last+ * message while `thread.isRunning`.+ *+ * A seam rather than a fixed widget because `isRunning` is all this file+ * knows: what the model is actually doing right now — reasoning round, active+ * tool, delegated sub-agent — lives in the host's own transport state, and+ * without somewhere to put it a long turn is an unlabelled spinner. The host+ * component returns `null` when it has nothing to say.+ */+ RunningStatus?: ComponentType | undefined;/** Host-owned attachment previews rendered above the editor. */ComposerAttachments?: ComponentType | undefined;/** Host-owned attachment picker rendered in the action row. */@@ -248,6 +259,7 @@ const ThreadRoot: FC<{<div data-slot="aui_message-group" className="mb-14 flex flex-col gap-y-6 empty:hidden"><ThreadPrimitive.Messages>{() => <ThreadMessage />}</ThreadPrimitive.Messages>+ <RunningStatusSlot /></div><ThreadPrimitive.ViewportFooter@@ -268,6 +280,22 @@ const ThreadRoot: FC<{);};+/**+ * The host's `RunningStatus`, gated on the thread actually running.+ *+ * Kept inside the message group so the line sits under the last message —+ * where the answer is about to appear — rather than pinned to the composer.+ */+const RunningStatusSlot: FC = () => {+ const { RunningStatus } = useContext(ThreadComponentsContext);+ if (!RunningStatus) return null;+ return (+ <AuiIf condition={s => s.thread.isRunning}>+ <RunningStatus />+ </AuiIf>+ );+};+const ThreadMessage: FC = () => {const { AssistantMessage: AssistantMessageComponent = AssistantMessage } =useContext(ThreadComponentsContext);diff --git a/app/src/features/conversations/components/AssistantUiChat.tsx b/app/src/features/conversations/components/AssistantUiChat.tsxindex 02e3d0da3f..f6c7021cd0 100644--- a/app/src/features/conversations/components/AssistantUiChat.tsx+++ b/app/src/features/conversations/components/AssistantUiChat.tsx@@ -14,6 +14,7 @@ import { emptySessionTokenUsage } from '../../../store/chatRuntimeSlice';import { useAppSelector } from '../../../store/hooks';import { DEFAULT_MASCOT_COLOR } from '../../../store/mascotSlice';import { MascotChipAvatar } from '../../human/Mascot/MascotChipAvatar';+import { AssistantUiInferenceStatus } from './AssistantUiInferenceStatus';import { ChatToolFallback, ChatToolGroup } from './ChatToolParts';import { contextUsageFromTokenUsage, ContextWindowPill } from './composer/ContextWindowPill';import {@@ -232,6 +233,9 @@ export function AssistantUiChat({ComposerExtras,ComposerHeader,ComposerIdleAction,+ // Phase / reasoning round / active tool for the turn in flight. Reads the+ // runtime's `extras`, so it needs no props and no dependency here.+ RunningStatus: AssistantUiInferenceStatus,onSwitchToMicCloud,...(attachmentsEnabled? {diff --git a/app/src/features/conversations/components/AssistantUiInferenceStatus.test.tsx b/app/src/features/conversations/components/AssistantUiInferenceStatus.test.tsxnew file mode 100644index 0000000000..86c79d45fc--- /dev/null+++ b/app/src/features/conversations/components/AssistantUiInferenceStatus.test.tsx@@ -0,0 +1,227 @@+/**+ * The progress line on the assistant-ui chat surface.+ *+ * `/chat` renders `AssistantUiChat`, never `ChatThreadView`, so before the+ * `RunningStatus` slot the whole of `chatRuntime.inferenceStatusByThread` —+ * reasoning round, active tool, delegated sub-agent — was dispatched by+ * `onInferenceStart` / `onIterationStart` / `onToolCall` and rendered nowhere.+ * assistant-ui knows only `thread.isRunning`, so a long turn was a spinner with+ * no round counter and no tool name.+ *+ * These tests mount the real surface (`AssistantUiChat` → its own+ * `AssistantUiRuntimeProvider` → `Thread`) over a real store, so they cover+ * both halves of the fix: the adapter publishing the status on the runtime's+ * `extras`, and the slot rendering it.+ */+import { combineReducers, configureStore } from '@reduxjs/toolkit';+import { act, render, screen } from '@testing-library/react';+import { Provider } from 'react-redux';+import { describe, expect, it, vi } from 'vitest';++import chatRuntimeReducer, {+ beginInferenceTurn,+ endInferenceTurn,+ markInferenceTurnStreaming,+ setInferenceStatusForThread,+ setToolTimelineForThread,+} from '../../../store/chatRuntimeSlice';+import mascotReducer from '../../../store/mascotSlice';+import threadReducer from '../../../store/threadSlice';+import { AssistantUiChat } from './AssistantUiChat';+import type { ThreadGoalController } from './ThreadGoalChip';++const THREAD_ID = 't-status';++function buildStore() {+ return configureStore({+ reducer: combineReducers({+ thread: threadReducer,+ chatRuntime: chatRuntimeReducer,+ mascot: mascotReducer,+ }),+ preloadedState: {+ thread: {+ threads: [+ {+ id: THREAD_ID,+ title: 'Status thread',+ chatId: null,+ isActive: true,+ messageCount: 1,+ lastMessageAt: '2026-01-01T00:00:00.000Z',+ createdAt: '2026-01-01T00:00:00.000Z',+ labels: ['general'],+ },+ ],+ selectedThreadId: THREAD_ID,+ activeThreadIds: {},+ welcomeThreadId: null,+ messagesByThreadId: {+ [THREAD_ID]: [+ {+ id: 'm-0',+ sender: 'user',+ type: 'text',+ content: 'run the suite',+ extraMetadata: {},+ createdAt: '2026-01-01T00:00:00.000Z',+ },+ ],+ },+ messages: [],+ isLoadingThreads: false,+ isLoadingMessages: false,+ messagesError: null,+ },+ } as never,+ });+}++const threadGoal: ThreadGoalController = {+ threadId: THREAD_ID,+ goal: null,+ expanded: false,+ draft: '',+ busy: false,+ setDraft: vi.fn(),+ open: vi.fn(),+ close: vi.fn(),+ toggle: vi.fn(),+ save: vi.fn(),+ complete: vi.fn(),+ pause: vi.fn(),+ resume: vi.fn(),+ clear: vi.fn(),+};++function renderChat(store: ReturnType<typeof buildStore>) {+ return render(+ <Provider store={store}>+ <AssistantUiChat+ threadGoal={threadGoal}+ model={null}+ onModelChange={vi.fn()}+ inputValue=""+ onInputValueChange={vi.fn()}+ attachments={[]}+ onAttachFiles={vi.fn()}+ onRemoveAttachment={vi.fn()}+ maxAttachments={5}+ attachmentsEnabled={false}+ attachmentInteractionBlocked={false}+ onAttachmentOnlySend={vi.fn()}+ />+ </Provider>+ );+}++/** Put the thread in the state a live turn leaves behind. */+function startTurn(store: ReturnType<typeof buildStore>) {+ act(() => {+ store.dispatch(beginInferenceTurn({ threadId: THREAD_ID }));+ store.dispatch(markInferenceTurnStreaming({ threadId: THREAD_ID }));+ });+}++describe('inference status on the assistant-ui chat surface', () => {+ it('shows the reasoning round while the model is thinking', async () => {+ const store = buildStore();+ renderChat(store);+ startTurn(store);++ // Nothing to say before the first `iteration_start`.+ expect(screen.queryByTestId('inference-status-line')).not.toBeInTheDocument();++ act(() => {+ store.dispatch(+ setInferenceStatusForThread({+ threadId: THREAD_ID,+ status: { phase: 'thinking', iteration: 3, maxIterations: 8 },+ })+ );+ });++ expect(await screen.findByTestId('inference-status-line')).toHaveTextContent('Thinking... (3)');+ });++ it('names the running tool when no timeline row carries it', async () => {+ const store = buildStore();+ renderChat(store);+ startTurn(store);++ // `tool_use` with an empty timeline: a restored snapshot, or a row that+ // settled ahead of the status. `status.activeTool` is then the only name+ // the surface has for the work in flight.+ act(() => {+ store.dispatch(+ setInferenceStatusForThread({+ threadId: THREAD_ID,+ status: { phase: 'tool_use', iteration: 2, maxIterations: 8, activeTool: 'shell' },+ })+ );+ });++ expect(await screen.findByTestId('inference-status-line')).toHaveTextContent('Running command');+ });++ it('yields to the tool part once the running row is on screen', async () => {+ const store = buildStore();+ renderChat(store);+ startTurn(store);++ act(() => {+ store.dispatch(+ setInferenceStatusForThread({+ threadId: THREAD_ID,+ status: { phase: 'thinking', iteration: 2, maxIterations: 8 },+ })+ );+ });+ expect(await screen.findByTestId('inference-status-line')).toHaveTextContent('Thinking... (2)');++ // The tool call lands: the row is projected as a tool part that already+ // names the command, so the line must not caption it a second time.+ act(() => {+ store.dispatch(+ setToolTimelineForThread({+ threadId: THREAD_ID,+ entries: [+ { id: 'tl-1', name: 'shell', round: 2, seq: 0, status: 'running', detail: 'npm test' },+ ],+ })+ );+ store.dispatch(+ setInferenceStatusForThread({+ threadId: THREAD_ID,+ status: { phase: 'tool_use', iteration: 2, maxIterations: 8, activeTool: 'shell' },+ })+ );+ });++ expect(screen.queryByTestId('inference-status-line')).not.toBeInTheDocument();+ });++ it('drops the line when the turn ends', async () => {+ const store = buildStore();+ renderChat(store);+ startTurn(store);++ act(() => {+ store.dispatch(+ setInferenceStatusForThread({+ threadId: THREAD_ID,+ status: { phase: 'thinking', iteration: 1, maxIterations: 8 },+ })+ );+ });+ expect(await screen.findByTestId('inference-status-line')).toHaveTextContent('Thinking... (1)');++ act(() => {+ store.dispatch(endInferenceTurn({ threadId: THREAD_ID }));+ });++ // `thread.isRunning` is false now, so the slot is gone even though the+ // status slice has not been cleared yet.+ expect(screen.queryByTestId('inference-status-line')).not.toBeInTheDocument();+ });+});diff --git a/app/src/features/conversations/components/AssistantUiInferenceStatus.tsx b/app/src/features/conversations/components/AssistantUiInferenceStatus.tsxnew file mode 100644index 0000000000..95ca7335ec--- /dev/null+++ b/app/src/features/conversations/components/AssistantUiInferenceStatus.tsx@@ -0,0 +1,53 @@+import { type AssistantState, useAuiState } from '@assistant-ui/react';++import { readOpenHumanThreadExtras } from '../../../providers/useOpenHumanExternalStore';+import { InferenceStatusLine } from './aui/InferenceStatusLine';++const selectThreadExtras = (state: AssistantState) => state.thread.extras;++/**+ * The "what is the model doing right now" line, on the assistant-ui surface.+ *+ * assistant-ui knows only `thread.isRunning`, so before this the whole of+ * `chatRuntime.inferenceStatusByThread` — reasoning round, active tool,+ * delegated sub-agent — stopped at `ChatThreadView`, which `/chat` no longer+ * renders. A slow turn was an unlabelled spinner.+ *+ * The status arrives on the runtime's `extras` channel+ * (`useOpenHumanExternalStore`), so it is always the status of the thread *this+ * runtime* represents; this component holds no Redux read of its own and is+ * therefore safe on a second runtime such as the Workflow Copilot's.+ *+ * Rendering is shared with the legacy surface (`InferenceStatusLine`) so the+ * mic-cloud composer and `/chat` cannot drift apart, and so is the rule for+ * when to show it: the `tool_use` / `subagent` phases only restate the running+ * row, which this surface already paints as a tool part, so the line would be+ * a duplicate caption under the card. It is kept for `thinking` — the phase+ * with no row of its own, and the one a long turn spends minutes in — and as a+ * fallback whenever the phase's row is not on screen (a restored snapshot, or+ * a row that settled ahead of the status), where `status.activeTool` /+ * `status.activeSubagent` is the only name for the work in flight.+ */+export function AssistantUiInferenceStatus() {+ const extras = readOpenHumanThreadExtras(useAuiState(selectThreadExtras));+ const status = extras?.inferenceStatus;+ if (!status) return null;++ const activeRow =+ status.phase === 'subagent'+ ? extras?.activeSubagentEntry+ : status.phase === 'tool_use'+ ? extras?.activeToolEntry+ : undefined;+ if (status.phase !== 'thinking' && activeRow) return null;++ return (+ <InferenceStatusLine+ status={status}+ activeToolEntry={extras?.activeToolEntry}+ activeSubagentEntry={extras?.activeSubagentEntry}+ />+ );+}++export default AssistantUiInferenceStatus;diff --git a/app/src/features/conversations/components/aui/InferenceStatusLine.tsx b/app/src/features/conversations/components/aui/InferenceStatusLine.tsxindex 34d008eded..a71b908e73 100644--- a/app/src/features/conversations/components/aui/InferenceStatusLine.tsx+++ b/app/src/features/conversations/components/aui/InferenceStatusLine.tsx@@ -30,7 +30,9 @@ export function InferenceStatusLine({}: InferenceStatusLineProps) {const { t } = useT();return (- <div className="flex items-center gap-2 px-1 py-1.5 text-xs text-content-muted">+ <div+ data-testid="inference-status-line"+ className="flex items-center gap-2 px-1 py-1.5 text-xs text-content-muted"><span className="inline-block w-2 h-2 rounded-full bg-primary-400 animate-pulse" /><span>{status.phase === 'thinking' &&diff --git a/app/src/providers/useOpenHumanExternalStore.ts b/app/src/providers/useOpenHumanExternalStore.tsindex 47b88c1840..4ca1347dc6 100644--- a/app/src/providers/useOpenHumanExternalStore.ts+++ b/app/src/providers/useOpenHumanExternalStore.ts@@ -3,6 +3,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react';import { mapDisplayItems } from '../features/conversations/derived/mapDisplayItems';import { threadApi } from '../services/api/threadApi';+import type { InferenceStatus, ToolTimelineEntry } from '../store/chatRuntimeSlice';import { useAppSelector } from '../store/hooks';import type { DerivedDisplayItem } from '../types/derivedTranscript';import type { ThreadMessage } from '../types/thread';@@ -23,6 +24,46 @@ const DERIVED_TRANSCRIPT_PAGE_LIMIT = 500;*/const DERIVED_TRANSCRIPT_MAX_PAGES = 20;+/**+ * Everything the assistant-ui surface needs about the *currently running* turn+ * that is not a message, a tool part or a stream delta.+ *+ * assistant-ui derives its own running state from `thread.isRunning` alone, so+ * without this channel a long turn is a bare spinner: no phase, no round+ * counter, no active tool. The socket handlers already maintain all three in+ * `chatRuntime.inferenceStatusByThread` (`onInferenceStart`, `onIterationStart`,+ * `onToolCall`); this projects that slice onto the runtime the surface reads.+ *+ * It travels on the adapter's `extras` channel rather than being read from+ * Redux by the renderer so it stays scoped to *this runtime's* thread — the+ * Workflow Copilot mounts a second runtime on a thread that is deliberately not+ * `selectedThreadId`, and a renderer-side Redux read would paint the home+ * chat's progress inside it.+ */+export type OpenHumanThreadExtras = {+ /** Live phase/round/active-tool for the running turn, or `null` when idle. */+ inferenceStatus: InferenceStatus | null;+ /** Newest running non-subagent row, used to title the `tool_use` phase. */+ activeToolEntry?: ToolTimelineEntry | undefined;+ /** Running subagent row, used to title the `subagent` phase. */+ activeSubagentEntry?: ToolTimelineEntry | undefined;+};++const EMPTY_EXTRAS: OpenHumanThreadExtras = { inferenceStatus: null };++/**+ * Narrow assistant-ui's untyped `thread.extras` back to our own shape.+ *+ * `extras` is `unknown` by contract, and a surface can be mounted on a runtime+ * that is not ours (or on none at all), so this returns `null` rather than+ * asserting.+ */+export function readOpenHumanThreadExtras(extras: unknown): OpenHumanThreadExtras | null {+ if (typeof extras !== 'object' || extras === null) return null;+ if (!('inferenceStatus' in extras)) return null;+ return extras as OpenHumanThreadExtras;+}+type CoreTranscriptProjection = {threadId: string | null;timelines: ReturnType<typeof mapDisplayItems>['timelines'];@@ -148,6 +189,11 @@ export function useOpenHumanExternalStore(threadId: string | null) {? (state.chatRuntime.processingByThread?.[threadId] ?? EMPTY_TRANSCRIPT): EMPTY_TRANSCRIPT);+ // Progress status for the running turn. Cleared by the socket layer on turn+ // end/error/cancel, so its presence is itself the "still working" signal.+ const inferenceStatus = useAppSelector(state =>+ threadId ? (state.chatRuntime.inferenceStatusByThread?.[threadId] ?? null) : null+ );const settledRevision = `${messages.at(-1)?.id ?? ''}:${messages.at(-1)?.content?.length ?? 0}:${lifecycle ?? ''}`;const coreTranscript = useCoreTranscriptProjection(threadId,@@ -175,6 +221,23 @@ export function useOpenHumanExternalStore(threadId: string | null) {[messages, streaming, isRunning, liveTimeline, liveTranscript, coreTranscript]);+ // The status line titles its `tool_use` / `subagent` phases from the matching+ // running timeline row (the same rows the surface renders as tool parts), so+ // "Running command: npm test..." reads like the row rather than the raw tool+ // id. Resolved here so the renderer stays a pure projection of `extras`.+ const extras = useMemo<OpenHumanThreadExtras>(() => {+ if (!inferenceStatus) return EMPTY_EXTRAS;+ return {+ inferenceStatus,+ activeToolEntry: [...liveTimeline]+ .reverse()+ .find(entry => entry.status === 'running' && !entry.name.startsWith('subagent:')),+ activeSubagentEntry: liveTimeline.find(+ entry => entry.status === 'running' && entry.name.startsWith('subagent:')+ ),+ };+ }, [inferenceStatus, liveTimeline]);+const onNew = useCallback(async (message: AppendMessage) => {const surface = getChatSurface(threadId);@@ -198,11 +261,12 @@ export function useOpenHumanExternalStore(threadId: string | null) {messages: runtimeMessages,isRunning,isLoading,+ extras,// Already `ThreadMessageLike`; the runtime's converter is the identity.convertMessage: (m: (typeof runtimeMessages)[number]) => m,onNew,onCancel,}),- [runtimeMessages, isRunning, isLoading, onNew, onCancel]+ [runtimeMessages, isRunning, isLoading, extras, onNew, onCancel]);}diff --git a/app/src/store/chatRuntimeSlice.ts b/app/src/store/chatRuntimeSlice.tsindex 660d930c78..5f3c7e4017 100644--- a/app/src/store/chatRuntimeSlice.ts+++ b/app/src/store/chatRuntimeSlice.ts@@ -39,7 +39,8 @@ export type ToolTimelineEntryStatus =| 'awaiting_user'| 'cancelled';-interface InferenceStatus {+/** Live progress of the running turn, as the socket handlers maintain it. */+export interface InferenceStatus {phase: 'thinking' | 'tool_use' | 'subagent';iteration: number;maxIterations: number;