Loading component…
Loading component…
Agent tasks sorted into a week of sessions – each session has a usage limit, small tasks fill the gaps and big ones are split across sessions
To reuse this local React demo, copy all files from the Code tab into the same folder, then import ScheduledRuns from ./scheduled-runs.
import { ScheduledRuns, type ScheduledTask } from "@/components/ui/scheduled-runs";
const tasks: ScheduledTask[] = [
{ id: "metrics", title: "Weekly metrics report", usage: 40, at: { day: 1, session: 0 } },
{ id: "oauth", title: "Migrate auth to OAuth 2.1", agent: "Claude Code", usage: 140 },
{ id: "flaky", title: "Fix flaky checkout test", agent: "Claude Code", usage: 35 },
];
export function Week() {
return <ScheduledRuns tasks={tasks} now={{ day: 1, session: 0 }} note="5-hour sessions" />;
}| Name | Type | Default | Description |
|---|---|---|---|
| tasks | ScheduledTask[] | { id, title, usage, agent?, detail?, logo?, at? } – booked tasks have at: { day, session }; the rest wait in the stack and are sorted in, in this order | |
| usage | number | Per task – what it takes out of one session's limit, in percent; over the limit it's split across sessions | |
| days | (string \| { name, date? })[] | Mon–Wed | Column heads – three days read best; more fit, the week then scrolls sideways on narrow screens |
| sessions | string[] | ["07:00", "12:00", "17:00"] | Row heads – when each session starts |
| now | { day, session } | { day: 0, session: 0 } | The session running now – earlier ones are dimmed and take no new tasks; a red line marks where it starts |
| limit | number | 100 | What one session can take, in the unit of usage |
| minPiece | number | 15 | A split task never leaves a piece smaller than this in a session |
| agents | { name, logo? }[] | every task's agent | The agents in the head as small overlapping logos – picking one fans them out, slides its name out and fades the other agents' tasks back |
| defaultMode | "auto" \| "manual" | "auto" | Auto sorts the stack in when switched to; Manual puts the sorted-in cards back on the stack – booked cards and cards placed by hand stay. Both switch mid-run |
| autoRun | boolean \| number | false | In Auto: sorts the stack in on its own – after 800ms, or after the number of ms |
| loop | boolean | false | Clears the week and sorts in again, over and over – for demos |
| title / note | string | "This week" | Heading, and a quiet note next to it – e.g. "5-hour sessions" |
| onScheduled | (parts: ScheduledPart[]) => void | Every piece in the week once the stack is sorted in – { task, day, session, usage, part, parts } | |
| onPlace | (task: ScheduledTask, parts: ScheduledPart[]) => void | A task was dragged from the stack into a session – with the pieces it was split into | |
| onMove | (part: ScheduledPart, to: { day, session }) => void | A card was dragged to another session – save it | |
| className | string | Extra class on the root |
Every session keeps its height and takes two cards – sessions with two are full for dragging and for Auto
A long stack scrolls inside its column – it never stretches the board
Under 640px the stack moves on top and the week scrolls sideways
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"