<!-- GENERATED by scripts/build-llms.mjs from llms/retrieval.md — do not edit this file. -->

# `lr-memory-panel`

- **Import** `import '@aceshooting/lyra-ui/components/lr-memory-panel.js';` (stable tag alias; registers the tag)
- **Class** `LyraMemoryPanel`, also available unregistered from `@aceshooting/lyra-ui/components/retrieval/memory-panel/memory-panel.class.js`
- **Family** `components/retrieval/` — see `llms/index.md` for its siblings
- **Status** `stable` since `4.1.0` — see the maturity and deprecation policy in `llms/shared.md`
- **Release history** [CHANGELOG.md](../../CHANGELOG.md); family-wide breaking-change summaries: [llms-full.txt](../../llms-full.txt)
- **Deprecations** none
- **Optional peers** none
- **Themeable via** 18 parts, 3 custom properties — see this component's own `@csspart`/`@cssprop` list below
- **Library-wide behavior** (events, form association, `locale`/`strings`, tokens, TS types): `llms/shared.md`

---

## `lr-memory-panel`

Agent working-memory surface: short-term context and long-term memories, each with confidence and
optional grounding provenance, and add/remove/forget actions gated behind an explicit confirmation.
Composes `lr-provenance-panel` (per-item provenance, behind a disclosure toggle) and `lr-confirm-bar`
(every confirmation).

**Properties:**

- `shortTerm: LyraMemoryItem[] = []` / `longTerm: LyraMemoryItem[] = []` (both attribute: false) —
  `LyraMemoryItem { id: string; text: string; confidence?: number; provenance?: LyraProvenance }`
  (exported here). `text` renders as plain text. `confidence` is 0–1; omit it and the confidence
  indicator is omitted entirely rather than showing 0%/unknown. `provenance` reuses
  `lr-provenance-panel`'s own `LyraProvenance` shape verbatim (`{ entities?; relationships?;
communities?; chunks? }`); omit it and the disclosure toggle is omitted entirely. Both arrays are
  controlled and never mutated here — approving an action only fires the matching event
- `types: LyraNodeTypeStyle[] = []` (attribute: false) — readonly `{ id: string; label: string; color?: string;
shape?: 'circle' | 'square' | 'diamond' }`, forwarded verbatim to every expanded item's
  `lr-provenance-panel`
- `thresholds: { high: number; medium: number } = { high: 0.75, medium: 0.5 }` (attribute: false) —
  confidence-tier boundaries (reusing `lr-citation-badge`'s high/medium/low confidence vocabulary and
  success/warning/danger tones), also forwarded as the provenance relevance tiers
- `label?: string` — fallback name for the stable overall group; omission uses the localized memory
  panel label. A non-empty host `aria-label`
  makes the host the sole overall owner; an explicitly empty host label stays empty

Each memory list is canonicalized independently by nonblank `id`. Malformed rows and later
duplicates are omitted first-wins before empty state, focus/disclosure state, confirmations, counts,
rendering, or actions. Rows whose `text` is missing, nonstring, blank, or whitespace-only are also
omitted without hiding later valid memories.

**Events:**

- `lr-add` (`detail: LyraMemoryAddDetail` = `{ memory: LyraMemoryItem }`) — a pending "promote to
  long-term" was approved; the short-term item as-is. Only offered on short-term items.
- `lr-remove` (`detail: LyraMemoryRemoveDetail` = `{ memoryId: string; scope: 'short-term' | 'long-term' }`)
  — a pending per-item removal was approved. Offered on every item.
- `lr-forget` (`detail: null`) — the pending "forget all long-term memories" bulk action was
  approved. Only rendered while `longTerm` is non-empty.
- `lr-expand` (`detail: LyraMemoryExpandDetail` = `{ memoryId: string; scope: 'short-term' |
'long-term'; expanded: boolean }`) — an item's provenance disclosure was toggled.

**Slots:** none.

**CSS parts:** `base`, `empty` (the all-empty `lr-empty`, shown when both lists are empty),
`section` (one of the two, carries `data-scope`), `section-header`, `heading` (a section's visible
heading text), `section-empty`, `list` (`role="list"`, omitted while that section is empty), `item`
(`role="listitem"`, carries `data-id`/`data-scope` and a stable `tabindex="-1"` so focus has
somewhere to land after a confirmation resolves), `item-row`, `item-text`, `confidence` (carries
`data-tone`; omitted when `confidence` is unset), `expand-toggle` / `item-body` (both omitted when
`provenance` is unset; `item-body` is `hidden` while collapsed), `item-actions`, `add-button`,
`remove-button`, `forget-all-button`, `forget-all-confirm` (the `lr-confirm-bar` that replaces
`forget-all-button` while the bulk confirmation is pending).

**Keyboard/focus contract:** activating an action from the keyboard replaces that control with an
`lr-confirm-bar`, and focus moves into the bar (landing on Deny, the safe action) rather than
falling to `<body>` when the control unmounts. Cancelling — Escape or Deny — returns focus to the
control the confirmation replaced: the row's own action for a per-item confirmation, and
`forget-all-button` for the bulk one. This holds through a controlled `shortTerm`/`longTerm`
replacement that closes an open confirmation. Escape only stops propagating when it actually closed
a confirmation, so it never blocks an enclosing dialog for nothing.

**Themeable custom properties:** `--lr-memory-panel-confidence-success-color` (default
`var(--lr-color-success)`), `--lr-memory-panel-confidence-warning-color` (default
`var(--lr-color-warning)`), `--lr-memory-panel-confidence-danger-color` (default
`var(--lr-color-danger)`) — text color of an item's `confidence` indicator, one per confidence
tier (`high`/`medium`/`low` against `thresholds`, the same tiering `lr-chunk-inspector` uses for
its score bar). Plus shared tokens otherwise.

**Optional peer deps:** none.

**Known gotchas:**

- At most one confirmation is pending at a time — starting a new action (same item or not) silently
  cancels whichever confirmation was already open.
- `remove` (one item, either list) and `forget` (the whole long-term list) are deliberately distinct
  actions; there is no per-item forget and no bulk remove.

---
