Renders an enhanced chat message component that supports rich content including markdown, inline entity cards, mention chips, tool execution displays, approval requests, and context-aware streaming with intelligent segment splitting. ## Key Components ### `ChatMessageEnhanced` The primary `forwardRef` component that handles multi-role message rendering (`user`, `error`, assistant variants) with: - **`renderingPlan`** — Memoized plan that splits text segments at `[card://type:id]` markers so block-level entity cards render at exact marker positions during streaming, not at segment end - **`renderedCardNodeCache`** — `useRef`-backed cache keyed by `type:id` that preserves React element identity across stream chunks, preventing card remounts and preserving open menus/fetch state - **`inlineMentionIds`** — Scans text segments for `@marker:id` tokens to exclude already-inline-rendered mentions from the chip strip - **`stripContextItems`** — Filters `contextItems` to only show context NOT already rendered inline ### Regex Constants - **`MENTION_MARKER_REGEX`** — Mirrors `remark-mention-chips.ts` left-boundary to avoid stripping tokens the plugin would also skip - **`CARD_MARKER_REGEX`** — Mirrors `remarkCardLinks` grammar; both must stay in lockstep when the marker syntax changes ### Utilities - **`formatMessageTimestamp`** — Shows time-only for today's messages; prepends locale date for older ones - **`normalizeContent`** — Normalizes `MessageContent` (string or `MessageSegment[]`) to a uniform `MessageSegment[]` ## Usage Example ```typescript import { ChatMessageEnhanced } from "@openframe-oss/lib" } renderMention={(type, id) => } contextItems={contextItems} timestamp={new Date()} /> ``` ## Related Files - [`remark-card-links.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/src/remark-card-links.ts) — Remark plugin; grammar must stay in sync with `CARD_MARKER_REGEX` - [`remark-mention-chips.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/src/remark-mention-chips.ts) — Remark plugin; left-boundary must stay in sync with `MENTION_MARKER_REGEX` - [`block-card.tsx`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/src/entity-cards/block-card.tsx) — Block-level card wrapper used in segment splitting logic