Skip to Content
Kokonut UI

AI-25AINew, October 21, 2026

AI Redact

Masks names, emails, card numbers and keys as placeholders before a prompt is sent, then fills the real values back into the reply.

Install with
lucide-react, motion

Usage

Pass respond to answer with your model. It gets the masked message, with placeholders like PERSON_1 and EMAIL_1 in place of the real values, and returns the reply, a Promise of it, or a stream of deltas. Placeholders the model writes back stay as chips while the reply streams, then the real values are filled in on this side once it ends. A throw shows the error's message as the reply. Pass names from your CRM so people are masked too; emails, phone numbers, cards and API keys are found by pattern.

"use client";

import AIRedact from "@/components/kokonutui/ai-redact";

export function SupportComposer({ contacts }: { contacts: string[] }) {
  return (
    <AIRedact
      defaultValue=""
      names={contacts}
      respond={async function* (masked, signal) {
        const res = await fetch("/api/reply", {
          method: "POST",
          body: JSON.stringify({ prompt: masked }),
          signal,
        });
        if (!(res.ok && res.body)) {
          throw new Error("Couldn't reach the model. Try again.");
        }
        const reader = res.body.pipeThrough(new TextDecoderStream()).getReader();
        while (true) {
          const { done, value } = await reader.read();
          if (done) return;
          yield value;
        }
      }}
    />
  );
}

On the server, stream with streamText(...).toTextStreamResponse() and tell the model to keep placeholders exactly as written. The real values never leave the browser.

PROSlash Command Menu and more like it are in Kokonut UI Pro

Installation

AI Redact 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-redact.tsx, so the code is yours to change.

npx shadcn@latest add @kokonutui/ai-redact

Or add it by hand: install its packages, then copy the source from Copy code above into components/kokonutui/ai-redact.tsx.

npm install lucide-react motion

Props

title
stringDefault "Support assistant"
defaultValue
stringDefault demo data

Text already in the composer when it mounts.

names
string[]Default demo data

Names to mask, e.g. contacts from your CRM. Regexes cover the rest.

respond
(masked: string, signal: AbortSignal) => ReplyDefault demo data

Answers the masked prompt. It only ever sees placeholders like EMAIL_1; any it writes back are filled in on this side. Return the reply, a Promise of it, or a stream of text deltas (like the AI SDK's textStream). Throw and the reply shows the error's message.

className
string

Extra classes for the root element.

Reply

A reply: the text, a Promise of it, or a stream of text deltas.

type Reply = string | Promise<string> | AsyncIterable<string>;

Dependencies

NeedsVersionComes from
lucide-react^0.556.0npm, installed by the CLI
motion^12.23.25npm, installed by the CLI
cn from lib/utils.tsshadcn init
React19Your app
Tailwind CSS4Your app

No provider, font or global CSS to set up: the file works as soon as it lands.