Skip to content
SettingsMemory managerMenu

Memory manager

Everything the assistant remembers, searchable and editable in place. Delete hides a memory at once and offers Undo for 5 seconds before it is really gone.

Search, edit in place, delete with a 5 second undo, grouped by topic.

Installation

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/memory-manager.json

Usage

tsx
import { MemoryManager } from "@/components/ui/chatcn/memory-manager"

<MemoryManager
  memories={memories}
  usage={0.62}
  onUpdate={(id, text) => updateMemory(id, text)}
  onDelete={(id) => deleteMemory(id)}
  onDeleteAll={() => deleteAllMemories()}
/>

onDelete runs when the undo window closes, or when the manager unmounts with a delete still pending. Your store never needs a restore endpoint.

Examples

States

Loading, empty, no results, memory off, nearly full and managed by an admin.

Props

PropTypeNotes
memoriesMemory[]{ id, text, topic?, source?, updatedAt? }
onUpdate(id, text) => voidOmit to make memories read only
onDelete(id) => voidCalled after the 5 s undo window
onDeleteAll() => voidShows Delete all with an inline confirmation
loadingbooleanStatic skeleton rows
enabled, onEnableboolean, () => voidMemory off notice with Turn on
usagenumber0 to 1. Warns at 90%
lockedReasonReactNodeAdmin managed: no edits or deletes
query, defaultQuery, onQueryChangeControlled or uncontrolled search
groupByTopicbooleanDefault true when memories have topics
emptyStateReactNodeReplace the empty state

Keyboard

KeyAction
Esc in searchClear the search
Enter while editingSave. Never fires during IME composition
Shift+Enter while editingNew line
Esc while editingCancel and return focus to Edit

Accessibility

  • Edit and Delete are labelled icon buttons, revealed on hover or focus and always visible on touch.
  • After a delete, focus moves to the next memory's actions, or the search field. Undo returns focus to the restored memory.
  • The undo toast is a polite live region and pauses its timer while hovered or focused. Capacity is a meter with its percentage as text.

Motion

  • A deleted row folds away in 160 ms, so the list never jumps. A restored row fades back in.
  • The undo toast rises 8 px and fades in over 200 ms. Row actions appear instantly: they are used constantly.