UI

Memory

Assistant memory settings card with a live capacity meter, saved-memories and chat-history switches, filter pills with widening search, inline edit, undoable forget, captured-memory glide, and keyword-classified add field.

import { AgentMemory } from '@uthereal/ui/agent-memory'

Agent memory playground

Memory

What Assistant remembers across chats

Uses and adds to the memories below

Searches past chats when they help

About you3

  • Is learning Portuguese, about 20 minutes a day

    From a chat

  • Lives in Zurich and works on Central European Time

    From a chat

  • Works as a staff product engineer on the billing team at Northwind

    From a chat

Preferences3

  • Wants the short answer first, with details after

    Added by you

  • Prefers metric units and 24 hour times

    From a chat

  • Likes diffs instead of whole files when reviewing code

    From a chat

Projects2

  • Is writing a design doc on usage based pricing, due Oct 31

    From a chat

  • Is moving the billing dashboard to Next.js 16 before the Q4 freeze

    From a chat

People3

  • Chloe Nguyen runs the pricing analysis for the design doc

    Added by you

  • Daniel Kim owns the billing API and reviews every schema change

    From a chat

  • Reports to Sofia Ramirez, with 1:1s on Thursday mornings

    From a chat

Loading interactive preview…

Overview

AgentMemory renders a complete settings card for what an assistant remembers across chats. The header pairs the title with a role="meter" capacity gauge that counts smoothly in tabular numerals, turns amber with a warning icon at 90%, and shifts to danger when full. Two switches control whether the assistant references saved memories or past chat history, crossfading their descriptive subtext on toggle.

Below the switches, readers filter by group (All, About you, Preferences, Projects, People) or widen the search button into a live substring filter with highlighted matches. A Memory updated pill files a captured note into its group with a glide animation, each row edits inline (Enter saves, Escape cancels) or forgets with a countdown Undo bar, and the footer field classifies and files new memories automatically.

Use AgentMemory on assistant settings pages, personalization panels, or drawers beside a chat. For documents and files an agent retrieves from, use Knowledge base. For the token budget of a single conversation, use Context window.

Usage

'use client'
import { AgentMemory, type MemoryItem } from '@uthereal/ui/agent-memory'

export function MemorySettings({
  memories,
  userId,
}: {
  memories: MemoryItem[]
  userId: string
}) {
  return (
    <AgentMemory
      assistantName="Northwind"
      memories={memories}
      captured={null}
      classify={async (text) => {
        const res = await fetch('/api/memory/classify', {
          method: 'POST',
          body: JSON.stringify({ text }),
        })
        const data = (await res.json()) as { group: string }
        return data.group
      }}
      onChange={async (_next, change) => {
        if (change.type === 'forget') {
          await fetch(`/api/users/${userId}/memories/${change.memory.id}`, {
            method: 'DELETE',
          })
          return
        }
        await fetch(`/api/users/${userId}/memories`, {
          method: 'PUT',
          body: JSON.stringify(change.memory),
        })
      }}
      onToggle={(setting, on) => {
        void fetch(`/api/users/${userId}/memory-settings`, {
          method: 'PATCH',
          body: JSON.stringify({ [setting]: on }),
        })
      }}
    />
  )
}

Omit memories, onChange, and classify to run the built-in 11-entry sample set with local edits, keyword classification, and a demo Memory updated capture pill (nothing leaves the browser).

Examples

Near-capacity warning

Set a tight capacity (or fill the store past 90%) to surface the amber warning meter and icon, and pass captured={null} when captures come from a live chat instead of a static banner.

Memory

What Northwind remembers across chats

Uses and adds to the memories below

Searches past chats when they help

About you2

  • Lives in Zurich, works on Central European Time, and prefers async notes

    From a chat

  • Works as a staff product engineer on the billing team at Northwind

    From a chat

Preferences3

  • Wants the short answer first, followed by code snippets and trade-offs

    Added by you

  • Prefers metric units, ISO dates, and 24-hour timestamps in every report

    From a chat

  • Likes unified diffs instead of full files when reviewing pull requests

    From a chat

Projects2

  • Is writing the usage-based pricing design doc ahead of the Oct 31 review

    From a chat

  • Is migrating the billing dashboard to Next.js 16 before the Q4 freeze

    From a chat

People1

  • Daniel Kim owns the billing API and reviews every schema migration

    From a chat

Paused memories

Initialize defaultSettings={{ savedMemories: false, chatHistory: true }} to show the paused notice banner, dimmed memory list, and guarded add field while keeping existing facts visible for review.

Memory

What Northwind remembers across chats

Paused. Nothing new is saved or used

Searches past chats when they help

Northwind won't use or add to these while saved memories are off.

About you3

  • Is learning Portuguese, about 20 minutes a day

    From a chat

  • Lives in Zurich and works on Central European Time

    From a chat

  • Works as a staff product engineer on the billing team at Northwind

    From a chat

