uimaxxer

Composer

The input box for agent apps. One Captain switch turns one agent into a swarm: the agents deal out of the switch into a tray, with the count and the model they run on. Mentions, skills, files and a model picker, and Send becomes Stop while it works.

npx shadcn@latest add https://uimaxxer.com/r/composer.json
PasskeysFix the duplicate Stripe charge

Checkout charges twice when Stripe retries. Find out why.

Captain

The webhook handler keys on the request, not the Stripe event, so a retry looks new. I can move it onto the job queue and dedupe on event.id.

  • stripe-webhook-504s.log13 KB

Usage

import { CaptainComposer, fromChat } from "@/components/ui/composer"
import { useChat } from "@ai-sdk/react"

const chat = useChat()

<CaptainComposer
  {...fromChat(chat)}
  models={[
    { id: "opus", label: "Opus 5.5" },
    { id: "sonnet", label: "Sonnet 5.5" },
  ]}
  triggers={[
    { char: "@", items: agents },
    { char: "/", items: skills, startOnly: true },
  ]}
/>

Props

PropTypeDefaultWhat it does
onSubmit(message: ComposerMessage) => void | Promise<void>Text, mentions, attachments, the model and the Captain settings. A rejected promise puts the message back.
status"ready" | "submitted" | "streaming" | "error""ready"The same four states as useChat().status. Busy turns Send into Stop.
onStop() => voidStop, or Escape while it works.
models{ id; label; brand?; description?; usd? }[]The model picker, with real provider marks. usd is kept as data for your thread (planSwarm returns the estimate); the composer shows no money.
captain{ enabled; size; autonomy; budget; types; crew? }Controlled Captain settings; pair with onCaptainChange. crew is the model id the agents run on.
defaultCaptainCaptainSettingson, 12 agents, $2Uncontrolled starting settings.
triggers{ char; items; startOnly?; limit? }[]@ mentions and / skills. items is a list or a (query) => items function, sync or async.
value / defaultValuestringControlled or starting text. Mentions in a starting text are marked.
defaultAttachmentsAttachment[]Files already attached, such as a restored draft.
upload(file: File) => Promise<{ url }>Upload as files are added. Without it, files stay local.
queuebooleantrueMessages sent while it works wait and go out in order.
placeholderstringAsk the Captain / Ask <model>While it works the field reads Add to the task.
noCaptainbooleanfalseHide the Captain switch and its swarm.

Keyboard

Enter
Send
Shift+Enter
New line
@ and /
Open mentions or skills
↑ ↓ then Enter or Tab
Pick a mention
Backspace after a mention
Remove it whole
Escape
Close the menu, or stop the turn
↑ in an empty field
Bring back the last message

Accessibility

  • A labelled textarea with a listbox for mentions (aria-activedescendant), so IME, spellcheck and screen readers behave natively.
  • The Captain is a real switch named Captain; the swarm is read once as one sentence: who leads, how many agents and on which model.
  • The model picker and the Captain settings are a listbox and a dialog with arrow keys, Escape and focus returned to their buttons.
  • Sends, stops, queued messages and errors are announced in a polite live region.
  • Reduced motion fades the swarm in place instead of dealing it.