Recurring agent work in plain sentences: a card with its last and next run, and the form that makes one.
Weekdays
Morning inbox triage
Every weekday morning, read new mail and DMs, answer what's simple, and list what needs me.
Every weekday at 7:30 AMRan 36 minutes ago · Next in 21 hoursWeekly
Weekly pipeline review
Every Monday, refresh the pipeline sheet, say what moved and why, and flag deals at risk.
Every Monday at 8:00 AMRan 3 days ago · Next in 4 daysWeekly
Vendor price watch
Every Friday, check our main vendors' pricing pages and tell me if anything changed.
Every Friday at 4:00 PMHasn't run yet · Paused
import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { ScheduledTask, ScheduledTaskCard } from "./ui/uicontext/components/kit/ScheduledTasks.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { space } from "./ui/uicontext/components/tokens.stylex.ts"const now = "2026-12-03T15:10:00.000Z"const tasks: ReadonlyArray<ScheduledTask> = [ { id: "triage", title: "Morning inbox triage", instruction: "Every weekday morning, read new mail and DMs, answer what's simple, and list what needs me.", schedule: { repeat: "weekdays", time: "07:30" }, paused: false, lastRun: "2026-12-03T14:34:00.000Z" }, { id: "pipeline", title: "Weekly pipeline review", instruction: "Every Monday, refresh the pipeline sheet, say what moved and why, and flag deals at risk.", schedule: { repeat: "weekly", time: "08:00", day: 1 }, paused: false, lastRun: "2026-11-30T13:00:00.000Z" }, { id: "prices", title: "Vendor price watch", instruction: "Every Friday, check our main vendors' pricing pages and tell me if anything changed.", schedule: { repeat: "weekly", time: "16:00", day: 5 }, paused: true },]const Message = UiSchema.TaggedEnum({ ToggledPause: { id: Schema.String, paused: Schema.Boolean }, ClickedDelete: { id: Schema.String } })const styles = stylex.create({ list: { display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(min(100%, 20rem), 1fr))", gap: space.lg, width: "100%", margin: 0, padding: 0, listStyle: "none" } })export const Scheduled = Html.component({ name: "ScheduledTasksExample", model: Schema.Struct({ tasks: Schema.Array(ScheduledTask) }), message: Message,}).make({ init: () => ({ tasks }), update: { ToggledPause: ($, { id, paused }) => $.evolve({ tasks: (all) => all.map((t) => (t.id === id ? { ...t, paused } : t)) }), ClickedDelete: ($, { id }) => $.evolve({ tasks: (all) => all.filter((t) => t.id !== id) }), }, view: (h, model) => h.ul.attrs({ "aria-label": "Scheduled tasks", ...sx(styles.list) }).children(model.tasks.map((task) => h.li.key(task.id).children(ScheduledTaskCard(h, { task, now, timeZone: "America/New_York", locale: "en-US", onPause: (paused) => Message.ToggledPause({ id: task.id, paused }), onDelete: Message.ClickedDelete({ id: task.id }), })))),})Installation
pnpm dlx shadcn@latest add checkfu/uicontext/scheduled-tasksUsage
import { ScheduleDraft, type ScheduledTask, ScheduledTaskCard, ScheduleForm } from "./ui/uicontext/components/kit/ScheduledTasks.ts"const Message = UiSchema.TaggedEnum({ ToggledPause: { id: Schema.String, paused: Schema.Boolean }, ClickedRunNow: { id: Schema.String }, CreatedSchedule: { draft: ScheduleDraft }, CancelledSchedule: {},})// a card per scheduled task, and the form that makes one from a task the person wants againexport const Schedules = (h: Html.H<typeof Message.Type>, task: ScheduledTask, now: string) => [ ScheduledTaskCard(h, { task, now, onPause: (paused) => Message.ToggledPause({ id: task.id, paused }), onRunNow: Message.ClickedRunNow({ id: task.id }), }), ScheduleForm(h, { props: { initial: { title: "Monthly board metrics", schedule: { repeat: "monthly", day: 1, time: "09:00" } } }, onEmit: { Submitted: ({ draft }) => Message.CreatedSchedule({ draft }), Cancelled: () => Message.CancelledSchedule() }, }),]Examples
Make one
Name it, say what to do, pick how often. The schedule reads back as a sentence while you choose; empty fields say what they need on Schedule.
import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { ScheduleDraft, ScheduleForm, scheduleSentence } from "./ui/uicontext/components/kit/ScheduledTasks.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, font } from "./ui/uicontext/components/tokens.stylex.ts"const Message = UiSchema.TaggedEnum({ Submitted: { draft: ScheduleDraft }, Cancelled: {} })const styles = stylex.create({ frame: { width: "min(100%, 30rem)" }, done: { margin: 0, color: color.muted, fontSize: font.sm },})export const NewSchedule = Html.component({ name: "ScheduleFormExample", model: Schema.Struct({ saved: Schema.NullOr(Schema.String), round: Schema.Number }), message: Message,}).make({ init: () => ({ saved: null, round: 0 }), update: { Submitted: ($, { draft }) => $.evolve({ saved: `Scheduled “${draft.title}”: ${scheduleSentence(draft.schedule)}.`, round: (n) => n + 1 }), Cancelled: ($) => $.evolve({ saved: null, round: (n) => n + 1 }), }, view: (h, model) => h.div.attrs(sx(styles.frame)).children( ScheduleForm(h, { key: `form-${model.round}`, props: { initial: { title: "Weekly pipeline review" }, timeZone: "America/New_York", today: "2026-12-03" }, onEmit: { Submitted: ({ draft }) => Message.Submitted({ draft }), Cancelled: () => Message.Cancelled() }, }), model.saved !== null && h.p.attrs({ role: "status", ...sx(styles.done) }).children(model.saved), ),})API reference
ScheduleFormComponent
Props
| Name | Type | Default | Description |
|---|---|---|---|
initial | { title, instruction, schedule } | — | What the form starts with: a task's title and instruction when it's made recurring. Read once, as it mounts. |
submitLabel | string | "Schedule" | The submit button's text; "Schedule" by default |
saving | boolean | — | The app is saving it: the form waits |
error | string | null | — | Why the last save failed, from the app |
timeZone | string | — | The reader's time zone, said under the time |
today | string | — | "YYYY-MM-DD": today, the default for Once |
Events
| Event | Payload | Description |
|---|---|---|
Submitted | { draft: ScheduleDraft } | — |
Cancelled | {} | — |
ScheduledTaskCardView function
Options
| Name | Type | Description |
|---|---|---|
taskrequired | ScheduledTask | — |
nowrequired | string | ISO 8601: the app's clock, for "Ran 36m ago" and the next run |
timeZone | string | — |
locale | string | — |
onPauserequired | (paused: boolean) => Message | The switch: true asks to pause it |
onRunNow | Message | — |
onDelete | Message | — |
running | boolean | A Run now is on its way |
style | Style | — |