Preferences3

  • Wants the short answer first, with details after

    Added by you

  • Prefers metric units and 24 hour times

    From a chat

  • Likes diffs instead of whole files when reviewing code

    From a chat

Projects2

  • Is writing a design doc on usage based pricing, due Oct 31

    From a chat

  • Is moving the billing dashboard to Next.js 16 before the Q4 freeze

    From a chat

People3

  • Chloe Nguyen runs the pricing analysis for the design doc

    Added by you

  • Daniel Kim owns the billing API and reviews every schema change

    From a chat

  • Reports to Sofia Ramirez, with 1:1s on Thursday mornings

    From a chat

Capacity, filters, and undo

Meter thresholds

Usage sharedata-levelVisual indicatorAdd field behavior
< 90%okAccent progress bar and muted percentage readout.Accepts typed memories under 200 characters.
90%–99%highWarning-colored bar, warning label, and triangle-alert icon.Accepts typed memories that fit within capacity.
100%fullDanger-colored bar, danger label, and triangle-alert icon.Refuses new additions with "Memory is full".

Row lifecycle states

StateTriggerBehavior
ViewDefaultShows portrait (for people), plain sentence, source (From a chat or Added by you), and UTC date.
EditingEdit buttonAuto-sizing <textarea> with live 200-character guard; Enter saves, Shift+Enter adds a newline.
UndoForget buttonCrossfades to a countdown bar for undoSeconds (default 5s); onChange fires only after expiration.
LandingCapture pill or AddFlies a copy of the row onto its target slot, then flashes a soft accent highlight that fades cleanly.

API reference

These serializable arguments and defaults come directly from the component schema.

ArgumentType / defaultDescription
assistantNamestringDefault: "Assistant"The assistant's name in the subtitle and notes. Defaults to Assistant.
defaultMemoriesMemoryItem[]Default: [{"id":"m-portuguese","group":"about","text":"Is learning Portuguese, about 20 minutes a day","source":{"kind":"chat","date":"2026-10-02"}},{"id":"m-zurich","group":"about","text":"Lives in Zurich and works on Central European Time","source":{"kind":"chat","date":"2026-09-08"}},{"id":"m-role","group":"about","text":"Works as a staff product engineer on the billing team at Northwind","source":{"kind":"chat","date":"2026-09-08"}},{"id":"m-short","group":"preferences","text":"Wants the short answer first, with details after","source":{"kind":"manual","date":"2026-09-12"}},{"id":"m-units","group":"preferences","text":"Prefers metric units and 24 hour times","source":{"kind":"chat","date":"2026-09-21"}},{"id":"m-diffs","group":"preferences","text":"Likes diffs instead of whole files when reviewing code","source":{"kind":"chat","date":"2026-10-14"}},{"id":"m-pricing","group":"projects","text":"Is writing a design doc on usage based pricing, due Oct 31","source":{"kind":"chat","date":"2026-10-17"}},{"id":"m-next","group":"projects","text":"Is moving the billing dashboard to Next.js 16 before the Q4 freeze","source":{"kind":"chat","date":"2026-10-14"}},{"id":"m-chloe","group":"people","person":{"name":"Chloe Nguyen"},"text":"Chloe Nguyen runs the pricing analysis for the design doc","source":{"kind":"manual","date":"2026-10-17"}},{"id":"m-daniel","group":"people","person":{"name":"Daniel Kim"},"text":"Daniel Kim owns the billing API and reviews every schema change","source":{"kind":"chat","date":"2026-10-09"}},{"id":"m-sofia","group":"people","person":{"name":"Sofia Ramirez"},"text":"Reports to Sofia Ramirez, with 1:1s on Thursday mornings","source":{"kind":"chat","date":"2026-10-01"}}]Initial memories when uncontrolled, newest first within a group. Defaults to an 11-entry sample across all four groups.
capturedCapturedMemory[]Default: [{"note":"Noted: you prefer pnpm over npm","memory":{"id":"m-pnpm","group":"preferences","text":"Prefers pnpm over npm in install commands"}}]Memories the assistant just noted in the current chat, offered as "Memory updated" pills. The first unfiled one shows; pressing it files the memory into its group. Pass null or an empty array to hide the pill.
groupsMemoryGroup[]—Groups in filter order, each with its empty-state line. Defaults to About you, Preferences, Projects and People.
defaultSettingsAgentMemorySettingsDefault: {"savedMemories":true,"chatHistory":true}Starting values for the saved-memories and chat-history switches. Both default to on.
capacityintegerDefault: 2400Characters of memory the assistant can hold. The meter shows the share in use, turns to the warning color at 90% and to danger when full, and the add field refuses new memories when full.
undoSecondsintegerDefault: 5How long a forgotten memory can be restored. Defaults to 5.
changeActionstring—Registered host action requested when a memory is captured or added.
toggleActionstring—Registered host action requested when either setting switch changes.
localestring—BCP 47 locale for source date labels; inherited when omitted.
recipestudio | softDefault: "studio"Visual treatment. Both recipes preserve interaction behavior.
themeAgentMemoryThemeDefault: {}Color mode, accent, and typed semantic token overrides.
motionnone | subtle | expressiveDefault: "subtle"Animation preset. System reduced-motion preferences take precedence.
motionOptionsAgentMemoryMotionOptionsDefault: {}Row height, flight, pill highlight, and label swap timing overrides in milliseconds.
dirltr | rtl—Reading direction; inherited from the page when omitted.
  • MemoryItem accepts { id, text, group, source: { kind: 'chat' | 'manual', date: 'YYYY-MM-DD', href? }, person?: { name, src? } }.
  • CapturedMemory accepts { note, memory: { id, text, group, source?, person? } }.
  • MemoryGroup accepts { id, label, empty }. Every memory and capture group must match a configured group ID.

