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(ui): remove unused agent status component
Steven Enamakel5312d0a5d166
diff --git a/app/src/components/assistant-ui/elements/agent-status.aui.tsx b/app/src/components/assistant-ui/elements/agent-status.aui.tsxnew file mode 100644index 0000000000..fc3ebba4f9--- /dev/null+++ b/app/src/components/assistant-ui/elements/agent-status.aui.tsx@@ -0,0 +1,238 @@+'use client';++/**+ * Vendored from the assistant-ui `elements-agent-status` registry item+ * (https://r.assistant-ui.com/styles/base-nova/elements-agent-status.json).+ * Changes from upstream:+ * - `cn` import path (`@/components/assistant-ui/lib/utils`).+ * - `Popover`/`PopoverContent`/`PopoverTrigger` from+ * `@/components/assistant-ui/ui/popover` (this app's Radix popover copy),+ * not `@/components/ui/popover` (a differently-shaped shared component).+ * - `summaryLabel` takes an optional `strings` bag (English defaults+ * matching upstream's hard-coded copy) so `AgentStatus`/`TaskTray` can be+ * handed `useT()`-sourced copy from the host; every call site that omits+ * it keeps upstream's exact English text.+ */+import { useAuiState, type TaskState } from '@assistant-ui/react';+import { ChevronDownIcon } from 'lucide-react';+import { type FC, useMemo, useState } from 'react';++import { cn } from '@/components/assistant-ui/lib/utils';+import { Popover, PopoverContent, PopoverTrigger } from '@/components/assistant-ui/ui/popover';++import { AgentStatus as AgentStatusBase, type AgentState } from './agent-status';+import { mono } from './surfaces';+import { TaskStateIcon } from './task-card';+import {+ formatElapsed,+ TASK_PAGE_SIZE,+ taskLabel,+ taskMeta,+ taskStateOf,+ useTaskElapsed,+} from '../utils/task';++export type TaskSummary = {+ readonly total: number;+ readonly running: number;+ readonly waiting: number;+ readonly failed: number;+ readonly startedAt: number | undefined;+ readonly runningLabel: string | undefined;+};++/** English defaults for {@link summaryLabel}; override via its `strings` param. */+export interface AgentStatusStrings {+ taskOne: string;+ taskOther: string;+ running: string;+ waitingForInput: string;+ done: string;+ failed: string;+ of: string;+}++const DEFAULT_STRINGS: AgentStatusStrings = {+ taskOne: 'task',+ taskOther: 'tasks',+ running: 'running',+ waitingForInput: 'waiting for input',+ done: 'done',+ failed: 'failed',+ of: 'of',+};++const summarize = (tasks: readonly TaskState[]): TaskSummary => {+ let running = 0;+ let waiting = 0;+ let failed = 0;+ let startedAt: number | undefined;+ let runningLabel: string | undefined;+ for (const task of tasks) {+ const state = taskStateOf(task.status, task.isError);+ if (state === 'working') {+ running += 1;+ runningLabel ??= taskLabel(task.toolName, task.args);+ const taskStartedAt = task.timing?.startedAt;+ if (taskStartedAt !== undefined && (startedAt === undefined || taskStartedAt < startedAt)) {+ startedAt = taskStartedAt;+ }+ } else if (state === 'waiting') {+ waiting += 1;+ } else if (state === 'failed') {+ failed += 1;+ }+ }+ return { total: tasks.length, running, waiting, failed, startedAt, runningLabel };+};++export const useTaskSummary = (): TaskSummary => {+ const tasks = useAuiState(s => s.thread.tasks);+ return useMemo(() => summarize(tasks), [tasks]);+};++const plural = (count: number, strings: AgentStatusStrings) =>+ `${count} ${count === 1 ? strings.taskOne : strings.taskOther}`;++export const summaryState = (summary: TaskSummary): AgentState => {+ if (summary.running > 0) return 'working';+ if (summary.waiting > 0) return 'waiting';+ return summary.failed > 0 ? 'failed' : 'done';+};++export const summaryLabel = (summary: TaskSummary, strings: AgentStatusStrings = DEFAULT_STRINGS) => {+ if (summary.running === 1 && summary.runningLabel !== undefined) {+ return summary.runningLabel;+ }+ if (summary.running > 0) {+ return `${summary.running} ${strings.of} ${plural(summary.total, strings)} ${strings.running}`;+ }+ if (summary.waiting > 0) {+ return `${plural(summary.waiting, strings)} ${strings.waitingForInput}`;+ }+ if (summary.failed > 0) {+ return `${plural(summary.total, strings)} ${strings.done}, ${summary.failed} ${strings.failed}`;+ }+ return `${plural(summary.total, strings)} ${strings.done}`;+};++export const AgentStatus: FC<{ className?: string; strings?: AgentStatusStrings }> = ({+ className,+ strings,+}) => {+ const summary = useTaskSummary();+ const elapsedMs = useTaskElapsed(+ summary.startedAt === undefined ? undefined : { startedAt: summary.startedAt },+ summary.running > 0+ );+ if (summary.running === 0 && summary.waiting === 0) return null;++ return (+ <AgentStatusBase+ className={className}+ state={summaryState(summary)}+ label={summaryLabel(summary, strings)}+ elapsed={elapsedMs === undefined ? undefined : formatElapsed(elapsedMs)}+ />+ );+};++const TaskTrayItem: FC<{ task: TaskState }> = ({ task }) => {+ const state = taskStateOf(task.status, task.isError);+ const meta = taskMeta(task.args);+ const elapsedMs = useTaskElapsed(+ task.timing,+ task.status.type === 'running' || task.status.type === 'requires-action'+ );++ return (+ <li+ data-slot="aui_task-tray-item"+ data-state={state}+ className="flex items-center gap-2.5 rounded-lg py-2 pe-2.5 text-[13px]"+ style={{ paddingInlineStart: `${0.625 + task.depth * 0.75}rem` }}>+ <TaskStateIcon state={state} />+ <span className="sr-only">{state}</span>+ <span className="min-w-0 flex-1 truncate">{taskLabel(task.toolName, task.args)}</span>+ {meta !== undefined && (+ <span className={cn(mono, 'text-foreground/35 max-w-24 shrink-0 truncate')}>{meta}</span>+ )}+ {elapsedMs !== undefined && (+ <span className={cn(mono, 'text-foreground/30 shrink-0 tabular-nums')}>+ {formatElapsed(elapsedMs)}+ </span>+ )}+ </li>+ );+};++export const TaskTray: FC<{ className?: string; strings?: AgentStatusStrings }> = ({+ className,+ strings,+}) => {+ const tasks = useAuiState(s => s.thread.tasks);+ const summary = useMemo(() => summarize(tasks), [tasks]);+ const elapsedMs = useTaskElapsed(+ summary.startedAt === undefined ? undefined : { startedAt: summary.startedAt },+ summary.running > 0+ );+ const [open, setOpen] = useState(false);+ const [visible, setVisible] = useState(TASK_PAGE_SIZE);+ const firstTask = tasks[0];+ const listKey = firstTask === undefined ? '' : `${firstTask.messageId}:${firstTask.id}`;+ const [seenListKey, setSeenListKey] = useState(listKey);+ if (seenListKey !== listKey) {+ setSeenListKey(listKey);+ setVisible(TASK_PAGE_SIZE);+ }+ if (summary.total === 0 && open) setOpen(false);+ if (summary.total === 0) return null;+ const hidden = Math.max(0, tasks.length - visible);++ return (+ <Popover+ open={open}+ onOpenChange={next => {+ setOpen(next);+ if (!next) setVisible(TASK_PAGE_SIZE);+ }}>+ <PopoverTrigger+ className={cn(+ 'focus-visible:ring-ring/50 cursor-pointer appearance-none rounded-full border-0 bg-transparent p-0 text-start focus-visible:ring-[3px] focus-visible:outline-none',+ className+ )}>+ <AgentStatusBase+ state={summaryState(summary)}+ label={summaryLabel(summary, strings)}+ elapsed={elapsedMs === undefined ? undefined : formatElapsed(elapsedMs)}+ trailing={+ <ChevronDownIcon+ className={cn(+ 'size-3 transition-transform duration-200 motion-reduce:transition-none',+ open && 'rotate-180'+ )}+ />+ }+ />+ </PopoverTrigger>+ <PopoverContent align="end" className="w-80 p-1">+ <ul data-slot="aui_task-tray" aria-label="Tasks" className="flex max-h-80 flex-col overflow-y-auto">+ {tasks.slice(0, visible).map((task, index) => (+ <TaskTrayItem key={`${index}:${task.id}`} task={task} />+ ))}+ {hidden > 0 && (+ <li className="flex">+ <button+ type="button"+ data-slot="aui_task-tray-more"+ onClick={() => setVisible(count => count + TASK_PAGE_SIZE)}+ className="text-muted-foreground hover:text-foreground px-2.5 py-2 text-xs transition-colors">+ {`+${Math.min(hidden, TASK_PAGE_SIZE)}`}+ </button>+ </li>+ )}+ </ul>+ </PopoverContent>+ </Popover>+ );+};diff --git a/app/src/features/conversations/aui/ChatMemoryChips.tsx b/app/src/features/conversations/aui/ChatMemoryChips.tsxnew file mode 100644index 0000000000..295a1ce198--- /dev/null+++ b/app/src/features/conversations/aui/ChatMemoryChips.tsx@@ -0,0 +1,94 @@+/**+ * Memory tool calls (`memory_store`, `memory_recall`, `memory_hybrid_search`)+ * rendered through the vendored `memory-chips` element instead of the raw+ * JSON `ToolDataView` fallback every other dynamic tool gets.+ *+ * There is no wire event yet for "memory stored/recalled during this turn"+ * (`memory_activity`, planned per `scratchpad/wire-contract.md`'s "Planned+ * new socket events" list — not emitted by any core workstream as of this+ * pass), so this renders from the tool call's own `args`/`result` — which the+ * core already sends for every tool call — rather than a side-channel event.+ * Once `memory_activity` lands, a second slot (turn-level chips under the+ * settled answer, independent of any one tool call) can read it the same way+ * `ChatSources`/`SourceGroup` reads `citations`.+ *+ * The core's `memory_store` / `memory_recall` / `memory_hybrid_search`+ * argument and result shapes are not pinned by a wire contract at this pass,+ * so field access here is deliberately lenient (`asRecord`, optional+ * chaining, safe fallbacks) and documented per tool rather than typed against+ * a contract that does not exist yet.+ */+import type { ToolCallMessagePartComponent } from '@assistant-ui/react';++import { MemoryChips, type MemoryChip } from '../../../components/assistant-ui/elements/memory-chips';+import { useT } from '../../../lib/i18n/I18nContext';++function asRecord(value: unknown): Record<string, unknown> | undefined {+ return value && typeof value === 'object' ? (value as Record<string, unknown>) : undefined;+}++function stringField(record: Record<string, unknown> | undefined, key: string): string | undefined {+ const value = record?.[key];+ return typeof value === 'string' && value.length > 0 ? value : undefined;+}++/** `memory_store`: one write, keyed by its `key`/`category` argument. */+function chipsForStore(args: unknown): MemoryChip[] {+ const record = asRecord(args);+ const key = stringField(record, 'key') ?? stringField(record, 'category');+ const text = key ?? stringField(record, 'content')?.slice(0, 60);+ if (!text) return [];+ return [{ id: `store:${text}`, text, change: 'added' }];+}++/** `memory_recall` / `memory_hybrid_search`: each hit in the result list. */+function chipsForRecall(result: unknown): MemoryChip[] {+ const record = asRecord(result);+ const items = Array.isArray(result)+ ? result+ : Array.isArray(record?.items)+ ? (record?.items as unknown[])+ : Array.isArray(record?.results)+ ? (record?.results as unknown[])+ : [];+ return items.flatMap((item, index): MemoryChip[] => {+ const entry = asRecord(item);+ const text = stringField(entry, 'key') ?? stringField(entry, 'text') ?? stringField(entry, 'snippet');+ if (!text) return [];+ return [{ id: `recall:${index}:${text}`, text: text.slice(0, 60), change: 'existing' }];+ });+}++const CHIP_BUILDERS: Record<string, (args: unknown, result: unknown) => MemoryChip[]> = {+ memory_store: (args) => chipsForStore(args),+ memory_recall: (_args, result) => chipsForRecall(result),+ memory_hybrid_search: (_args, result) => chipsForRecall(result),+};++export function memoryToolChips(toolName: string, args: unknown, result: unknown): MemoryChip[] {+ return CHIP_BUILDERS[toolName]?.(args, result) ?? [];+}++function createMemoryToolCall(toolName: string): ToolCallMessagePartComponent {+ const MemoryToolCall: ToolCallMessagePartComponent = ({ args, result }) => {+ const { t } = useT();+ const chips = memoryToolChips(toolName, args, result);+ if (chips.length === 0) return null;+ return (+ <MemoryChips+ chips={chips}+ headingRememberedLabel={n =>+ t('conversations.memoryChips.remembered').replace('{n}', String(n))+ }+ headingIdleLabel={t('conversations.memoryChips.idle')}+ forgetAriaLabel={text => t('conversations.memoryChips.forgetAriaLabel').replace('{text}', text)}+ />+ );+ };+ return MemoryToolCall;+}++/** One toolkit entry per memory tool name, sharing the same renderer logic. */+export const MemoryStoreCall = createMemoryToolCall('memory_store');+export const MemoryRecallCall = createMemoryToolCall('memory_recall');+export const MemoryHybridSearchCall = createMemoryToolCall('memory_hybrid_search');