Skip to content

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

chore: files changed crates/openhuman-core/src/web_chat/event_bus.rs,app/src/components/assistant-ui

Steven Enamakelb6a33782311d
diff --git a/app/src/components/assistant-ui/elements/stopped-run.tsx b/app/src/components/assistant-ui/elements/stopped-run.tsx
new file mode 100644
index 0000000000..51641bc4ab
--- /dev/null
+++ b/app/src/components/assistant-ui/elements/stopped-run.tsx
@@ -0,0 +1,74 @@
+'use client';
+
+/**
+ * Vendored from the assistant-ui `elements-stopped-run` registry item
+ * (https://r.assistant-ui.com/styles/base-nova/elements-stopped-run.json).
+ * Changes from upstream:
+ * - `cn` import path (`@/components/assistant-ui/lib/utils`).
+ * - "Continue"/"Discard" are `continueLabel`/`discardLabel` props with
+ * English defaults, for `useT()`.
+ */
+import { cn } from '@/components/assistant-ui/lib/utils';
+import { ArrowRightIcon, SquareIcon } from 'lucide-react';
+import type { ComponentProps } from 'react';
+
+import { field, mono } from './surfaces';
+
+export function StoppedRun({
+ words,
+ reason,
+ onContinue,
+ onDiscard,
+ continueLabel = 'Continue',
+ discardLabel = 'Discard',
+ className,
+ ...props
+}: Omit<
+ ComponentProps<'div'>,
+ 'children' | 'words' | 'reason' | 'onContinue' | 'onDiscard'
+> & {
+ words: readonly string[];
+ reason: string;
+ onContinue?: () => void;
+ onDiscard?: () => void;
+ continueLabel?: string;
+ discardLabel?: string;
+}) {
+ return (
+ <div data-slot="stopped-run" className={cn('flex w-full max-w-sm flex-col gap-3', className)} {...props}>
+ <p className="text-foreground/80 text-[13.5px] leading-relaxed">
+ {words.join(' ')}
+ <span
+ aria-hidden
+ className="bg-foreground/20 ms-1 inline-block h-[1em] w-[2px] translate-y-[0.15em] rounded-full"
+ />
+ </p>
+
+ <div className="flex items-center gap-2">
+ <span
+ className={cn(
+ field,
+ mono,
+ 'text-foreground/45 inline-flex items-center gap-1.5 rounded-full px-2.5 py-1'
+ )}>
+ <SquareIcon className="size-2.5 fill-current" />
+ {reason}
+ </span>
+
+ <button
+ type="button"
+ onClick={onContinue}
+ className="text-foreground/70 hover:bg-foreground/[0.06] hover:text-foreground/95 ms-auto flex h-7 items-center gap-1 rounded-full px-2.5 text-xs font-medium transition-[background-color,color,scale] duration-150 active:scale-[0.96]">
+ {continueLabel}
+ <ArrowRightIcon className="size-3" />
+ </button>
+ <button
+ type="button"
+ onClick={onDiscard}
+ className="text-foreground/45 hover:bg-foreground/[0.06] hover:text-foreground/90 flex h-7 items-center rounded-full px-2.5 text-xs font-medium transition-[background-color,color,scale] duration-150 active:scale-[0.96]">
+ {discardLabel}
+ </button>
+ </div>
+ </div>
+ );
+}
diff --git a/crates/openhuman-core/src/web_chat/event_bus.rs b/crates/openhuman-core/src/web_chat/event_bus.rs
index a7c0fc752a..593c5e3213 100644
--- a/crates/openhuman-core/src/web_chat/event_bus.rs
+++ b/crates/openhuman-core/src/web_chat/event_bus.rs
@@ -560,17 +560,17 @@ impl EventHandler<DomainEvent> for ApprovalSurfaceSubscriber {
}
async fn handle(&self, event: &DomainEvent) {
- if let DomainEvent::ApprovalRequested {
- request_id,
- tool_name,
- action_summary,
- args_redacted,
- thread_id,
- client_id,
- ..
- } = event
- {
- match (thread_id, client_id) {
+ match event {
+ DomainEvent::ApprovalRequested {
+ request_id,
+ tool_name,
+ action_summary,
+ args_redacted,
+ thread_id,
+ client_id,
+ tool_call_id,
+ expires_at,
+ } => match (thread_id, client_id) {
(Some(thread_id), Some(client_id)) => {
log::info!(
"[web-channel] approval-surface emitting approval_request request_id={request_id} thread_id={thread_id} client_id={client_id} tool={tool_name}"
@@ -582,6 +582,8 @@ impl EventHandler<DomainEvent> for ApprovalSurfaceSubscriber {
args_redacted,
thread_id,
client_id,
+ tool_call_id.as_deref(),
+ expires_at.as_deref(),
));
}
_ => {
@@ -591,33 +593,62 @@ impl EventHandler<DomainEvent> for ApprovalSurfaceSubscriber {
client_id.is_some()
);
}
- }
- } else if let DomainEvent::PlanReviewRequested {
- request_id,
- thread_id,
- client_id,
- summary,
- steps,
- ..
- } = event
- {
- match (thread_id, client_id) {
+ },
+ DomainEvent::ApprovalDecided {
+ request_id,
+ tool_name,
+ decision,
+ thread_id,
+ client_id,
+ tool_call_id,
+ resolution,
+ } => match (thread_id, client_id) {
(Some(thread_id), Some(client_id)) => {
log::info!(
- "[web-channel] plan-review-surface emitting plan_review_request request_id={request_id} thread_id={thread_id} client_id={client_id} steps={}",
- steps.len()
+ "[web-channel] approval-surface emitting approval_decided request_id={request_id} thread_id={thread_id} client_id={client_id} tool={tool_name} decision={decision}"
);
publish_web_channel_event(WebChannelEvent {
- event: "plan_review_request".to_string(),
+ event: "approval_decided".to_string(),
client_id: client_id.clone(),
thread_id: thread_id.clone(),
request_id: request_id.clone(),
- tool_name: Some("request_plan_review".to_string()),
- message: Some(summary.clone()),
- args: Some(serde_json::json!({ "steps": steps })),
+ tool_name: Some(tool_name.clone()),
+ message: Some(decision.clone()),
+ tool_call_id: tool_call_id.clone(),
+ cancel_reason: resolution.clone(),
..Default::default()
});
}
+ _ => {
+ log::debug!(
+ "[web-channel] approval-surface received ApprovalDecided request_id={request_id} tool={tool_name} decision={decision} but thread_id/client_id absent — NOT surfacing (non-chat origin)"
+ );
+ }
+ },
+ DomainEvent::PlanReviewRequested {
+ request_id,
+ thread_id,
+ client_id,
+ summary,
+ steps,
+ tool_call_id,
+ expires_at,
+ } => match (thread_id, client_id) {
+ (Some(thread_id), Some(client_id)) => {
+ log::info!(
+ "[web-channel] plan-review-surface emitting plan_review_request request_id={request_id} thread_id={thread_id} client_id={client_id} steps={}",
+ steps.len()
+ );
+ publish_web_channel_event(plan_review_request_event(
+ request_id,
+ summary,
+ steps,
+ thread_id,
+ client_id,
+ tool_call_id.as_deref(),
+ expires_at.as_deref(),
+ ));
+ }
_ => {
log::warn!(
"[web-channel] plan-review-surface received PlanReviewRequested request_id={request_id} but thread_id/client_id absent (thread={}, client={}) — NOT surfacing",
@@ -625,7 +656,38 @@ impl EventHandler<DomainEvent> for ApprovalSurfaceSubscriber {
client_id.is_some()
);
}
- }
+ },
+ DomainEvent::PlanReviewDecided {
+ request_id,
+ decision,
+ thread_id,
+ client_id,
+ tool_call_id,
+ resolution,
+ } => match (thread_id, client_id) {
+ (Some(thread_id), Some(client_id)) => {
+ log::info!(
+ "[web-channel] plan-review-surface emitting plan_review_decided request_id={request_id} thread_id={thread_id} client_id={client_id} decision={decision}"
+ );
+ publish_web_channel_event(WebChannelEvent {
+ event: "plan_review_decided".to_string(),
+ client_id: client_id.clone(),
+ thread_id: thread_id.clone(),
+ request_id: request_id.clone(),
+ tool_name: Some("request_plan_review".to_string()),
+ message: Some(decision.clone()),
+ tool_call_id: tool_call_id.clone(),
+ cancel_reason: resolution.clone(),
+ ..Default::default()
+ });
+ }
+ _ => {
+ log::debug!(
+ "[web-channel] plan-review-surface received PlanReviewDecided request_id={request_id} decision={decision} but thread_id/client_id absent — NOT surfacing (non-chat origin)"
+ );
+ }
+ },
+ _ => {}
}
}
}