Chat Permission
The quick yes or no an agent asks in a chat. While it waits, the composer becomes the question, so the answer happens where the person already types: allow once, allow for this chat, or tell it what to do instead. A line in the thread keeps the record.
Installation#
Usage#
The preview is yours to explore. Its code comes with a Pro license, paid once and used in every project.
Have a license? Unlock it here
Anatomy#
A header that asks the command as a question, the options as menu rows, and a deny row that becomes a field. It renders in the composer's own shell, same width, same place. Once answered, the rows fold away into an empty composer and onClose hands the slot back to yours. In the thread, ChatPermissionReceipt waits for the answer and then records it.
import {
ChatPermission,
ChatPermissionHeader,
ChatPermissionIcon,
ChatPermissionTitle,
ChatPermissionDescription,
ChatPermissionCommand,
ChatPermissionOptions,
ChatPermissionOption,
ChatPermissionDeny,
ChatPermissionReceipt,
} from "@/components/ui/chat-permission"
<ChatPermissionReceipt />
<ChatPermission>
<ChatPermissionHeader>
<ChatPermissionIcon />
<ChatPermissionTitle>
<ChatPermissionCommand />
</ChatPermissionTitle>
<ChatPermissionDescription />
</ChatPermissionHeader>
<ChatPermissionOptions>
<ChatPermissionOption />
<ChatPermissionDeny />
</ChatPermissionOptions>
</ChatPermission>Destructive#
With risk="destructive" the allow row turns red, nothing is highlighted and Enter does nothing until a row has focus. Offer only Allow once: a destructive call is allowed one at a time or not at all. Say it in ChatPermissionDescription; nothing else turns red.
Scopes#
Each option is a scope, and its value comes back in onAllow. Name the tool in the label so the person knows exactly what they let through. Add Always only where your app has a settings page to take it back.
Receipts#
ChatPermissionReceipt is the line that stays in the thread. It waits while the composer asks, then its icon turns into the answer. Render it from stored data to show past decisions.
API reference#
ChatPermission
The request, rendered in the composer's own shell so it takes the composer's place. A role="group" labelled by its title, with a polite live region that announces the request and the answer. Arrow keys, Home and End move between the rows; Esc opens the deny field. Forwards PromptInput props.
| Prop | Type | Default | Description |
|---|---|---|---|
| risk | "default" | "destructive" | "default" | destructive turns the allow rows red, highlights nothing and takes the Enter shortcut away: a destructive call needs a deliberate pick. |
| defaultOption | string | "once" | The option that takes focus on mount and answers to Enter. |
| onAllow | ({ scope }) => void | - | Called once with the picked option's value. |
| onDeny | ({ reason }) => void | - | Called once on deny. reason is the trimmed text from the deny field, or undefined. |
| onClose | () => void | - | Called when the rows have folded away after an answer. Swap your composer back in here. |
| placeholder | string | "Ask anything…" | The composer placeholder shown while the request folds back. Match your composer's. |
| autoFocus | boolean | true | Focuses the default option on mount, or the request itself when destructive. |
| announcement | string | "Permission requested" | What the live region says when the request appears. |
| Data attribute | Description |
|---|---|
| data-state | pending, denying while the field is open, or closing after an answer. |
| data-risk | The risk. |
| data-outcome | allowed or denied, once answered. |
ChatPermissionHeader
The question: icon column, title and optional description. Forwards native <div> props.
ChatPermissionIcon
The 16px glyph of the tool. aria-hidden. Renders a <span>.
ChatPermissionTitle
Ask it as the command itself: Run <command>?. Labels the request. Renders a <p>.
ChatPermissionDescription
One muted line, for the warning on a destructive call. Describes the request. Renders a <p>.
ChatPermissionCommand
Inline mono command or tool name, for the title and option labels. Renders a <code>.
ChatPermissionOptions
Stacks the rows. Forwards native <div> props.
ChatPermissionOption
An allow row, in the same anatomy as a menu item. Picking it answers straight away. Forwards native <button> props.
| Prop | Type | Default | Description |
|---|---|---|---|
| value | "once" | "chat" | "always" | string | - | Comes back as scope in onAllow. |
| hint | React.ReactNode | - | Tooltip content on hover. The default option shows its label and Enter on its own. |
| Data attribute | Description |
|---|---|
| data-value | The value. |
| data-default | Present on the option that answers to Enter. |
ChatPermissionDeny
The last row. Picking it turns the row into a one-line field with a send button, so the person types the correction where they always type. Enter sends, empty is a plain deny, Esc goes back to the rows.
| Prop | Type | Default | Description |
|---|---|---|---|
| children | React.ReactNode | "No, tell the agent what to do" | The row's label. |
| placeholder | string | "Tell the agent what to do instead" | Placeholder and accessible name of the field. |
| sendLabel | string | "Send" | Accessible name of the send button. |
ChatPermissionReceipt
The line that stays in the thread: waiting while the request is open, then the answer. The icon morphs into a check or a prohibit sign. Built on a plain Tool row.
| Prop | Type | Default | Description |
|---|---|---|---|
| state | "pending" | "allowed" | "denied" | "pending" | What the line says and which icon it shows. |
| icon | React.ReactNode | - | The tool's glyph, shown while pending. |
| summary | React.ReactNode | - | Muted after the words, usually the command. |
| time | React.ReactNode | - | At the right, in tabular figures. |
| children | React.ReactNode | - | The words. Defaults to Waiting for your answer, Allowed or Denied. |