A long conversation folds into a few memory notes, and the next run recalls the right one. A 4:3 card for bento grids, a wide scene for heroes, and a quiet mode for dashboards.
Used for
- Bento card about agent memory
- Dashboard card next to a memory list
- Long chats that need a summary story
- Hero scene for context and recall
Examples
Mode
Recalled note
Installation
npx knowns-ui@latest add context-memoryFor Claude Code, Cursor or Codex: installs it and wires the props to your own data.
Paste this into your coding agent (Claude Code, Cursor, Codex). It checks your project, sets up the registry, runs the install and verifies it.
Install prompt
Install Context memory from Knowns UI into this project. Work step by step, show me each change, and ask before you edit files outside this project.
Context: Knowns UI (https://ui.knowns.dev) is a shadcn registry. Items land in the project as source files. Docs: https://ui.knowns.dev/docs/context-memory
1. Check the project first. Stop and tell me if any of these is missing:
- React 19 and Tailwind CSS v4.
- A components.json at the project root. If there is none, ask me before running `npx knowns-ui@latest init --no-key` (it runs shadcn init when needed, then adds the registries).
2. Run:
```bash
npx knowns-ui@latest add context-memory
```
It writes these files:
- lib/knowns/run.ts
- lib/knowns/json.tsx
- lib/knowns/status.ts
- lib/knowns/tone.ts
- lib/knowns/types.ts
- lib/knowns/use-abortable.ts
- lib/knowns/utils.ts
- components/ui/knowns/illustrations/illust-utils.ts
- components/ui/knowns/illustrations/use-in-view.ts
- lib/knowns/motion.tsx
- lib/knowns/motion-utils.ts
- components/ui/knowns/use-floating.ts
- components/ui/knowns/tooltip.tsx
- components/ui/knowns/tooltip-utils.ts
- components/ui/knowns/badge.tsx
- components/ui/knowns/illustrations/context-memory.tsx
and installs these npm packages: clsx@^2.1.1, tailwind-merge@^3.7.0.
3. While it runs:
- It also adds a few @keyframes (all named kn-*) to the global CSS file (globals.css or the file components.json points at). Let it: they only add animations.
- If it asks to overwrite files under lib/knowns/: these are shared by every Knowns UI item. List them, say whether I changed them (check git), and ask me before you answer.
- If it asks to overwrite any other file, show me the diff and ask me.
4. Verify:
- Every file in the list above exists.
- The project type-checks (for example `npx tsc --noEmit`) and the dev build has no new errors.
5. Use it: follow the examples and props on https://ui.knowns.dev/docs/context-memory, and ask me if anything about my data is unclear.
If the Knowns UI MCP server is connected (https://ui.knowns.dev/docs/ai-and-mcp), use get_component({ name: "context-memory" }) or search_docs for details.
Finish with a short summary: the files you added or changed, the packages you installed, and anything I still need to do.Props
- notes
{ id, text, tag? }[]- Default
3 billing and style notes - What the long conversation is compacted into. Three or four read best; the fifth is not drawn.
- thread
{ from: 'user' | 'agent', text }[]- Default
6 short lines - The conversation that fills first. Up to six lines are drawn; the narrow card shows four.
- messageCount
number- Default
214 - The size of the long run, shown as the counter.
- recall
string- Default
the second note - The id of the note the next run pulls in. It lights up, a line is drawn from it, and it is echoed as 'Recalled'. Notes wrap, they are never cut.
- prompt / answer
string- Default
a refund request and its reply - The next run's first message, and the reply that uses the recalled note.
- mode
'loop'|'once'- Default
'loop' - Loop repeats the story. Once stops on the recalled frame.
- quiet
boolean- Default
false - A compact single card for a dashboard: the memory notes and one recall line, opacity only. No thread, no new run.
- paused
boolean- Default
false - Holds the scene. It also stops offscreen and in hidden tabs.
- className
string- On the root, a size container. Under 560px it is a 4:3 card (the next run takes the thread's place, the memory sits below); from 560px the three parts sit side by side. `quiet` ignores this.
| Prop | Type | Default | Description |
|---|---|---|---|
| notes | { id, text, tag? }[] | 3 billing and style notes | What the long conversation is compacted into. Three or four read best; the fifth is not drawn. |
| thread | { from: 'user' | 'agent', text }[] | 6 short lines | The conversation that fills first. Up to six lines are drawn; the narrow card shows four. |
| messageCount | number | 214 | The size of the long run, shown as the counter. |
| recall | string | the second note | The id of the note the next run pulls in. It lights up, a line is drawn from it, and it is echoed as 'Recalled'. Notes wrap, they are never cut. |
| prompt / answer | string | a refund request and its reply | The next run's first message, and the reply that uses the recalled note. |
| mode | 'loop' | 'once' | 'loop' | Loop repeats the story. Once stops on the recalled frame. |
| quiet | boolean | false | A compact single card for a dashboard: the memory notes and one recall line, opacity only. No thread, no new run. |
| paused | boolean | false | Holds the scene. It also stops offscreen and in hidden tabs. |
| className | string | - | On the root, a size container. Under 560px it is a 4:3 card (the next run takes the thread's place, the memory sits below); from 560px the three parts sit side by side. `quiet` ignores this. |
What it handles
- 01Plays one story in four beats: a long chat fills, its lines fly into a few memory notes as the counter ticks down, a new run opens, and a line is drawn from the note it needs.
- 02Takes your own `notes` (id, text, optional tag), a `thread` of up to six lines and a `messageCount`, and recalls the note named by `recall`, by default the second. Notes wrap onto two lines, they are never cut.
- 03Writes the next run from `prompt` and `answer`, and echoes the recalled note as a 'Recalled' line so it is clear where the answer came from.
- 04Loops with `mode` set to loop, or plays once and holds the recalled frame with `once`, which suits a dashboard that should not keep moving.
- 05Changes shape with its container: under 560px it is a 4:3 card where the next run takes the thread's place; from 560px the thread, the memory and the next run sit side by side.
- 06Turns into one compact card with `quiet`: the memory notes and a single recall line, opacity only, for a dashboard. Text is fixed at 11 to 12.5px, so it stays readable at 320px.
States
- First render
- The conversation is full and the memory slots are empty
- none
- Compact
- Each line travels into its note slot, 40ms apart, and the counter ticks down; the notes land as the lines arrive
- none, a half-second flight
- Recall
- The next run opens, the chosen note lights, a line is drawn from it to the Recalled line, then the answer appears
- 180ms, ease out
- Loop end
- The recalled frame dissolves straight back to the first one, never through an empty scene (loop only)
- 180ms, ease out
- Offscreen, hidden tab or paused
- The story holds where it is
- none
- Reduced motion and the server render
- The finished frame shows: notes kept, one recalled, the answer written
- 0ms
| State | What moves | Timing |
|---|---|---|
| First render | The conversation is full and the memory slots are empty | none |
| Compact | Each line travels into its note slot, 40ms apart, and the counter ticks down; the notes land as the lines arrive | none, a half-second flight |
| Recall | The next run opens, the chosen note lights, a line is drawn from it to the Recalled line, then the answer appears | 180ms, ease out |
| Loop end | The recalled frame dissolves straight back to the first one, never through an empty scene (loop only) | 180ms, ease out |
| Offscreen, hidden tab or paused | The story holds where it is | none |
| Reduced motion and the server render | The finished frame shows: notes kept, one recalled, the answer written | 0ms |
Works with
When to use
When to use
- A feature or bento card about memory: a long chat shrinks to a few notes and the next run starts with the right one.
- A quiet dashboard card next to an agent's memory list, in `quiet` mode: just the notes and one recall line, playing once.
When not to use
- Showing the real memory entries of an agent: use Agent Memory.
- Showing how full the context window is: use Context Window.
Using with AI
Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:
- Add the Knowns UI Context Memory to my app and wire it to my own data.
- I need a feature or bento card about memory: a long chat shrinks to a few notes and the next run starts with the right one. Set that up with the Knowns UI Context Memory.
- Which Context Memory props do I need for a minimal setup? Show me a short example.
With the server connected, your assistant calls get_component({ name: "context-memory" }) and search_docs({ query: "context memory" }).