An agent's tool calls folded into one line, "Read 4 files, ran 2 commands", that opens into each call.
I’ll swap the HTTP client for fetch with a retry wrapper, then run the API tests.
Done: requests retry on a 429 or 503, up to three times. The tests pass.
import { Command, UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Effect, Schema } from "effect"import { Button } from "./ui/uicontext/components/Button.ts"import { ToolCall, ToolCallGroup } from "./ui/uicontext/components/kit/ToolCallGroup.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, font, space } from "./ui/uicontext/components/tokens.stylex.ts"const plan: ReadonlyArray<ToolCall> = [ { id: "1", kind: "search", target: "withRetry", status: "queued" }, { id: "2", kind: "read", target: "src/api/client.ts", status: "queued" }, { id: "3", kind: "edit", target: "src/api/client.ts", status: "queued", additions: 112, deletions: 84 }, { id: "4", kind: "create", target: "src/api/retry.ts", status: "queued", additions: 47, deletions: 0 }, { id: "5", kind: "run", target: "bun test src/api", status: "queued" },]const durations = [900, 300, 2100, 1400, 2400]const Message = UiSchema.TaggedEnum({ ClickedRun: {}, CompletedCall: { index: Schema.Number } })// stands in for the agent: each call takes a momentconst RunCall = Command.make("RunCall", { args: { index: Schema.Number } }, ({ index }) => Effect.sleep(`${600 + index * 150} millis`).pipe(Effect.as(Message.CompletedCall({ index }))))const styles = stylex.create({ frame: { display: "grid", gap: space.lg, inlineSize: "min(100%, 34rem)" }, text: { margin: 0, fontSize: font.base, color: color.fg },})export const AgentAtWork = Html.component({ name: "AgentAtWork", model: Schema.Struct({ calls: Schema.Array(ToolCall), run: Schema.Number, done: Schema.Boolean }), message: Message,}).make({ init: () => ({ calls: plan.map((c, i): ToolCall => ({ ...c, status: "succeeded", duration: durations[i] ?? 500 })), run: 0, done: true }), update: { ClickedRun: ($) => $.evolve({ calls: [{ ...plan[0]!, status: "running" }], run: (n) => n + 1, done: false }).run(RunCall.make({ index: 0 })), CompletedCall: ($, { index }) => { const calls = $.model.calls.map((c, i): ToolCall => (i === index ? { ...c, status: "succeeded", duration: durations[i] ?? 500 } : c)) const next = plan[index + 1] return next === undefined ? $.evolve({ calls, done: true }) : $.evolve({ calls: [...calls, { ...next, status: "running" }] }).run(RunCall.make({ index: index + 1 })) }, }, view: (h, model) => { const calls = model.calls return h.div.attrs(sx(styles.frame)).children( h.p.attrs(sx(styles.text)).children("I’ll swap the HTTP client for fetch with a retry wrapper, then run the API tests."), calls.length > 0 && ToolCallGroup(h, { key: `run-${model.run}`, props: { id: `run-${model.run}`, calls } }), model.done && h.p.attrs(sx(styles.text)).children("Done: requests retry on a 429 or 503, up to three times. The tests pass."), h.div.children(Button(h, { size: "sm" }).disabled(calls.length > 0 && !model.done).on("click", Message.ClickedRun()).children("Run again")), ) },})Installation
pnpm dlx shadcn@latest add checkfu/uicontext/tool-call-groupUsage
import { type ToolCall, ToolCallGroup } from "./ui/uicontext/components/kit/ToolCallGroup.ts"export const Calls = <M>(h: Html.H<M>, id: string, calls: ReadonlyArray<ToolCall>) => ToolCallGroup(h, { key: id, props: { id, calls } })API reference
Props
| Name | Type | Description |
|---|---|---|
idrequired | string | Names the group for agents |
callsrequired | ToolCall[] | — |
agentId | string | — |
locale | string | — |
Agent actions
| Action | Description |
|---|---|
ClickedHeader | Open or fold the list of tool calls |
Accessibility
- The fold is a button with
aria-expanded; the calls are an ordered list, each saying what it did in words, past tense once done. - A running call has a spinner named Running, and a failed one says Failed with its output beside it. Reduced motion stops the spinner.