Screens where an agent works
How a screen shows a person asking an agent, watching it run, deciding where it stops and reading what it made.
Some screens have a person direct or review an agent's work. Every other rule still binds them: one primary action, the states and the words and what moves. This page follows one run, an assistant chasing an overdue invoice, through each thing such a screen shows.
The composer
"use client"
import { useState } from "react"
import { Message } from "@/components/ui/message"
import {
PromptInputAddMenu,
PromptInputDictation,
PromptInputFooter,
PromptInputInset,
PromptInputModelSelect,
PromptInputSelect,
PromptInputSuggestions,
} from "@/components/prompt-input/prompt-controls"
import {
PromptInput,
PromptInputActions,
PromptInputAttachments,
PromptInputBody,
PromptInputSubmit,
PromptInputTextarea,
PromptInputTools,
} from "@/components/prompt-input/prompt-input"
import { PromptInputMenu } from "@/components/prompt-input/prompt-menu"
const customers = [
{ value: "brightwater-dental", label: "Brightwater Dental", hint: "1 overdue" },
{ value: "kestrel-print-co", label: "Kestrel Print Co", hint: "1 sent" },
{ value: "oakline-joinery", label: "Oakline Joinery", hint: "1 sent" },
{ value: "pennant-cycles", label: "Pennant Cycles", hint: "1 paid" },
{ value: "fernhill-bakery", label: "Fernhill Bakery", hint: "1 draft" },
]
const models = [
{ value: "quick", label: "Quick" },
{ value: "thorough", label: "Thorough" },
]
const reaches = [
{ value: "read", label: "Invoices and payments", description: "Reads them and changes nothing" },
{ value: "email", label: "Invoices, payments and email", description: "Also drafts emails for you to send" },
]
const starters = [
{ label: "Chase overdue invoices", prompt: "Chase the invoices that are overdue." },
{ label: "Sum up this month", prompt: "Sum up what was paid this month." },
{ label: "Draft a statement", prompt: "Draft a statement of what Oakline Joinery owes." },
]
export default function TheComposer() {
const [sent, setSent] = useState("")
const [model, setModel] = useState("quick")
const [reach, setReach] = useState("read")
return (
<div className="flex w-full max-w-xl flex-col gap-4">
{sent ? (
<Message key={sent} from="user" animateIn>
<p className="max-w-[85%] rounded-xl bg-muted px-3 py-2 whitespace-pre-wrap">{sent}</p>
</Message>
) : null}
<PromptInput layout="expanded" onSubmit={(message) => setSent(message.text)} className="gap-3">
<PromptInputInset>
<PromptInputBody>
<PromptInputAttachments />
<PromptInputTextarea placeholder="Ask about an invoice, or @ to add a customer" />
<PromptInputTools>
<PromptInputAddMenu />
</PromptInputTools>
<PromptInputActions>
<PromptInputModelSelect models={models} value={model} onValueChange={setModel} />
<PromptInputDictation />
<PromptInputSubmit />
</PromptInputActions>
</PromptInputBody>
<PromptInputFooter>
<PromptInputSelect
label="Can reach"
heading="The assistant can reach"
options={reaches}
value={reach}
onValueChange={setReach}
/>
</PromptInputFooter>
</PromptInputInset>
<PromptInputSuggestions suggestions={starters} />
<PromptInputMenu trigger="@" items={customers} label="Customers" />
</PromptInput>
</div>
)
}
The composer is one rounded box, the same wherever the assistant is called: add at the bottom left, then the model, the microphone and the send at the bottom right, with what the assistant may reach in one strip beneath. Its send is the screen's one filled button and stays quiet while the box is empty, and a home offers three to five starters under it.
A plan a person writes
When
An invoice is 7 days overdueIf
No payment has arrivedAsk
A person approves the reminderWait
5 days, then check again
import { GitBranchIcon, HourglassIcon, UserCheckIcon, ZapIcon } from "@keyline-icons/react"
import { Item, ItemContent, ItemDescription, ItemMedia, ItemTitle } from "@/components/ui/item"
const nodes = [
{ kind: "When", does: "An invoice is 7 days overdue", icon: ZapIcon },
{ kind: "If", does: "No payment has arrived", icon: GitBranchIcon },
{ kind: "Ask", does: "A person approves the reminder", icon: UserCheckIcon },
{ kind: "Wait", does: "5 days, then check again", icon: HourglassIcon },
]
export default function APlanAPersonWrites() {
return (
<ol aria-label="Plan for chasing overdue invoices" className="flex w-full max-w-xs flex-col">
{nodes.map(({ kind, does, icon: Icon }, index) => (
<li key={kind} className="flex flex-col">
{index > 0 ? <span aria-hidden className="ml-5 h-4 w-px bg-border" /> : null}
<Item variant="outline" size="sm" className="bg-card">
<ItemMedia variant="icon">
<Icon aria-hidden />
</ItemMedia>
<ItemContent>
<ItemDescription>{kind}</ItemDescription>
<ItemTitle>{does}</ItemTitle>
</ItemContent>
</Item>
</li>
))}
</ol>
)
}
A plan that a person writes is an object of its own: a canvas of nodes, one each for the trigger, the condition, the approval and the wait.
Steps in one line
import { BanknoteIcon, ChevronRightIcon, MailIcon, PenLineIcon, ReceiptIcon } from "@keyline-icons/react"
import { ActivityItem, ActivityList } from "@/components/ui/agent-activity"
import { Button } from "@/components/ui/button"
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"
import { Message } from "@/components/ui/message"
const steps = [
{ icon: ReceiptIcon, text: "Read 5 invoices: 1 is overdue" },
{ icon: BanknoteIcon, text: "Checked payments from Brightwater Dental: none received" },
{ icon: MailIcon, text: "Read 2 emails to Brightwater Dental: no reply" },
{ icon: PenLineIcon, text: "Drafted a second reminder" },
]
export default function StepsInOneLine() {
return (
<div className="flex w-full max-w-md flex-col gap-4">
<Message from="user">
<p className="max-w-[85%] rounded-xl bg-muted px-3 py-2">Chase the invoices that are overdue.</p>
</Message>
<Message from="assistant" className="gap-2">
<Collapsible defaultOpen>
<CollapsibleTrigger
render={
<Button
variant="ghost"
className="-ml-2 max-w-full shrink text-sm font-normal text-muted-foreground aria-expanded:bg-transparent aria-expanded:text-muted-foreground aria-expanded:hover:bg-muted"
/>
}
>
<ChevronRightIcon
aria-hidden
className="transition-[rotate] duration-(--duration-fast) ease-(--ease-standard) group-data-[panel-open]/button:rotate-90 motion-reduce:transition-none"
/>
<span className="truncate">Read 5 invoices, checked payments, drafted a reminder</span>
</CollapsibleTrigger>
<CollapsibleContent>
<ActivityList aria-label="Steps taken" className="gap-2 pt-2 text-sm text-muted-foreground">
{steps.map(({ icon: Icon, text }) => (
<ActivityItem key={text} className="flex items-center gap-2">
<Icon aria-hidden className="size-4 shrink-0" />
<span className="truncate">{text}</span>
</ActivityItem>
))}
</ActivityList>
</CollapsibleContent>
</Collapsible>
<p className="text-sm text-muted-foreground tabular-nums">Worked for 38s</p>
</Message>
</div>
)
}
A run says what it is doing in rows of one line: an icon, the action and what it found, muted, unboxed and in the smallest text size. A finished group folds to one summary row with a chevron, and the status line carries the time.
Running
"use client"
import { BanknoteIcon, MailIcon, ReceiptIcon } from "@keyline-icons/react"
import { useEffect, useState } from "react"
import { ActivityItem, ActivityList } from "@/components/ui/agent-activity"
import { ThinkingOrb } from "@/components/ui/loader"
import { Message } from "@/components/ui/message"
const done = [
{ icon: ReceiptIcon, text: "Read 5 invoices: 1 is overdue" },
{ icon: BanknoteIcon, text: "Checked payments from Brightwater Dental: none received" },
{ icon: MailIcon, text: "Read 2 emails to Brightwater Dental: no reply" },
]
export default function Running() {
const [seconds, setSeconds] = useState(24)
// The run stays at its fourth step, so that it can be seen: only its clock moves.
useEffect(() => {
const clock = setInterval(() => setSeconds((count) => count + 1), 1000)
return () => clearInterval(clock)
}, [])
return (
<div className="flex w-full max-w-md flex-col gap-4">
<Message from="user">
<p className="max-w-[85%] rounded-xl bg-muted px-3 py-2">Chase the invoices that are overdue.</p>
</Message>
<Message from="assistant" className="gap-2">
<ActivityList aria-label="Steps so far" className="gap-2 text-sm text-muted-foreground">
{done.map(({ icon: Icon, text }) => (
<ActivityItem key={text} className="flex items-center gap-2">
<Icon aria-hidden className="size-4 shrink-0" />
<span className="truncate">{text}</span>
</ActivityItem>
))}
<ActivityItem className="flex items-center gap-2 text-foreground">
<span className="grid size-4 shrink-0 place-items-center">
<ThinkingOrb state="composing" size={20} aria-hidden />
</span>
Drafting a second reminder…
</ActivityItem>
</ActivityList>
<p className="text-sm text-muted-foreground tabular-nums">
Working for {seconds < 60 ? `${seconds}s` : `${Math.floor(seconds / 60)}m ${seconds % 60}s`}
</p>
</Message>
</div>
)
}
Running is told in words: the verb ending in "-ing" with an ellipsis, a spinner on the current step and a status line that counts the time. It has no progress bar.
Waiting for a person
"use client"
import { useState } from "react"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
import { Message } from "@/components/ui/message"
export default function WaitingForAPerson() {
const [decision, setDecision] = useState<"sent" | "dismissed">()
const [undone, setUndone] = useState(false)
return (
<Message from="assistant" className="max-w-md gap-3">
<p className="text-sm text-muted-foreground">Read 5 invoices, checked payments, drafted a reminder</p>
{decision ? (
<div className="flex items-center justify-between gap-4 text-sm text-muted-foreground">
<span role="status">
{decision === "sent" ? "Sent the reminder to Brightwater Dental" : "Dismissed the draft"}
</span>
<Button
variant="ghost"
autoFocus
onClick={() => {
setDecision(undefined)
setUndone(true)
}}
>
Undo
</Button>
</div>
) : (
<Card>
<CardHeader>
<CardTitle>Second reminder for INV-2051</CardTitle>
<CardDescription>To Brightwater Dental</CardDescription>
<CardAction>
<Badge variant="warning">Needs your decision</Badge>
</CardAction>
</CardHeader>
<CardContent className="text-base">
INV-2051 for £1,280.00 is now overdue, and our first reminder has had no reply. Could you tell us when to
expect payment?
</CardContent>
<CardFooter className="justify-end gap-2">
<Button variant="ghost" onClick={() => setDecision("dismissed")}>
Dismiss
</Button>
<Button autoFocus={undone} onClick={() => setDecision("sent")}>
Send reminder
</Button>
</CardFooter>
</Card>
)}
</Message>
)
}
A run that stops for a person shows a card inside the run: a label that says what is needed, one filled action and a quieter refusal, each a verb. While the card waits, its action is the screen's one filled button.
Failed
"use client"
import { useEffect, useState } from "react"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { Card, CardAction, CardContent, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
import { Message } from "@/components/ui/message"
export default function FailedWhereItHappened() {
const [connected, setConnected] = useState(false)
const [state, setState] = useState<"failed" | "sending" | "sent">("failed")
const sending = state === "sending"
// The timer stands in for the send, which fails again until email is reconnected.
useEffect(() => {
if (!sending) return
const timer = setTimeout(() => setState(connected ? "sent" : "failed"), 1500)
return () => clearTimeout(timer)
}, [sending, connected])
return (
<Message from="assistant" className="max-w-md gap-3">
<p className="text-sm text-muted-foreground">Read 5 invoices, checked payments, drafted a reminder</p>
{state === "sent" ? (
<p ref={(line) => line?.focus()} tabIndex={-1} className="text-sm text-muted-foreground outline-none">
Reconnected email and sent the reminder to Brightwater Dental
</p>
) : (
<Card>
<CardHeader>
<CardTitle>The reminder was not sent</CardTitle>
<CardAction>
<Badge role="status" variant={sending ? "info" : "negative"}>
{sending ? "Sending…" : "Failed"}
</Badge>
</CardAction>
</CardHeader>
<CardContent className="text-base">
The email account is disconnected. The draft is kept, and reconnecting email sends it.
</CardContent>
<CardFooter className="justify-end gap-2">
<Button
variant="ghost"
disabled={sending}
focusableWhenDisabled
className="aria-disabled:opacity-50"
onClick={() => setState("sending")}
>
Retry
</Button>
<Button
disabled={sending}
focusableWhenDisabled
className="aria-disabled:opacity-50"
onClick={() => {
setConnected(true)
setState("sending")
}}
>
Reconnect email
</Button>
</CardFooter>
</Card>
)}
</Message>
)
}
A failure sits where it happened, in the run, as a card that gives the cause, what was kept and the fix. The fix is its filled action and trying again is the quieter one.
Finished
"use client"
import {
BanknoteIcon,
CheckIcon,
ChevronRightIcon,
CopyIcon,
MailIcon,
PenLineIcon,
ReceiptIcon,
RefreshCwIcon,
SendIcon,
} from "@keyline-icons/react"
import { useState } from "react"
import { ActivityItem, ActivityList } from "@/components/ui/agent-activity"
import { Button } from "@/components/ui/button"
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"
import { IconSwap } from "@/components/ui/icon-swap"
import { Item, ItemContent, ItemDescription, ItemMedia, ItemTitle } from "@/components/ui/item"
import { ThinkingOrb } from "@/components/ui/loader"
import { Message } from "@/components/ui/message"
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"
const sources = [
{ icon: ReceiptIcon, text: "Read 5 invoices: 1 is overdue" },
{ icon: BanknoteIcon, text: "Checked payments from Brightwater Dental: none received" },
{ icon: MailIcon, text: "Read 2 emails to Brightwater Dental: no reply" },
{ icon: PenLineIcon, text: "Drafted a second reminder" },
{ icon: SendIcon, text: "Sent it once you approved" },
]
const answer = "Brightwater Dental has a second reminder for INV-2051, with £1,280.00 still to pay."
const again = "The second reminder for INV-2051 is with Brightwater Dental, who still owe £1,280.00."
export default function Finished() {
const [finding, setFinding] = useState(answer)
const [writing, setWriting] = useState(false)
const [copied, setCopied] = useState(false)
async function copy() {
try {
await navigator.clipboard.writeText(finding)
setCopied(true)
setTimeout(() => setCopied(false), 2000)
} catch {
setCopied(false)
}
}
// The timer stands in for the assistant writing its answer again.
function regenerate() {
setWriting(true)
setTimeout(() => {
setFinding((current) => (current === answer ? again : answer))
setWriting(false)
}, 1500)
}
return (
<TooltipProvider>
<Message from="assistant" className="max-w-md gap-3">
<Collapsible>
<CollapsibleTrigger
render={
<Button
variant="ghost"
className="-ml-2 max-w-full shrink text-sm font-normal text-muted-foreground aria-expanded:bg-transparent aria-expanded:text-muted-foreground aria-expanded:hover:bg-muted"
/>
}
>
<ChevronRightIcon
aria-hidden
className="transition-[rotate] duration-(--duration-fast) ease-(--ease-standard) group-data-[panel-open]/button:rotate-90 motion-reduce:transition-none"
/>
<span className="truncate">Read 5 invoices, checked payments, sent a reminder</span>
</CollapsibleTrigger>
<CollapsibleContent>
<ActivityList aria-label="Steps taken" className="gap-2 pt-2 text-sm text-muted-foreground">
{sources.map(({ icon: Icon, text }) => (
<ActivityItem key={text} className="flex items-center gap-2">
<Icon aria-hidden className="size-4 shrink-0" />
<span className="truncate">{text}</span>
</ActivityItem>
))}
</ActivityList>
</CollapsibleContent>
</Collapsible>
<p className="flex items-center justify-between gap-4 text-sm text-muted-foreground">
<span className="flex items-center gap-2">
<CheckIcon aria-hidden className="size-4" />
Done
</span>
<span className="tabular-nums">Worked for 42s</span>
</p>
<p role="status" className="flex min-h-10 items-start gap-2">
{writing ? (
<>
<span className="mt-0.5 grid size-4 shrink-0 place-items-center">
<ThinkingOrb state="composing" size={20} aria-hidden />
</span>
Writing the answer again…
</>
) : (
finding
)}
</p>
<Item variant="outline">
<ItemMedia variant="icon">
<MailIcon aria-hidden />
</ItemMedia>
<ItemContent>
<ItemTitle>Second reminder for INV-2051</ItemTitle>
<ItemDescription>Sent to Brightwater Dental</ItemDescription>
</ItemContent>
</Item>
<div className="-ml-1.5 flex items-center gap-1">
<Tooltip>
<TooltipTrigger render={<Button variant="ghost" size="icon" aria-label="Copy the answer" onClick={copy} />}>
<IconSwap state={copied ? "copied" : "copy"}>{copied ? <CheckIcon /> : <CopyIcon />}</IconSwap>
</TooltipTrigger>
<TooltipContent>{copied ? "Copied" : "Copy the answer"}</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger
render={
<Button
variant="ghost"
size="icon"
aria-label="Write the answer again"
disabled={writing}
focusableWhenDisabled
className="aria-disabled:opacity-50"
onClick={regenerate}
/>
}
>
<RefreshCwIcon />
</TooltipTrigger>
<TooltipContent>Write the answer again</TooltipContent>
</Tooltip>
<span role="status" className="sr-only">
{copied ? "Copied" : ""}
</span>
</div>
</Message>
</TooltipProvider>
)
}
A finished run closes its steps with a Done row and puts its status line in the past tense, then gives one sentence of finding, the one thing it made and a row of actions on the answer. Its sources are the steps that read them, one fold away, and the answer carries no numbered citations.