AI-01AINew, December 6, 2026
AI Composer
A chat composer that shows what the model will read. Type @ to pull in files, docs, chats and pages as tokens in the message, and watch each one get read when you send.
Usage
Pass sources for what @ can pull in. With the AI SDK, hand the composer useChat's status and stop: "submitted" and "streaming" turn Send into Stop, "ready" finishes the run, and "error" puts the message back in the box. onSubmit gets the text, the model, the sources mentioned (in the order they appear) and the files.
"use client";
import { useChat } from "@ai-sdk/react";
import AIComposer, { type ComposerSource } from "@/components/kokonutui/ai-composer";
const sources: ComposerSource[] = [
{ id: "readme", label: "README.md", kind: "file", detail: "Repository root", tokens: 1800 },
{ id: "roadmap", label: "Roadmap", kind: "doc", detail: "Doc · Product", tokens: 4200 },
];
export function Chat() {
const { sendMessage, status, stop } = useChat();
return (
<AIComposer
accept="image/*,.pdf,.md"
defaultValue=""
onStop={stop}
onSubmit={({ text, model, sources, files }) => {
const transfer = new DataTransfer();
for (const file of files) transfer.items.add(file);
sendMessage(
{ text, files: transfer.files },
{ body: { model, sources: sources.map((s) => s.id) } }
);
}}
sources={sources}
status={status}
tokenLimit={200_000}
/>
);
}Without status, return a promise from onSubmit instead: the run lasts until it settles, signal aborts on Stop, and a rejection puts the message back. With neither, the composer plays a short pretend run.
Details
- A mention is
@and a source'slabel, so labels can hold spaces ("@Q4 launch plan"). Backspace takes a whole mention at once. - Hovering a chip lights up its words, clicking it selects them, and its × takes them out of the message.
- Send is drawn as the key that sends. It goes down when you press Enter, reads "New line" while Shift is held, and turns into Stop (or Esc) during a run.
- ↑ in an empty box brings back the last message.
accept,maxFilesandmaxFileSizecheck files as they are picked, dropped or pasted. A file turned away callsonErrorwith a code (accept,max_file_sizeormax_files), and the bar says why.tokensis a rough size per source. The bar adds them up with the files and the message, and pasttokenLimitit says by how much and Send waits.
PROSlash Command Menu and more like it are in Kokonut UI Pro
Installation
AI Composer is a free, open-source React component in the Kokonut UI AI collection. Add it with the shadcn CLI, which copies the source into components/kokonutui/ai-composer.tsx, so the code is yours to change.
npx shadcn@latest add @kokonutui/ai-composerOr add it by hand: install its packages, then copy the source from Copy code above into components/kokonutui/ai-composer.tsx.
npm install lucide-react motionProps
sourcesComposerSource[]Default built-inWhat @ can pull in: files, docs, past chats and pages.
modelsComposerModel[]Default built-indefaultModelstringDefault "Claude Opus 5.5"Name of the model picked at first.
defaultValuestringDefault built-inThe message the composer opens with. Pass "" for an empty box.
placeholderstringDefault "Ask anything. Type @ to add context"onSubmit(message: ComposerMessage, options: { signal: AbortSignal }) => unknownSends the message. Return a promise to keep the run going until it settles; signal aborts on Stop. If it rejects, the message comes back into the box. Without it (and without status), a short pretend run plays.
statusComposerStatusDrives the run from your chat instead of from onSubmit's promise: pass useChat().status. "submitted" and "streaming" show Stop, back to "ready" finishes the run, and "error" puts the message back.
onStop() => voidCalled on Stop (the key, or Esc) during a run.
acceptstringFile types to take, as in an input's accept: "image/*,.pdf".
maxFilesnumberDefault 8Most files one message can carry.
maxFileSizenumberDefault 20 * MBLargest file, in bytes.
onError(error: ComposerError) => voidCalled when a file is turned away; the bar also says why.
tokenLimitnumberThe model's context budget in tokens. Past it, the bar says by how much and Send waits until something is taken out.
classNamestringExtra classes for the root element.
ComposerSource
idrequiredstringlabelrequiredstringWhat follows @ in the message, e.g. "pricing-table.tsx".
kindrequiredComposerSourceKinddetailstringSecond line in the @ menu, e.g. a folder or where the doc lives.
tokensnumberRough size in tokens, added up in the context bar.
ComposerModel
namerequiredstringdescriptionstringOne line under the name in the menu.
ComposerMessage
textrequiredstringmodelrequiredstringsourcesrequiredComposerSource[]The sources
filesrequiredFile[]Files picked, dropped or pasted in.
ComposerStatus
The same states as the AI SDK's useChat().status, so you can pass it on.
type ComposerStatus = "ready" | "submitted" | "streaming" | "error";ComposerError
coderequired"max_files" | "max_file_size" | "accept"messagerequiredstringComposerSourceKind
type ComposerSourceKind = "file" | "doc" | "chat" | "web";Dependencies
| Needs | Version | Comes from |
|---|---|---|
lucide-react | ^0.556.0 | npm, installed by the CLI |
motion | ^12.23.25 | npm, installed by the CLI |
dropdown-menu | shadcn/ui, added by the CLI | |
cn from lib/utils.ts | shadcn init | |
| React | 19 | Your app |
| Tailwind CSS | 4 | Your app |
No provider, font or global CSS to set up: the file works as soon as it lands.
AI Components
Free React components for AI chat and agents: prompt inputs, voice, tool calls and approvals, in-chat checkout and order tracking, citations and diff review.
AI Input Selector
AI chat input with a model menu, a separate Effort control, file chips you can drop or paste, a / command menu, and Stop while replying.

