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(assistant-ui): handle missing plan review gate in loading state
Steven Enamakel06cf46097256
diff --git a/app/src/components/assistant-ui/elements/loading-state.tsx b/app/src/components/assistant-ui/elements/loading-state.tsxindex ce473bb313..15e1509430 100644--- a/app/src/components/assistant-ui/elements/loading-state.tsx+++ b/app/src/components/assistant-ui/elements/loading-state.tsx@@ -13,8 +13,7 @@ import { ShimmerLabel } from './surfaces';export type GenerationLoaderVariant = 'dots' | 'squares' | 'rounded';-export interface GenerationLoaderProps- extends Omit<ComponentProps<'div'>, 'children'> {+export interface GenerationLoaderProps extends Omit<ComponentProps<'div'>, 'children'> {label: string;tick: number;variant?: GenerationLoaderVariant;diff --git a/crates/openhuman-core/src/agent/plan_review/gate.rs b/crates/openhuman-core/src/agent/plan_review/gate.rsindex 1e40e1f12b..c8fcef4345 100644--- a/crates/openhuman-core/src/agent/plan_review/gate.rs+++ b/crates/openhuman-core/src/agent/plan_review/gate.rs@@ -32,6 +32,25 @@ use super::types::PlanReviewResolution;/// default approval TTL (10 min) — long enough for a human to read the plan.const DEFAULT_PLAN_REVIEW_TTL: Duration = Duration::from_secs(60 * 10);+/// Snapshot of a parked plan review, captured at park time. Used to replay+/// the `plan_review_request` event to a socket that (re)joins the thread+/// room after the live emit — mirrors+/// [`crate::security::approval::PendingApproval`], but in-memory only (a+/// plan review parks a live turn; it has nothing to recover across a+/// restart).+#[derive(Debug, Clone)]+pub struct ParkedReview {+ pub request_id: String,+ pub thread_id: Option<String>,+ pub client_id: Option<String>,+ pub summary: String,+ pub steps: Vec<String>,+ /// The gated tool call's provider-assigned call id, when known.+ pub tool_call_id: Option<String>,+ /// RFC3339 expiry of this parked review.+ pub expires_at: Option<String>,+}+/// In-memory registry of parked plan reviews. Process-global singleton (see/// [`global`]); no persistence — a parked interactive turn cannot resume/// across a restart, so an orphaned review has nothing to recover.@@ -41,6 +60,11 @@ pub struct PlanReviewGate {/// Newest parked `request_id` per thread, so a typed reply or a UI action/// that only knows the thread can resolve the latest review.thread_to_request: Mutex<HashMap<String, String>>,+ /// request_id → [`ParkedReview`] for every currently-parked review —+ /// consulted by `parked_review_for_thread` so a socket that (re)joins a+ /// thread room can be handed whatever is parked on it, the same+ /// reconciliation `ApprovalGate::parked_request_for_thread` performs.+ parked: Mutex<HashMap<String, ParkedReview>>,}impl PlanReviewGate {@@ -49,6 +73,7 @@ impl PlanReviewGate {ttl,waiters: Mutex::new(HashMap::new()),thread_to_request: Mutex::new(HashMap::new()),+ parked: Mutex::new(HashMap::new()),}}@@ -56,13 +81,16 @@ impl PlanReviewGate {/// or the TTL elapses. `summary` is a one-line description; `steps` are the/// ordered plan items shown in the review card. `thread_id` / `client_id`/// route the surface to the originating chat (absent → no routable surface,- /// so the park TTL-rejects).+ /// so the park TTL-rejects). `tool_call_id` is the gated `request_plan_review`+ /// call's provider-assigned id, when known, so the UI can correlate the+ /// review card back to the exact timeline row.pub async fn request_review(&self,thread_id: Option<String>,client_id: Option<String>,summary: String,steps: Vec<String>,+ tool_call_id: Option<String>,) -> PlanReviewResolution {let request_id = format!("plan-{}", Uuid::new_v4());let (tx, rx) = oneshot::channel();@@ -72,12 +100,26 @@ impl PlanReviewGate {.lock().insert(tid, request_id.clone());}+ let expires_at = (chrono::Utc::now() + chrono::Duration::from_std(self.ttl).unwrap_or_default())+ .to_rfc3339();+ self.parked.lock().insert(+ request_id.clone(),+ ParkedReview {+ request_id: request_id.clone(),+ thread_id: thread_id.clone(),+ client_id: client_id.clone(),+ summary: summary.clone(),+ steps: steps.clone(),+ tool_call_id: tool_call_id.clone(),+ expires_at: Some(expires_at.clone()),+ },+ );- // RAII cleanup: remove the waiter + thread mapping on ANY exit path,- // including when the parked future is cancelled/dropped before- // `rx.await` completes (turn cancel, supervisor shutdown). Without this,- // a cancelled review would leak a `waiters` / `thread_to_request` entry- // that could be re-decided against a dead turn.+ // RAII cleanup: remove the waiter + thread + parked mappings on ANY+ // exit path, including when the parked future is cancelled/dropped+ // before `rx.await` completes (turn cancel, supervisor shutdown).+ // Without this, a cancelled review would leak entries that could be+ // re-decided against a dead turn or replayed as still-pending.let _guard = ParkGuard {gate: self,request_id: request_id.clone(),@@ -94,15 +136,15 @@ impl PlanReviewGate {BUS.publish(DomainEvent::PlanReviewRequested {request_id: request_id.clone(),thread_id: thread_id.clone(),- client_id,+ client_id: client_id.clone(),summary,steps,- tool_call_id: None,- expires_at: None,+ tool_call_id: tool_call_id.clone(),+ expires_at: Some(expires_at),});- let resolution = match tokio::time::timeout(self.ttl, rx).await {- Ok(Ok(resolution)) => resolution,+ let (resolution, timed_out_or_dropped) = match tokio::time::timeout(self.ttl, rx).await {+ Ok(Ok(resolution)) => (resolution, false),// Sender dropped (decided elsewhere / shutdown) or TTL elapsed →// fail closed: never execute a plan the user didn't approve.Ok(Err(_)) | Err(_) => {@@ -110,7 +152,7 @@ impl PlanReviewGate {request_id = %request_id,"[plan_review::gate] review unresolved (timeout/dropped) → reject");- PlanReviewResolution::Reject+ (PlanReviewResolution::Reject, true)}};@@ -119,9 +161,10 @@ impl PlanReviewGate {BUS.publish(DomainEvent::PlanReviewDecided {request_id: request_id.clone(),decision: resolution.as_str().to_string(),- thread_id: None,- client_id: None,- tool_call_id: None,+ thread_id,+ client_id,+ tool_call_id,+ resolution: timed_out_or_dropped.then(|| "expired".to_string()),});tracing::info!(request_id = %request_id,@@ -131,6 +174,13 @@ impl PlanReviewGate {resolution}+ /// The parked review on `thread_id`, if any — lets a socket (re)joining a+ /// thread room be handed whatever review is still parked on it.+ pub fn parked_review_for_thread(&self, thread_id: &str) -> Option<ParkedReview> {+ let request_id = self.thread_to_request.lock().get(thread_id)?.clone();+ self.parked.lock().get(&request_id).cloned()+ }+/// Resolve a parked review by `request_id`. Returns `true` when a waiter was/// woken; `false` when the id is unknown (already decided / expired).pub fn decide(&self, request_id: &str, resolution: PlanReviewResolution) -> bool {@@ -169,6 +219,7 @@ struct ParkGuard<'a> {impl Drop for ParkGuard<'_> {fn drop(&mut self) {self.gate.waiters.lock().remove(&self.request_id);+ self.gate.parked.lock().remove(&self.request_id);if let Some(tid) = &self.thread_id {let mut map = self.gate.thread_to_request.lock();if map.get(tid) == Some(&self.request_id) {