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(elicitation-form): handle missing subagent in transcript view
Steven Enamakel273fc826377b
diff --git a/app/src/components/assistant-ui/elements/elicitation-form.tsx b/app/src/components/assistant-ui/elements/elicitation-form.tsxnew file mode 100644index 0000000000..d243d258cb--- /dev/null+++ b/app/src/components/assistant-ui/elements/elicitation-form.tsx@@ -0,0 +1,211 @@+'use client';++/**+ * assistant-ui's elicitation-form element: a structured human-input request+ * (an MCP server, or a sub-agent's `ask_user_clarification`) with a+ * server/requester label, a message, a set of read-only fields, and+ * Decline / Send.+ *+ * Vendored from the assistant-ui `elements-elicitation-form` registry item+ * (https://r.assistant-ui.com/styles/base-nova/elements-elicitation-form.json).+ * Changes from upstream:+ * - `cn` import path (`@/components/assistant-ui/lib/utils`).+ * - Every user-facing label is now a prop with an English default.+ * - `acceptProps` / `declineProps` slots (same `data-analytics-id` rationale+ * as `approval-card.tsx`).+ * - `onFieldChange` slot: upstream's fields are read-only display rows; a+ * plain-text/free-form OpenHuman clarification question needs the user to+ * actually type an answer before "Send" is meaningful. When supplied, a+ * `kind: 'text'` field renders an editable input instead of a static+ * value.+ */+import type { ChangeEvent, ComponentProps } from 'react';+import { CheckIcon, PlugIcon, XIcon } from 'lucide-react';++import { cn } from '@/components/assistant-ui/lib/utils';++import { field, inkButton, mono, paper } from './surfaces';++export type ElicitationState = 'request' | 'accepted' | 'declined';++export interface ElicitationField {+ name: string;+ label: string;+ value: string;+ kind: 'text' | 'choice' | 'toggle';+ options?: readonly string[];+ required?: boolean;+}++export function ElicitationForm({+ server,+ needsInputLabel = 'needs input',+ message,+ fields,+ state,+ onAccept,+ onDecline,+ onFieldChange,+ declineLabel = 'Decline',+ sendLabel = 'Send',+ acceptedLabel = (serverName: string) => `Sent to ${serverName}`,+ declinedLabel = 'Declined',+ acceptProps,+ declineProps,+ className,+ ...props+}: Omit<+ ComponentProps<'div'>,+ | 'children'+ | 'server'+ | 'message'+ | 'fields'+ | 'state'+ | 'onAccept'+ | 'onDecline'+> & {+ server: string;+ needsInputLabel?: string;+ message: string;+ fields: readonly ElicitationField[];+ state: ElicitationState;+ onAccept?: () => void;+ onDecline?: () => void;+ /** Editable text fields when supplied; upstream fields render read-only. */+ onFieldChange?: (name: string, value: string) => void;+ declineLabel?: string;+ sendLabel?: string;+ acceptedLabel?: (server: string) => string;+ declinedLabel?: string;+ acceptProps?: ComponentProps<'button'>;+ declineProps?: ComponentProps<'button'>;+}) {+ return (+ <div+ data-slot="elicitation-form"+ className={cn(paper, 'flex w-full max-w-sm flex-col gap-3.5 rounded-[20px] p-4', className)}+ {...props}+ >+ <div className="flex items-center gap-2.5">+ <span className="bg-foreground/[0.05] text-foreground/45 flex size-7 shrink-0 items-center justify-center rounded-lg">+ <PlugIcon className="size-3.5" />+ </span>+ <span className="min-w-0 flex-1 truncate text-[13.5px] font-medium">{server}</span>+ <span className={cn(mono, 'text-foreground/30 shrink-0')}>{needsInputLabel}</span>+ </div>++ <p className="text-foreground/55 text-xs leading-relaxed">{message}</p>++ <div className="flex flex-col gap-2.5">+ {fields.map(item => (+ <div key={item.name} className="flex flex-col gap-1">+ <span className={cn(mono, 'text-foreground/35')}>+ {item.label}+ {item.required && <span className="text-foreground/25"> *</span>}+ </span>+ {item.kind === 'choice' ? (+ <div className="flex flex-wrap gap-1.5">+ {item.options?.map(option => (+ <span+ key={option}+ className={cn(+ 'rounded-full px-2.5 py-1 text-xs transition-colors',+ option === item.value+ ? 'bg-foreground text-background'+ : cn(field, 'text-foreground/55')+ )}+ >+ {option}+ </span>+ ))}+ </div>+ ) : item.kind === 'toggle' ? (+ <span className="flex items-center gap-2">+ <span+ aria-hidden+ className={cn(+ 'flex h-4 w-7 items-center rounded-full p-0.5 transition-colors duration-200',+ item.value === 'true' ? 'bg-foreground/80' : 'bg-foreground/15'+ )}+ >+ <span+ className={cn(+ 'bg-background size-3 rounded-full transition-transform duration-200 motion-reduce:transition-none',+ item.value === 'true' && 'translate-x-3'+ )}+ />+ </span>+ <span className="text-foreground/55 text-xs">+ {item.value === 'true' ? 'On' : 'Off'}+ </span>+ </span>+ ) : onFieldChange && state === 'request' ? (+ <input+ type="text"+ value={item.value}+ onChange={(e: ChangeEvent<HTMLInputElement>) =>+ onFieldChange(item.name, e.target.value)+ }+ className={cn(+ field,+ 'text-foreground/80 rounded-lg px-2.5 py-1.5 text-xs outline-none'+ )}+ />+ ) : (+ <span className={cn(field, 'text-foreground/80 rounded-lg px-2.5 py-1.5 text-xs')}>+ {item.value}+ </span>+ )}+ </div>+ ))}+ </div>++ <div className="flex h-8 items-center justify-end gap-2">+ {state === 'request' ? (+ <>+ <button+ type="button"+ onClick={onDecline}+ {...declineProps}+ className={cn(+ 'text-foreground/55 hover:bg-foreground/[0.06] hover:text-foreground/90 h-8 rounded-full px-3.5 text-xs font-medium transition-[background-color,color,scale] duration-150 active:scale-[0.96]',+ declineProps?.className+ )}+ >+ {declineLabel}+ </button>+ <button+ type="button"+ onClick={onAccept}+ {...acceptProps}+ className={cn(+ inkButton,+ 'flex h-8 items-center rounded-full px-3.5 text-xs font-medium',+ acceptProps?.className+ )}+ >+ {sendLabel}+ </button>+ </>+ ) : (+ <span+ key={state}+ className="fade-in animate-in text-foreground/55 flex items-center gap-2 text-xs duration-300"+ >+ {state === 'accepted' ? (+ <>+ <CheckIcon className="size-3.5 text-emerald-500" />+ {acceptedLabel(server)}+ </>+ ) : (+ <>+ <XIcon className="text-foreground/45 size-3.5" />+ {declinedLabel}+ </>+ )}+ </span>+ )}+ </div>+ </div>+ );+}diff --git a/crates/openhuman-core/src/threads/transcript_view/subagents.rs b/crates/openhuman-core/src/threads/transcript_view/subagents.rsindex eb90f4c253..1efa29f6c1 100644--- a/crates/openhuman-core/src/threads/transcript_view/subagents.rs+++ b/crates/openhuman-core/src/threads/transcript_view/subagents.rs@@ -74,7 +74,12 @@ pub(super) fn attach(/// Project the direct children of `parent_stem` (or of the roots, when/// `None`), recursing into their own children.-fn build_children(sub_paths: &[PathBuf], parent_stem: Option<&str>, depth: usize) -> Vec<ChildRun> {+fn build_children(+ sub_paths: &[PathBuf],+ parent_stem: Option<&str>,+ depth: usize,+ workspace_dir: Option<&Path>,+) -> Vec<ChildRun> {if depth >= MAX_SUBAGENT_DEPTH {return Vec::new();}@@ -94,7 +99,7 @@ fn build_children(sub_paths: &[PathBuf], parent_stem: Option<&str>, depth: usize_ => continue,},};- if let Some(child) = build_child(path, stem, suffix, sub_paths, depth) {+ if let Some(child) = build_child(path, stem, suffix, sub_paths, depth, workspace_dir) {children.push(child);}}@@ -108,6 +113,7 @@ fn build_child(suffix: &str,sub_paths: &[PathBuf],depth: usize,+ workspace_dir: Option<&Path>,) -> Option<ChildRun> {let display = match transcript::read_transcript_display(path) {Ok(display) => display,@@ -121,8 +127,13 @@ fn build_child(};let own_state = own_state(&display.records);let mut items = project_records(&display.records);- let grandchildren = build_children(sub_paths, Some(stem), depth + 1);- place(&mut items, grandchildren, &turn_segments(&display.records));+ let grandchildren = build_children(sub_paths, Some(stem), depth + 1, workspace_dir);+ place(+ &mut items,+ grandchildren,+ &turn_segments(&display.records),+ workspace_dir,+ );let task_id = display.meta.task_id.clone().filter(|id| !id.is_empty());let agent_id = display@@ -135,6 +146,7 @@ fn build_child(Some(ChildRun {spawn_unix: child_spawn_unix(suffix),agent_id: agent_id.clone(),+ task_id: task_id.clone(),item: DisplayItem::Subagent {id,agent_id,@@ -148,6 +160,37 @@ fn build_child(})}+/// Exact correlation: the run ledger's `AgentRunUpsert.metadata.parentCallId`+/// for this task (stamped by `progress_bridge`'s `SubagentSpawned` handling),+/// resolved to the unclaimed [`DisplayItem::ToolCall`] with that `call_id`.+///+/// Preferred over [`find_spawning_call`]'s timestamp/target-argument+/// heuristic whenever it resolves — the ledger has the actual call id, no+/// guessing required. `None` on any miss (no workspace, no task id, no+/// ledger row, no matching/unclaimed call), so callers fall back to the+/// heuristic unconditionally.+fn find_exact_spawning_call(+ items: &[DisplayItem],+ claimed: &[bool],+ task_id: Option<&str>,+ workspace_dir: Option<&Path>,+) -> Option<usize> {+ let workspace_dir = workspace_dir?;+ let task_id = task_id?;+ let run = tinyagents_session::run_ledger::get_agent_run(workspace_dir, task_id)+ .ok()+ .flatten()?;+ let parent_call_id = run.metadata.get("parentCallId")?.as_str()?;+ items.iter().enumerate().find_map(|(index, item)| match item {+ DisplayItem::ToolCall { call_id, .. }+ if !claimed[index] && call_id == parent_call_id =>+ {+ Some(index)+ }+ _ => None,+ })+}+/// What the child's own transcript says about how it ended.fn own_state(records: &[DisplayRecord]) -> OwnState {let last = records.iter().rev().find_map(|record| match record {@@ -169,7 +212,12 @@ fn own_state(records: &[DisplayRecord]) -> OwnState {/// Insert `children` into `items`, each after its correlated spawning call/// (claimed at most once), else at the end of its anchored turn.-fn place(items: &mut Vec<DisplayItem>, children: Vec<ChildRun>, segments: &[(String, i64)]) {+fn place(+ items: &mut Vec<DisplayItem>,+ children: Vec<ChildRun>,+ segments: &[(String, i64)],+ workspace_dir: Option<&Path>,+) {if children.is_empty() {return;}@@ -179,7 +227,10 @@ fn place(items: &mut Vec<DisplayItem>, children: Vec<ChildRun>, segments: &[(Strfor (order, mut child) in children.into_iter().enumerate() {let request_id = anchor_request_id(child.spawn_unix, segments);let (start, end) = turn_range(items, request_id.as_deref());- let pick = find_spawning_call(items, &claimed, start, end, child.agent_id.as_deref());+ let pick = find_exact_spawning_call(items, &claimed, child.task_id.as_deref(), workspace_dir)+ .or_else(|| {+ find_spawning_call(items, &claimed, start, end, child.agent_id.as_deref())+ });let (position, call) = match pick {Some(index) => {claimed[index] = true;