A team's timeline of people and agents, with days, threads, reactions and private replies.
import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { Approval, ApprovalState } from "./ui/uicontext/components/kit/Approval.ts"import { Channel, ChannelMessage } from "./ui/uicontext/components/kit/Channel.ts"import { Composer } from "./ui/uicontext/components/kit/Composer.ts"import { toggleReaction } from "./ui/uicontext/components/kit/Reactions.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, radius } from "./ui/uicontext/components/tokens.stylex.ts"import { ada, ben, channel, members, moveApproval, now, scout } from "./team.ts"const styles = stylex.create({ frame: { display: "grid", gridTemplateRows: "minmax(0, 1fr) auto", blockSize: 560, inlineSize: "min(100%, 44rem)", overflow: "hidden", borderWidth: 1, borderStyle: "solid", borderColor: color.line, borderRadius: radius.lg, backgroundColor: color.panel, }, composer: { padding: 12 },})const Message = UiSchema.TaggedEnum({ ReactedChannel: { message: Schema.String, emoji: Schema.String, on: Schema.Boolean }, DismissedChannelMessage: { message: Schema.String }, EditedChannelMessage: { message: Schema.String, body: Schema.String }, DeletedChannelMessage: { message: Schema.String }, MarkedUnread: { message: Schema.String }, RequestedEditLast: {}, ChoseMove: { choice: Schema.String }, SentMessage: { text: Schema.String },})export const TeamChannel = Html.component({ name: "TeamChannel", model: Schema.Struct({ messages: Schema.Array(ChannelMessage), move: ApprovalState, sent: Schema.Number, lastRead: Schema.String, editRequest: Schema.NullOr(Schema.Struct({ message: Schema.String, request: Schema.String })), edits: Schema.Number, }), message: Message,}).make({ init: () => ({ messages: channel, move: { _tag: "Pending" }, sent: 0, lastRead: "c4", editRequest: null, edits: 0 }), update: { // show each change at once; a real app also sends it to the server ReactedChannel: ($, { message, emoji, on }) => $.evolve({ messages: (all) => all.map((m) => m.id === message ? { ...m, reactions: toggleReaction(m.reactions ?? [], emoji, on, ada.name) } : m), }), DismissedChannelMessage: ($, { message }) => $.evolve({ messages: (all) => all.filter((m) => m.id !== message) }), EditedChannelMessage: ($, { message, body }) => $.evolve({ messages: (all) => all.map((m) => m.id === message ? { ...m, body, edited: true } : m), }), // a message with replies leaves a placeholder that keeps its thread; any other one goes DeletedChannelMessage: ($, { message }) => $.evolve({ messages: (all) => all.flatMap((m) => m.id !== message ? [m] : m.replies === undefined ? [] : [{ ...m, body: "", deleted: true }]), }), // the "New" line moves up to start at this message MarkedUnread: ($, { message }) => { const at = $.model.messages.findIndex((m) => m.id === message) return at < 1 ? $.model : $.evolve({ lastRead: $.model.messages[at - 1]!.id }) }, // Up in an empty composer opens Ada's last message for editing RequestedEditLast: ($) => { const last = $.model.messages.findLast((m) => m.actor.id === ada.id) // each request is new, so pressing Up again reopens it return last === undefined ? $.model : $.evolve({ edits: (n) => n + 1, editRequest: { message: last.id, request: `edit-${$.model.edits + 1}` } }) }, ChoseMove: ($, { choice }) => $.evolve({ move: { _tag: "Answered", choice, actor: ada, at: "2026-12-01T09:48:00Z" } }), // ids come from a counter, never from the list's length, which shrinks when a message goes SentMessage: ($, { text }) => $.evolve({ sent: (n) => n + 1, messages: (all) => [...all, { id: `ada-${$.model.sent + 1}`, actor: ada, at: "2026-12-01T09:50:00Z", body: text }], }), }, view: (h, { messages, move, lastRead, editRequest }) => h.div.attrs(sx(styles.frame)).children( Channel(h, { key: "triage", // Ada last read Scout's question: what came after it is marked New props: { label: "#triage", messages, me: ada.id, lastRead, now, timeZone: "UTC", typing: [ben], can: ["react", "reply", "edit", "delete"], ...(editRequest === null ? {} : { editRequest }) }, onEmit: { RequestedReaction: ({ message, emoji, on }) => Message.ReactedChannel({ message, emoji, on }), RequestedDismiss: ({ message }) => Message.DismissedChannelMessage({ message }), RequestedEdit: ({ message, body }) => Message.EditedChannelMessage({ message, body }), RequestedOpenThread: () => undefined, RequestedAction: () => undefined, RequestedSave: () => undefined, RequestedDelete: ({ message }) => Message.DeletedChannelMessage({ message }), RequestedRetry: () => undefined, RequestedMarkUnread: ({ message }) => Message.MarkedUnread({ message }), }, // Scout's empty message is its approval card, inline in the channel renderBody: (message) => message.id !== "c4" ? undefined : Approval(h, { key: "move", props: { ...moveApproval, actor: scout, can: ["answer"], state: move, timeZone: "UTC", expires: "Expires in 30 min" }, onEmit: { Chose: ({ choice }) => Message.ChoseMove({ choice }) }, }), }), h.div.attrs(sx(styles.composer)).children(Composer(h, { props: { label: "Message #triage", placeholder: "Message #triage… @ to mention", mentionables: members, editLast: true }, onEmit: { Sent: ({ text }) => Message.SentMessage({ text }), Attached: () => undefined, RequestedStop: () => undefined, RequestedEditLast: () => Message.RequestedEditLast(), Drafted: () => undefined }, })), ),})Installation
pnpm dlx shadcn@latest add checkfu/uicontext/channelUsage
import { Channel } from "./ui/uicontext/components/kit/Channel.ts"import type { ChannelMessage } from "./ui/uicontext/components/kit/Channel.ts"const Message = UiSchema.TaggedEnum({ Reacted: { message: Schema.String, emoji: Schema.String, on: Schema.Boolean }, OpenedThread: { message: Schema.String },})export const TriageChannel = (h: Html.H<typeof Message.Type>, messages: ReadonlyArray<ChannelMessage>) => Channel(h, { props: { label: "#triage", messages, me: "ada", can: ["react", "reply"] }, onEmit: { RequestedReaction: ({ message, emoji, on }) => Message.Reacted({ message, emoji, on }), RequestedOpenThread: ({ message }) => Message.OpenedThread({ message }), RequestedDismiss: () => undefined, RequestedEdit: () => undefined, RequestedAction: () => undefined, RequestedSave: () => undefined, RequestedDelete: () => undefined, RequestedRetry: () => undefined, RequestedMarkUnread: () => undefined, }, })Examples
Read-only, with a running agent
Without react and reply in can, reactions show but can't be changed. An agent's run sits above its message.
import type { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import type { Actor } from "./ui/uicontext/components/domain/Actor.ts"import { Channel } from "./ui/uicontext/components/kit/Channel.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, radius } from "./ui/uicontext/components/tokens.stylex.ts"const styles = stylex.create({ frame: { inlineSize: "min(100%, 44rem)", overflow: "hidden", borderWidth: 1, borderStyle: "solid", borderColor: color.line, borderRadius: radius.lg, backgroundColor: color.panel, },})const lena: Actor = { id: "lena", name: "Lena Fischer", kind: "person" }const omar: Actor = { id: "omar", name: "Omar Haddad", kind: "person" }const relay: Actor = { id: "relay", name: "Release Bot", kind: "agent" }// A guest's view of #releases: no reactions or replies (`can: []`), and the bot's run as a status lineexport const ReleaseChannel = <M>(h: Html.H<M>) => h.div.attrs(sx(styles.frame)).children( Channel(h, { key: "releases", props: { label: "#releases", me: "guest", can: [], now: "2026-12-01T12:00:00Z", timeZone: "UTC", maxHeight: 360, messages: [ { id: "r1", actor: lena, at: "2026-12-01T10:02:00Z", body: "Cutting **2.14** from main after the standup." }, { id: "r2", actor: relay, onBehalfOf: lena, at: "2026-12-01T10:31:00Z", status: { status: "running", label: "Deploying 2.14", detail: "Step 3 of 5: database migrations" }, body: "Release notes are drafted from the 23 merged changes. Production follows staging once checks pass.", reactions: [{ emoji: "🚀", count: 4, mine: false, names: ["Lena Fischer", "Omar Haddad", "Ben Okafor", "Mira Patel"] }], }, { id: "r3", actor: omar, at: "2026-12-01T10:40:00Z", body: "Support is ready for the new export format." }, ], }, onEmit: { RequestedReaction: () => undefined, RequestedOpenThread: () => undefined, RequestedDismiss: () => undefined, RequestedEdit: () => undefined, RequestedAction: () => undefined, RequestedSave: () => undefined, RequestedDelete: () => undefined, RequestedRetry: () => undefined, RequestedMarkUnread: () => undefined, }, }), )Message states
import type { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import type { Actor } from "./ui/uicontext/components/domain/Actor.ts"import { Channel, type ChannelMessage } from "./ui/uicontext/components/kit/Channel.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, radius } from "./ui/uicontext/components/tokens.stylex.ts"const styles = stylex.create({ frame: { display: "grid", blockSize: 620, inlineSize: "min(100%, 44rem)", overflow: "hidden", borderWidth: 1, borderStyle: "solid", borderColor: color.line, borderRadius: radius.lg, backgroundColor: color.panel },})const maya: Actor = { id: "maya", name: "Maya Chen", kind: "person" }const mira: Actor = { id: "mira", name: "Mira Patel", kind: "person" }const ci: Actor = { id: "ci", name: "CI", kind: "integration" }const messages: ReadonlyArray<ChannelMessage> = [ { id: "m1", actor: mira, at: "2026-12-01T10:02:00Z", body: "@Maya Chen can you check the pricing file before the review?", mentioned: true }, { id: "m2", actor: mira, at: "2026-12-01T10:03:00Z", body: "Here it is: https://design.northwind.dev/files/pricing-v4", pinned: true, links: [{ url: "https://design.northwind.dev/files/pricing-v4", site: "Northwind Design", title: "Pricing v4: mobile", description: "Comparison table with sticky plan names and the annual toggle." }], attachments: [{ id: "f1", name: "Pricing copy - final - v7 (Theo's edits).docx", size: 86_000, type: "application/msword", href: "#" }] }, { id: "m3", actor: ci, at: "2026-12-01T10:20:00Z", body: "", card: { title: "Deploy #482 to staging failed", tone: "danger", fields: [{ label: "Step", value: "migrate" }, { label: "Error", value: "lock timeout" }], actions: [{ id: "retry", label: "Retry deploy", primary: true }] } }, { id: "m4", actor: maya, at: "2026-12-01T10:31:00Z", body: "Looks good, one nit on the annual toggle.", edited: true, saved: true }, { id: "m5", actor: maya, at: "2026-12-01T10:32:00Z", body: "", deleted: true }, { id: "m6", actor: maya, at: "2026-12-01T10:33:00Z", body: "Sending the mock in a minute", delivery: "pending" }, { id: "m7", actor: maya, at: "2026-12-01T10:34:00Z", body: "Mock attached", delivery: "failed" },]// A mention, a pinned link with its preview and a file, an app's card, an edited and saved message, one// deleted, one sending and one that didn't send; hover a message for its bar, or long-press on a phoneexport const MessageStates = <M>(h: Html.H<M>) => h.div.attrs(sx(styles.frame)).children(Channel(h, { key: "states", props: { label: "#design-crit", messages, me: maya.id, now: "2026-12-01T12:00:00Z", timeZone: "UTC", can: ["react", "reply", "edit", "delete", "save"] }, onEmit: { RequestedReaction: () => undefined, RequestedOpenThread: () => undefined, RequestedDismiss: () => undefined, RequestedAction: () => undefined, RequestedEdit: () => undefined, RequestedSave: () => undefined, RequestedDelete: () => undefined, RequestedRetry: () => undefined, RequestedMarkUnread: () => undefined, }, }))API reference
Props
| Name | Type | Default | Description |
|---|---|---|---|
agentId | string | — | The id agents see this channel by; derived from label when left out |
labelrequired | string | — | The channel's name, and the timeline's accessible name: "#triage" |
messagesrequired | ChannelMessage[] | — | The timeline's messages, oldest first |
me | string | — | The reader's id: their reactions are theirs, and only their ephemeral messages show |
typing | Actor[] | — | Who is writing right now |
can | Can(["react", "reply", "edit", "delete", "save"]) | both | What the reader may do: react, open threads to reply (both by default), and opt-in: edit and delete their own messages, save messages for later |
quickReactions | string[] | — | The emoji a hovered message offers in one press; three common ones by default |
editRequest | { message, request } | — | Opens one of the reader's own messages for editing, as Up in an empty composer does: a new request opens message, or opens it once it's stored if it's still sending. A remount with the same request opens it again, so clear it after. |
start | string | — | Shown at the very top once there's nothing older: "This is the start of #general." |
lastRead | string | — | The id of the last message the reader has seen. A "New" line marks where the unread ones start, unless the reader wrote them. |
thread | boolean | — | A thread, not a channel: the first message is the parent, and a divider counts the replies |
now | string | — | The time "Today" is measured from (ISO); the reader's clock when left out |
maxHeight | number | — | A fixed height for the timeline, in CSS pixels; otherwise a constrained parent sizes it |
locale | string | — | Formats times and days; the reader's own when left out |
timeZone | string | — | The time zone for times and days; the reader's own when left out |
Events
| Event | Payload | Description |
|---|---|---|
RequestedReaction | { message: string; emoji: string; on: boolean } | Add (on) or take back the reader's reaction |
RequestedOpenThread | { message: string } | The person opened a message's replies |
RequestedDismiss | { message: string } | Hide an ephemeral message |
RequestedAction | { message: string; action: string } | The person picked an action on a message |
RequestedEdit | { message: string; body: string } | The reader saved a new text for their own message; show it with edited: true |
RequestedSave | { message: string; on: boolean } | Save a message for later (on), or take it off the list |
RequestedDelete | { message: string } | Delete the reader's own message, or discard one that failed to send |
RequestedRetry | { message: string } | Send a failed message again |
RequestedMarkUnread | { message: string } | Move the reader's last-read mark to just before this message |
Agent actions
| Action | Description |
|---|---|
ClickedReaction | React to a message, or take the reader's reaction back (on: false). Target: { id, body } |
ClickedReplies | Open a message's thread to read or reply |
ClickedSave | Save a message for later (on: true), or take it off the saved list |
ClickedMessageAction | Take one of a message's actions (its menu or its card's buttons), by message id and action id |
Accessibility
- Each day is a named region with an ordered list of messages; each message names its author and time, and says when only you can see it.
- Message actions show on hover and on keyboard focus: quick reactions, find a reaction, reply in thread, save, and a menu with the rest. On a touch screen a long press opens them as a sheet.
- A message that mentions you, didn't send or was deleted says so in its name; a failed send's Retry is a button. The New line says how many messages are new, and a button jumps back to it.
- Who's typing is announced. Agents read the newest messages and can react, open a thread or take a message's action, naming the message.