Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(assistant-ui): handle tool fallback and feedback dialog edge cases

Steven Enamakelc679b4f64377
diff --git a/app/src/components/assistant-ui/activity-group.tsx b/app/src/components/assistant-ui/activity-group.tsx
index e57e999f03..5e67e3aa03 100644
--- a/app/src/components/assistant-ui/activity-group.tsx
+++ b/app/src/components/assistant-ui/activity-group.tsx
@@ -1,5 +1,15 @@
'use client';
+/**
+ * Not a vendored element. A local composition of two vendored primitives —
+ * `ToolGroupRoot` / `ToolGroupTrigger` / `ToolGroupContent`
+ * (`elements/tool-group.tsx`, from the assistant-ui `tool-group` registry
+ * item) and `OpenHumanReasoningGroup` (`reasoning-group.tsx`, over the
+ * `reasoning-trace` element) — that upstream has no equivalent for: one
+ * disclosure per `MessagePrimitive.GroupedParts` run of reasoning-and-tool
+ * activity, rather than a separate collapsible per part type. See the
+ * `ActivityGroup` doc comment below for why.
+ */
import { OpenHumanReasoningGroup } from '@/components/assistant-ui/reasoning-group';
import {
ToolGroupContent,
diff --git a/app/src/components/assistant-ui/elements/feedback-dialog.tsx b/app/src/components/assistant-ui/elements/feedback-dialog.tsx
new file mode 100644
index 0000000000..d7d0d803ab
--- /dev/null
+++ b/app/src/components/assistant-ui/elements/feedback-dialog.tsx
@@ -0,0 +1,141 @@
+'use client';
+
+/**
+ * Vendored from the assistant-ui `elements-feedback-dialog` registry item
+ * (https://r.assistant-ui.com/styles/base-nova/elements-feedback-dialog.json).
+ * Changes from upstream:
+ * - `cn` import path (`@/components/assistant-ui/lib/utils`).
+ * - "What went wrong?"/"optional"/"Anything else?"/"Thanks. That helps us
+ * tune the model."/"Send feedback" are now `promptLabel`/`optionalLabel`/
+ * `notePlaceholder`/`thanksLabel`/`submitLabel` props with English
+ * defaults, for `useT()`.
+ */
+import { cn } from '@/components/assistant-ui/lib/utils';
+import { CheckIcon, ThumbsDownIcon } from 'lucide-react';
+import type { ComponentProps } from 'react';
+
+import { field, inkButton, mono, paper } from './surfaces';
+
+export function FeedbackDialog({
+ reasons,
+ selected,
+ note,
+ sent,
+ onToggleReason,
+ onNoteChange,
+ onSubmit,
+ promptLabel = 'What went wrong?',
+ optionalLabel = 'optional',
+ notePlaceholder = 'Anything else?',
+ thanksLabel = 'Thanks. That helps us tune the model.',
+ submitLabel = 'Send feedback',
+ className,
+ ...props
+}: Omit<
+ ComponentProps<'div'>,
+ 'children' | 'reasons' | 'selected' | 'note' | 'sent' | 'onToggleReason' | 'onNoteChange' | 'onSubmit'
+> & {
+ reasons: readonly string[];
+ selected: readonly string[];
+ note: string;
+ sent: boolean;
+ onToggleReason?: (reason: string) => void;
+ onNoteChange?: (note: string) => void;
+ onSubmit?: () => void;
+ promptLabel?: string;
+ optionalLabel?: string;
+ notePlaceholder?: string;
+ thanksLabel?: string;
+ submitLabel?: string;
+}) {
+ return (
+ <div
+ data-slot="feedback-dialog"
+ className={cn(
+ paper,
+ 'flex w-full max-w-sm rounded-[20px] p-4',
+ sent ? 'items-center gap-2.5 text-[13.5px]' : 'flex-col gap-3',
+ className
+ )}
+ {...props}>
+ {/*
+ Mounted whether or not the feedback has been sent, because a live region
+ only announces a change that happens after it is already in the tree; a
+ region created together with its text is the case AT is free to miss.
+ */}
+ <div
+ role="status"
+ className={sent ? 'fade-in animate-in flex items-center gap-2.5 duration-300' : 'sr-only'}>
+ {sent && (
+ <>
+ <CheckIcon className="size-4 shrink-0 text-emerald-500" />
+ {thanksLabel}
+ </>
+ )}
+ </div>
+
+ {sent ? null : (
+ <>
+ <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">
+ <ThumbsDownIcon className="size-3.5" />
+ </span>
+ <span className="text-[13.5px] font-medium">{promptLabel}</span>
+ <span className={cn(mono, 'text-foreground/30 ms-auto')}>{optionalLabel}</span>
+ </div>
+
+ <div className="flex flex-wrap gap-1.5">
+ {reasons.map((reason) => {
+ const active = selected.includes(reason);
+ const buttonClassName = cn(
+ 'rounded-full px-2.5 py-1 text-xs transition-[background-color,color,scale] duration-150',
+ onToggleReason && 'active:scale-[0.96]',
+ active
+ ? 'bg-foreground text-background'
+ : cn(field, 'text-foreground/55', onToggleReason && 'hover:text-foreground/90')
+ );
+ return onToggleReason ? (
+ <button
+ key={reason}
+ type="button"
+ aria-pressed={active}
+ onClick={() => onToggleReason(reason)}
+ className={buttonClassName}>
+ {reason}
+ </button>
+ ) : (
+ <span key={reason} role="button" aria-disabled="true" aria-pressed={active} className={buttonClassName}>
+ {reason}
+ </span>
+ );
+ })}
+ </div>
+
+ <textarea
+ value={note}
+ onChange={(event) => onNoteChange?.(event.target.value)}
+ rows={2}
+ placeholder={notePlaceholder}
+ aria-label={notePlaceholder}
+ className={cn(
+ field,
+ 'text-foreground/80 placeholder:text-foreground/30 focus-visible:ring-foreground/20 resize-none rounded-xl px-3 py-2 text-xs outline-none focus-visible:ring-1'
+ )}
+ />
+
+ {onSubmit && (
+ <button
+ type="button"
+ onClick={onSubmit}
+ className={cn(
+ inkButton,
+ 'flex h-8 items-center justify-center self-end rounded-full px-3.5 text-xs font-medium'
+ )}>
+ {submitLabel}
+ </button>
+ )}
+ </>
+ )}
+ </div>
+ );
+}
diff --git a/app/src/components/assistant-ui/elements/tool-fallback.tsx b/app/src/components/assistant-ui/elements/tool-fallback.tsx
index 6c58e57f63..1488c08ea5 100644
--- a/app/src/components/assistant-ui/elements/tool-fallback.tsx
+++ b/app/src/components/assistant-ui/elements/tool-fallback.tsx
@@ -574,6 +574,8 @@ ToolFallback.Error = ToolFallbackError;
ToolFallback.Approval = ToolFallbackApproval;
export {
+ formatUnknownValue,
+ offersInterruptAction,
ToolFallback,
ToolFallbackRoot,
ToolFallbackTrigger,
diff --git a/crates/openhuman-core/src/threads/transcript_view/types.rs b/crates/openhuman-core/src/threads/transcript_view/types.rs
index 1a2b576c65..ebb215ae69 100644
--- a/crates/openhuman-core/src/threads/transcript_view/types.rs
+++ b/crates/openhuman-core/src/threads/transcript_view/types.rs
@@ -119,6 +119,8 @@ pub enum DisplayItem {
/// frontend expands for the `ToolFailureLines` renderer.
#[serde(skip_serializing_if = "Option::is_none")]
failure: Option<ToolCallFailure>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ ts: Option<String>,
},
/// A delegated sub-agent run, with its own nested projected items.
///
@@ -148,6 +150,8 @@ pub enum DisplayItem {
status: SubagentStatus,
#[serde(skip_serializing_if = "Option::is_none")]
request_id: Option<String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ ts: Option<String>,
items: Vec<DisplayItem>,
},
/// A turn boundary — emitted when the `request_id` changes between lines.
diff --git a/crates/openhuman-core/src/tools/ops.rs b/crates/openhuman-core/src/tools/ops.rs
index 7d4c6cd9fd..438bfabdaa 100644
--- a/crates/openhuman-core/src/tools/ops.rs
+++ b/crates/openhuman-core/src/tools/ops.rs
@@ -213,7 +213,7 @@ pub fn all_tools_with_runtime(
// The session todo list (Claude/Codex style): one whole-list write per
// call, scoped to the conversation thread. `plan_exit` is the marker
// that hands a plan-mode pass off to a build-mode pass.
- Box::new(TodoTool::new()),
+ Box::new(TodoTool::new(root_config.workspace_dir.clone())),
// Interactive plan-review gate: parks the live turn on a thread-scoped
// plan the user must approve before execution (Codex/Claude plan mode).
Box::new(crate::agent::plan_review::RequestPlanReviewTool::new()),