Agent Activity
beui/agent-activityFreeComponent
One adaptive activity stream for reasoning, searches, tool calls, structured execution traces, or a chronological mix.
Install it
npx shadcn@latest add https://beui.dev/r/agent-activity.jsonSource
1"use client";2// beui.dev/components/agents/agent-activity34import { ChevronDown } from "lucide-react";5import { AnimatePresence, motion, useReducedMotion } from "motion/react";6import {7 type ReactNode,8 useCallback,9 useEffect,10 useId,11 useLayoutEffect,12 useRef,13 useState,14} from "react";15import { ThinkingShimmer } from "@/components/agents/loading-states/thinking-shimmer";16import { AgentDisclosure } from "@/components/agents/agent-disclosure";17import {18 EASE_OUT,19 SPRING_LAYOUT,20 SPRING_SWAP,21} from "@/lib/ease";22import { cn } from "@/lib/utils";23import { ActivityRow } from "./activity-row";24import type {25 AgentActivityContentType,26 AgentActivityItem,27 AgentActivityProps,28} from "./types";2930export type {31 AgentActivityContentType,32 AgentActivityItem,33 AgentActivityProps,34 AgentActivitySearch,35 AgentActivityStatus,36 AgentActivityStep,37 AgentActivityText,38 AgentActivityTool,39 AgentActivityTrace,40 AgentSearchResult,41 AgentStepStatus,42 AgentTraceKind,43} from "./types";4445function formatDuration(duration: number) {46 const seconds = Math.max(0, Math.round(duration));47 if (seconds < 60) return `${seconds}s`;4849 const minutes = Math.floor(seconds / 60);50 const remainder = seconds % 60;51 return remainder === 0 ? `${minutes}m` : `${minutes}m ${remainder}s`;52}5354function useControllableOpen({55 open,56 defaultOpen,57 onOpenChange,58}: {59 open?: boolean;60 defaultOpen: boolean;61 onOpenChange?: (open: boolean) => void;62}) {63 const [internalOpen, setInternalOpen] = useState(defaultOpen);64 const controlled = open !== undefined;65 const currentOpen = open ?? internalOpen;6667 const setOpen = useCallback(68 (next: boolean) => {69 if (!controlled) setInternalOpen(next);70 onOpenChange?.(next);71 },72 [controlled, onOpenChange],73 );7475 return [currentOpen, setOpen] as const;76}7778function getContentType(items: AgentActivityItem[]): AgentActivityContentType {79 const first = items[0]?.type;80 return first && items.every((item) => item.type === first) ? first : "mixed";81}8283function getActiveLabel(type: AgentActivityContentType) {84 if (type === "search") return "Searching the web…";85 if (type === "tool") return "Running tools…";86 if (type === "trace") return "Working through the run…";87 if (type === "mixed") return "Working through it…";88 return "Thinking…";89}9091function getSummary(92 type: AgentActivityContentType,93 items: AgentActivityItem[],94 duration: number,95): ReactNode {96// … truncated
What it pulls in
npm packages
Files it writes
More from beui
All 104 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Action Swap Bluraction-swap-blur | beui | Components | Free | 3 deps · 4 files | |
| Action Swap Cascadeaction-swap-cascade | beui | Components | Free | 3 deps · 4 files | |
| Action Swap Rollaction-swap-roll | beui | Components | Free | 3 deps · 4 files | |
| Agent Loading States Agent Progressagent-progress | beui | Components | Free | 3 deps · 3 files | |
| AI Sidebarai-sidebar | beui | Components | Free | 4 deps · 5 files | |
| Animated Badgeanimated-badge | beui | Components | Free | 4 deps · 3 files | |
| Number Animation Animated Numberanimated-number | beui | Components | Free | 3 deps · 3 files | |
| Animated Sidebaranimated-sidebar | beui | Components | Free | 4 deps · 4 files |
