Agents as conversations, each with its face, when it spoke and its status in two lines, plus pinned faces for a phone.
import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { AgentList, AgentRow } from "./ui/uicontext/components/kit/AgentList.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, radius } from "./ui/uicontext/components/tokens.stylex.ts"import { agents } from "./agents.ts"const Message = UiSchema.TaggedEnum({ PickedAgent: { agent: Schema.String } })const styles = stylex.create({ frame: { width: "min(100%, 22rem)", padding: 6, borderRadius: radius.lg, backgroundColor: color.raised } })export const ConsoleAgents = Html.component({ name: "ConsoleAgents", model: Schema.Struct({ open: Schema.String, read: Schema.Array(Schema.String) }), message: Message,}).make({ init: () => ({ open: "chief", read: [] }), update: { PickedAgent: ($, { agent }) => $.evolve({ open: agent, read: (read) => [...read, agent] }) }, view: (h, model) => h.div.attrs(sx(styles.frame)).children(AgentList(h, { label: "Agents", children: agents.map((agent) => AgentRow(h, { key: agent.id, name: agent.name, persona: agent.persona, state: agent.state, stamp: agent.stamp, preview: agent.status, unread: agent.unread && !model.read.includes(agent.id), current: agent.id === model.open, ...(agent.activity === undefined ? {} : { activity: agent.activity }), onSelect: Message.PickedAgent({ agent: agent.id }), })), })),})Installation
pnpm dlx shadcn@latest add checkfu/uicontext/agent-listUsage
import { AgentList, AgentRow } from "./ui/uicontext/components/kit/AgentList.ts"import { formatStamp } from "./ui/uicontext/components/domain/Time.ts"import type { Persona } from "./ui/uicontext/components/kit/Persona.ts"interface Agent { readonly id: string; readonly name: string; readonly persona: Persona; readonly status: string; readonly at: string; readonly unread: boolean }// each row links to its conversation; the time reads "7:34 PM", "Yesterday" or "Tuesday"export const Agents = <M>(h: Html.H<M>, agents: ReadonlyArray<Agent>, open: string, now: string) => AgentList(h, { label: "Agents", children: agents.map((agent) => AgentRow(h, { key: agent.id, href: `/agents/${agent.id}`, name: agent.name, persona: agent.persona, stamp: formatStamp(agent.at, now), preview: agent.status, unread: agent.unread, current: agent.id === open, })), })Examples
A phone's home
The agents opened most sit above the list as big faces, three across; more scroll sideways.
import type { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { AgentList, AgentRow, PinnedAgents } from "./ui/uicontext/components/kit/AgentList.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, radius } from "./ui/uicontext/components/tokens.stylex.ts"import { agents } from "./agents.ts"const styles = stylex.create({ phone: { width: "min(100%, 360px)", padding: 8, borderRadius: radius.xl, backgroundColor: color.raised } })export const PhoneHome = <M>(h: Html.H<M>) => h.div.attrs(sx(styles.phone)).children( PinnedAgents(h, { label: "Pinned agents", agents: agents.slice(0, 4).map((a) => ({ id: a.id, name: a.name, persona: a.persona, state: a.state, href: `#${a.id}`, unread: a.unread })) }), AgentList(h, { label: "Agents", children: agents.slice(3).map((a) => AgentRow(h, { key: a.id, href: `#${a.id}`, name: a.name, persona: a.persona, stamp: a.stamp, preview: a.status, unread: a.unread })), }), )Hard data
A long name and role, an unbroken address, emoji, other scripts, a big count and no status at all, in a 280px column.
- Aleksandra Wiśniewska-Kowalczyk's Procurement AgentBenachrichtigungseinstellungenYesterdaySent 1,284 reminders to [email protected] and 12 others; 3 bounced and need a new address.Unread
- 🦊 Fox11:02 PM👩🏽💻 Priya's PR is merged. 🎉
- 王秀英Nov 12日程を更新しました。木曜日の会議は午後三時からです。
- نور الهدىMondayتم إرسال التقرير الأسبوعي.
- J
import type { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { AgentList, AgentRow } from "./ui/uicontext/components/kit/AgentList.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, radius } from "./ui/uicontext/components/tokens.stylex.ts"const styles = stylex.create({ column: { width: "min(100%, 280px)", padding: 6, borderRadius: radius.lg, backgroundColor: color.raised } })export const HardData = <M>(h: Html.H<M>) => h.div.attrs(sx(styles.column)).children(AgentList(h, { label: "Agents", children: [ AgentRow(h, { key: "long", href: "#long", name: "Aleksandra Wiśniewska-Kowalczyk's Procurement Agent", role: "Benachrichtigungseinstellungen", persona: { shape: "hexagon", color: "teal" }, stamp: "Yesterday", unread: true, starred: true, preview: "Sent 1,284 reminders to [email protected] and 12 others; 3 bounced and need a new address." }), AgentRow(h, { key: "emoji", href: "#emoji", name: "🦊 Fox", persona: { shape: "blob", color: "orange" }, stamp: "11:02 PM", preview: "👩🏽💻 Priya's PR is merged. 🎉" }), AgentRow(h, { key: "cjk", href: "#cjk", name: "王秀英", persona: { shape: "cloud", color: "pink" }, stamp: "Nov 12", preview: "日程を更新しました。木曜日の会議は午後三時からです。" }), AgentRow(h, { key: "rtl", href: "#rtl", name: "نور الهدى", persona: { shape: "drop", color: "blue" }, stamp: "Monday", preview: "تم إرسال التقرير الأسبوعي." }), AgentRow(h, { key: "j", href: "#j", name: "J", persona: { shape: "square", color: "gray" } }), ], }))API reference
AgentRowView function
Options
| Name | Type | Default | Description |
|---|---|---|---|
keyrequired | string | — | Names the row in its list |
namerequired | string | — | — |
personarequired | Persona | — | — |
state | "idle" | "thinking" | "working" | "waiting" | "blocked" | "done" | idle | What it's doing, shown on its face; idle by default |
activity | string | — | What it's doing right now, shown when the pointer rests on the row: "Reading Priya's reply" |
role | string | — | A short role beside the name: "SEO content" |
stamp | string | — | When it last spoke, already formatted: "7:34 PM", "Yesterday" (see formatStamp) |
preview | string | — | Its latest status, as a result and what's next: "Inbox at 3. Two need replies." |
lines | 1 | 2 | 2 | Lines of preview before it's cut; 2 by default |
unread | boolean | — | — |
starred | boolean | — | — |
current | boolean | — | The open conversation |
href | string | — | A link to its conversation; or onSelect for a list that isn't routed |
onSelect | Message | — | — |
style | Style | — | — |
AgentListView function
Options
| Name | Type | Description |
|---|---|---|
labelrequired | string | — |
childrenrequired | View.Children | — |
AgentGroupView function
Options
| Name | Type | Description |
|---|---|---|
keyrequired | string | — |
labelrequired | string | — |
childrenrequired | View.Children | — |
PinnedAgentsView function
Options
| Name | Type | Description |
|---|---|---|
label | string | — |
agentsrequired | PinnedAgent[] | — |