/** * Wait State Indicator * * Renders an inline banner within a thread or channel when an agent * is waiting for human input (reply, review, or approval). * Provides a primary action button to reply or navigate to the approval. */ import { Hourglass, ChatCircle, CheckCircle } from "@phosphor-icons/react" import type { AgentRecord } from "@shared/types" export interface WaitStateInfo { id: string threadId: string companyId: string waitingFor: "user_reply" | "user_review" | "user_approval" reason: string createdAt: string relatedApprovalId: string | null } interface WaitStateIndicatorProps { waitState: WaitStateInfo agents: AgentRecord[] onReply: (waitStateId: string, threadId: string) => void onNavigateApproval?: (approvalId: string) => void } function formatWaitDuration(createdAt: string): string { const diff = Date.now() - new Date(createdAt).getTime() const minutes = Math.floor(diff / 60000) if (minutes < 1) return "just now" if (minutes < 60) return `${minutes}m ago` const hours = Math.floor(minutes / 60) if (hours < 24) return `${hours}h ago` const days = Math.floor(hours / 24) return `${days}d ago` } export default function WaitStateIndicator({ waitState, onReply, onNavigateApproval }: WaitStateIndicatorProps) { const isApproval = waitState.waitingFor === "user_approval" && waitState.relatedApprovalId const isReview = waitState.waitingFor === "user_review" const duration = formatWaitDuration(waitState.createdAt) return (
{waitState.reason}
Waiting since {duration}