What a person and an assistant say to each other: each message with its actions, versions, tool calls, sources and artifacts.
Why are sign-in links expiring before the email arrives?
Support has 12 tickets about it since Friday.
- Scoutfor Ada Lovelace
Thought for 9s
Compare each sign-in email's send time with its delivery time, for the last 200 sends.
Links last 10 minutes, but the mail queue has been taking up to 14. I checked the last 200 sends: 31 arrived after their link expired.
Can you draft a fix that keeps links valid for 30 minutes?
- Scout
On it. I'll change
LINK_TTLto 30 minutes and add a test for a slow queue
import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import type { Actor } from "./ui/uicontext/components/domain/Actor.ts"import { Stream } from "./ui/uicontext/components/kit/Stream.ts"import { ConversationMessage, ConversationView } from "./ui/uicontext/components/kit/Conversation.ts"import { sx } from "./ui/uicontext/components/Sx.ts"const styles = stylex.create({ frame: { inlineSize: "min(100%, 36rem)" },})const ada: Actor = { id: "ada", name: "Ada Lovelace", kind: "person" }const scout: Actor = { id: "scout", name: "Scout", kind: "agent" }const Message = UiSchema.TaggedEnum({ RequestedMessageAction: { message: Schema.String, action: Schema.String, body: Schema.optional(Schema.String) }, ClickedStop: {}, ClickedRetry: {},})export const IssueConversation = Html.component({ name: "IssueConversation", model: Schema.Struct({ messages: Schema.Array(ConversationMessage), reply: Schema.Literals(["streaming", "stopped"]) }), message: Message,}).make({ init: () => ({ reply: "streaming" as const, messages: [ { id: "m1", actor: ada, at: "2026-12-01T09:41:00Z", body: "Why are sign-in links expiring before the email arrives?" }, { id: "m1b", actor: ada, at: "2026-12-01T09:41:30Z", body: "Support has 12 tickets about it since Friday." }, { id: "m2", actor: scout, onBehalfOf: ada, at: "2026-12-01T09:42:00Z", body: "Links last **10 minutes**, but the mail queue has been taking up to 14. I checked the last 200 sends: 31 arrived after their link expired.", // the agent's reasoning folds into "Thought for 9s" reasoning: { seconds: 9, text: "Compare each sign-in email's send time with its delivery time, for the last 200 sends." }, }, { id: "m3", actor: ada, at: "2026-12-01T09:44:00Z", body: "Can you draft a fix that keeps links valid for 30 minutes?" }, ], }), update: { // the thread copies on its own; the app deletes, and stores an edit's new body RequestedMessageAction: ($, { message, action, body }) => action === "delete" ? $.evolve({ messages: (all) => all.filter((m) => m.id !== message) }) : action === "edit" && body !== undefined ? $.evolve({ messages: (all) => all.map((m) => (m.id === message ? { ...m, body } : m)) }) : $.model, // a stopped reply keeps what it wrote, and can run again ClickedStop: ($) => $.evolve({ reply: "stopped" }), ClickedRetry: ($) => $.evolve({ reply: "streaming" }), }, view: (h, { messages, reply }) => h.div.attrs(sx(styles.frame)).children( ConversationView(h, { props: { label: "ENG-142 discussion", me: ada.id, timeZone: "UTC", messages: messages.map((m) => ({ ...m, // known ids (copy, react, retry, edit, delete) show as icon buttons actions: [ { id: "copy", label: "Copy", consequential: false }, { id: "react", label: "Add a reaction", consequential: false }, ...(m.actor.id === scout.id ? [{ id: "retry", label: "Retry" }] : []), ...(m.actor.id === ada.id ? [{ id: "edit", label: "Edit" }, { id: "delete", label: "Delete", tone: "danger" as const }] : []), ], })), pendingActor: scout, }, onEmit: { RequestedAction: (e) => Message.RequestedMessageAction(e) }, slots: { pending: Stream(h, { status: reply, text: "On it. I'll change `LINK_TTL` to 30 minutes and add a test for a slow queue", ...(reply === "streaming" ? { onStop: Message.ClickedStop() } : { onRetry: Message.ClickedRetry() }), }), }, }), ),})Installation
pnpm dlx shadcn@latest add checkfu/uicontext/conversationUsage
import { ConversationView } from "./ui/uicontext/components/kit/Conversation.ts"import type { ConversationMessage } from "./ui/uicontext/components/kit/Conversation.ts"const Message = UiSchema.TaggedEnum({ RequestedMessageAction: { message: Schema.String, action: Schema.String } })export const IssueConversation = (h: Html.H<typeof Message.Type>, messages: ReadonlyArray<ConversationMessage>) => ConversationView(h, { props: { label: "Discussion", messages, // each with an actor, an ISO `at`, a Markdown body and its `actions` me: "ada", }, onEmit: { RequestedAction: ({ message, action }) => Message.RequestedMessageAction({ message, action }) }, })Examples
With an approval
An agent asks before it acts, and the thread keeps the answer.
Email the conference receipt to finance so they can expense it.
- Scoutfor Ada Lovelace
Found it in your inbox: the 2-day pass, $749. Here's the email I'll send.
import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import type { Actor } from "./ui/uicontext/components/domain/Actor.ts"import { Approval } from "./ui/uicontext/components/kit/Approval.ts"import { type ConversationMessage, ConversationViewWithBodies } from "./ui/uicontext/components/kit/Conversation.ts"import { sx } from "./ui/uicontext/components/Sx.ts"const styles = stylex.create({ frame: { inlineSize: "min(100%, 36rem)" },})const ada: Actor = { id: "ada", name: "Ada Lovelace", kind: "person" }const scout: Actor = { id: "scout", name: "Scout", kind: "agent" }const messages: ReadonlyArray<ConversationMessage> = [ { id: "m1", actor: ada, at: "2026-12-01T09:41:00Z", body: "Email the conference receipt to finance so they can expense it." }, { id: "m2", actor: scout, onBehalfOf: ada, at: "2026-12-01T09:42:00Z", body: "Found it in your inbox: the 2-day pass, **$749**. Here's the email I'll send." }, { id: "m3", actor: scout, onBehalfOf: ada, at: "2026-12-01T09:42:00Z", body: "" },]const Message = UiSchema.TaggedEnum({ ChoseSend: { choice: Schema.String } })export const ConversationWithApproval = Html.component({ name: "ConversationWithApproval", model: Schema.Struct({ choice: Schema.NullOr(Schema.String) }), message: Message,}).make({ init: () => ({ choice: null }), update: { ChoseSend: ($, { choice }) => $.evolve({ choice }) }, view: (h, { choice }) => h.div.attrs(sx(styles.frame)).children( ConversationViewWithBodies(h, { props: { label: "Expenses", me: ada.id, messages, timeZone: "UTC" }, onEmit: { RequestedAction: () => undefined }, // the agent's last message is an approval; the others render their text renderBody: (message) => message.id !== "m3" ? undefined : Approval(h, { key: message.id, props: { id: "email-finance", title: "Send this email to [email protected]", fields: [ { label: "Subject", value: "Conference pass receipt, $749" }, { label: "Attachment", value: "receipt-2026.pdf" }, ], digest: "email:[email protected]:7f3a", actor: scout, choices: [ { id: "not-now", label: "Not now" }, { id: "send", label: "Send", primary: true }, ], can: ["answer"], timeZone: "UTC", state: choice === null ? { _tag: "Pending" } : { _tag: "Answered", choice, actor: ada, at: "2026-12-01T09:43:00Z" }, }, onEmit: { Chose: ({ choice }) => Message.ChoseSend({ choice }) }, }), }), ),})Read-only
Conversation renders a transcript without actions, for history, exports and audit pages.
- Alan Turing
The nightly export failed again at the invoices step.
Second night in a row, same step.
- Scoutfor Alan Turing
The invoices table grew past the export's 5,000 row page limit on Friday. Paging the query fixes it; I opened a draft change.
Thanks. Merged it, and tonight's run finished in 4 minutes.
import type { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import type { Actor } from "./ui/uicontext/components/domain/Actor.ts"import { Conversation } from "./ui/uicontext/components/kit/Conversation.ts"import { sx } from "./ui/uicontext/components/Sx.ts"const styles = stylex.create({ frame: { inlineSize: "min(100%, 36rem)" },})const grace: Actor = { id: "grace", name: "Grace Hopper", kind: "person" }const alan: Actor = { id: "alan", name: "Alan Turing", kind: "person" }const scout: Actor = { id: "scout", name: "Scout", kind: "agent" }// A transcript for an audit page or an export: no actions, no composer, grouped by authorexport const RunTranscript = <M>(h: Html.H<M>) => h.div.attrs(sx(styles.frame)).children( Conversation(h, { label: "Incident review transcript", me: grace.id, timeZone: "UTC", messages: [ { id: "t1", actor: alan, at: "2026-11-30T16:02:00Z", body: "The nightly export failed again at the invoices step." }, { id: "t2", actor: alan, at: "2026-11-30T16:03:00Z", body: "Second night in a row, same step." }, { id: "t3", actor: scout, onBehalfOf: alan, at: "2026-11-30T16:04:00Z", body: "The invoices table grew past the export's **5,000 row** page limit on Friday. Paging the query fixes it; I opened a draft change.", }, { id: "t4", actor: grace, at: "2026-11-30T16:10:00Z", body: "Thanks. Merged it, and tonight's run finished in 4 minutes." }, ], }), )An AI chat
Actions sit under the answer: Try again (with another model from its menu), a rating that asks what went wrong, and Read aloud. “‹ 2 / 2 ›” moves between versions, and the tool call it made shows above the reply.
Why does the invoices query return rows in a different order each time?
Thought for 4s
Unordered SELECT. The planner picks the cheapest path, so the order changes with the plan.
Without
ORDER BY, Postgres returns rows in whatever order is cheapest. Sort explicitly:sql · 4 lines select * from invoices where account_id = $1 order by created_at desc limit 50;An index on
(account_id, created_at)keeps it fast.Try againQuill 4 MiniEmber Pro
import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import type { Actor } from "./ui/uicontext/components/domain/Actor.ts"import { Rating } from "./ui/uicontext/components/domain/Chat.ts"import { type MessageAction, type ConversationMessage, ConversationView } from "./ui/uicontext/components/kit/Conversation.ts"import { sx } from "./ui/uicontext/components/Sx.ts"const maya: Actor = { id: "maya", name: "Maya Chen", kind: "person" }const assistant: Actor = { id: "assistant", name: "Assistant", kind: "agent" }const versions = [ "Postgres keeps the order of rows only when you ask for it: add `ORDER BY created_at` to the query.", "Without `ORDER BY`, Postgres returns rows in whatever order is cheapest. Sort explicitly:\n\n```sql\nselect * from invoices\nwhere account_id = $1\norder by created_at desc\nlimit 50;\n```\n\nAn index on `(account_id, created_at)` keeps it fast.",]const actions: ReadonlyArray<MessageAction> = [ { id: "copy", label: "Copy", consequential: false }, { id: "retry", label: "Try again", choices: [{ id: "quill-4-mini", label: "Quill 4 Mini" }, { id: "ember-pro", label: "Ember Pro" }] }, { id: "good", label: "Good answer" }, { id: "bad", label: "Bad answer" }, { id: "speak", label: "Read aloud", consequential: false },]const Message = UiSchema.TaggedEnum({ RequestedMessageAction: { message: Schema.String, action: Schema.String, choice: Schema.optional(Schema.String) },})const styles = stylex.create({ frame: { inlineSize: "min(100%, 40rem)" } })export const AssistantChat = Html.component({ name: "AssistantChat", model: Schema.Struct({ version: Schema.Number, rating: Schema.NullOr(Rating) }), message: Message,}).make({ init: () => ({ version: 2, rating: null }), update: { RequestedMessageAction: ($, { action }) => { if (action === "previous-branch") return $.evolve({ version: 1 }) if (action === "next-branch") return $.evolve({ version: 2 }) if (action === "good" || action === "bad") return $.evolve({ rating: (r) => (r === action ? null : action) }) return $.model }, }, view: (h, model) => { const messages: ReadonlyArray<ConversationMessage> = [ { id: "q", actor: maya, at: "2026-11-30T15:58:00Z", body: "Why does the invoices query return rows in a different order each time?", actions: [{ id: "edit", label: "Edit" }, { id: "copy", label: "Copy", consequential: false }] }, { id: "a", actor: assistant, at: "2026-11-30T15:58:20Z", body: versions[model.version - 1]!, meta: "Quill 4", reasoning: { text: "Unordered SELECT. The planner picks the cheapest path, so the order changes with the plan.", seconds: 4 }, steps: [{ id: "docs", title: "Read the Postgres docs on ORDER BY", status: "succeeded", duration: "0.8s" }], branch: { index: model.version, count: 2 }, actions, ...(model.rating === null ? {} : { feedback: model.rating }), }, ] return h.div.attrs(sx(styles.frame)).children( ConversationView(h, { props: { messages, me: maya.id, label: "Chat", actionsBelow: true }, onEmit: { RequestedAction: ({ message, action, choice }) => Message.RequestedMessageAction({ message, action, ...(choice === undefined ? {} : { choice }) }) }, }), ) },})API reference
ConversationViewComponent
Props
| Name | Type | Default | Description |
|---|---|---|---|
messagesrequired | ConversationMessage[] | — | The messages to show, oldest first |
me | string | — | The signed-in person's id: their messages are right-aligned bubbles |
label | string | "Messages" | The list's accessible name; "Messages" by default |
pendingActor | Actor | — | Who writes what's in the pending slot (a Stream); the slot shows only with an actor |
agentId | string | — | The id agents see this thread by; derived from label when left out |
locale | string | — | Formats each message's ISO at; the reader's own when left out |
timeZone | string | — | The time zone for message times; the reader's own when left out |
actionsBelow | boolean | — | An AI chat's layout: an agent's reply has no name line, its actions sit under it (always shown on the newest), and the reader's own message keeps its edit and copy beside it. |
runnable | { language, label }[] | — | Code blocks in these languages get a button with this label ("Run", "Preview"); a press arrives as action "run-code" |
Events
| Event | Payload | Description |
|---|---|---|
RequestedAction | { message: string; action: string; body?: string; choice?: string; reasons?: string[] } | The person picked an action on a message, such as Copy or Retry. An "edit" of the reader's own message (ConversationView) arrives once they save, with the new body. Paging through versions arrives as "previous-branch" or "next-branch". |
Slots
pending
ConversationView function
Options
| Name | Type | Default | Description |
|---|---|---|---|
messagesrequired | ConversationMessage[] | — | The messages to show, oldest first |
me | string | — | The signed-in person's id: their messages are right-aligned bubbles |
pending | { readonly actor: Actor; readonly children: View.Children } | — | Something still arriving (a Stream), shown last under its actor |
label | string | "Messages" | The list's accessible name; "Messages" by default |
locale | string | — | Formats each message's ISO at; the reader's own when left out |
timeZone | string | — | The time zone for message times; the reader's own when left out |
ConversationViewWithBodiesView function
Options
| Name | Type | Description |
|---|---|---|
renderBodyrequired | (message: ConversationMessage) => View.Input<NoInfer<Message>, R> | Draws a message's body; return undefined to show its text as Markdown |
slots | { readonly pending?: View.Input<NoInfer<Message>, P> } | pending: what's still arriving, such as a Stream, shown under pendingActor |
Accessibility
- The conversation is a list; each message names its author and time for screen readers, and agent messages say who they acted for.
- Message actions appear on hover and on keyboard focus, and always on touch screens.
- Agents can read recent messages and take an action, naming the message it applies to.