AI-26AINew, October 21, 2026
AI Memory
An assistant that saves what it learns about you into a memory list. New facts replace the ones they contradict, and you can edit or forget any of them.
Usage
Pass your saved memories as initialMemories and a remember that asks your model. It gets the message and the memories in the panel, and returns the reply plus, when there's something worth keeping, a memory to save (with replaces set to an older memory's id to update it). Return it as a Promise and the assistant shows it thinking until it resolves; throw and the reply shows the error's message. onSave, onEdit and onForget tell you what to persist; a forget only fires once its Undo has passed.
"use client";
import AIMemory, { type MemoryChange, type MemoryItem } from "@/components/kokonutui/ai-memory";
export function Assistant({ memories }: { memories: MemoryItem[] }) {
return (
<AIMemory
greeting="Hi. What's new?"
initialMemories={memories}
onEdit={(memory) => fetch(`/api/memories/${memory.id}`, { method: "PUT", body: JSON.stringify(memory) })}
onForget={(memory) => fetch(`/api/memories/${memory.id}`, { method: "DELETE" })}
onSave={(memory, replaced) =>
fetch("/api/memories", { method: "POST", body: JSON.stringify({ memory, replaces: replaced?.id }) })
}
remember={async (text, memories) => {
const res = await fetch("/api/remember", {
method: "POST",
body: JSON.stringify({ text, memories }),
});
if (!res.ok) {
throw new Error("Couldn't reach the model. Nothing was saved.");
}
return (await res.json()) as MemoryChange;
}}
suggestions={[]}
/>
);
}// app/api/remember/route.ts
import { anthropic } from "@ai-sdk/anthropic";
import { generateObject } from "ai";
import { z } from "zod";
export async function POST(req: Request) {
const { text, memories } = await req.json();
const { object } = await generateObject({
model: anthropic("claude-sonnet-5-5"),
schema: z.object({
reply: z.string(),
memory: z
.object({ text: z.string(), group: z.string(), replaces: z.string().optional() })
.optional(),
}),
system: `Reply briefly. Save a memory only for lasting facts about the user. Known: ${JSON.stringify(memories)}`,
prompt: text,
});
return Response.json(object);
}PROSlash Command Menu and more like it are in Kokonut UI Pro
Installation
AI Memory 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-memory.tsx, so the code is yours to change.
npx shadcn@latest add @kokonutui/ai-memoryOr add it by hand: install its packages, then copy the source from Copy code above into components/kokonutui/ai-memory.tsx.
npm install lucide-react motionProps
titlestringDefault "Assistant"greetingstringDefault "Hi Samantha. What's new? Tell me anything and …What the assistant opens with.
initialMemoriesMemoryItem[]Default demo dataYour saved memories, read once on mount.
suggestionsstring[]Default Object.keys(DEMO_REPLIES)Messages offered as one-tap replies.
remember(text: string, memories: MemoryItem[]) => MemoryChange | Promise<MemoryChange>Default demo dataAnswers a message and decides what to remember, from the memories in the panel. Return the change or a Promise of it; the assistant shows it thinking until it resolves. Throw and the reply shows the error's message. Demo when omitted.
onSave(memory: MemoryItem, replaced?: MemoryItem) => voidA memory was saved. With replaced, it took that one's place.
onEdit(memory: MemoryItem) => voidA memory was edited by hand.
onForget(memory: MemoryItem) => voidA memory was forgotten, once its Undo has passed.
classNamestringExtra classes for the root element.
MemoryItem
idrequiredstringtextrequiredstringgrouprequiredstringsavedrequiredstringWhen it was saved, in words, e.g. "Today" or "Sep 12".
MemoryChange
replyrequiredstringmemory{ text: string; group: string; replaces?: string }A fact to save. With replaces, it takes the place of an older one.
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 Redact
Masks names, emails, card numbers and keys as placeholders before a prompt is sent, then fills the real values back into the reply.
AI Autocomplete
A text box that suggests how your sentence ends in grey after the caret. Tab takes it all, the right arrow takes one word, and typing the same letters keeps it.

