A passive "context memory" strip rendered above the chat composer, showing a count of ambient remembered entities ("5 recently viewed items in context") with an ellipsis trigger that opens a scrollable dropdown listing each item with an optional remove button. ## Key Components ### `ChatContextMemoryBar` (exported component) The sole export. Renders `null` when `items` is empty, so it has zero DOM footprint when unused. **Props (`ChatContextMemoryBarProps`):** | Prop | Type | Description | |---|---|---| | `items` | `ChatContextItem[]` | Remembered entities, most-recent-first | | `onRemove` | `(item: ChatContextItem) => void` | Optional removal handler; omit for read-only | | `resolveIcon` | `(item: ChatContextItem) => React.ReactNode` | Entity-type icon resolver matching the picker/chip icon map | | `disabled` | `boolean` | Disables remove buttons (e.g. during streaming) | | `className` | `string` | Additional classes for the root strip | ### Internal behaviors - **Outside-click dismiss** — uses capture-phase `mousedown`/`touchstart` listeners on `document` to reliably close the dropdown even inside resizable drawers or `contentEditable` ancestors that may call `stopPropagation`. - **Auto-close on empty** — a `useEffect` watching `items.length` closes the dropdown before the bar unmounts, preventing a stale popover outliving its trigger. - **Escape key** — closes the dropdown via `onKeyDown` on the root element. ## Usage Example ```typescript import { ChatContextMemoryBar } from './chat-context-memory-bar' import type { ChatContextItem } from './types/context-item.types' const memoryItems: ChatContextItem[] = [ { type: 'ticket', id: '42', label: 'Printer offline – HQ' }, { type: 'device', id: '7', label: 'DESKTOP-ABC123' }, ] function Composer() { const handleRemove = (item: ChatContextItem) => { console.log('Remove from memory:', item.id) } return ( } disabled={isStreaming} /> ) } ``` > **Placement note:** This "ambient" bar sits above `` (user-assigned items). Both live above the textarea — memory on top (passive), chips below (active per-message selection).