Schedules and triggers that start an agent or an automation, and one routine's detail.
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
Sync the sales sheet
Paused- Schedule
- Every 2 hours
every 2 h - Time zone
- America/New_York
- Next run
- Not while paused
Paused after 3 failures in a row.
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/kit/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 }), }, }) }), }), ),})Installation
pnpm dlx shadcn@latest add checkfu/uicontext/routineUsage
import { RoutineCard } from "./ui/uicontext/components/kit/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
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/kit/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
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/kit/Routine.ts"import { RoutineEditor } from "./ui/uicontext/components/kit/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(), }, })),})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 |
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.