Skip to documentation content

Memory Viewer

List what an agent remembers about a person and their work, and let them search, edit, pin, or forget it.

memory-viewer-demo

Overview

Memory Viewer shows what an agent has learned and keeps: facts about the person, their preferences, and the projects they work on. Each memory shows where it came from, when it was learned, when it was last used, and how sure the agent is. People can search, correct a memory, pin the ones that matter, and forget the rest.

It shows the memories you pass and calls back on every change. Storing them, and giving them to the agent, is your application's work.

Anatomy

Memory Viewer
  • HeaderThe title, the count, search, and a filter for each group
  • Selection barSelect all shown, the selected count, and Forget, when you handle forgetting
  • GroupA label and the memories of one kind
  • MemoryIts text, source, dates, confidence, and actions
  • Undo barWhat was just forgotten, with Undo

Installing memory-viewer brings Button, Checkbox, Input, and Textarea along as registry dependencies.

Behavior

Groups

Memories are grouped by kind. The default groups are About you, Preferences, Facts, and Projects. Pass groups to rename or reorder them; memories of other kinds are listed after them. Pinned memories lead their group.

Search and filter

Search matches the memory and its source, and marks the match. The filter shows one group at a time, with a count for each. Both can be controlled with query and filter.

Editing

Edit turns the memory into a field. Enter or Save keeps the change, Shift+Enter adds a line, and Escape or Cancel leaves it as it was. Saving unchanged or empty text calls nothing.

Forgetting

Forget appears when you pass onForget, along with a checkbox on each memory for forgetting several at once. What happens next depends on onRestore:

  • With onRestore, forgetting happens at once and an Undo bar stays for eight seconds. Undo calls onRestore with the forgotten memories.
  • Without it, Forget asks to confirm first, inline, because it cannot be taken back.

Dates and confidence

Learned dates are absolute and last-used dates are relative, measured from now or the reader's clock after the page loads. Confidence below lowConfidence (0.5 by default) is marked Unsure.

Accessibility

The viewer is a region named by its title, and each group is a list named by its label. Every action is named with its memory, such as "Forget: Works from Lisbon". The filter buttons report whether they are pressed. Focus returns to Edit after editing and moves to Undo after forgetting, and the Undo bar is announced.

KeyAction
TabMove across search, the filters, the checkboxes, and the actions
Enter or SpacePress the focused control
EscapeCancel an edit or a confirmation

Installation

npx honestui@latest add memory-viewer

Usage

import { MemoryViewer } from "@/components/ai/memory-viewer"

<MemoryViewer
  memories={memories}
  onEdit={(id, content) => memory.update(id, { content })}
  onForget={(ids) => memory.forget(ids)}
  onRestore={(items) => memory.restore(items)}
  onPinnedChange={(id, pinned) => memory.update(id, { pinned })}
/>

Examples

Confirm before forgetting

Without onRestore, forgetting asks first. One group is renamed for a team's shared memory, and an unsure memory is marked.

memory-viewer-confirm

API reference

MemoryViewer

Accepts native section props beyond those listed.

PropTypeDefaultDescription
memoriesMemoryItem[]RequiredWhat the agent remembers.
groupsMemoryGroup[]About you, Preferences, Facts, ProjectsGroup order and names.
onEdit(id: string, content: string) => voidNonePassing it shows Edit.
onForget(ids: string[]) => voidNonePassing it shows Forget and selection.
onRestore(memories: MemoryItem[]) => voidNonePassing it makes forgetting immediate, with Undo.
onPinnedChange(id: string, pinned: boolean) => voidNonePassing it shows Pin.
querystringNoneControls the search text.
defaultQuerystring""The starting search text.
onQueryChange(query: string) => voidNoneCalled as the search changes.
filterstring | nullNoneControls the group shown; null shows all.
defaultFilterstring | nullnullThe starting group.
onFilterChange(kind: string | null) => voidNoneCalled when a filter is pressed.
lowConfidencenumber0.5Confidence below this is marked Unsure.
nowDateThe reader's clockThe time relative dates are measured from.
localestringThe reader'sFormats dates.
labelsPartial<MemoryViewerLabels>EnglishEvery visible and announced string.

Types

ExportShape
MemoryItemid, content, kind, createdAt, and optional source, lastUsedAt, confidence, and pinned
MemoryGroupkind and label