Planning & Execution

Background Agents Panel

Agents working in the background as a grid of live tiles or a compact dock that expands into the selected agent.

3 variantsMIT

Preview

Installation

Copies the component into components/ui and installs its dependencies and theme tokens.

pnpm dlx shadcn@latest add https://uilab.tmih06.com/r/background-agents.json

Usage

Pass your own data and wire the callbacks to your agent runtime.

import { BackgroundAgents, type BackgroundAgent } from "@/components/ui/background-agents";

export function AgentsPanel({ query }: { query: BackgroundAgentsQuery }) {
  // data is null before the first snapshot. During a refetch, stale agents can
  // stay in data so the skeleton keeps the same number of tiles without
  // presenting their old progress as current.
  return (
    <BackgroundAgents
      data={query.data ?? null}
      loading={query.isRefetching}
      skeleton={{ count: 4 }}
      onPause={(agent) => runtime.pause(agent.id)}
      onResume={(agent) => runtime.resume(agent.id)}
      onCancel={(agent) => runtime.cancel(agent.id)}
      onOpen={(agent) => router.push(`/agents/${agent.id}`)}
      onReview={(agent) => router.push(`/agents/${agent.id}/review`)}
    />
  );
}

Props

PropTypeDefaultDescription
data*BackgroundAgent[] | null—Agents to show, in your order. Each tile or avatar fills from the bottom as progress grows. Pass null while they load; an empty array is valid loaded data.
loadingbooleanfalseForce the layout-preserving skeleton while refetching, even when stale agents are available. The skeleton never paints stale progress or selection as current.
skeleton{ count?: number }—Shape hints for the loading state; count is the number of tile or avatar placeholders before the real cardinality is known.
layout"grid" | "dock""grid"Grid shows a live tile per agent; dock is a row of avatars that expands into the selected agent.
onPause / onResume / onCancel / onOpen(agent: BackgroundAgent) => void—Each shows its action on the tile (on hover or focus) or in the dock strip. Update the agent's status yourself.
onReview(agent: BackgroundAgent) => void—Called from the Review action of an agent with status waiting. Falls back to onOpen.
selectedIdstring | null—Controls which agent the dock expands; null collapses it.
onSelect(agent: BackgroundAgent | null) => void—Called when the viewer picks or collapses an agent in the dock.
labelsPartial<BackgroundAgentsLabels>—Your own UI strings: the labels.loading announcement, status names, Review and screen-reader text, for translating. Right-to-left works under `dir="rtl"`; the dock's level fills from the start edge.
classNamestring—Extra classes for the root section.
type BackgroundAgent = {
  id: string;
  name: string;
  task: string;
  status: "queued" | "running" | "waiting" | "paused" | "done" | "failed" | "cancelled";
  progress: number;  // 0–1
  action?: string;   // what it is doing right now
  elapsedMs: number;
};