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(web_chat): return typed errors from start_chat
Steven Enamakelac18a157f08f
diff --git a/app/src/components/assistant-ui/elements/background-inbox.tsx b/app/src/components/assistant-ui/elements/background-inbox.tsxnew file mode 100644index 0000000000..ad6b2d7a49--- /dev/null+++ b/app/src/components/assistant-ui/elements/background-inbox.tsx@@ -0,0 +1,124 @@+'use client';++/**+ * Vendored from the assistant-ui `elements-background-inbox` registry item+ * (https://r.assistant-ui.com/styles/base-nova/elements-background-inbox.json).+ * Changes from upstream:+ * - `cn` import path (`@/components/assistant-ui/lib/utils`).+ * - The hard-coded "Running elsewhere" / "{n} ready" / "{n} in flight" copy+ * is now a `strings` prop (English defaults matching upstream) so the host+ * can supply `useT()`-sourced copy — see `aui/BackgroundInboxCard.tsx`.+ */+import type { ComponentProps } from 'react';+import { CheckIcon, Loader2Icon, XIcon } from 'lucide-react';++import { cn } from '@/components/assistant-ui/lib/utils';++import { mono, paper } from './surfaces';++export type BackgroundState = 'running' | 'ready' | 'failed';++export interface BackgroundRun {+ id: string;+ title: string;+ state: BackgroundState;+ elapsed: string;+ summary?: string;+}++/** English defaults for the inbox header; override via the `strings` prop. */+export interface BackgroundInboxStrings {+ title: string;+ ready: (count: number) => string;+ inFlight: (count: number) => string;+}++const DEFAULT_STRINGS: BackgroundInboxStrings = {+ title: 'Running elsewhere',+ ready: count => `${count} ready`,+ inFlight: count => `${count} in flight`,+};++export function BackgroundInbox({+ runs,+ onCollect,+ strings = DEFAULT_STRINGS,+ className,+ ...props+}: Omit<ComponentProps<'div'>, 'children' | 'runs' | 'onCollect'> & {+ runs: readonly BackgroundRun[];+ onCollect?: (id: string) => void;+ strings?: BackgroundInboxStrings;+}) {+ const ready = runs.filter(run => run.state === 'ready').length;+ const running = runs.filter(run => run.state === 'running').length;++ return (+ <div+ data-slot="background-inbox"+ className={cn(paper, 'flex w-full max-w-sm flex-col gap-1 rounded-2xl p-3', className)}+ {...props}>+ <div className="flex items-baseline justify-between px-1 pb-1">+ <span className="text-[13.5px] font-medium">{strings.title}</span>+ <span+ className={cn(+ mono,+ 'tabular-nums',+ ready > 0 ? 'text-blue-600 dark:text-blue-400' : 'text-foreground/35'+ )}>+ {ready > 0 ? strings.ready(ready) : strings.inFlight(running)}+ </span>+ </div>++ {runs.map(run => {+ const rowClassName = cn(+ 'flex items-center gap-2.5 rounded-xl px-1.5 py-2 text-start transition-colors',+ run.state === 'running' ? 'cursor-default' : onCollect ? 'hover:bg-foreground/[0.04]' : undefined+ );+ const content = (+ <>+ <span className="flex size-3.5 shrink-0 items-center justify-center">+ {run.state === 'running' ? (+ <Loader2Icon className="text-foreground/30 size-3 animate-spin motion-reduce:animate-none" />+ ) : run.state === 'failed' ? (+ <XIcon className="size-3 text-red-500" />+ ) : (+ <CheckIcon className="size-3 text-emerald-500" />+ )}+ </span>++ <span className="flex min-w-0 flex-1 flex-col gap-0.5">+ <span+ className={cn(+ 'truncate text-[13px]',+ run.state === 'running' ? 'text-foreground/50' : 'text-foreground/90'+ )}>+ {run.title}+ </span>+ {run.summary && (+ <span className={cn(mono, 'text-foreground/30 truncate')}>{run.summary}</span>+ )}+ </span>++ <span className={cn(mono, 'text-foreground/25 shrink-0 tabular-nums')}>{run.elapsed}</span>+ </>+ );++ return onCollect ? (+ <button+ key={run.id}+ type="button"+ disabled={run.state === 'running'}+ onClick={() => onCollect(run.id)}+ className={rowClassName}>+ {content}+ </button>+ ) : (+ <div key={run.id} className={rowClassName}>+ {content}+ </div>+ );+ })}+ </div>+ );+}diff --git a/crates/openhuman-core/src/web_chat/ops/start_chat.rs b/crates/openhuman-core/src/web_chat/ops/start_chat.rsindex 20911bd81e..18f1634df1 100644--- a/crates/openhuman-core/src/web_chat/ops/start_chat.rs+++ b/crates/openhuman-core/src/web_chat/ops/start_chat.rs@@ -101,13 +101,13 @@ pub async fn start_chat(let message = message.trim().to_string();if client_id.is_empty() {- return Err("client_id is required".to_string());+ return Err(StartChatError::Other("client_id is required".to_string()));}if thread_id.is_empty() {- return Err("thread_id is required".to_string());+ return Err(StartChatError::Other("thread_id is required".to_string()));}if message.is_empty() {- return Err("message is required".to_string());+ return Err(StartChatError::Other("message is required".to_string()));}// [pdf/image-attach fix] Process attachments at ingress, BEFORE the message is@@ -267,7 +267,7 @@ pub async fn start_chat(log::info!("[web-channel] prompt blocked by a configured hook thread_id={thread_id}: {reason}");- return Err(reason);+ return Err(StartChatError::Other(reason));}}