Inbox

Everything waiting on you: approvals, questions and reviews.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/inbox

Usage

import { Inbox, type InboxItem } from "./ui/uicontext/components/kit/Inbox.ts"
const Message = UiSchema.TaggedEnum({	OpenedInboxRow: { item: Schema.String },	DoneInboxRow: { item: Schema.String },	ReadInboxRows: { items: Schema.Array(Schema.String), read: Schema.Boolean },	AnsweredInboxRow: { item: Schema.String, action: Schema.String },})// your app owns the rows: mark them read or done on its server, then pass the new list backexport const MyInbox = (h: Html.H<typeof Message.Type>, items: ReadonlyArray<InboxItem>) =>	Inbox(h, {		props: { label: "Inbox", items },		onEmit: {			RequestedOpen: ({ item }) => Message.OpenedInboxRow({ item }),			RequestedDone: ({ item }) => Message.DoneInboxRow({ item }),			RequestedRead: (e) => Message.ReadInboxRows(e),			RequestedSnooze: () => undefined,			RequestedAction: (e) => Message.AnsweredInboxRow(e),			RequestedUndo: () => undefined,		},	})

Examples

A long queue

240 requests waiting on one person. The list scrolls inside its frame and the keys keep working; End jumps to the oldest.

Loading and empty

Placeholder rows while the first page loads, and an empty inbox that says what will arrive.

Nothing waits on you. Agents will ask here when they need a decision.

API reference

Props

Inbox props
NameTypeDefaultDescription
labelrequiredstring—The list's accessible name: "Inbox"
agentIdstring—The id agents see this inbox by; inbox:<label> when left out
itemsrequiredInboxItem[]—What's waiting, newest first: approvals, questions, reviews and mentions
currentstring | null—The open item, highlighted
snoozeChoicesSnoozeChoice[]—When a row can be snoozed until: "Tomorrow" with its ISO time; no Snooze without them
nowstring—Now, as an ISO timestamp, for relative times and snoozing; the reader's clock when left out
loadingboolean—Shows placeholder rows
tools{ read, done }bothWhich row controls the app handles; both by default. A list whose rows have no read state you can set (read: false) or no done (done: false) shows no such control, key or agent action.
emptystring—What an empty inbox says: "You're all caught up"
undo{ id, text } | null—The last change the person can take back, said in a bar under the list with Undo (and z): { id, text: "Marked done: ENG-12" }. The app clears it after a while or on the next change.
localestring—Formats times; the reader's own when left out
timeZonestring—The time zone times are shown in; the reader's when left out

Events

Inbox events
EventPayloadDescription
RequestedOpen{ item: string }The person opened it (by keyboard; a click follows the row's link)
RequestedRead{ items: string[]; read: boolean }The person marked rows read, or unread
RequestedDone{ item: string }Done: out of the inbox
RequestedSnooze{ item: string; until: string | null }Until: an ISO timestamp, or null to wake it now
RequestedAction{ item: string; action: string }One of a row's answers
RequestedUndo{ id: string }Take back the change undo names, by its id

Agent actions

What agents can do with Inbox
ActionDescription
ChoseViewShow all, unread or snoozed rows
ClickedOpenOpen a row's object
ClickedReadMark a row read (true) or unread (false)
ClickedDoneMark a row done: it leaves the inbox
ClickedSnoozeSnooze a row until one of snoozeChoices' until timestamps
ClickedMarkAllReadMark every row read
ClickedUndoTake back the last change, as the undo bar says
ClickedItemActionAnswer a row with one of its actions (see its actions), by row id and action id. Target: { id, title, summary }

Accessibility

  • The rows are links in a list with one Tab stop: Up and Down (or J and K) move, Home and End jump, and Enter opens.
  • E marks a row done and moves to the next, U toggles read, and S snoozes. Each row says whether it's unread or needs you.
  • A row that waits on you carries its answers as buttons. Agents must name the row they answer.

Source