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 missing tool fallback and timing data

Steven Enamakel836410d1715a
diff --git a/app/src/components/assistant-ui/elements/message-timing.tsx b/app/src/components/assistant-ui/elements/message-timing.tsx
new file mode 100644
index 0000000000..ae7c83de40
--- /dev/null
+++ b/app/src/components/assistant-ui/elements/message-timing.tsx
@@ -0,0 +1,51 @@
+'use client';
+
+/**
+ * Vendored from the assistant-ui `message-timing` registry item
+ * (https://r.assistant-ui.com/styles/base-nova/message-timing.json).
+ * Changes from upstream:
+ * - `cn` import path (`@/components/assistant-ui/lib/utils`).
+ */
+import { cn } from '@/components/assistant-ui/lib/utils';
+import type { ComponentProps } from 'react';
+
+import { mono } from './surfaces';
+
+export interface TimingStat {
+ label: string;
+ value: string;
+}
+
+export function MessageTiming({
+ stats,
+ streaming,
+ className,
+ ...props
+}: Omit<ComponentProps<'div'>, 'children' | 'stats' | 'streaming'> & {
+ stats: readonly TimingStat[];
+ streaming?: boolean;
+}) {
+ return (
+ <div
+ data-slot="message-timing"
+ className={cn(
+ 'fade-in animate-in flex w-full max-w-sm flex-wrap items-center gap-x-3 gap-y-1 duration-500',
+ className
+ )}
+ {...props}>
+ {stats.map((stat) => (
+ <span key={stat.label} className="flex items-baseline gap-1">
+ <span className={cn(mono, 'text-foreground/25')}>{stat.label}</span>
+ <span
+ className={cn(
+ mono,
+ 'tabular-nums',
+ streaming ? 'text-blue-500 dark:text-blue-400' : 'text-foreground/50'
+ )}>
+ {stat.value}
+ </span>
+ </span>
+ ))}
+ </div>
+ );
+}
diff --git a/app/src/components/assistant-ui/elements/tool-fallback.tsx b/app/src/components/assistant-ui/elements/tool-fallback.tsx
index 9264418d26..c3aad105fb 100644
--- a/app/src/components/assistant-ui/elements/tool-fallback.tsx
+++ b/app/src/components/assistant-ui/elements/tool-fallback.tsx
@@ -278,7 +278,7 @@ function ToolFallbackResult({
Result:
</p>
<pre className="aui-tool-fallback-result-content bg-muted/50 text-foreground/90 mt-1 rounded-md p-2.5 text-xs whitespace-pre-wrap">
- {typeof result === 'string' ? result : JSON.stringify(result, null, 2)}
+ {formatUnknownValue(result, 2)}
</pre>
</div>
);
diff --git a/crates/openhuman-core/src/core/socketio.rs b/crates/openhuman-core/src/core/socketio.rs
index 1afd75c1a0..2fcc1cdca6 100644
--- a/crates/openhuman-core/src/core/socketio.rs
+++ b/crates/openhuman-core/src/core/socketio.rs
@@ -927,6 +927,7 @@ pub fn attach_socketio() -> (socketioxide::layer::SocketIoLayer, SocketIo) {
// already holds the card.
if joined {
replay_parked_approval(&socket, thread_id);
+ replay_parked_plan_review(&socket, thread_id);
}
ack.send(&ThreadSubscribeAck { joined }).ok();
},
@@ -1692,6 +1693,7 @@ fn replay_parked_approval(socket: &SocketRef, thread_id: &str) {
return;
};
let client_id = socket.id.to_string();
+ let expires_at = row.expires_at.map(|t| t.to_rfc3339());
let mut event = crate::web_chat::approval_request_event(
&row.request_id,
&row.tool_name,
@@ -1699,6 +1701,8 @@ fn replay_parked_approval(socket: &SocketRef, thread_id: &str) {
&row.args_redacted,
thread_id,
&client_id,
+ row.tool_call_id.as_deref(),
+ expires_at.as_deref(),
);
// Replay is a fresh emit to a newly-joined socket, not a resend of the
// original event, so stamp `ts` with "now" (same clock as
@@ -1715,6 +1719,37 @@ fn replay_parked_approval(socket: &SocketRef, thread_id: &str) {
emit_with_aliases(socket, "approval_request", &payload);
}
+/// Re-send the plan review parked on `thread_id`, if any, to the socket that
+/// just joined that thread's room. Mirrors [`replay_parked_approval`] — a
+/// plan review is a live, in-memory park (no SQLite row), but it reaches the
+/// UI the same fire-and-forget way, so the same reconciliation applies.
+#[cfg(feature = "http-server")]
+fn replay_parked_plan_review(socket: &SocketRef, thread_id: &str) {
+ let Some(row) = crate::agent::plan_review::gate::global().parked_review_for_thread(thread_id)
+ else {
+ return;
+ };
+ let client_id = socket.id.to_string();
+ let mut event = crate::web_chat::plan_review_request_event(
+ &row.request_id,
+ &row.summary,
+ &row.steps,
+ thread_id,
+ &client_id,
+ row.tool_call_id.as_deref(),
+ row.expires_at.as_deref(),
+ );
+ event.ts = Some(crate::web_chat::progress_bridge::unix_epoch_ms());
+ let Ok(payload) = serde_json::to_value(&event) else {
+ return;
+ };
+ log::info!(
+ "[socketio] replaying parked plan_review_request to joining socket client_id={client_id} thread_id={thread_id} request_id={}",
+ row.request_id
+ );
+ emit_with_aliases(socket, "plan_review_request", &payload);
+}
+
#[cfg(feature = "http-server")]
fn emit_with_aliases(socket: &SocketRef, name: &str, payload: &serde_json::Value) {
let _ = socket.emit(name, payload);