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
feat(chat): show the answer on /chat, move the explanation to the rail
M3gA-Mindaaceced47a71
diff --git a/app/src/components/assistant-ui/thread.tsx b/app/src/components/assistant-ui/thread.tsxindex 3f94478e76..cff79569dc 100644--- a/app/src/components/assistant-ui/thread.tsx+++ b/app/src/components/assistant-ui/thread.tsx@@ -111,6 +111,16 @@ export type ThreadComponents = {* component returns `null` when it has nothing to say.*/RunningStatus?: ComponentType | undefined;+ /**+ * Host-owned one-line footer for a **settled** assistant message — the+ * turn's process summary and the single door to its detail.+ *+ * A seam for the same reason `RunningStatus` is one: this file knows the+ * message, not what the host recorded while producing it. The host component+ * reads the message's own metadata and returns `null` when the turn has no+ * process behind it, so a plain answer gets no footer.+ */+ TurnFooter?: ComponentType | undefined;/** Host-owned attachment previews rendered above the editor. */ComposerAttachments?: ComponentType | undefined;/** Host-owned attachment picker rendered in the action row. */@@ -733,6 +743,7 @@ const AssistantMessage: FC = () => {ToolFallback: ToolFallbackComponent = ToolFallback,ToolGroup,ReasoningGroup,+ TurnFooter,} = useContext(ThreadComponentsContext);const ACTION_BAR_PT = 'pt-1.5';@@ -865,6 +876,7 @@ const AssistantMessage: FC = () => {Stopped</span></AuiIf>+ {TurnFooter ? <TurnFooter /> : null}<BranchPicker /><AssistantActionBar /></div>diff --git a/app/src/features/conversations/Conversations.tsx b/app/src/features/conversations/Conversations.tsxindex 2e2c73177f..59bc055a7a 100644--- a/app/src/features/conversations/Conversations.tsx+++ b/app/src/features/conversations/Conversations.tsx@@ -61,6 +61,7 @@ import {} from '../../lib/attachments';import { useRegisterAction } from '../../lib/commands/useRegisterAction';import { useT } from '../../lib/i18n/I18nContext';+import type { TurnProcessTrail } from '../../providers/assistantUiMessages';import { threadApi } from '../../services/api/threadApi';import { fetchThreadTokenUsage } from '../../services/api/threadUsageApi';import {@@ -301,6 +302,11 @@ const Conversations = ({const [showBackgroundProcesses, setShowBackgroundProcesses] = useState(false);const [openSubagentTaskId, setOpenSubagentTaskId] = useState<string | null>(null);const [showProcessSource, setShowProcessSource] = useState(false);+ // One settled turn's process trail, opened from that turn's `TurnFooter`.+ // Non-null takes over the process-source panel and scopes it to that turn —+ // the palette command below still opens the whole-thread live view, which is+ // the only view it ever had.+ const [turnProcessTrail, setTurnProcessTrail] = useState<TurnProcessTrail | null>(null);// The Agent Process Source panel's only trigger is the "View full agent// process source →" link at the foot of `ToolTimelineBlock` — a legacy-panel// component. assistant-ui renders its tool calls as inline cards and has no@@ -2662,6 +2668,9 @@ const Conversations = ({// set of resolvable delegations actually changes.onOpenSubagent={setOpenSubagentTaskId}canOpenSubagent={canOpenSubagentDrawer}+ // The settled turn's one-line footer opens the process rail on THAT+ // turn's trail, which the footer carries with the click.+ onOpenTurnProcess={setTurnProcessTrail}onModelChange={(value, contextWindow) => {setComposerModelOverride(value);setComposerModelContextWindow(contextWindow ?? null);@@ -2675,15 +2684,22 @@ const Conversations = ({overlay, positioned against the viewport. */}<TranscriptOverlaysthreadId={selectedThreadId ?? null}- entries={selectedThreadToolTimeline}- transcript={selectedThreadProcessing}+ /* A turn footer's trail wins over the thread-wide live slices: those+ hold only the newest turn (`chatRuntimeSlice` rehydrates+ `processingByThread` from the single latest `TurnState` snapshot), so+ they are the wrong answer for any older turn the user clicks. */+ entries={turnProcessTrail ? [...turnProcessTrail.timeline] : selectedThreadToolTimeline}+ transcript={turnProcessTrail ? [...turnProcessTrail.transcript] : selectedThreadProcessing}backgroundProcesses={backgroundProcesses}showBackgroundProcesses={showBackgroundProcesses}onCloseBackgroundProcesses={() => setShowBackgroundProcesses(false)}openSubagentTaskId={openSubagentTaskId}onOpenSubagent={setOpenSubagentTaskId}- showProcessSource={showProcessSource}- onCloseProcessSource={() => setShowProcessSource(false)}+ showProcessSource={showProcessSource || turnProcessTrail !== null}+ onCloseProcessSource={() => {+ setShowProcessSource(false);+ setTurnProcessTrail(null);+ }}/></div>);diff --git a/app/src/features/conversations/components/AssistantUiChat.tsx b/app/src/features/conversations/components/AssistantUiChat.tsxindex e91d8b3712..c03bed02a7 100644--- a/app/src/features/conversations/components/AssistantUiChat.tsx+++ b/app/src/features/conversations/components/AssistantUiChat.tsx@@ -9,6 +9,7 @@ import type { Attachment } from '../../../lib/attachments';import { useRegisterAction } from '../../../lib/commands/useRegisterAction';import { useSlashCommands } from '../../../lib/commands/useSlashCommands';import { useT } from '../../../lib/i18n/I18nContext';+import type { TurnProcessTrail } from '../../../providers/assistantUiMessages';import { AssistantUiRuntimeProvider } from '../../../providers/AssistantUiRuntimeProvider';import { emptySessionTokenUsage } from '../../../store/chatRuntimeSlice';import { useAppSelector } from '../../../store/hooks';@@ -16,6 +17,8 @@ import { DEFAULT_MASCOT_COLOR } from '../../../store/mascotSlice';import { MascotChipAvatar } from '../../human/Mascot/MascotChipAvatar';import { AssistantUiInferenceStatus } from './AssistantUiInferenceStatus';import { SubagentDrawerHost } from './aui/subagentDrawerHost';+import { TurnFooter } from './aui/TurnFooter';+import { TurnFooterHost } from './aui/turnFooterHost';import { ChatToolFallback, ChatToolGroup } from './ChatToolParts';import { contextUsageFromTokenUsage, ContextWindowPill } from './composer/ContextWindowPill';import {@@ -81,6 +84,7 @@ export function AssistantUiChat({onSwitchToMicCloud,onOpenSubagent,canOpenSubagent,+ onOpenTurnProcess,}: {threadGoal: ThreadGoalController;model: string | null;@@ -115,6 +119,8 @@ export function AssistantUiChat({onOpenSubagent?: (taskId: string) => void;/** Whether the host's drawer can resolve that delegation; see the same file. */canOpenSubagent?: (taskId: string) => boolean;+ /** Opens the host's process rail on one settled turn's trail (`TurnFooter`). */+ onOpenTurnProcess?: (trail: TurnProcessTrail) => void;}) {const { t } = useT();const fileInputRef = useRef<HTMLInputElement>(null);@@ -260,6 +266,9 @@ export function AssistantUiChat({// 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,+ // One-line process summary under a settled answer, and the only door to+ // the reasoning / narration / tool detail that no longer renders inline.+ TurnFooter,onSwitchToMicCloud,...(attachmentsEnabled? {@@ -286,16 +295,18 @@ export function AssistantUiChat({return (<AssistantUiRuntimeProvider><ComposerTextBridge value={inputValue} onChange={onInputValueChange} />- <SubagentDrawerHost onOpenSubagent={onOpenSubagent} canOpenSubagent={canOpenSubagent}>- <Thread- components={components}- model={model}- onModelChange={onModelChange}- loadError={loadError}- onEscape={onEscape}- slashCommands={slashCommands}- />- </SubagentDrawerHost>+ <TurnFooterHost onOpenTurnProcess={onOpenTurnProcess}>+ <SubagentDrawerHost onOpenSubagent={onOpenSubagent} canOpenSubagent={canOpenSubagent}>+ <Thread+ components={components}+ model={model}+ onModelChange={onModelChange}+ loadError={loadError}+ onEscape={onEscape}+ slashCommands={slashCommands}+ />+ </SubagentDrawerHost>+ </TurnFooterHost></AssistantUiRuntimeProvider>);}diff --git a/app/src/features/conversations/components/aui/TurnFooter.test.tsx b/app/src/features/conversations/components/aui/TurnFooter.test.tsxnew file mode 100644index 0000000000..56c562f76c--- /dev/null+++ b/app/src/features/conversations/components/aui/TurnFooter.test.tsx@@ -0,0 +1,101 @@+import {+ AssistantRuntimeProvider,+ type ThreadMessageLike,+ useExternalStoreRuntime,+} from '@assistant-ui/react';+import { fireEvent, render, screen } from '@testing-library/react';+import { describe, expect, it, vi } from 'vitest';++import { Thread } from '../../../../components/assistant-ui/thread';+import type { TurnProcessTrail } from '../../../../providers/assistantUiMessages';+import { TurnFooter } from './TurnFooter';+import { TurnFooterHost } from './turnFooterHost';++const trail = (over: Partial<TurnProcessTrail> = {}): TurnProcessTrail => ({+ steps: 8,+ tools: 2,+ timeline: [],+ transcript: [],+ ...over,+});++function mount(+ metadata: Record<string, unknown> | undefined,+ onOpenTurnProcess?: (t: TurnProcessTrail) => void+) {+ const messages: ThreadMessageLike[] = [+ { role: 'user', content: [{ type: 'text', text: 'hello' }] },+ {+ role: 'assistant',+ content: [{ type: 'text', text: 'the answer' }],+ ...(metadata ? { metadata: { custom: metadata } } : {}),+ },+ ];+ function Harness() {+ const runtime = useExternalStoreRuntime({+ messages,+ isRunning: false,+ convertMessage: (m: ThreadMessageLike) => m,+ onNew: async () => {},+ });+ return (+ <AssistantRuntimeProvider runtime={runtime}>+ <TurnFooterHost onOpenTurnProcess={onOpenTurnProcess}>+ <Thread components={{ TurnFooter }} />+ </TurnFooterHost>+ </AssistantRuntimeProvider>+ );+ }+ return render(<Harness />);+}++describe('TurnFooter', () => {+ it('summarises the turn and opens the rail on that turn’s own trail', () => {+ const open = vi.fn();+ mount({ processTrail: trail() }, open);++ const footer = screen.getByTestId('turn-process-footer');+ expect(footer.textContent).toBe('8 steps · 2 tools');++ fireEvent.click(footer);+ // The trail travels with the click: the host needs no second lookup, and+ // cannot show a different turn's trail by mistake.+ expect(open).toHaveBeenCalledWith(expect.objectContaining({ steps: 8, tools: 2 }));+ });++ it('drops the tool clause for a turn that called none', () => {+ mount({ processTrail: trail({ steps: 3, tools: 0 }) }, vi.fn());+ expect(screen.getByTestId('turn-process-footer').textContent).toBe('3 steps');+ });++ it('reads as process, not answer: muted and no larger than 12px', () => {+ // The whole point of moving reasoning and narration off this surface is+ // that what is left reads as one class of thing. jsdom performs no layout,+ // so the utilities are the only observable — but they are the same two the+ // in-flight status line carries (`InferenceStatusLine`), which is the+ // invariant worth pinning: one treatment, not three greys.+ mount({ processTrail: trail() }, vi.fn());+ const classes = screen.getByTestId('turn-process-footer').className.split(/\s+/);+ expect(classes).toContain('text-content-muted');+ expect(classes).toContain('text-xs');+ });++ it('renders no door for a turn with no process behind it', () => {+ mount({ processTrail: null }, vi.fn());+ expect(screen.queryByTestId('turn-process-footer')).toBeNull();+ });++ it('renders nothing when no host is mounted to open the rail', () => {+ mount({ processTrail: trail() }, undefined);+ expect(screen.queryByTestId('turn-process-footer')).toBeNull();+ });++ it('survives a message this projection did not build', () => {+ // The footer can be mounted on the kit's own runtime or a test harness,+ // where `metadata.custom` is absent or shaped differently.+ mount(undefined, vi.fn());+ expect(screen.queryByTestId('turn-process-footer')).toBeNull();+ mount({ processTrail: { steps: 'lots' } }, vi.fn());+ expect(screen.queryByTestId('turn-process-footer')).toBeNull();+ });+});diff --git a/app/src/features/conversations/components/aui/TurnFooter.tsx b/app/src/features/conversations/components/aui/TurnFooter.tsxnew file mode 100644index 0000000000..b1fd02acf5--- /dev/null+++ b/app/src/features/conversations/components/aui/TurnFooter.tsx@@ -0,0 +1,82 @@+import { type AssistantState, useAuiState } from '@assistant-ui/react';++import { useT } from '../../../../lib/i18n/I18nContext';+import type { TurnProcessTrail } from '../../../../providers/assistantUiMessages';+import { useTurnFooterHost } from './turnFooterHost';++const selectMessageMetadata = (state: AssistantState) => state.message.metadata;++/**+ * Narrow the runtime's untyped `message.metadata.custom` back to our own shape.+ *+ * `custom` is `unknown` by contract and the footer can be mounted on a message+ * this projection did not build (the kit's own demo runtime, a test harness),+ * so this returns `null` rather than asserting.+ */+function readProcessTrail(metadata: unknown): TurnProcessTrail | null {+ if (typeof metadata !== 'object' || metadata === null) return null;+ const custom = (metadata as { custom?: unknown }).custom;+ if (typeof custom !== 'object' || custom === null) return null;+ const trail = (custom as { processTrail?: unknown }).processTrail;+ if (typeof trail !== 'object' || trail === null) return null;+ const candidate = trail as Partial<TurnProcessTrail>;+ if (typeof candidate.steps !== 'number' || typeof candidate.tools !== 'number') return null;+ return candidate as TurnProcessTrail;+}++/**+ * The settled turn's one-line process footer — `8 steps · 2 tools` — and the+ * single door to the detail behind it.+ *+ * This is the other half of moving reasoning, narration and read-only tool+ * detail off the main surface (`assistantParts`): the transcript keeps the+ * answer, and everything explaining how the agent got there is one click away+ * in the process rail rather than stacked above the answer.+ *+ * Deliberately quiet. It is process, not answer, so it takes the same+ * treatment the rail already gives its own process text — `text-content-muted`+ * at 12px — while the answer above it keeps full-contrast `text-foreground` at+ * its normal size. Same meaning, same look, on both surfaces.+ *+ * Renders nothing when the turn recorded no process (a plain answer needs no+ * door) or when no host is mounted to open the rail.+ */+export function TurnFooter() {+ const { t } = useT();+ const host = useTurnFooterHost();+ const trail = readProcessTrail(useAuiState(selectMessageMetadata));++ if (!host || !trail || trail.steps === 0) return null;++ // Existing, fully-translated keys rather than new ones: `I18nContext`'s+ // English fallback is real, but `i18n/__tests__/coverage.test.ts` requires+ // every locale to define every English key, so a new key is 14 translations+ // this change is in no position to write. The cost is that+ // `conversations.backgroundTasks.steps` has no singular form, so a one-step+ // turn reads "1 steps". Worth a proper key next time someone touches i18n.+ const stepLabel = t('conversations.backgroundTasks.steps').replace(+ '{count}',+ String(trail.steps)+ );+ const toolLabel =+ trail.tools > 0+ ? t(+ trail.tools === 1+ ? 'intelligence.agents.toolCountOne'+ : 'intelligence.agents.toolCountOther'+ ).replace('{count}', String(trail.tools))+ : null;++ return (+ <button+ type="button"+ data-testid="turn-process-footer"+ title={t('conversations.agentTaskInsights.viewProcessSource')}+ onClick={() => host.open(trail)}+ className="text-content-muted hover:text-content-secondary -ms-1 rounded px-1 text-xs transition-colors">+ {toolLabel ? `${stepLabel} · ${toolLabel}` : stepLabel}+ </button>+ );+}++export default TurnFooter;diff --git a/app/src/features/conversations/components/aui/turnFooterHost.tsx b/app/src/features/conversations/components/aui/turnFooterHost.tsxnew file mode 100644index 0000000000..b06abf60e1--- /dev/null+++ b/app/src/features/conversations/components/aui/turnFooterHost.tsx@@ -0,0 +1,46 @@+import { createContext, type ReactNode, useContext, useMemo } from 'react';++import type { TurnProcessTrail } from '../../../../providers/assistantUiMessages';++export interface TurnFooterHostValue {+ /** Opens the host's process rail on one settled turn's trail. */+ open: (trail: TurnProcessTrail) => void;+}++/**+ * The host that owns the process rail the turn footer opens.+ *+ * A context rather than a prop for the same reason+ * {@link import('./subagentDrawerHost').SubagentDrawerHost} is one: the+ * consumer is rendered by assistant-ui from *inside* the transcript, many+ * layers below anything the host passes props to, while the panel belongs to+ * `Conversations`.+ *+ * The trail travels with the click rather than being looked up by request id.+ * `useOpenHumanExternalStore` has already paged the core transcript projection+ * and split it per turn; the footer is handed those same array references on+ * the message's own metadata, so opening the rail costs no second fetch and no+ * second copy of the paging policy.+ *+ * `null` outside a provider, which is what every read-only mount wants: no+ * host, no footer.+ */+const TurnFooterHostContext = createContext<TurnFooterHostValue | null>(null);++export function TurnFooterHost({+ onOpenTurnProcess,+ children,+}: {+ onOpenTurnProcess?: ((trail: TurnProcessTrail) => void) | undefined;+ children: ReactNode;+}) {+ const value = useMemo<TurnFooterHostValue | null>(+ () => (onOpenTurnProcess ? { open: onOpenTurnProcess } : null),+ [onOpenTurnProcess]+ );+ return <TurnFooterHostContext.Provider value={value}>{children}</TurnFooterHostContext.Provider>;+}++export function useTurnFooterHost(): TurnFooterHostValue | null {+ return useContext(TurnFooterHostContext);+}diff --git a/app/src/providers/__tests__/assistantUiMessages.test.ts b/app/src/providers/__tests__/assistantUiMessages.test.tsindex 4a409046e9..c6aa781f3f 100644--- a/app/src/providers/__tests__/assistantUiMessages.test.ts+++ b/app/src/providers/__tests__/assistantUiMessages.test.ts@@ -21,8 +21,13 @@ function msg(over: Partial<ThreadMessage> = {}): ThreadMessage {};}+// `file_write` rather than a read-only name on purpose: only tools that might+// have changed something outside the app still render on the main surface+// (`toolRowStaysOnMainSurface`), so a read-only default would make every+// identity / status / naming assertion below vacuous. The visibility rule+// itself is covered separately in `main-surface tool visibility`.function tool(over: Partial<ToolTimelineEntry> = {}): ToolTimelineEntry {- return { id: 'call-1', name: 'web_search', round: 1, seq: 0, status: 'running', ...over };+ return { id: 'call-1', name: 'file_write', round: 1, seq: 0, status: 'running', ...over };}describe('toThreadMessageLike', () => {@@ -80,12 +85,20 @@ describe('streamingTailMessage', () => {});});- it('projects streamed thinking as a reasoning part before visible text', () => {+ it('keeps streamed thinking off the main surface', () => {+ // Reasoning is not dropped — it stays in `processingByThread` and in the+ // persisted transcript, and renders in the process rail. It just does not+ // belong in the answer stream; `RunningStatus` is the in-flight signal.const tail = streamingTailMessage({ requestId: 'r', content: 'answer', thinking: 'reasoning' });- expect(tail?.content).toEqual([- { type: 'reasoning', text: 'reasoning' },- { type: 'text', text: 'answer' },- ]);+ expect(tail?.content).toEqual([{ type: 'text', text: 'answer' }]);+ });++ it('mints no tail at all for a turn that has only produced thinking', () => {+ // Nothing to paint: no answer yet, no visible tool. The status line under+ // the last message is what tells the user the turn is alive.+ expect(streamingTailMessage({ requestId: 'r', content: '', thinking: 'still working' })).toBe(+ null+ );});it('keeps a running delegation on args and adds result only when complete', () => {@@ -144,13 +157,12 @@ describe('buildRuntimeMessages', () => {expect(ids).toEqual(['answer']);expect(ids).not.toContain(STREAMING_TAIL_ID);expect(projected[0]?.content).toEqual([- { type: 'reasoning', text: 'already finished thinking' },expect.objectContaining({ type: 'tool-call', toolCallId: 'stale-tool' }),{ type: 'text', text: 'hello' },]);});- it('replays a settled turn reasoning and tool calls from its request id', () => {+ it('replays a settled turn tool calls from its request id, without its prose', () => {const answer = msg({id: 'answer',sender: 'agent',@@ -170,12 +182,12 @@ describe('buildRuntimeMessages', () => {turnTranscripts: { 'req-1': transcript },})[0]?.content).toEqual([- { type: 'reasoning', text: 'need to search' },- { type: 'text', text: 'I will check the sources.' },+ // No `reasoning` part and no narration `text` part: both are process and+ // live in the rail. Only the tool row and the answer remain.expect.objectContaining({type: 'tool-call',toolCallId: 'call-1',- toolName: 'web_search',+ toolName: 'file_write',result: 'found it',}),{ type: 'text', text: 'finished' },@@ -201,7 +213,6 @@ describe('buildRuntimeMessages', () => {})[0]?.content;expect(content).toEqual([- { type: 'reasoning', text: 'delegate this research' },expect.objectContaining({ type: 'tool-call', toolCallId: 'async-tool' }),{ type: 'text', text: 'Accepted background work' },]);@@ -443,10 +454,10 @@ describe('recovered tool names', () => {id: 'a',sender: 'agent',content: 'done',- extraMetadata: { assistantUiToolNames: ['web_search', 'web_fetch'] },+ extraMetadata: { assistantUiToolNames: ['shell', 'apply_patch'] },}),[- tool({ id: 'c1', name: 'read_file', seq: 0, status: 'success' }),+ tool({ id: 'c1', name: 'file_write', seq: 0, status: 'success' }),tool({ id: 'c2', name: 'tool', seq: 1, status: 'success' }),tool({ id: 'c3', name: 'tool', seq: 2, status: 'success' }),]@@ -454,7 +465,7 @@ describe('recovered tool names', () => {const names = (converted.content as unknown as { type: string; toolName?: string }[]).filter(part => part.type === 'tool-call').map(part => part.toolName);- expect(names).toEqual(['read_file', 'web_search', 'web_fetch']);+ expect(names).toEqual(['file_write', 'shell', 'apply_patch']);});});@@ -462,6 +473,8 @@ describe('terminal tool status', () => {it('carries a failed tool status through to the rendered part', () => {// assistant-ui's tool-call part has no status field, so a failed tool that// produced output used to arrive as a bare result and read as success.+ // `web_search` is read-only, so this doubles as proof that a FAILED row+ // stays on the main surface whatever its category.const converted = toThreadMessageLike(msg({ id: 'a', sender: 'agent', content: 'done' }), [tool({ id: 'c1', name: 'web_search', seq: 0, status: 'error', result: 'boom' }),]);@@ -473,7 +486,7 @@ describe('terminal tool status', () => {it('leaves a successful tool result untouched', () => {const converted = toThreadMessageLike(msg({ id: 'a', sender: 'agent', content: 'done' }), [- tool({ id: 'c1', name: 'web_search', seq: 0, status: 'success', result: 'the answer' }),+ tool({ id: 'c1', name: 'file_write', seq: 0, status: 'success', result: 'the answer' }),]);const part = (converted.content as unknown as { type: string; result?: unknown }[]).find(candidate => candidate.type === 'tool-call'@@ -482,6 +495,96 @@ describe('terminal tool status', () => {});});+describe('main-surface tool visibility', () => {+ const partsOf = (entries: ToolTimelineEntry[]) =>+ toThreadMessageLike(msg({ id: 'a', sender: 'agent', content: 'done' }), entries)+ .content as unknown as { type: string; toolCallId?: string }[];+ const visibleIds = (entries: ToolTimelineEntry[]) =>+ partsOf(entries)+ .filter(part => part.type === 'tool-call')+ .map(part => part.toolCallId);++ it('drops a read-only step to the rail', () => {+ // Reading, listing and searching are process. The row is not lost — it is+ // still in the timeline the turn footer opens — it just does not stack+ // above the answer.+ expect(+ visibleIds([+ tool({ id: 'r1', name: 'file_read', seq: 0, status: 'success' }),+ tool({ id: 'r2', name: 'grep', seq: 1, status: 'success' }),+ tool({ id: 'r3', name: 'web_search', seq: 2, status: 'success' }),+ ])+ ).toEqual([]);+ });++ it('keeps a tool it cannot prove is read-only', () => {+ // The fail-SAFE direction, and the whole point of the allowlist: an agent+ // sending an email or spending money behind a collapsed panel is a trust+ // problem. An unmapped name lands in `other` and keeps its line.+ expect(+ visibleIds([+ tool({ id: 'w', name: 'file_write', seq: 0, status: 'success' }),+ tool({ id: 's', name: 'shell', seq: 1, status: 'success' }),+ tool({ id: 'x', name: 'send_email_to_customer', seq: 2, status: 'success' }),+ tool({ id: 'f', name: 'curl', seq: 3, status: 'success' }),+ ])+ ).toEqual(['w', 's', 'x', 'f']);+ });++ it('keeps a read-only step that failed or is waiting on the user', () => {+ // An error and a parked approval are the user's to see and to answer, so+ // they outrank the category.+ expect(+ visibleIds([+ tool({ id: 'e', name: 'file_read', seq: 0, status: 'error' }),+ tool({ id: 'a', name: 'web_search', seq: 1, status: 'awaiting_user' }),+ ])+ ).toEqual(['e', 'a']);+ });++ it('keeps a delegation row — it is the only door to the sub-agent drawer', () => {+ expect(visibleIds([tool({ id: 'd', name: 'subagent:researcher', status: 'success' })])).toEqual(+ ['d']+ );+ });+});++describe('turn process footer metadata', () => {+ const trailOf = (message: { metadata?: unknown }) =>+ (message.metadata as { custom?: { processTrail?: unknown } } | undefined)?.custom?.processTrail;++ it('counts every process step and the tool rows behind them', () => {+ const converted = toThreadMessageLike(+ msg({ id: 'a', sender: 'agent', content: 'done' }),+ [tool({ id: 'c1', name: 'file_read', status: 'success' })],+ [+ { kind: 'thinking', round: 1, seq: 0, text: 'think' },+ { kind: 'narration', round: 1, seq: 1, text: 'narrate' },+ { kind: 'toolCall', round: 1, seq: 2, callId: 'c1' },+ ]+ );+ expect(trailOf(converted)).toMatchObject({ steps: 3, tools: 1 });+ });++ it('falls back to the tool rows for a legacy snapshot with no transcript', () => {+ const converted = toThreadMessageLike(msg({ id: 'a', sender: 'agent', content: 'done' }), [+ tool({ id: 'c1', status: 'success' }),+ tool({ id: 'c2', seq: 1, status: 'success' }),+ ]);+ expect(trailOf(converted)).toMatchObject({ steps: 2, tools: 2 });+ });++ it('is null for a plain answer, so the footer renders no door', () => {+ expect(trailOf(toThreadMessageLike(msg({ id: 'a', sender: 'agent', content: 'hi' })))).toBe(+ null+ );+ });++ it('is absent on a user message', () => {+ expect(trailOf(toThreadMessageLike(msg({ id: 'u' })))).toBeUndefined();+ });+});+describe('narration merged into the final answer', () => {it('does not render narration that the final text already contains', () => {// `mergedAssistantText` prefers the longest text when it *contains* everydiff --git a/app/src/providers/assistantUiMessages.ts b/app/src/providers/assistantUiMessages.tsindex 18d1f55a11..cc50a7617f 100644--- a/app/src/providers/assistantUiMessages.ts+++ b/app/src/providers/assistantUiMessages.ts@@ -15,6 +15,7 @@ import {type ToolTimelineEntry,} from '../store/chatRuntimeSlice';import type { ThreadMessage } from '../types/thread';+import { categorizeTool, type ToolCategory } from '../utils/toolTimelineFormatting';/*** Redux -> assistant-ui message mapping.@@ -204,9 +205,71 @@ function withApproval();}+/**+ * Categories `categorizeTool` can prove are read-only. Everything else —+ * including its `other` default, which is where every unmapped tool lands — is+ * treated as potentially side-effecting.+ *+ * The direction is the point: this is a fail-SAFE allowlist, not a+ * classification. An agent sending an email or writing a file behind a+ * collapsed panel is a trust problem, not a clutter fix, so an unrecognised+ * tool keeps its line on the main surface. Being wrong here costs one extra+ * row; being wrong the other way hides a real-world action.+ *+ * `web_fetch` / `http_request` / `curl` (`fetch`) and `browser*` (`browse`) are+ * deliberately NOT here: a `curl` can POST and a browser click can buy+ * something.+ *+ * **This is a stand-in.** The core already models exactly this, precisely, as+ * `PermissionLevel` (`ReadOnly` / `Write` / `Execute` / `Dangerous`,+ * `vendor/tinyagents/vendor/tinytools/.../permission/types.rs:18-30`) on every+ * tool. It is simply not on the wire: `AgentProgress::ToolCallStarted`+ * (`src/openhuman/agent/progress.rs:31-47`) carries no permission field, so the+ * renderer cannot see it. When that field is plumbed through to+ * `ToolTimelineEntry`, delete this set and the function below and test+ * `entry.permissionLevel === 'read_only'` instead.+ */+const READ_ONLY_TOOL_CATEGORIES: ReadonlySet<ToolCategory> = new Set<ToolCategory>([+ 'read',+ 'search',+]);++/**+ * Whether this tool row still earns a line on the main `/chat` surface.+ *+ * Read-only steps (reading a file, searching memory, listing) are process, and+ * move to the rail behind the turn footer. Everything else keeps one line:+ *+ * - anything not provably read-only — the side-effect exception above;+ * - a failed call, because an error is the user's to see;+ * - a parked call, because an approval gate is the user's to answer. The part's+ * `approval` is attached later by {@link withApproval}, so the check here is+ * on the row's own `awaiting_user` status.+ *+ * A `subagent:*` delegation also stays, for two reasons that outrank tidiness:+ * its card is the only route to the sub-agent drawer on this surface (see+ * `ChatToolParts.SubagentCall`), and a delegation spends real money and can act+ * outside the app through its own tools. Its *transcript* is already behind the+ * drawer, which is where the brief wanted it; the row itself is one line.+ */+function toolRowStaysOnMainSurface(entry: ToolTimelineEntry): boolean {+ if (entry.status === 'error' || entry.status === 'awaiting_user') return true;+ if (entry.name.startsWith('subagent:')) return true;+ return !READ_ONLY_TOOL_CATEGORIES.has(categorizeTool(entry.name));+}+/*** Project one assistant message into assistant-ui parts.*+ * The main surface carries **the answer, plus anything the user must see or+ * act on** — a failed or parked tool call, and any call that might have changed+ * something outside the app. The agent's *explanation* of how it got there —+ * reasoning, narration prose, and the arguments and results of read-only steps+ * — is not dropped: it stays in Redux and in the persisted transcript, and+ * renders in the process rail reached from the turn footer+ * (`TurnFooter` → `AgentProcessSourcePanel`). Nothing here changes what is+ * stored, only what is painted.+ ** **Every tool part must have a distinct `toolCallId`.** assistant-ui keys them* as `toolCallId-${id}` and *throws* on a repeat ("Duplicate key … in* useResources"), which takes the whole thread render down rather than dropping@@ -224,48 +287,68 @@ function assistantParts(const parts: ThreadAssistantMessagePart[] = [];const timelineById = new Map(timeline.map(entry => [entry.id, entry]));const emittedToolIds = new Set<string>();+ // A row is considered once, whether or not it is painted. Both passes apply+ // the same filter, so this is belt-and-braces rather than load-bearing — it+ // is here so the two can never disagree and mint a duplicate `toolCallId`,+ // which assistant-ui throws on.+ const claim = (entry: ToolTimelineEntry): boolean => {+ if (emittedToolIds.has(entry.id)) return false;+ emittedToolIds.add(entry.id);+ return true;+ };for (const item of transcript) {- if (item.kind === 'thinking') {- if (item.text.trim().length > 0) parts.push({ type: 'reasoning', text: item.text });- continue;- }+ // `thinking` and `narration` are the turn's explanation of itself. Both+ // live on in `processingByThread` / the persisted transcript and render in+ // the rail; neither belongs in the answer stream.if (item.kind === 'toolCall') {const entry = timelineById.get(item.callId);// Guarded here too, not only in the timeline pass below: two transcript// pointers can name the same `callId` (a provider that emits tool calls// without ids writes the empty string for all of them), and both resolve// to the same timeline row.- if (entry && !emittedToolIds.has(entry.id)) {- emittedToolIds.add(entry.id);+ if (entry && claim(entry) && toolRowStaysOnMainSurface(entry)) {parts.push(toolPart(entry));}}- if (- item.kind === 'narration' &&- item.text.trim().length > 0 &&- !text.trim().includes(item.text.trim())- ) {- // Narration emitted before a tool call is assistant content in its own- // right. Keep it inline in assistant-ui's ordered part stream; the final- // answer is appended separately below. A final-round narration is the- // same streamed bytes as that answer and must not render twice —- // `includes`, not equality, because `mergedAssistantText` prefers the- // longest text when it *contains* every segment, so the duplicate is a- // substring rather than an exact match.- parts.push({ type: 'text', text: item.text });- }}for (const entry of [...timeline].sort((a, b) => a.seq - b.seq)) {- if (emittedToolIds.has(entry.id)) continue;- emittedToolIds.add(entry.id);- parts.push(toolPart(entry));+ if (!claim(entry)) continue;+ if (toolRowStaysOnMainSurface(entry)) parts.push(toolPart(entry));}if (text.length > 0) parts.push({ type: 'text', text });return parts;}+/**+ * The one-line summary the settled turn footer renders, and the trail its click+ * opens. Counted from what the store already holds — no new telemetry.+ *+ * `steps` is every process item the turn recorded (reasoning blocks, narration+ * segments and tool pointers); `tools` is the tool rows. `null` when the turn+ * recorded no process at all, which is the footer's signal to render nothing —+ * a plain answer with no trail behind it gets no door.+ */+export type TurnProcessTrail = {+ steps: number;+ tools: number;+ timeline: readonly ToolTimelineEntry[];+ transcript: readonly ProcessingTranscriptItem[];+};++function processTrail(+ timeline: readonly ToolTimelineEntry[],+ transcript: readonly ProcessingTranscriptItem[]+): TurnProcessTrail | null {+ if (timeline.length === 0 && transcript.length === 0) return null;+ // Prefer the transcript's own length when it has one: it is the ordered+ // record of what happened. A legacy snapshot with tool rows but no transcript+ // still has a step per row.+ const steps = transcript.length > 0 ? transcript.length : timeline.length;+ return { steps, tools: timeline.length, timeline, transcript };+}+function stringArray(value: unknown): string[] {return Array.isArray(value)? value.filter((item): item is string => typeof item === 'string')@@ -457,7 +540,17 @@ export function toThreadMessageLike(...(msg.sender === 'agent' && msg.extraMetadata?.stopped === true? { status: { type: 'incomplete' as const, reason: 'cancelled' as const } }: {}),- metadata: { custom: { extraMetadata: msg.extraMetadata ?? {}, sourceType: msg.type } },+ metadata: {+ custom: {+ extraMetadata: msg.extraMetadata ?? {},+ sourceType: msg.type,+ // The settled turn's one-line footer + the trail its click opens.+ // Only on the assistant side: a user message has no process behind it.+ ...(msg.sender === 'agent'+ ? { processTrail: processTrail(effectiveTimeline, transcript) }+ : {}),+ },+ },};conversionCache.set(msg, { timeline, transcript, converted });@@ -481,11 +574,11 @@ export function streamingTailMessage(): ThreadMessageLike | null {if (!approval && !streaming && timeline.length === 0 && transcript.length === 0) return null;const text = streaming?.content ?? '';+ // `streaming.thinking` is deliberately not projected: reasoning does not+ // render on the main surface any more. While the turn runs, `RunningStatus`+ // is the in-flight signal; the thinking itself is in `processingByThread`+ // and reachable through the rail. See `assistantParts`.let parts = assistantParts(text, timeline, transcript);- if (streaming?.thinking.trim()) {- const hasTranscriptThinking = transcript.some(item => item.kind === 'thinking');- if (!hasTranscriptThinking) parts.unshift({ type: 'reasoning', text: streaming.thinking });- }if (approval) parts = withApproval(parts, approval);if (parts.length === 0) return null;return {