The rail beside an agent's task: Progress as a checklist, the Outputs it made, and the Context it reaches.
import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { WorkRail, type WorkRailCard } from "./ui/uicontext/components/kit/WorkRail.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, radius, space } from "./ui/uicontext/components/tokens.stylex.ts"const Card = Schema.Literals(["progress", "outputs", "context"])const Message = UiSchema.TaggedEnum({ ToggledCard: { card: Card, open: Schema.Boolean }, OpenedOutput: { id: Schema.String } })const styles = stylex.create({ frame: { width: "min(100%, 19rem)", padding: space.lg, borderRadius: radius.lg, backgroundColor: color.raised } })export const RunningTask = Html.component({ name: "WorkRailExample", model: Schema.Struct({ open: Schema.Array(Card), current: Schema.NullOr(Schema.String) }), message: Message,}).make({ init: () => ({ open: ["progress", "outputs", "context"], current: null }), update: { ToggledCard: ($, { card, open }) => $.evolve({ open: (all) => (open ? [...all.filter((c) => c !== card), card] : all.filter((c) => c !== card)) }), OpenedOutput: ($, { id }) => $.evolve({ current: (now) => (now === id ? null : id) }), }, view: (h, model) => h.div.attrs(sx(styles.frame)).children(WorkRail(h, { progress: [ { id: "1", label: "Read the data room", status: "done" }, { id: "2", label: "Check the latest feedback", status: "done" }, { id: "3", label: "Build the forecast", status: "in-progress" }, { id: "4", label: "Add the slide in the deck's style", status: "not-started" }, ], outputs: [ { id: "notes", name: "Forecast-notes.md", detail: "Document · 1 page", current: model.current === "notes", onOpen: Message.OpenedOutput({ id: "notes" }) }, { id: "deck", name: "Halden-Account-Plan.pptx", generating: true, onOpen: Message.OpenedOutput({ id: "deck" }) }, ], context: { connectors: [ { id: "files", name: "Files", mark: { letter: "F", tone: "blue" }, access: "Allowed" }, { id: "chat", name: "Team chat", mark: { letter: "T", tone: "purple" }, access: "Asks first" }, ], folder: "Halden / Data room", files: [{ id: "usage", name: "Halden-usage-Q4.xlsx" }, { id: "pilot", name: "Pilot-proposal-v3.docx" }], }, open: model.open, onToggle: (card: WorkRailCard, open) => Message.ToggledCard({ card, open }), })),})Installation
pnpm dlx shadcn@latest add checkfu/uicontext/work-railUsage
import { WorkRail, type WorkRailCard } from "./ui/uicontext/components/kit/WorkRail.ts"const Message = UiSchema.TaggedEnum({ ToggledCard: { card: Schema.Literals(["progress", "outputs", "context"]), open: Schema.Boolean }, OpenedFile: { id: Schema.String },})// which cards are open is yours; an output's press asks the app to open it in its viewerexport const Rail = (h: Html.H<typeof Message.Type>, open: ReadonlyArray<WorkRailCard>) => WorkRail(h, { progress: [{ id: "1", label: "Match invoices to payments", status: "done" }, { id: "2", label: "Write up the mismatches", status: "in-progress" }], outputs: [{ id: "recon", name: "November-Reconciliation.xlsx", detail: "Spreadsheet · 3 sheets", onOpen: Message.OpenedFile({ id: "recon" }) }], context: { connectors: [{ id: "books", name: "Accounting", mark: { letter: "A", tone: "orange" } }], folder: "Finance / November close" }, open, onToggle: (card, isOpen) => Message.ToggledCard({ card, open: isOpen }), })API reference
Options
| Name | Type | Description |
|---|---|---|
progressrequired | ChecklistItem[] | — |
outputsrequired | WorkOutput<Message>[] | — |
contextrequired | WorkContext | — |
openrequired | WorkRailCard[] | The cards shown open |
onTogglerequired | (card: WorkRailCard, open: boolean) => Message | — |
label | string | The rail's accessible name; "Task details" by default |
style | Style | — |