--- title: Composer description: Rich-text chat input with chips, slash/mention commands, attachments, and an ask-user flow. source: composer --- import { Basic } from './composer/demos/basic'; import { Commands } from './composer/demos/commands'; import { Popover } from './composer/demos/popover'; import { AskUserFlow } from './composer/demos/ask-user-flow'; import { AttachmentsDemo } from './composer/demos/attachments'; import { Controlled } from './composer/demos/controlled'; import { Store } from './composer/demos/store'; } file="primitives/composer/demos/basic.tsx" /> ## Usage guidelines - **Chat input** — a hand-rolled contenteditable over a flat segment model: native typing and IME, inline chips, attachments. - **Prefix commands** — type `/`, `@`, or other prefixes to open command lists. - **Panel** — hosts command results, live steps, or an ask-user prompt above the field. - **Headless** — behavior lives in `@intentface/ui`; the demos below show one way to style it, and every class in them is yours to change. - **Isolate it from your stream** — see [Why the composer needs isolating](#why-the-composer-needs-isolating). The editor is the most expensive thing on the page to re-render per token. - **Fits inside your form** — `Composer.Root` renders a `
`, so it can sit inside your own `
`, and `Composer.Textarea`'s `name` puts its text in that form's `FormData`. Submitting your form doesn't send the message, which goes through `Composer.Root`'s `onSubmit`. Pass `render={}` to make the root a form itself. - **Get started** — see [Quick start](/quick-start) to add the package. ## Anatomy The bare nesting — every part is optional except `Composer` and `Container`: ```tsx {(composer) => composer.commands.active && ( {(item) => ( {item.label} )} ) } ``` `Composer.Panel` takes plain children or a callback receiving the composer state, and shows only while its resolved content is non-empty. Gate each part on the state it belongs to (`commands.active`, `askUser.active`, …) and the panel opens and closes to match — priority is the order of your branches. ## Examples ### Mention command list Type `@` to open the command list — the panel routes to it automatically while a prefix is active. `commands` maps each prefix to its config and items. } file="primitives/composer/demos/commands.tsx" /> ### Floating command popover `Composer.Popover` is the floating alternative to `Composer.Panel`. It takes the same children — plain nodes or a state callback — but portals them above the field, anchored to the active trigger token, so the list overlays instead of growing the composer and needs no reserved height. It's collision-aware — near a viewport edge it flips, shifts, and caps its height to stay on screen. Mount one or the other; the content is identical. } file="primitives/composer/demos/popover.tsx" /> ### Ask-user flow Setting the `questions` prop — typically from an assistant's clarifying question — arms the ask-user flow and flips `askUser.active`; compose the `AskUser` parts from `@intentface/ui/ask-user` inside a `Panel` (or `Popover`), reading the current step from `useComposer(c => c.askUser)`. The flow steps through each question (single- or multi-select), and answering or skipping the last one fires `onSubmit` with `{ kind: "answers" }`. Pass a new `questions` array to ask again. } file="primitives/composer/demos/ask-user-flow.tsx" /> ### Attachments `Composer.Attachments` carries the accept/limit policy and the hidden file input — it renders no strip of its own. The visible list is yours: read `useComposer(c => c.attachments)` and lay the items out with the `@intentface/ui/attachments` parts. `Composer.AttachmentTrigger` opens the file dialog, and files can also be dropped onto the composer. } file="primitives/composer/demos/attachments.tsx" /> ### Controlled value `Composer.Textarea` accepts a controlled plain-text `value` with `onValueChange`. Here the parent's buttons drive the field and typing reports back. } file="primitives/composer/demos/controlled.tsx" /> ### Drawing the placeholder `Composer.Textarea`'s `placeholder` sets `aria-placeholder` and stamps `data-placeholder` on the editable while the editor is empty and not composing. The package ships no CSS, so add this rule once and set the colour where you use it. Each doubled line is a fallback and must keep its order: older Safari and Firefox drop the `/ ""` alt text that hides the generated text from assistive tech, and `float: inline-start` fixes right-to-left layouts but is newer than Chrome 111. ```css [data-composer-editor][data-placeholder]::before { content: attr(aria-placeholder); content: attr(aria-placeholder) / ""; float: left; float: inline-start; height: 0; pointer-events: none; } ``` Because `::before` sits inside the editable, it inherits the editor's font and line height and the caret starts before it. For rich or animated content, render a `Composer.Placeholder` as a child instead. ### Reaching a composer from outside Every `Composer.Root` creates its own isolated store, so several composers can share a page with no wiring at all. Reaching into one from outside its tree is the case that needs a handle: `Composer.createStore()` returns one you own, and passing it as `store` lets a toolbar, a shortcut or a status bar drive the composer through `store.controller` or `useComposerStore`, with no context or ref threading. } file="primitives/composer/demos/store.tsx" /> ## Why the composer needs isolating Typing costs nothing outside the composer: editor state lives in the store and parts subscribe by slice with `useComposer(selector)`, so a keystroke re-renders only the parts that read the changed slice — never your app tree. The integration risk runs the other way: a streaming chat re-rendering the composer on every chunk. The editor is the most expensive thing to re-render per token, so isolate it behind a thin bridge — subscribe to your messages state in a small component, derive the panel props there, and hand them to a memoized inner composer: ```tsx // Reads the stream and derives only what the composer needs. const ChatInput = ({ messages, status }: ChatInputProps) => { const panel = derivePanelState(messages, status); return ; }; const ChatInputInner = memo(({ panel, status }: ChatInputInnerProps) => ( )); ``` `derivePanelState` is yours — what belongs in the panel (an ask-user prompt, a status line) is your product's policy. Return a referentially stable value while nothing has changed, so the inner composer bails on every chunk except real panel transitions. ## Keyboard A key belongs to what has focus. The editor's keys are its own, and an open question's keys work from its options and from the page once focus has fallen out of every control. They also work from a container around the composer, such as a popup that a click on the question's text focused. Escape there is the container's, so the popup closes. A key typed into another field inside the composer, such as your own input, is that field's. A command list being open, or a question being asked, takes priority over normal typing. **Normal typing** export const normalKeys = [ { keys: "Enter", description: "Send the message." }, { keys: "Shift + Enter", description: "Insert a soft line break." }, { keys: "Backspace", description: "When the editor is empty and attachments exist, remove the last attachment." }, ]; **Command list open** export const commandKeys = [ { keys: "ArrowUp / ArrowDown", description: "Move the highlight through the items." }, { keys: "ArrowLeft / ArrowRight", description: "Move the caret within the trigger token." }, { keys: "Enter / Tab", description: "Select the highlighted item." }, { keys: "Escape", description: "Close the command list." }, ]; **Ask-user active** export const askUserKeys = [ { keys: "ArrowUp / ArrowDown", description: "Navigate options, from the editor too; up past the first refocuses the editor." }, { keys: "ArrowLeft / ArrowRight", description: "Go to the previous / next question. In the editor, move the caret instead." }, { keys: "Enter", description: "Select the highlighted option. In the editor, answer the step with the typed text." }, { keys: "Space", description: "Select the highlighted option. In the editor, type a space." }, { keys: "Escape", description: "Dismiss the current step." }, { keys: "Any character", description: "Focus the editor and start typing a free-text answer." }, ]; On a focused button inside the composer, Enter and Space press the button. Escape goes to the first of these that applies: 1. An IME conversion in progress, which it cancels. 2. Whatever already handled it. 3. The open command list, which closes. 4. The open question, whose step it dismisses. 5. A generation, which stops while `isGenerating` with an `onStop`. 6. Nothing in the composer, so it reaches the surface around it. While `isGenerating`, `Escape` inside the composer calls `Submit`'s `onStop` (via `useComposerSubmit`): from the editor, a button, or a part a positioned `Panel` renders elsewhere on the page. An Escape outside the composer is left alone, as is one something already handled, such as the command list closing. The composer marks the Escape it uses with `preventDefault()` and stops its propagation, so the same press does not also close a surface around it. That covers a floating `Tabs.Popup` and portaled popups from other libraries, such as a Base UI `Popover` or `Dialog`, which close on any Escape that reaches them. To keep Escape for something else, call `event.preventPrimitiveHandler()` in `Composer.Root`'s `onKeyDown`. That skips every key `Composer.Root` handles, so it also skips an open question's keys from the editor and the options. To stop from anywhere in the chat, handle Escape on its container — the floating dock on the Tabs page does this on `Thread.Root`. ## API reference Every part accepts `className`, `style`, and `render` (see [Styling](/handbook/styling)) and emits a bespoke part attribute (`data-`) unless noted. Only part-specific props and state-driven attributes are listed below. These tables are hand-authored from the package source. ### Composer The `
` that owns submission, store resolution, drag-and-drop, and the prop → store bridges. Renders `data-composer-root`. Pass `render={}` to make it a form; a submit event on that form sends too. The root measures itself and the `Container` in whole px and publishes the result twice. Descendants read the four CSS variables below, with a fallback because each is absent until measured: `height: var(--composer-height, 0px)`. The container pair is absent while no `Container` is mounted. A composer under `display: none` measures 0, which is a real size; under a hidden `` the variables are removed instead. A positioned `Panel` (the default) and the `Popover` are portaled out of the root, so they don't inherit the variables; an `anchor={false}` Panel renders inside the root and does. Read `useComposer((c) => c.size)` inside the tree, portals included, and `useComposerStore(store, (c) => c.size)` from a sibling or parent that holds a `Composer.createStore()` handle. `size` is `null` until a root mounts and while a hidden `` holds it. Don't size the root's own content from `--composer-height`, because that feeds back into the measurement. export const rootProps = [ { name: "onSubmit", type: "(data: ComposerSubmitData) => void | Promise", description: "Fires on message submit and on ask-user answers. Discriminate on data.kind." }, { name: "commands", type: "ComposerCommandsMap", default: "{}", description: "Prefix → command config (kind, trigger, items, suggestion, placeholder). suggestion: false disables ghost-text completion; placeholder sets the per-prefix empty-query hint (never shown alongside a suggestion — the suggestion wins)." }, { name: "questions", type: "AskUserQuestion[]", description: "When set to a non-empty array, asks it and flips askUser.active. A new array asks again; the same array, once answered, stays answered." }, { name: "isSubmitting", type: "boolean", default: "false", description: "Flips Submit to a stop affordance and gates re-submits." }, { name: "value", type: "ComposerSnapshot", description: "Controlled editor content." }, { name: "defaultValue", type: "ComposerSnapshot", description: "Uncontrolled initial editor content." }, { name: "onValueChange", type: "(snapshot: ComposerSnapshot) => void", description: "Fires on editor updates with a fresh snapshot." }, { name: "store", type: "ComposerStore", default: "per-mount instance", description: "An explicit Composer.createStore() handle, whose state outlives remounts. Without one, each mount creates its own store, which goes away with it." }, ]; export const rootAttrs = [ { attribute: "data-composer-root", description: "The root element." }, { attribute: "data-submitting", description: "Present while isSubmitting is true." }, { attribute: "data-dragging", description: "Present while files are dragged over the drop scope." }, { attribute: "--composer-height", values: "whole px", description: "The root's height. Absent until measured." }, { attribute: "--composer-width", values: "whole px", description: "The root's width. Absent until measured." }, { attribute: "--composer-container-height", values: "whole px", description: "The Container's height. Absent until measured, and while no Container is mounted." }, { attribute: "--composer-container-width", values: "whole px", description: "The Container's width. Absent until measured, and while no Container is mounted." }, ]; ### Composer.createStore() Returns a `ComposerStore` handle. Pass it to `store`, read it with `useComposerStore(store, selector)`, and drive it imperatively through `store.controller` (`focus`, `blur`, `clear`, `insertText`, `insertChip`, `getText`, `setText`, `serialize`, `ensureFocus`). `focus` takes the same options as `HTMLElement.focus()`: pass `{ preventScroll: true }` to focus a composer that's already on screen without scrolling the page around it. To subscribe without `useComposerStore`, pass `store.subscribe`, `store.getSnapshot` and `store.getServerSnapshot` to `useSyncExternalStore`. The server snapshot keeps `size` null, as the server rendered it, so a part that hydrates after the root has measured still matches the server HTML. ```tsx import { Composer, useComposerStore } from "@intentface/ui/composer"; // Created outside the tree, so anything can reach it: no context, no ref. const store = Composer.createStore(); export const Chat = () => { const hasContent = useComposerStore(store, (composer) => composer.textarea.hasContent); return ( <> {/* … */} ); }; ``` `onSubmit` receives a discriminated `ComposerSubmitData`: ```ts type ComposerSubmitData = | { kind: "message"; text: string; files: AttachmentItem[] } | { kind: "answers"; answers: ComposerAnswerEntry[] }; ``` `files` are the generic attachment descriptors — your `onSubmit` adapts them to your wire format (this app inlines blob URLs into AI SDK file parts with its `prepareAttachmentsForSend` helper). ### Composer.Container Focus proxy and layout frame. Renders `data-composer-container`; clicking its chrome focuses the editor. Not focusable itself — it carries no role or tab stop. ### Composer.Textarea The editor surface — a contenteditable that acts like a native textarea with atomic mention chips. Renders `data-composer-textarea` wrapping the editable element (`data-composer-editor`). With `name` set, a hidden input mirrors the serialized text into the surrounding form's FormData. export const textareaProps = [ { name: "value", type: "string", description: "Controlled plain-text value." }, { name: "onValueChange", type: "(text: string) => void", description: "Fires on each editor update with plain text." }, { name: "disabled", type: "boolean", default: "false", description: "Makes the editor non-editable." }, { name: "autoFocus", type: "boolean", default: "false", description: "Focus the editor on mount." }, { name: "placeholder", type: "string", description: "Native-textarea-style placeholder string. Sets aria-placeholder and stamps data-placeholder on the editable while it should show; your CSS draws it. For rich content, pass a Composer.Placeholder child instead." }, { name: "submitOn", type: '"enter" | "shift-enter"', default: '"enter"', description: "Which Enter chord sends the message; the other inserts a soft break. Pair \"shift-enter\" with enterKeyHint=\"enter\"." }, { name: "renderChip", type: "(chip: ChipData) => ReactNode", description: "Custom renderer for a committed chip. ChipData carries prefix, value, label, and icon — the default renders label only; add chip.prefix in front to show the trigger." }, { name: "children", type: "ReactNode | ((state: { disabled: boolean; filled: boolean; composing: boolean }) => ReactNode)", description: "Rendered beside the editable, inside the Textarea's relative wrapper. Typically a Composer.Placeholder. A function receives the editor state, to gate the content yourself." }, { name: "maxLength", type: "number", description: "Logical-length cap — one per character, one per chip. IME input is capped at composition commit." }, { name: "required", type: "boolean", default: "false", description: "Native form validation via the hidden input (requires name)." }, { name: "name", type: "string", description: "Mirrors the serialized text (chips as chip-markdown) into FormData." }, { name: "spellCheck", type: "boolean", default: "false", description: "Forwarded to the editable element, with autoCapitalize, enterKeyHint, inputMode, dir, and aria-* passthrough." }, { name: "onFocus / onBlur / onKeyDown / onKeyUp / onPaste / onCopy / onCut", type: "React handlers", description: "Route to the editable element, native-textarea style: they run before the engine, and preventDefault overrides the engine's handling (keydown/clipboard)." }, ]; export const textareaAttrs = [ { attribute: "data-composer-textarea", description: "The wrapper element." }, { attribute: "data-composer-editor", description: "The contenteditable editor element." }, { attribute: "data-filled", description: "Present when the editor has content." }, { attribute: "data-disabled", description: "Present when disabled." }, { attribute: "data-composing", description: "Present on the wrapper during an IME composition." }, { attribute: "data-placeholder", description: "On the editable element while a placeholder string is set and the editor is empty and not composing." }, { attribute: "data-command-badge", description: "On the active trigger token decoration (e.g. the leading @)." }, { attribute: "data-command-placeholder", description: "On the inline hint decoration after a trigger." }, { attribute: "data-command-hint", description: "The badge's hint element — ghost-text completion of the highlighted item, or the empty-query placeholder. A real span, engine-owned like the badge." }, ]; ### Composer.Placeholder Rich or animated placeholder content, overlaid on the editable at `inset: 0`. It gates itself: inside `Composer.Textarea` it shows only while the editor is empty and not composing, and it throws outside one. Renders `data-composer-placeholder` and is hidden from assistive tech. export const placeholderProps = [ { name: "children", type: "ReactNode", description: "The placeholder content." }, { name: "keepMounted", type: "boolean", default: "false", description: "Keep rendering while the editor has content or composes, marked data-hidden." }, ]; export const placeholderAttrs = [ { attribute: "data-composer-placeholder", description: "The overlay element." }, { attribute: "data-hidden", description: "Present while the placeholder would be hidden. Only seen with keepMounted." }, ]; ### Composer.ContextWindow A slot above the input, open only when it has content and no panel is active. Content-driven and exposing `data-open`/`data-closed` like `Panel`/`Popover`. Renders `data-composer-context-window`. export const contextWindowAttrs = [ { attribute: "data-composer-context-window", description: "The context-window element." }, { attribute: "data-open", description: "Present while the window has content and no panel is active." }, { attribute: "data-closed", description: "Present while empty or yielding to an active panel." }, ]; ### Composer.Actions Layout row for buttons. Renders `data-composer-actions`. No part-specific props or state attributes. ### Composer.Submit Submit button that morphs into a stop control while generating. Renders `data-composer-submit`. export const submitProps = [ { name: "isGenerating", type: "boolean", default: "false", description: "Morphs into a stop control: clicking calls onStop instead of sending." }, { name: "onStop", type: "() => void", description: "Abort callback — on click while generating, or on Escape inside the composer (see Keyboard)." }, ]; export const submitAttrs = [ { attribute: "data-composer-submit", description: "The button element." }, { attribute: "data-generating", description: "Present while isGenerating is true." }, ]; ### Composer.Attachments Owns the hidden file input and renders the file strip / drop zone as children. This part does **not** take `className` / `style` / `render` and emits no part attribute of its own. export const attachmentsProps = [ { name: "convert", type: "(file: File) => AttachmentItem", default: "blob ingestion", description: "Converts a picked/dropped/pasted File into an item. Override (with destroy) for custom ids, extra fields, or upload-backed items." }, { name: "destroy", type: "(item: AttachmentItem) => void", default: "revoke blob URL", description: "Cleanup for a removed item, or a sent one once onSubmit has settled." }, { name: "accept", type: "string", default: '"" (everything)', description: "Accepted MIME types — the package imposes no policy; pass yours." }, { name: "maxFiles", type: "number", default: "unlimited", description: "Maximum file count." }, { name: "maxFileSize", type: "number", default: "unlimited", description: "Maximum size per file." }, { name: "multiple", type: "boolean", default: "true", description: "Allow selecting multiple files." }, { name: "globalDrop", type: "boolean", default: "false", description: "Accept drops anywhere in the document, not only over the composer." }, { name: "children", type: "ReactNode", description: "The visible strip / drop zone." }, ]; ### Composer.AttachmentTrigger Button that opens the file dialog. Renders `data-composer-attachment-trigger` named "Add attachment" by default. No part-specific props. ### Composer.Panel A surface region above the field. `children` is either plain nodes or a callback `(composer) => ReactNode` receiving the composer state, so you pick what to show by priority (`commands.active ? : askUser.active ? : null`). By default (`anchor`) it renders as a **collision-aware, portaled overlay** anchored to the `Container` — flipping / shifting / sizing to stay on screen (via `@floating-ui/dom`); anchor a ref/element elsewhere, or pass `anchor={false}` for an **in-flow** block that grows the composer. Pass `pin` to hold the placement without flip/shift. `open` — whether the resolved content is non-empty — arrives as the `render` prop's second argument and is mirrored to `data-open`/`data-closed`; the host stays mounted through its close animation (exposing `data-starting-style`/`data-ending-style`) and, when positioned, publishes the resolved `data-side`/`data-align` so the transition origin follows a flip. When positioned, the overlay publishes the anchor's geometry as CSS variables — opt in from your styling rather than having the primitive impose a size (Base UI-style): `--anchor-width` / `--anchor-height` (the anchor's box, e.g. `width: var(--anchor-width)` to match the composer) and `--anchor-available-height` (free space toward the resolved side, e.g. `max-height: var(--anchor-available-height)` so the content scrolls instead of overflowing). export const panelProps = [ { name: "children", type: 'ReactNode | ((composer: Omit) => ReactNode)', description: "Panel content, or a callback that reads composer state and returns one branch by priority." }, { name: "anchor", type: "boolean | Element | RefObject", description: "Positioned, portaled overlay (default true, anchored to the Container) or an in-flow block (false). A ref/element anchors elsewhere. Match its width with width: var(--anchor-width)." }, { name: "side", type: '"top" | "bottom" | "left" | "right"', description: "Overlay preferred side; flips to the opposite on collision. Default \"top\"." }, { name: "align", type: '"start" | "center" | "end"', description: "Overlay alignment along the side. Default \"center\"." }, { name: "sideOffset", type: "number", description: "Overlay gap between the anchor and the panel, in px. Default 0." }, { name: "pin", type: "boolean", description: "Hold side/align without collision repositioning (drops flip + shift). Default false." }, ]; export const panelAttrs = [ { attribute: "data-composer-panel", description: "The panel element." }, { attribute: "data-open", description: "Present while the resolved content is non-empty." }, { attribute: "data-closed", description: "Present while empty." }, { attribute: "data-starting-style", description: "Present on the first open frame — the enter transition's from-state." }, { attribute: "data-ending-style", description: "Present while the close transition runs, before unmount." }, { attribute: "data-side", values: '"top" | "bottom" | "left" | "right"', description: "Resolved side when positioned (anchor) — the origin to animate from." }, { attribute: "data-align", values: '"start" | "center" | "end"', description: "Resolved alignment when positioned." }, ]; ### Composer.Popover Floating alternative to `Composer.Panel`. Takes the same `children` (nodes or a state callback) but portals them to the body, anchored to the active trigger token — overlaying instead of growing the composer. It's collision-aware (via `@floating-ui/dom`): opens upward by default and flips below / shifts / caps its height to stay on screen, tracking the anchor across scroll, resize, and composer growth. It stays mounted and exposes `open` the same way as `Panel` (the `render` prop's second argument plus `data-open`/`data-closed`), and publishes the resolved `data-side`/`data-align` so the transition origin follows a flip. Positioning is written imperatively — the styled layer supplies only box and animation styling, not `left`/`top`. export const popoverProps = [ { name: "children", type: 'ReactNode | ((composer: Omit) => ReactNode)', description: "Same content as Panel — nodes or a state callback." }, { name: "pin", type: "boolean", description: "Hold the placement without collision repositioning (drops flip + shift). Default false." }, ]; export const popoverAttrs = [ { attribute: "data-composer-popover", description: "The portaled popover element." }, { attribute: "data-open", description: "Present while the resolved content is non-empty." }, { attribute: "data-closed", description: "Present while empty (stays mounted, holding its last position)." }, { attribute: "data-side", values: '"top" | "bottom" | "left" | "right"', description: "Resolved side — flips to \"bottom\" when there's no room above; the origin to animate from." }, { attribute: "data-align", values: '"start" | "center" | "end"', description: "Resolved alignment along the side." }, ]; ### Composer.Command The command popup for one prefix. Renders `data-composer-command-list` **only while that prefix is active** (returns nothing otherwise). export const commandListProps = [ { name: "prefix", type: "string", default: "(required)", description: "Which trigger prefix this list serves." }, ]; export const commandListAttrs = [ { attribute: "data-composer-command-list", description: "The list element." }, { attribute: "data-loading", description: "Present while async items are being fetched." }, { attribute: "data-empty", description: "Present when no items match." }, ]; ### Composer.CommandList Maps resolved items through a render-prop child. Renders `data-composer-command-items`. export const commandItemsProps = [ { name: "children", type: "(item: Item) => ReactNode", default: "(required)", description: "Row renderer, called per resolved item." }, ]; ### Composer.CommandItem One selectable row. Renders `data-composer-command-item`. To disable a row, set `disabled: true` on its item data (not on this component) — the row renders inert (`aria-disabled` + `data-disabled`), the keyboard highlight skips it, and mouse selection is a no-op. Disabled rows still match the filter. export const commandItemProps = [ { name: "value", type: "string", default: "(required)", description: "Item identity, matched against the highlight and selection." }, ]; export const commandItemAttrs = [ { attribute: "data-composer-command-item", description: "The row button." }, { attribute: "data-highlighted", description: "Present when this row is the active highlight." }, { attribute: "data-disabled", description: "Present when the item data marks this row disabled." }, ]; ### Row content & states `Composer.CommandItemIcon`, `Composer.CommandItemLabel`, and `Composer.CommandItemDescription` render ``s with `data-composer-command-item-{icon,label,description}`. `Composer.CommandLoading` (`composer-command-loading`), `Composer.CommandEmpty` (`composer-command-empty`), and `Composer.CommandDismiss` (`composer-command-dismiss`, a button) fill the list states — all render only your children, so you supply the copy. To group, give `Composer.CommandGroup` a `groupBy` and a render callback: it buckets the resolved (already-filtered) items by your key — in first-appearance order, so keyboard nav still flows top-to-bottom — and calls the callback once per group with `(group, items)`, wrapping each in `data-command-group`. You render `Composer.CommandGroupLabel` (`composer-command-group-label`) + the group's items: ```tsx item.group}> {(group, items) => ( <> {group} {items.map((item) => ( {item.label} ))} )} ``` ### Ask-user The composer owns the ask-user *state* — `questions`, the current step, the answers — but renders none of the question UI. Compose that from the `AskUser` namespace in `@intentface/ui/ask-user`, reading the step through `useComposer((c) => c.askUser)` and gating the enclosing `Panel` or `Popover` on `askUser.active`. `askUser.active` is true while a question is being asked. It turns false as soon as the last step is answered or skipped, even while `questions` stays set, so a panel gated on it closes then. To ask again, pass a new array; passing the same array does nothing. `AskUser.Dismiss` is a plain button you wire to `askUser.dismissStep`; `AskUser.Continue` is a `type="button"` that continues the step with the editor's text, like Enter, and does nothing once the last step is answered. Neither ships copy — supply the labels as children, and read `askUser.isLastStep` to switch the continue wording. ### Hooks export const hooks = [ { name: "useComposer", type: "(selector?) => Selected", description: "Subscribe to a slice of the nearest composer's store. Throws outside ." }, { name: "useComposerStore", type: "(store, selector?) => Selected", description: "Same, for an explicit createStore() handle — the outside-the-tree twin." }, { name: "useComposerController", type: "() => ComposerEditorState", description: "The nearest composer's imperative editor controls (focus, insert, clear, …)." }, { name: "useComposerSubmit", type: "(options) => ComposerSubmitState", description: "Computes Submit's disabled/generating/onClick; auto-disables while empty or submitting; aborts on Escape inside the composer." }, { name: "useCommandListItems", type: "() => { items, state }", description: "The resolved items and load state inside a Command. Throws outside one." }, ];