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(assistant-ui): correct data table rendering in thread view
Steven Enamakel9a2e54b079c1
diff --git a/app/src/components/assistant-ui/elements/data-table.tsx b/app/src/components/assistant-ui/elements/data-table.tsxnew file mode 100644index 0000000000..8f822b6e83--- /dev/null+++ b/app/src/components/assistant-ui/elements/data-table.tsx@@ -0,0 +1,109 @@+'use client';++/**+ * assistant-ui's data-table element: a compact card for a short list of+ * rows, each row a fixed set of columns with a leading letter avatar.+ *+ * Vendored from the assistant-ui `elements-data-table` registry item+ * (https://r.assistant-ui.com/styles/base-nova/elements-data-table.json).+ * Changes from upstream:+ * - `cn` import path.+ * - Generalized: upstream hardcodes three `ModelUsage` columns (model /+ * context / cost). Here the row shape and column set are both a `columns`+ * prop (`DataTableColumn<TRow>[]`, each an accessor + header text), so any+ * tool result that is an array of flat objects can render through this+ * element without a bespoke table. `header`/column `label`s are plain+ * strings supplied by the caller via `useT()`, not hardcoded here.+ * - `avatarKey` picks which column seeds the leading letter avatar (defaults+ * to the first column) instead of assuming a `name` field.+ */+import { cn } from '@/components/assistant-ui/lib/utils';+import { mono, paper } from '@/components/assistant-ui/elements/surfaces';+import type { ComponentProps, ReactNode } from 'react';++export interface DataTableColumn<TRow> {+ /** Stable key for the column, also used for the row's React key when no `rowKey` is given. */+ key: string;+ /** Column header text. Caller-supplied (i18n), not hardcoded. */+ header: string;+ /** Renders one row's value for this column. */+ cell: (row: TRow, index: number) => ReactNode;+ /** `true` right-aligns the column, matching the tabular-numeric columns upstream renders. */+ align?: 'start' | 'end';+}++export interface DataTableProps<TRow> extends Omit<ComponentProps<'div'>, 'children'> {+ rows: readonly TRow[];+ columns: readonly DataTableColumn<TRow>[];+ /** Bumping this replays the row entrance animation, e.g. after a refresh. */+ cycle?: number;+ /** Row identity for React's key; defaults to the row's index. */+ rowKey?: (row: TRow, index: number) => string;+ /** Which column seeds the leading letter avatar; defaults to the first column. */+ avatarKey?: string;+}++export function DataTable<TRow>({+ rows,+ columns,+ cycle = 0,+ rowKey,+ avatarKey,+ className,+ ...props+}: DataTableProps<TRow>) {+ const avatarColumn = columns.find(c => c.key === avatarKey) ?? columns[0];++ return (+ <div+ data-slot="data-table"+ className={cn(paper, 'w-full max-w-sm overflow-hidden rounded-2xl text-[13px]', className)}+ {...props}>+ <div className="flex items-center px-4 pt-3 pb-2">+ {columns.map(column => (+ <span+ key={column.key}+ className={cn(+ mono,+ 'text-foreground/35',+ column.align === 'end' ? 'w-16 text-end' : 'flex-1'+ )}>+ {column.header}+ </span>+ ))}+ </div>+ <div className="bg-foreground/[0.06] mx-4 h-px" />+ <div key={cycle}>+ {rows.map((row, index) => {+ const key = rowKey?.(row, index) ?? String(index);+ const avatarValue = avatarColumn ? avatarColumn.cell(row, index) : null;+ const avatarLetter =+ typeof avatarValue === 'string' && avatarValue.length > 0+ ? avatarValue[0]!.toUpperCase()+ : '·';++ return (+ <div+ key={key}+ className="fade-in slide-in-from-bottom-1 animate-in fill-mode-both hover:bg-foreground/[0.03] flex items-center gap-2.5 px-4 py-2.5 transition-colors duration-300"+ style={{ animationDelay: `${index * 80}ms` }}>+ <span className="bg-foreground/[0.06] text-foreground/45 flex size-5 shrink-0 items-center justify-center rounded-md text-[9px] font-medium">+ {avatarLetter}+ </span>+ {columns.map(column => (+ <span+ key={column.key}+ className={cn(+ column === avatarColumn ? 'text-foreground/90 truncate' : cn(mono, 'text-foreground/55 tabular-nums'),+ column.align === 'end' ? 'w-16 text-end' : 'flex-1'+ )}>+ {column.cell(row, index)}+ </span>+ ))}+ </div>+ );+ })}+ </div>+ </div>+ );+}diff --git a/app/src/components/assistant-ui/thread.tsx b/app/src/components/assistant-ui/thread.tsxindex 32a9ee5a80..ded863f15c 100644--- a/app/src/components/assistant-ui/thread.tsx+++ b/app/src/components/assistant-ui/thread.tsx@@ -98,8 +98,12 @@ export type ThreadComponents = {* and the answer — as a single group. Defaults to `ActivityGroup`.*/ActivityGroup?: ComponentType<PropsWithChildren<{ group: ThreadGroupPart }>> | undefined;- /** Host-owned disclosure for the URL source parts emitted after an answer. */- SourceGroup?: ComponentType<{ sources: readonly SourceUrlPart[] }> | undefined;+ /**+ * Host-owned disclosure for the source parts emitted after an answer:+ * `url` sources (web fetch/search) and `document` sources (memory+ * citations, `sourceType: 'document'`).+ */+ SourceGroup?: ComponentType<{ sources: readonly SourceItemPart[] }> | undefined;/*** Extra controls in the composer's action row, to the right of the model* selector. A seam rather than a fixed set because what belongs there is@@ -1226,21 +1230,30 @@ const MessageError: FC = () => {);};-/** A URL `source` part, the only kind this app emits. */-export type SourceUrlPart = { id: string; url: string; title?: string };+/** A URL `source` part, e.g. a web fetch/search result. */+export type SourceUrlPart = { id: string; sourceType: 'url'; url: string; title?: string };+/** A document `source` part, e.g. a memory citation. */+export type SourceDocumentPart = { id: string; sourceType: 'document'; title?: string };+/** Either kind of `source` part this app emits. */+export type SourceItemPart = SourceUrlPart | SourceDocumentPart;const selectMessageParts = (state: AssistantState) => state.message.parts;-/** Gives the host all URL source parts represented by one grouped source node. */-const SourceGroupSlot: FC<{ Component: ComponentType<{ sources: readonly SourceUrlPart[] }> }> = ({+/** Gives the host all source parts (`url` and `document`) represented by one grouped source node. */+const SourceGroupSlot: FC<{ Component: ComponentType<{ sources: readonly SourceItemPart[] }> }> = ({Component,}) => {const parts = useAuiState(selectMessageParts);- const sources = parts.flatMap(part =>- part.type === 'source' && part.sourceType === 'url'- ? [{ id: part.id, url: part.url, ...(part.title ? { title: part.title } : {}) }]- : []- );+ const sources = parts.flatMap((part): SourceItemPart[] => {+ if (part.type !== 'source') return [];+ if (part.sourceType === 'url') {+ return [{ id: part.id, sourceType: 'url', url: part.url, ...(part.title ? { title: part.title } : {}) }];+ }+ if (part.sourceType === 'document') {+ return [{ id: part.id, sourceType: 'document', ...(part.title ? { title: part.title } : {}) }];+ }+ return [];+ });return sources.length > 0 ? <Component sources={sources} /> : null;};diff --git a/app/src/providers/ChatRuntimeProvider.tsx b/app/src/providers/ChatRuntimeProvider.tsxindex 65256a012c..63e5f0c461 100644--- a/app/src/providers/ChatRuntimeProvider.tsx+++ b/app/src/providers/ChatRuntimeProvider.tsx@@ -38,6 +38,7 @@ import {clearInferenceStatusForThread,clearPendingApprovalForThread,clearPendingPlanReviewForThread,+ resolvePendingApprovalForThread,clearProcessingForThread,clearStreamingAssistantForThread,endInferenceTurn,diff --git a/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs b/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rsindex 1b95450ab6..4ec112a2af 100644--- a/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs+++ b/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs@@ -6,8 +6,8 @@ use std::sync::Arc;use tinyagents_harness::cache::InMemoryResponseCache;use tinyagents_harness::middleware::{- BudgetLimits, BudgetMiddleware, ContextCompressionMiddleware, PromptCacheGuardMiddleware,- ToolPolicyMiddleware as TaToolPolicyMiddleware,+ plan_mode_middleware, BudgetLimits, BudgetMiddleware, ContextCompressionMiddleware,+ PromptCacheGuardMiddleware, RunModeHandle, ToolPolicyMiddleware as TaToolPolicyMiddleware,};use tinyagents_harness::runtime::AgentHarness;use tinyagents_harness::steering::SteeringHandle;diff --git a/crates/openhuman-core/src/agent/tinyagents/mod.rs b/crates/openhuman-core/src/agent/tinyagents/mod.rsindex 673e66ef6c..c5623b533c 100644--- a/crates/openhuman-core/src/agent/tinyagents/mod.rs+++ b/crates/openhuman-core/src/agent/tinyagents/mod.rs@@ -31,6 +31,7 @@ pub(crate) mod journal;pub(crate) mod middleware;pub(crate) mod model;pub(crate) mod observability;+pub mod run_mode;// `pub` since issue #6014, and the inconsistency it removes is the point:// `AgentBuilder::payload_summarizer` is a **public** setter taking// `Arc<dyn PayloadSummarizer>`, so the seam was already advertised to embedders