Chat Permission

Pro

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.

The auth tests started failing after I bumped the session library. Can you fix them?

The session library renamed expiresAt to expires, and three tests still read the old field. I updated them. Now I want to run the auth suite to confirm.

Run pnpm test --filter auth?

Installation#

# One-time setup (tokens + lib helpers)npx koalaui-cli@latest init# Activate your Pro license (once per machine)npx koalaui-cli@latest login <key># Add this component (its dependencies come along)npx koalaui-cli@latest add chat-permission

Usage#

This example is part of Koala UI Pro

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.

The auth tests started failing after I bumped the session library. Can you fix them?

The session library renamed expiresAt to expires, and three tests still read the old field. I updated them. The tests pass, but the dev server still serves the old session code. I want to clear the build cache.

Run rm -rf .next/cache?

This cannot be undone.

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.

The auth tests started failing after I bumped the session library. Can you fix them?

The session library renamed expiresAt to expires, and three tests still read the old field. I updated them. Now I want to run the auth suite to confirm.

Run pnpm test --filter auth?

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.

PropTypeDefaultDescription
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.
defaultOptionstring"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.
placeholderstring"Ask anything…"The composer placeholder shown while the request folds back. Match your composer's.
autoFocusbooleantrueFocuses the default option on mount, or the request itself when destructive.
announcementstring"Permission requested"What the live region says when the request appears.
Data attributeDescription
data-statepending, denying while the field is open, or closing after an answer.
data-riskThe risk.
data-outcomeallowed 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.

PropTypeDefaultDescription
value"once" | "chat" | "always" | string-Comes back as scope in onAllow.
hintReact.ReactNode-Tooltip content on hover. The default option shows its label and Enter on its own.
Data attributeDescription
data-valueThe value.
data-defaultPresent 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.

PropTypeDefaultDescription
childrenReact.ReactNode"No, tell the agent what to do"The row's label.
placeholderstring"Tell the agent what to do instead"Placeholder and accessible name of the field.
sendLabelstring"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.

PropTypeDefaultDescription
state"pending" | "allowed" | "denied""pending"What the line says and which icon it shows.
iconReact.ReactNode-The tool's glyph, shown while pending.
summaryReact.ReactNode-Muted after the words, usually the command.
timeReact.ReactNode-At the right, in tabular figures.
childrenReact.ReactNode-The words. Defaults to Waiting for your answer, Allowed or Denied.

FAQ#

Chat Permission is the everyday prompt: one question, a pick, done, in the composer's place. Approval is the card for high-stakes requests that need a preview, a risk level, an expiry or edits before running, such as a payment, an email or a deploy.