Memory mode
ProWhether agents use memory: on, paused or off, with what each does to the memories already kept. Paused never reads as deleted: it says the memories stay. What off does depends on the app, so it says what you tell it (whenOff), and an off that deletes asks first and offers pausing instead. The mode shown is the one the app last reported; while a change is on its way it says so.
Preview
Install
With the Candor CLI
First time? Get started sets up the registry and theme. Or with shadcn directly: npx shadcn@latest add @candor/memory-mode
Usage
"use client"
import * as React from "react"
import type { MemoryModeValue } from "@/lib/know"
import { MemoryMode } from "@/components/memory-mode"
export default function Example() {
// The mode shown is the one the app reports; here the "app" reports the change after a moment.
const [mode, setMode] = React.useState<MemoryModeValue>("on")
const [count, setCount] = React.useState(12)
const [pending, setPending] = React.useState(false)
const change = (next: MemoryModeValue) => {
setPending(true)
setTimeout(() => {
setMode(next)
if (next === "off") setCount(0)
setPending(false)
}, 600)
}
return (
<div className="flex max-w-md flex-col gap-8">
{/* In this app, turning memory off deletes it, so Off asks first and offers pausing instead. */}
<MemoryMode mode={mode} whenOff="deleted" count={count} pending={pending} onChange={change} />
<MemoryMode mode="paused" whenOff="kept" count={12} locked="Your workspace’s policy sets memory for everyone." />
</div>
)
}<MemoryMode>
| Prop | Type | Default | Description |
|---|---|---|---|
| mode | MemoryModeValue | undefined | — | The mode the app last reported. Undefined while it hasn't said. |
| whenOffrequired | "kept" | "deleted" | — | What turning memory off does to existing memories in your app: they're "kept", or "deleted" (asks first). |
| count | number | undefined | — | How many memories are kept now, if known. Shown on paused and off, and in the delete question. |
| onChange | ((mode: MemoryModeValue) => void) | undefined | — | Asks for a change. Show the new mode once the app reports it (`mode`). |
| pending | boolean | undefined | false | A change is on its way. |
| error | string | undefined | — | Why the last change failed, if it did. Pass "" for no reason. |
| locked | string | undefined | — | Why memory can't be changed here: a policy, a role. |
| className | string | undefined | — | Extra classes for the outer element. |
Strings
The fixed words, in English by default. Change any of them under memoryMode in <LocaleProvider strings={{ … }}>; the table is exported as memoryModeStrings.
| Key | English |
|---|---|
| label | Memory |
| on | On |
| onDetail | Agents use what’s remembered and can save new memories. |
| paused | Paused |
| pausedDetail | Agents don’t use or save memories for now. Existing memories are kept as they are, and used again when memory is back on. |
| off | Off |
| offKeptDetail | Agents don’t use or save memories. Existing memories are kept until you forget them. |
| offDeletedDetail | Agents don’t use or save memories, and existing memories are deleted. This can’t be undone. |
| kept | { one: "{count} memory kept", other: "{count} memories kept" } |
| confirmTitle | Turn memory off and delete what’s remembered? |
| confirmCount | { one: "This deletes {count} memory, and it can’t be undone. Pausing keeps it instead.", other: "This deletes {count} memories, and it can’t be undone. Pausing keeps them instead." } |
| confirmNoCount | This deletes every memory, and it can’t be undone. Pausing keeps them instead. |
| confirm | Turn off and delete |
| pauseInstead | Pause instead |
| cancel | Keep “{mode}” |
| changing | Changing… |
| failed | Memory didn’t change: {reason} |
| failedNoReason | Memory didn’t change. |
| unknown | Not reported |