AI-23AINew, October 21, 2026
AI Inline Edit
Select text in a document and ask AI to rewrite it. The edit streams in place as a word-level diff you accept, discard or try again.
Usage
Pass your document as paragraphs and a rewrite that calls your model. It gets the selected text and the instruction, and returns the new text, a Promise of it, or a stream of deltas such as the AI SDK's textStream. The bar works until the text is complete, then writes the changes into the sentence. Stop aborts the signal, and a throw shows the error's message in the bar. onChange gets every paragraph once a rewrite is accepted.
"use client";
import AIInlineEdit from "@/components/kokonutui/ai-inline-edit";
export function Editor({ doc, save }: { doc: string[]; save: (doc: string[]) => void }) {
return (
<AIInlineEdit
onChange={save}
paragraphs={doc}
rewrite={async function* (text, instruction, attempt, signal) {
const res = await fetch("/api/rewrite", {
method: "POST",
body: JSON.stringify({ text, instruction, attempt }),
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;
}
}}
title="Billing launch update"
/>
);
}// app/api/rewrite/route.ts
import { anthropic } from "@ai-sdk/anthropic";
import { streamText } from "ai";
export async function POST(req: Request) {
const { text, instruction, attempt } = await req.json();
const result = streamText({
model: anthropic("claude-sonnet-5-5"),
temperature: attempt > 0 ? 1 : 0.3,
system: "Rewrite the text as asked. Reply with the new text only.",
prompt: `${instruction}:\n\n${text}`,
abortSignal: req.signal,
});
return result.toTextStreamResponse();
}PROSlash Command Menu and more like it are in Kokonut UI Pro
Installation
AI Inline Edit 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-inline-edit.tsx, so the code is yours to change.
npx shadcn@latest add @kokonutui/ai-inline-editOr add it by hand: install its packages, then copy the source from Copy code above into components/kokonutui/ai-inline-edit.tsx.
npm install lucide-react motionProps
titlestringDefault "Billing launch update"paragraphsstring[]Default demo dataThe document, one string per paragraph. Read once, on mount.
rewrite(text: string, instruction: string, attempt: number, signal: AbortSignal) => RewriteDefault demo dataRewrites the selected text. Return the text, a Promise of it, or a stream of deltas (like the AI SDK's textStream); the bar shows it working until the text is complete, then writes the changes in. attempt counts up with each Try again, so you can ask for a different take. signal aborts when the person presses Stop. Throw and the bar shows the error's message.
onChange(paragraphs: string[]) => voidCalled with every paragraph once a rewrite is accepted.
classNamestringExtra classes for the root element.
Rewrite
A rewrite: the text, a Promise of it, or a stream of text deltas.
type Rewrite = string | Promise<string> | AsyncIterable<string>;Dependencies
| Needs | Version | Comes from |
|---|---|---|
lucide-react | ^0.556.0 | npm, installed by the CLI |
motion | ^12.23.25 | npm, installed 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 Agent Lanes
A lead agent hands work to sub-agents that run side by side. Each gets a lane of tool calls, and you can scrub through the whole run.
AI Message Queue
Keep typing while the agent works. Follow-ups stack above the composer, where you can reorder, edit or send one now, and go in one by one when the run ends.

