Scheduled Tasks

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 hours
  • Weekly

    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 days
  • Weekly

    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

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/scheduled-tasks

Usage

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.

America/New York

Every Monday at 9:00 AM

API reference

ScheduleFormComponent

Props

ScheduleForm props
NameTypeDefaultDescription
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.
submitLabelstring"Schedule"The submit button's text; "Schedule" by default
savingboolean—The app is saving it: the form waits
errorstring | null—Why the last save failed, from the app
timeZonestring—The reader's time zone, said under the time
todaystring—"YYYY-MM-DD": today, the default for Once

Events

ScheduleForm events
EventPayloadDescription
Submitted{ draft: ScheduleDraft }—
Cancelled{}—

ScheduledTaskCardView function

Options

ScheduledTaskCard options
NameTypeDescription
taskrequiredScheduledTask—
nowrequiredstringISO 8601: the app's clock, for "Ran 36m ago" and the next run
timeZonestring—
localestring—
onPauserequired(paused: boolean) => MessageThe switch: true asks to pause it
onRunNowMessage—
onDeleteMessage—
runningbooleanA Run now is on its way
styleStyle—

Source