Schedules and triggers that start an agent or an automation: one routine's detail, and recurring tasks written as plain sentences with their last and next run.
- 22.7 kB JS 8.0 kB CSS gzipped
- No serious axe issues
- Server-rendered, hydrates
- 44px touch targets
- Right-to-left
- 49 tests
Post the pipeline digest
Active- Schedule
- Every weekday at 9
Mon–Fri 09:00 (Europe/London) - Time zone
- Europe/London
- Next run
- SucceededMon, Nov 30, 9:00 AM
- FailedFri, Nov 27, 9:00 AM
- SucceededThu, Nov 26, 9:00 AM
Delete “Post the pipeline digest”?
It stops running and won't start again. Past runs stay in the history.
Sync the sales sheet
Paused- Schedule
- Every 2 hours
every 2 h - Time zone
- America/New_York
- Next run
- Not while paused
Delete “Sync the sales sheet”?
It stops running and won't start again. Past runs stay in the history.
import { UiSchema } from "effect/ui"import { Html } from "effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { RoutineCard, RoutineList, RoutineState } from "./ui/uicontext/components/Routine.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { previewOf } from "./schedule.ts"const styles = stylex.create({ frame: { inlineSize: "min(100%, 36rem)" } })const Message = UiSchema.TaggedEnum({ Paused: { id: Schema.String }, Resumed: { id: Schema.String }, Previewed: { id: Schema.String, text: Schema.String, timeZone: Schema.String, request: Schema.String }, Rescheduled: { id: Schema.String, text: Schema.String, timeZone: Schema.String }, Deleted: { id: Schema.String },})const Routine = Schema.Struct({ id: Schema.String, title: Schema.String, state: RoutineState, text: Schema.String, timeZone: Schema.String })const zones = ["Europe/London", "America/New_York", "Asia/Tokyo"]export const TeamRoutines = Html.component({ name: "TeamRoutines", model: Schema.Struct({ routines: Schema.Array(Routine), preview: Schema.NullOr(Schema.Struct({ id: Schema.String, text: Schema.String, timeZone: Schema.String, request: Schema.String })), }), message: Message,}).make({ init: () => ({ routines: [ { id: "digest", title: "Post the pipeline digest", state: "active", text: "Every weekday at 9", timeZone: "Europe/London" }, { id: "sync", title: "Sync the sales sheet", state: "paused", text: "Every 2 hours", timeZone: "America/New_York" }, ], preview: null, }), update: { Paused: ($, { id }) => $.evolve({ routines: (rs) => rs.map((r) => (r.id === id ? { ...r, state: "paused" as const } : r)) }), Resumed: ($, { id }) => $.evolve({ routines: (rs) => rs.map((r) => (r.id === id ? { ...r, state: "active" as const } : r)) }), Previewed: ($, preview) => $.evolve({ preview }), Rescheduled: ($, { id, text, timeZone }) => $.evolve({ routines: (rs) => rs.map((r) => (r.id === id ? { ...r, text, timeZone } : r)), preview: null }), Deleted: ($, { id }) => $.evolve({ routines: (rs) => rs.filter((r) => r.id !== id) }), }, view: (h, model) => h.div.attrs(sx(styles.frame)).children( RoutineList(h, { status: "ready", empty: { title: "No routines yet", hint: "Schedule a workflow to run on its own." }, children: model.routines.map((r) => { const parsed = previewOf(r.text, r.timeZone) const pending = model.preview?.id === r.id ? model.preview : null return RoutineCard(h, { key: r.id, props: { id: r.id, agentId: `routine-demo-${r.id}`, title: r.title, trigger: { kind: "schedule", text: r.text, ...(parsed.parsed === undefined ? {} : { parsed: parsed.parsed }) }, state: r.state, ...(r.state === "paused" ? { pausedReason: "Paused after 3 failures in a row." } : {}), nextRun: r.state === "active" ? (parsed.nextRuns[0] ?? null) : null, timeZone: r.timeZone, timeZones: zones, lastResults: r.id === "digest" ? [ { id: "d3", at: "2026-11-30T09:00:00Z", status: "succeeded" }, { id: "d2", at: "2026-11-27T09:00:00Z", status: "failed", reason: "The chat account’s sign-in expired" }, { id: "d1", at: "2026-11-26T09:00:00Z", status: "succeeded" }, ] : [], can: ["pause", "resume", "test", "reschedule", "delete"], requirePreview: true, ...(pending === null ? {} : { preview: { ...previewOf(pending.text, pending.timeZone), request: pending.request } }), }, onEmit: { RequestedPause: ({ id }) => Message.Paused({ id }), RequestedResume: ({ id }) => Message.Resumed({ id }), RequestedTest: () => undefined, RequestedApprove: () => undefined, RequestedDecline: () => undefined, RequestedPreview: ({ id, text, timeZone, request }) => (request === undefined ? undefined : Message.Previewed({ id, text, timeZone, request })), RequestedReschedule: ({ id, text, timeZone }) => Message.Rescheduled({ id, text, timeZone }), RequestedDelete: ({ id }) => Message.Deleted({ id }), }, }) }), }), ),})When to use
Schedules and triggers that start an agent or an automation: one routine's detail, and recurring tasks written as plain sentences with their last and next run. Use Flow Diagram instead when you edit what the automation does, not when it runs.
Usage
import { RoutineCard } from "./ui/uicontext/components/Routine.ts"const Message = UiSchema.TaggedEnum({ PausedRoutine: { id: Schema.String }, ResumedRoutine: { id: Schema.String }, RescheduledRoutine: { id: Schema.String, text: Schema.String, timeZone: Schema.String },})export const DigestRoutine = (h: Html.H<typeof Message.Type>, state: "active" | "paused", nextRun: string | null) => RoutineCard(h, { props: { id: "digest", title: "Post the pipeline digest", trigger: { kind: "schedule", text: "Every weekday at 9", parsed: "Mon–Fri 09:00" }, state, nextRun, timeZone: "Europe/London", can: ["pause", "resume", "reschedule"], }, onEmit: { RequestedPause: ({ id }) => Message.PausedRoutine({ id }), RequestedResume: ({ id }) => Message.ResumedRoutine({ id }), RequestedReschedule: ({ id, text, timeZone }) => Message.RescheduledRoutine({ id, text, timeZone }), RequestedTest: () => undefined, RequestedApprove: () => undefined, RequestedDecline: () => undefined, RequestedPreview: () => undefined, RequestedDelete: () => undefined, }, })Examples
Proposed by an agent
An agent suggests a routine; it does nothing until a person approves it.
Triage new support tickets
Waiting for you- Trigger
- When a ticket arrives in the Support inbox
- Next run
- Nothing scheduled
Delete “Triage new support tickets”?
It stops running and won't start again. Past runs stay in the history.
import { UiSchema } from "effect/ui"import { Html } from "effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { RoutineCard, RoutineState } from "./ui/uicontext/components/Routine.ts"import { sx } from "./ui/uicontext/components/Sx.ts"const styles = stylex.create({ frame: { inlineSize: "min(100%, 36rem)" } })const Message = UiSchema.TaggedEnum({ Approved: {}, Declined: {} })export const ProposedRoutine = Html.component({ name: "ProposedRoutine", model: RoutineState, message: Message,}).make({ init: () => "proposed" as const, update: { Approved: () => "active" as const, Declined: () => "ended" as const }, view: (h, state) => h.div.attrs(sx(styles.frame)).children( RoutineCard(h, { props: { id: "triage", agentId: "routine-proposed", title: "Triage new support tickets", trigger: { kind: "event", text: "When a ticket arrives in the Support inbox" }, state, ...(state === "proposed" ? {} : { stateLabel: state === "active" ? "On" : "Declined" }), nextRun: null, timeZone: "Europe/London", can: state === "proposed" ? ["approve", "decline"] : [], }, onEmit: { RequestedApprove: () => Message.Approved(), RequestedDecline: () => Message.Declined(), RequestedPause: () => undefined, RequestedResume: () => undefined, RequestedTest: () => undefined, RequestedPreview: () => undefined, RequestedReschedule: () => undefined, RequestedDelete: () => undefined, }, }), ),})Routine detail
Turn it on or off, edit what it does and when, then Save or press ⌘S. A schedule without a time is refused with the reason. Test run adds to the history.
When to run
Run history
Delete “Morning briefing”?
It stops running. Its run history goes with it.
import { Command, UiSchema } from "effect/ui"import { Html } from "effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Effect, Schema } from "effect"import { accepted, Outcome, pending, refused } from "./ui/uicontext/components/domain/Outcome.ts"import { RoutineResult } from "./ui/uicontext/components/Routine.ts"import { RoutineEditor } from "./ui/uicontext/components/RoutineEditor.ts"import { sx } from "./ui/uicontext/components/Sx.ts"const Draft = Schema.Struct({ name: Schema.String, instruction: Schema.String, schedules: Schema.Array(Schema.String) })const Message = UiSchema.TaggedEnum({ RequestedSave: { draft: Draft }, RequestedActive: { active: Schema.Boolean }, RequestedTestRun: {}, RequestedDelete: {}, CompletedSave: { draft: Draft }, CompletedTestRun: { at: Schema.String },})// Stand in for the server: it saves after a moment, and a test run takes a little longer.const Save = Command.make("SaveSampleRoutine", { args: { draft: Draft } }, ({ draft }) => Effect.sleep("400 millis").pipe(Effect.as(Message.CompletedSave({ draft }))))const TestRun = Command.make("TestSampleRoutine", {}, () => Effect.sleep("900 millis").pipe(Effect.andThen(Effect.sync(() => Message.CompletedTestRun({ at: new Date().toISOString() })))))const styles = stylex.create({ panel: { width: "min(100%, 22rem)" } })const hasTime = (schedule: string) => /\d/u.test(schedule)export const DailyBriefing = Html.component({ name: "DailyBriefing", model: Schema.Struct({ routine: Draft, active: Schema.Boolean, runs: Schema.Array(RoutineResult), outcome: Schema.NullOr(Outcome), now: Schema.String }), message: Message,}).make({ init: () => ({ routine: { name: "Morning briefing", instruction: "Check every agent's status, my calendar and my inbox. Send me five lines: what changed, what needs me today, and anything at risk.", schedules: ["Every day at 8:00 AM"] }, active: true, runs: [{ id: "r1", at: "2026-11-30T13:00:00.000Z", status: "succeeded" }, { id: "r0", at: "2026-11-29T13:00:00.000Z", status: "succeeded" }], outcome: null, now: "2026-11-30T15:00:00.000Z", }), update: { RequestedSave: ($, { draft }) => { const bad = draft.schedules.find((s) => !hasTime(s)) return bad !== undefined ? $.evolve({ outcome: refused("save", `“${bad}” needs a time, like “Every weekday at 9:00 AM”.`) }) : $.evolve({ outcome: pending("save") }).run(Save.make({ draft })) }, CompletedSave: ($, { draft }) => $.evolve({ routine: draft, outcome: accepted("save") }), RequestedActive: ($, { active }) => $.evolve({ active }), RequestedTestRun: ($) => $.evolve({ outcome: pending("test") }).run(TestRun.make({})), CompletedTestRun: ($, { at }) => $.evolve({ outcome: accepted("test"), now: at, runs: (runs) => [{ id: `r${runs.length}`, at, status: "succeeded" }, ...runs] }), RequestedDelete: ($) => $.model, }, view: (h, model) => h.div.attrs(sx(styles.panel)).children(RoutineEditor(h, { props: { id: "briefing", ...model.routine, active: model.active, runs: model.runs, now: model.now, timeZone: "America/New_York", locale: "en-US", can: ["edit", "toggle", "test"], outcome: model.outcome, agentId: "routine-editor-demo", }, onEmit: { RequestedSave: ({ name, instruction, schedules }) => Message.RequestedSave({ draft: { name, instruction, schedules } }), RequestedActive: ({ active }) => Message.RequestedActive({ active }), RequestedTestRun: () => Message.RequestedTestRun(), RequestedDelete: () => Message.RequestedDelete(), }, })),})Scheduled tasks
What each does and when, in plain words, with when it last ran and runs next. Pause one with its switch, or delete it.
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/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 }), })))),})Make a scheduled task
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/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: { RequestedSubmit: ({ draft }) => Message.Submitted({ draft }), RequestedCancel: () => Message.Cancelled() }, }), model.saved !== null && h.p.attrs({ role: "status", ...sx(styles.done) }).children(model.saved), ),})API reference
RoutineCardComponent
Props
| Name | Type | Description |
|---|---|---|
idrequired | string | The routine's id, sent back with every request |
titlerequired | string | What the routine does: "Summarize new support tickets" |
triggerrequired | RoutineTrigger | What starts it: a schedule, an event or a webhook |
staterequired | RoutineState | Whether it's active, paused, proposed or ended |
stateLabel | string | The product's word for the state: "On", "Turned off" |
pausedReason | string | Why it's paused: "Paused after 3 failures in a row" |
nextRun | string | null | ISO 8601, or null when nothing is scheduled |
timeZonerequired | string | The person's time zone (IANA), for every time shown |
locale | string | The locale dates are formatted in; the browser's by default |
showYear | boolean | Include the year in next-run, schedule preview, and history timestamps. |
timeZones | string[] | The time zones the editor offers; defaults to every zone the runtime knows |
lastResults | RoutineResult[] | The most recent runs, newest first, shown as a row of results |
webhook | { url, secret } | A webhook trigger's address and key, shown once |
canrequired | RoutineAction[] | What this person may do here; anything absent is hidden |
labels | { test, delete } | Labels the product uses: { test: "Run now", delete: "End routine" } |
readOnly | string | Why this person can't change it: "Only the owner changes this routine" |
outcome | Outcome | null | The app's answer to the last request; its request is the action ("pause", "reschedule") |
preview | SchedulePreview | The app's reading of the schedule being typed: its next runs, or why it can't be saved |
requirePreview | boolean | Require a successful preview tied to the current request before Save. |
agentId | string | This card's id for agents; defaults to routine:<id> |
Events
| Event | Payload | Description |
|---|---|---|
RequestedPause | { id: string } | Stop the routine from starting until it's resumed |
RequestedResume | { id: string } | Start the paused routine again |
RequestedTest | { id: string } | Run the routine once now |
RequestedApprove | { id: string } | Turn on a routine an agent proposed |
RequestedDecline | { id: string } | Turn down a routine an agent proposed |
RequestedPreview | { id: string; text: string; timeZone: string; request?: string } | The person is typing a schedule: answer with preview |
RequestedReschedule | { id: string; text: string; timeZone: string } | Save the schedule the person typed, in the time zone they chose |
RequestedDelete | { id: string } | End the routine for good, after the person confirmed |
Agent actions
| Action | Description |
|---|---|
ClickedPause | Pause the routine |
ClickedResume | Resume the paused routine |
ClickedTest | Run the routine once now, as a test |
ClickedApprove | Approve the routine an agent proposed |
ClickedDecline | Decline the routine an agent proposed |
ClickedEditSchedule | Open the schedule editor |
UpdatedSchedule | Type the schedule in plain words, as a person would: 'every weekday at 9am' |
ChoseTimeZone | Choose the schedule's IANA time zone |
SubmittedSchedule | Save the schedule being edited |
ClickedDelete | Ask to delete the routine (opens the confirmation) |
ConfirmedDeleteasks first | Delete the routine. Name it as your target. |
RoutineListView function
Options
| Name | Type | Default | Description |
|---|---|---|---|
statusrequired | "loading" | "ready" | — | loading shows a placeholder while the routines load |
label | string | Routines | What the list is of, for screen readers; Routines by default |
emptyrequired | { readonly title: string; readonly hint?: string } | — | "No routines yet", "Ask the agent to do something on a schedule" |
childrenrequired | View.Children | — | The routine cards |
RoutineEditorComponent
Props
| Name | Type | Description |
|---|---|---|
idrequired | string | — |
namerequired | string | — |
instructionrequired | string | What the agent does when it runs, in its own words |
schedulesrequired | string[] | When it runs, each in plain words: "Every day at 8:00 AM", "Weekdays at 6:00 PM" |
activerequired | boolean | — |
runsrequired | RoutineResult[] | Its runs, newest first |
nowrequired | string | The clock its runs are read in |
timeZonerequired | string | — |
locale | string | — |
canrequired | ("edit" | "toggle" | "test" | "delete")[] | What this person may do; anything absent is hidden |
outcome | Outcome | null | The app's answer to the last request: "save", "active", "test" or "delete" |
agentId | string | — |
Events
| Event | Payload | Description |
|---|---|---|
RequestedSave | { id: string; name: string; instruction: string; schedules: string[] } | — |
RequestedActive | { id: string; active: boolean } | — |
RequestedTestRun | { id: string } | — |
RequestedDelete | { id: string } | — |
Agent actions
| Action | Description |
|---|---|
RequestedChangeasks first | Change the routine's name, instruction or schedules (plain words, such as 'Every weekday at 9:00 AM') and save |
ToggledActiveasks first | Turn the routine on or off |
ClickedTestRun | Run the routine once now |
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 |
|---|---|---|
RequestedSubmit | { draft: ScheduleDraft } | — |
RequestedCancel | {} | — |
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 | — |
Keyboard and accessibility
- Each routine is a labelled card; its schedule, time zone and next run are a description list, and every time is a
<time>. - Editing a schedule is a form: the app's reading of it and its next runs are announced as you type.
- Deleting asks first, and agents must name the routine they end.
Installation
pnpm dlx shadcn@latest add checkfu/uicontext/routines