Xzero UI
Pro library

Agent memoryPro

One card for what an assistant remembers about you: filter and search memories, edit or forget one in place, and turn saved memories and chat history on or off.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui-pro/agent-memory
Live · keyboard ready

Pass memories and the onEdit, onForget and onToggle callbacks to wire your memory store; with no props it shows a sample set.

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui-pro/agent-memory

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { AgentMemory, type MemoryItem } from "@/components/xzero/blocks/agent-memory/agent-memory";

export function MemorySettings({ memories, userId }: { memories: MemoryItem[]; userId: string }) {
  return (
    <AgentMemory
      memories={memories}
      captured={null}
      classify={text => fetch("/api/memory/classify", { method: "POST", body: text }).then(r => r.json()).then(r => r.group)}
      onChange={async (next, change) => {
        if (change.type === "forget") await deleteMemory(userId, change.memory.id);
        else await saveMemory(userId, change.memory); // throw to show the error in place
      }}
      onToggle={(setting, on) => updatePreference(userId, setting, on)}
    />
  );
}

// Offer what the assistant noted in the current chat as a "Memory updated" pill.
<AgentMemory captured={[{ note: "Noted: you prefer pnpm over npm", memory: { id: "m-pnpm", group: "preferences", text: "Prefers pnpm over npm in install commands" } }]} />

API reference

AgentMemory

One card for what an assistant remembers about you. The header shows how full memory is and two switches for saved memories and chat history. A row of filter pills (All, About you, Preferences, Projects, People) and a search button that widens into a field sit over the list, where each memory is one plain sentence; hovering or focusing a row reveals its source and the Edit and Forget actions in reserved space. A Memory updated pill from the current chat files its memory into the right group with a glide and a soft highlight, Forget leaves an undo bar with a countdown, and the field at the bottom sorts a typed memory into its group.

PropTypeDefaultDescription
memoriesMemoryItem[]sampleMemoriesThe saved memories: { id, text, group, source, person? }. text is one sentence without a closing period; group is "about", "preferences", "projects" or "people"; source is { kind: "chat" | "manual", date (ISO), href? } and reads From a chat or Added by you; person is { name, src? } and shows a small portrait. Newest first within a group. Passing a new array replaces what the card shows, so it can be controlled through onChange.
capturedCapturedMemory[] | nullsampleCapturedMemories the assistant just noted in the current chat: { note, memory }. The first one not yet filed shows as a Memory updated pill with its note, such as "Noted: you prefer pnpm over npm". Pressing it files the memory into its group (switching the filter or clearing the search first if needed), then the pill reads Saved to Preferences and folds away. Pass null or [] to hide the pill.
onChange(memories: MemoryItem[], change: MemoryChange) => void | Promise<void>–Called after every change with the full new list and what changed: { type: "capture" | "add", memory }, { type: "edit", memory, previous } or { type: "forget", memory }. Reject from an add or an edit to show the message in place and keep the old state. Forgets are reported only after their undo window closes. Without it, edits simulate a short save.
onToggle(setting: "savedMemories" | "chatHistory", on: boolean) => void–Called when either switch changes.
settings{ savedMemories?: boolean; chatHistory?: boolean }both onStarting values for the switches. With saved memories off the list dims under a short note and the pill is hidden; each switch's line below its title says what the current setting does.
classify(text: string) => MemoryGroupId | Promise<MemoryGroupId>guessGroupSorts a typed memory into a group, for example with a model call. The default is a keyword guess that checks people first, then preferences, projects and finally about you, and the status region says the preview guessed with keywords.
groupsMemoryGroup[]memoryGroupsThe groups in filter order, each { id, label, empty } where empty is the line a filter shows when its group holds nothing.
capacitynumbersampleCapacityCharacters of memory the assistant can hold. The meter shows the share in use, turns to the warning color with an icon at 90%, and the add field refuses new memories when full. The sample sets it so the demo starts 62% full.
assistantNamestring"Claude"The assistant's name in the subtitle and the notes.
undoSecondsnumber5How long a forgotten memory can be restored.
classNamestring–Class on the outer wrapper.

Keyboard interactions

KeysAction
TabMoves through the two switches, the selected filter pill, the search button, the Memory updated pill, each memory's Edit and Forget buttons (a row's source and actions appear while it has focus), and the add field.
Arrow left, Arrow right, Home, EndMove between the filter pills; only the selected pill is a tab stop.
Enter, SpacePress the focused control: toggle a switch, file the captured memory, start editing, forget, or restore with Undo.
EnterIn the edit field, saves; in the add field, sorts and adds the memory. Shift+Enter adds a line break while editing.
EscapeCancels an edit, or closes the search and clears it.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Guidance for AI tools

Blocks are complete, self-contained screens with sample data. Replace the sample data and connect the callbacks described above. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components