React integration

PropPurpose
memoriesControlled array of MemoryItem entries. Omit to run uncontrolled state seeded by defaultMemories.
onChange(memories, change)Called after capture, add, edit, and expired forget (change.type: 'capture' | 'add' | 'edit' | 'forget'). Reject to surface errors.
onToggle(setting, on)Called when savedMemories or chatHistory toggles.
classify(text)Maps a typed sentence to a group ID (sync or async). Defaults to guessMemoryGroup.
onAction(action)Called with changeAction on capture/add or toggleAction on switch changes.
presetApplication defaults overridden by explicit instance arguments.
tokensCSS variables applied after the typed theme, forwarded to root and composed child controls.
ref, className, styleApplied to the root <section> element.
Native attributesid, aria-*, data-*, and remaining <section> props forwarded to the root element.

Keyboard & accessibility

KeyAction
TabMoves across both switches, the active filter pill, search toggle, capture pill, rows, and add.
ArrowLeft / ArrowRightMoves between filter pills with roving tabIndex (respects RTL).
Home / EndJumps to the first or last filter pill.
Enter / SpaceActivates switches, filter pills, capture pill, row actions, or Undo.
Enter (in editor)Saves the edited memory (Shift+Enter inserts a line break).
EscapeCancels inline editing or closes and clears search.
  • The capacity bar uses role="meter" with aria-valuemin={0}, aria-valuemax={100}, aria-valuenow, and aria-valuetext ("62% full").
  • Focus moves deterministically across row transitions: into the edit field on Edit, back to Edit on cancel/save, onto Undo on Forget, back to Forget on restore, and onto the active filter if an undo timer expires while focused.
  • A pre-mounted polite role="status" live region announces captures, additions, saves, forgets with their undo window, restores, switch toggles, and search match counts.
  • Row actions reveal on hover or :focus-within on pointer devices and stay visible on touch screens (@media (hover: none)).
  • Below 440px container width, the header stacks vertically, padding tightens, and filter pills scroll horizontally with dynamic edge masks. Logical CSS properties mirror cleanly in RTL (dir="rtl"), and @media (forced-colors: active) maps borders, highlights, and the meter to system colors.

Motion & theming

The active filter pill glides on a shared layoutId snappy spring while rows and groups expand on a critically damped smooth spring (0.4s, zero overshoot). Captured and newly added memories fly to their landing slot on transform only while the row height opens beneath them, followed by a fading accent flash.

Under prefers-reduced-motion: reduce, the flight, layout reflow, height springs, and countdown ring drain turn off while label swaps keep a 120ms opacity crossfade. Setting motion="none" makes every transition immediate (0ms).

theme accepts mode, accent, and typed tokens across these groups:

Token groupCSS custom properties
core--ui-surface, --ui-surface-raised, --ui-text, --ui-text-secondary, --ui-muted, --ui-border, --ui-highlight, --ui-accent, --ui-accent-foreground, --ui-danger, --ui-focus-ring, --ui-radius, --ui-border-width, --ui-shadow, --ui-disabled-opacity, --ui-font, --ui-font-size, --ui-font-weight
extended--ui-surface-sunken, --ui-border-strong, --ui-border-subtle, --ui-track, --ui-info, --ui-success, --ui-warning, --ui-tone-foreground, --ui-overlay, --ui-tint-strength
shape--ui-radius-sm, --ui-popup-radius, --ui-surface-radius
accentTones--ui-accent-strong, --ui-accent-subtle
control--ui-control-height, --ui-control-padding-x, --ui-control-gap, --ui-icon-size
include--ui-item-radius, --ui-shadow-raised

An application-wide UtherealProvider supplies defaults.

Composition

In an agent composition, AgentMemory is a leaf block. Supply plain third-person sentences under 200 characters matching configured group IDs, and wire changeAction and toggleAction to registered host actions. See Building with agents.

{
  "type": "AgentMemory",
  "props": {
    "assistantName": "Assistant",
    "capacity": 2400,
    "undoSeconds": 5,
    "captured": null,
    "changeAction": "update_agent_memory",
    "toggleAction": "toggle_memory_setting"
  },
  "children": []
}

On this page