Memory
What the assistant remembers: a settings page to search, edit and delete memories, the note that appears in a chat when one is saved, and a profile of what it knows grouped by topic.
Loading preview…
Install
- 1
Run this command in your Tailwind CSS project. It adds
components/ai/memory-manage.tsxand installs its dependencies.$ npx shadcn@latest add https://gradientdeck.com/ai-components/r/memory-manage.json
Usage & API
Example
import { MemoryManager } from "@/components/ai/memory-manage"
<MemoryManager
memories={[]}
enabled={true}
onEnabledChange={() => {}}
onEdit={() => {}}
onDelete={() => {}}
onRestore={() => {}}
/>Props MemoryManager
| Prop | Type & description | Required |
|---|---|---|
memories | Memory[] | Required |
limit | number | Optional |
enabled | boolean | Required |
onEnabledChange | (on: boolean) => void | Required |
onEdit | (id: string, text: string) => void | Required |
onDelete | (ids: string[]) => void | Required |
onRestore | (removed: RemovedMemory[]) => voidCalled from the undo toast with the memories and the positions they were removed from. | Required |
Dependencies
- React
- Tailwind CSS
- motion
- lucide-react
Implementation notes
Manage is headed Memory, with the line that details are picked up from chats and carried into new ones. The switch row is first. Search memories and a Select button share the next row. While selecting, that row becomes a checkbox, a selected count, Delete and Cancel. The list is labelled Saved memories. An empty store says they show up as you chat. Each row shows the text and, under it, the saved time and the source chat title. Search highlights matches in both. The footer meter is labelled Memory used. The undo toast sits over the bottom of the section, with Undo and a dismiss control. Editing uses a textarea labelled Edit memory. A blank edit is ignored. The text is only committed when it changed.
Example
import { MemoryUpdated } from "@/components/ai/memory-inline"
<MemoryUpdated
items={[]}
status="saved"
onUndo={() => {}}
onRedo={() => {}}
onManage={() => {}}
/>Props MemoryUpdated
| Prop | Type & description | Required |
|---|---|---|
items | SavedMemory[] | Required |
status | "saved" | "undone""undone" after the person takes the update back. | Required |
onUndo | () => void | Required |
onRedo | () => void | Required |
onManage | () => void | Required |
defaultOpen | boolean | Optional |
Dependencies
- React
- Tailwind CSS
- motion
- lucide-react
Implementation notes
Saved in chat is two exports. Memory updated takes the saved items, a status of saved or undone, and undo, redo and manage callbacks. The closed control reads Memory updated, or Memory update undone after undo. Open, the card says Saved for future chats, or Not saved, and lists the sentences. Undo becomes Save again while the status is undone, and the text is struck through. Manage memories is the second button. Memories used takes items that include a source title. The control reads Used and the count. Open, each line is the text plus from and the source title, with Manage memories as a link when you passed onManage. Both start closed unless defaultOpen is set. The preview places them inside a thread and opens a separate saved-memories sheet. That sheet is demo chrome, not one of the two exports.
Example
import { MemoryProfile } from "@/components/ai/memory-profile"
<MemoryProfile
topics={[]}
onRemoveFact={() => {}}
onForgetTopic={() => {}}
/>Props MemoryProfile
| Prop | Type & description | Required |
|---|---|---|
topics | ProfileTopic[] | Required |
onRemoveFact | (topicId: string, factId: string) => void | Required |
onForgetTopic | (topicId: string) => void | Required |
defaultCollapsed | string[]Topics that start collapsed. | Optional |
Dependencies
- React
- Tailwind CSS
- motion
- lucide-react
Implementation notes
Profile renders one section per topic that still has facts. The header button shows a chevron, the topic icon, the name and the count. Topics in defaultCollapsed start shut. Forget everything about the topic asks for confirmation, naming the count, with Cancel and a Forget button. That confirmation is an alert dialog, and Escape dismisses it. Each fact is the sentence, a button labelled with the source chat, and a remove control. Opening the chat name reveals the quote and a caption: you, in that chat, and the when string. Removing the last fact drops the topic from the list, because empty topics are filtered out. With nothing left, the empty line says nothing is saved and that things mentioned in chats will show up here.
Choosing a layout
Use manage on the memory settings page, where a person should correct a sentence, delete one, or turn memory off without losing the list. Use the chat notes in the thread, directly under or above the reply they belong to. Memories used belongs above the answer that drew on them, because the person can open it and see which lines were used and which chat each came from. Memory updated belongs under the answer that wrote something new, with Undo and Save again, so a wrong save can be taken back before they ever open settings. Both notes have a Manage memories button that should route to the manage page.
Use profile when the right view is topical rather than a flat log. Work, food, travel and preferences are just the topics you pass, each with an icon. It fits a page titled as what the assistant knows, where the action is remove one fact or forget a topic, not edit the wording. Do not use these as the tool allow-list or the MCP server list. A memory here is a sentence about the person or the project. It is not a permission, and none of the three variants call a model or write storage except through the callbacks.
Does turning the switch off delete the saved list?
No. The description under Reference saved memories says turning it off does not delete anything. The list stays, faded, and a note says it is not used in replies and nothing new gets saved. Deleting is a separate action, one row at a time or through Select, and it can be undone from the toast.
Where should the used-memory note sit relative to the reply?
Memories used is the note for context the reply drew on, so it belongs above that reply. Memory updated is the note that something was written, so it belongs under the reply, where Undo can take the save back. Neither one edits the list. Manage memories is the way out to the settings page.