Agent routines
Scheduled background-agent list showing cadence, next run, source-to-destination flow, run history dots, active toggle and Run now.
pnpm dlx shadcn@latest add @haze/agent-routines---
import { ArrowRight, CalendarClock, Check, ChevronDown, Play } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";
interface Routine {
id: string;
name: string;
cadence: string;
nextRun: string;
flow: string;
active: boolean;
history: ("ok" | "warn")[];
}
interface Props {
id?: string;
heading?: string;
routines?: Routine[];
class?: string;
}
const {
id = "haze-agent-routines",
heading = "Scheduled agent routines",
routines = [
{ id: "rt1", name: "Morning dependency audit", cadence: "Every weekday at 08:00", nextRun: "In 11h", flow: "GitHub → Slack #eng", active: true, history: ["ok", "ok", "ok", "ok", "ok"] },
{ id: "rt2", name: "Weekly churn risk digest", cadence: "Mondays at 09:00", nextRun: "In 3d", flow: "Stripe + Linear → Email", active: true, history: ["ok", "ok", "warn", "ok", "ok"] },
{ id: "rt3", name: "Stale PR cleanup reminder", cadence: "Fridays at 16:00", nextRun: "Paused", flow: "GitHub → Linear", active: false, history: ["ok", "warn", "ok", "ok", "ok"] },
],
class: className,
} = Astro.props;
---
<section aria-labelledby={`${id}-title`} data-haze-agent-routines class={cn("bg-background px-4 py-10 sm:px-6 sm:py-14", className)}>
<div class="mx-auto max-w-3xl rounded-2xl border border-border bg-card p-5 sm:p-6">
<header class="flex flex-wrap items-center justify-between gap-2 border-b border-border pb-4">
<div class="flex items-center gap-2">
<CalendarClock class="size-4 text-muted-foreground" aria-hidden="true" />
<h2 id={`${id}-title`} class="text-base/6 font-semibold tracking-tight text-foreground">{heading}</h2>
</div>
<span class="text-xs text-muted-foreground tabular-nums">2 active · 1 paused</span>
</header>
<ul role="list" class="mt-4 space-y-2.5">
{
routines.map((rt) => (
<li class="rounded-xl border border-border bg-muted/40 p-4">
<div class="flex flex-wrap items-start justify-between gap-3">
<div class="min-w-0 flex-1">
<div class="flex flex-wrap items-center gap-2">
<h3 class="text-sm/5 font-semibold text-foreground">{rt.name}</h3>
<span class="rounded-md border border-border bg-card px-2 py-0.5 font-mono text-[0.6875rem] text-muted-foreground">{rt.nextRun}</span>
</div>
<p class="mt-1 text-xs/5 text-muted-foreground">{rt.cadence} · {rt.flow}</p>
<div class="mt-2 flex items-center gap-1.5" aria-label="Last 5 runs">
{rt.history.map((h) => (
<span class={cn("size-2 rounded-full", h === "ok" ? "bg-success" : "bg-warning")} aria-hidden="true"></span>
))}
<span class="ml-1 text-[0.6875rem] text-muted-foreground">Last 5 runs</span>
</div>
</div>
<div class="flex items-center gap-2">
<button type="button" data-rt-run={rt.name} class="inline-flex h-8 cursor-pointer items-center gap-1 rounded-lg border border-frame bg-field px-2.5 text-xs font-medium text-foreground hover:border-frame-strong hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring transition-[background-color,border-color,color,opacity,scale] duration-150 ease-snappy active:scale-[0.97] active:duration-75">
<Play class="size-3 text-muted-foreground" aria-hidden="true" />
Run now
</button>
<label class="inline-flex cursor-pointer items-center gap-1.5 text-xs text-muted-foreground">
<span class="relative inline-grid size-4 shrink-0 place-items-center"><input type="checkbox" checked={rt.active} data-rt-toggle={rt.name} class="peer col-start-1 row-start-1 focus-visible:outline-2 focus-visible:outline-ring size-4 shrink-0 cursor-pointer appearance-none rounded-sm border border-border-strong bg-field transition-[background-color,border-color,scale] duration-150 ease-snappy hover:border-foreground active:scale-90 checked:border-primary checked:bg-primary focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring forced-colors:appearance-auto" /><Check class="pointer-events-none col-start-1 row-start-1 size-3 scale-50 text-primary-foreground opacity-0 transition-[opacity,scale] duration-200 ease-spring peer-checked:scale-100 peer-checked:opacity-100 forced-colors:hidden" stroke-width={3} aria-hidden="true" /></span>
<span>Active</span>
</label>
</div>
</div>
<details class="group mt-3 border-t border-border pt-2.5">
<summary class="flex cursor-pointer list-none items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground select-none focus-visible:outline-2 focus-visible:outline-ring [&::-webkit-details-marker]:hidden">
<span>Schedule settings</span>
<ChevronDown class="size-3.5 transition-transform duration-150 ease-snappy group-open:rotate-180" aria-hidden="true" />
</summary>
<div class="mt-2.5 flex flex-wrap items-center gap-2 text-xs text-muted-foreground">
<span class="rounded-md border border-border bg-card px-2 py-1 font-mono text-foreground">{rt.cadence}</span>
<ArrowRight class="size-3.5" aria-hidden="true" />
<span class="rounded-md border border-border bg-card px-2 py-1 text-foreground">{rt.flow}</span>
</div>
</details>
</li>
))
}
</ul>
<p data-rt-status role="status" class="mt-3 min-h-4 text-xs/4 text-muted-foreground"></p>
</div>
</section>
<script>
function initAgentRoutines() {
document.querySelectorAll<HTMLElement>("[data-haze-agent-routines]").forEach((root) => {
if (root.hasAttribute("data-enhanced")) return;
root.setAttribute("data-enhanced", "");
const status = root.querySelector<HTMLElement>("[data-rt-status]");
root.querySelectorAll<HTMLButtonElement>("[data-rt-run]").forEach((btn) => {
btn.addEventListener("click", () => {
if (status) status.textContent = `Triggered immediate run for "${btn.dataset.rtRun}".`;
});
});
root.querySelectorAll<HTMLInputElement>("[data-rt-toggle]").forEach((chk) => {
chk.addEventListener("change", () => {
if (status) status.textContent = `${chk.dataset.rtToggle} ${chk.checked ? "activated" : "paused"}.`;
});
});
});
}
initAgentRoutines();
document.addEventListener("astro:page-load", initAgentRoutines);
</script>When to use
- Managing recurring AI automations with human-readable cadences and recent run health
- Letting operators pause a routine, inspect its routing or trigger an immediate run
When not to use
- Running one-off ad-hoc coding tasks; use agent-tasks
Installation
Add the Haze registry to components.json once, then install Agent routines with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/agent-routinesnpx shadcn@latest add @haze/agent-routinesyarn dlx shadcn@latest add @haze/agent-routinesbunx --bun shadcn@latest add @haze/agent-routinesFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | "haze-agent-routines" | Unique prefix for section heading IDs. |
| heading | string | "Scheduled agent routines" | Card heading. |
| routines | Routine[] | 3 demo routines | Scheduled routines with cadence, next run and run history. |
| class | string | – | Extra classes on the outer section. |
Keyboard interactions
- Tab
- Move across Run now buttons, Active checkboxes and Schedule settings disclosures
- EnterSpace
- Trigger a run, toggle active status or expand schedule settings
Accessibility
- Inline settings expand with native details/summary, and active switches use native checkboxes.
- Run now and active toggles announce feedback via a polite role="status" line.
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
Install and use
Install the Haze UI block "Agent routines" with `npx shadcn@latest add @haze/agent-routines`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import AgentRoutines from "@/components/haze/blocks/agent-routines.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/blocks/agent-routines.md
Customize with real content
Adapt the Haze agent-routines block for our product. Replace the demo values of these props with our real content: id, heading, routines, class. Keep the layout, the heading level rules and these accessibility details: Inline settings expand with native details/summary, and active switches use native checkboxes. Run now and active toggles announce feedback via a polite role="status" line. Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using agent-routines, check it fits: use it when managing recurring ai automations with human-readable cadences and recent run health; letting operators pause a routine, inspect its routing or trigger an immediate run. Avoid it when running one-off ad-hoc coding tasks; use agent-tasks. Alternatives: @haze/uptime-tracker, @haze/agent-tasks.
Dependencies
- npm: @lucide/astro
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.