Skip to content

[chat][docs] Add docs overview gallery and playground - #22488

Merged
hasdfa merged 163 commits into
mui:masterfrom
hasdfa:x-chat-docs-overview-gallery
Jun 15, 2026
Merged

hasdfa merged 163 commits into
mui:masterfrom
hasdfa:x-chat-docs-overview-gallery

Conversation

@hasdfa

@hasdfa hasdfa commented May 17, 2026 •

Copy link
Copy Markdown
Member

This PR builds out the Chat docs overview gallery and playground experience, hardens the Material message surfaces in @mui/x-chat, and follows up with a docs-accuracy pass that ships the runtime APIs the docs describe and adds a CI guard so docs code stays in sync with the package.

Docs

  • Overview gallery — new docs/src/modules/chat-gallery/* component showcase (message, composer, conversation, layout, and state thumbnails) plus a ChatComponentsSection and an all-components page that links every chat surface.
  • Interactive playground — new docs/src/modules/components/chat-playground/* infrastructure (PlaygroundCard, controls, shared fixtures/providers, parseSx) wiring Props + Classes tabs onto live demos.
  • Overview main demo — multiple presets (basic, agent, copilot, messenger, widget, captions) with generated code sources and a view toggle.
  • New / updated pages — basics/conversation, display/date-divider, display/unread-marker, customization/{overview,structure,look-and-feel}, backend/built-in-adapters/{ai-sdk,echo}, plus refreshed quickstart, basics, behavior, display, and multi-conversation content.
  • API docs regenerated for the new/changed components and translations.

@mui/x-chat package

  • ChatMessageError — new public error-surface component with its own classes (chatMessageErrorClasses, getChatMessageErrorUtilityClass).
  • Context-based slot distribution — new ChatSlotsContext and a flat slot vocabulary across the Material message/composer/conversation surfaces.
  • ChatBox layout modes — new ChatBoxLayoutMode / ChatBoxLayoutModeBreakpoints types and layout slots.
  • Hardened content rendering — replaced the hand-rolled markdown parser with markdown-to-jsx (^9.8.1), with streamingMarkdownRepair to gracefully close partial markdown during streaming.
  • New internals (tested) — mergeSlotProps, useCopyToClipboard, streamingMarkdownRepair, and a DefaultMessageItem for ChatMessageList.
  • Polish — unread marker rendered as a centered chip with a divider; theme.alpha used for the error card background (CSS-vars safe).

New runtime APIs

A docs review found several pages documenting APIs (or recipes) that didn't actually exist. Rather than weaken the docs, these were implemented in @mui/x-chat-headless and surfaced through @mui/x-chat:

  • Regenerate — chat.regenerate(messageId) runtime action (useChat().regenerate) plus a new subscription-free useChatActions() hook, an optional adapter.regenerate transport hook, a REGENERATE_ERROR code, and regenerate bridges for the echo and Vercel AI SDK adapters. Message actions gain extraActions with function-valued slotProps.messageActions.
  • Typing signal — opt-in features.typingSignal (off by default) that edge-triggers adapter.setTyping() on the composer going empty↔non-empty, via new ChatFeatures plumbing through ChatProvider / ChatRoot / ChatBox.
  • onReachBottom on the message list (strict reach semantics mirroring onReachTop), plus JSDoc for the existing onReachTop.
  • isLoadingHistory — exposed across the store, a selectIsLoadingHistory selector, useChat / useChatStatus, and ChatPublicState; true during both initial history fetch and loadMoreHistory.
  • shouldShowDivider predicate on the date divider for custom grouping (default by-day behavior unchanged), with by-week / every-N-messages recipes in the docs.
  • ConversationList.Item added to the headless namespace (was documented but only Root was exported).

ChatMessageSkeleton now respects prefers-reduced-motion. All additions are covered by new unit + browser tests (882 jsdom / 908 browser passing).

Docs correctness

  • New Accessibility page (nav-reachable) documenting roving focus, Enter drill-in, landmarks, the streaming announcer, and reduced motion, plus an "Accessible by default" overview section.
  • Fixed broken API tables — union types were mis-escaped (\ | instead of \|), splitting cells and adding phantom columns across 16 pages; repaired mechanically.
  • Correctness pass across the page set — real slot names, actual defaults (read status, author grouping, renderStreamingMarkdown), data-${string} part types, toolCallId vs approvalId, and completed over-claimed sets (the all-components gallery, the streaming chunk-type table, and the selector/hook reference pages now match the real export surface).
  • Live demos added to previously code-only feature pages (markdown rendering, files & images, tool calling, tool approval, reasoning, step tracking, read-receipts scroll-to-bottom, layout two-pane, controlled state, adapters).
  • Removed six orphan customization draft pages; customization docs consolidated on overview / look-and-feel / structure.

Tooling

  • Docs-correctness guard — a new vitest suite (packages/x-chat/src/tests/docsCorrectnessGuard/) that fails CI if any docs code fence or demo .tsx imports a symbol that isn't exported from the stated entry point, or if frontmatter components: / hooks: reference a missing export. Export surfaces are enumerated via the TypeScript checker; it ships green and prevents this whole class of doc drift from regressing.

New dependency

  • markdown-to-jsx@^9.8.1 (added to @mui/x-chat).

hasdfa added 3 commits May 17, 2026 20:16
Two built-in adapters that ship with @mui/x-chat-headless: a simple
echo adapter for examples and an AI SDK adapter that bridges Vercel
AI SDK UIMessage streams into ChatMessageChunk events. Wire both
through the headless core barrel so they can be imported from
'@mui/x-chat-headless' and '@mui/x-chat-headless/core'.
@code-infra-dashboard

code-infra-dashboard Bot commented May 17, 2026 •

Copy link
Copy Markdown

Deploy preview

Bundle size

Bundle Parsed size Gzip size
@mui/x-data-grid 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-pro 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-premium 0B(0.00%) 0B(0.00%)
@mui/x-charts 0B(0.00%) 0B(0.00%)
@mui/x-charts-pro 0B(0.00%) 0B(0.00%)
@mui/x-charts-premium 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers-pro 0B(0.00%) 0B(0.00%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 0B(0.00%)
@mui/x-license 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@hasdfa hasdfa added scope: chat Changes related to the AI chat. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. docs Improvements or additions to the documentation. labels May 17, 2026
@hasdfa
hasdfa force-pushed the x-chat-docs-overview-gallery branch 4 times, most recently from 7d92cab to 54abad4 Compare May 18, 2026 10:33
@hasdfa
hasdfa marked this pull request as ready for review May 18, 2026 13:14
Copilot AI review requested due to automatic review settings May 18, 2026 13:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f7606d1d4b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@hasdfa
hasdfa force-pushed the x-chat-docs-overview-gallery branch from f7606d1 to ec631c3 Compare May 18, 2026 14:37
@hasdfa
hasdfa force-pushed the x-chat-docs-overview-gallery branch from ec631c3 to 1ad9d05 Compare May 18, 2026 14:46
@hasdfa
hasdfa force-pushed the x-chat-docs-overview-gallery branch from 1ad9d05 to 3defa8e Compare May 18, 2026 14:53
hasdfa added 6 commits June 12, 2026 12:03
When the AI SDK backend omits messageId on its start/finish chunks (the
SDK's own default — bare `{ type: 'start' }`), the adapter synthesized one.
But the counter lived inside convertToChatStream, which is recreated per
sendMessage call, so it reset to 0 every send and always produced the same
first id (`ai-sdk-msg-1`). processStream keys messages by id, so every reply
bound to the same assistant message and appended into a single bubble.

Hoist the counter to adapter scope (shared by sendMessage + regenerate) so
each response gets a unique synthetic id. Correct the test that had codified
the collision.
Addresses test_lint, test_static/test_types, and the docs:build
link-check (netlify) on this branch.

- backend/adapters: add explicit column alignment (`:---`) to two API
  tables (remark-lint-mui-table-alignment)
- remove ExtraActionsMessageActions.tsx.preview: the demo's JSX exceeds
  the preview maxLines, so docs:typescript:formatted strips it (drift)
- material/composer: drop ChatComposer from frontmatter components (no
  generated API page exists for the root → broken footer link)
- read-receipts: correct two API links to /x/api/chat/... (were
  /x/react-chat/api/...)
- core/adapters: point the Vercel AI SDK link at the ai-sdk-adapter page
  (integrations/ai-sdk does not exist)
- error-handling: fix the useMessageError anchor (#usemessageerror-messageid)

Verified: 711-page + 1665-anchor deterministic scan shows zero remaining
broken internal links; eslint/prettier/valelint/typescript:ci/proptypes/
docs:api/generate:exports/l10n all clean.
Second CI pass after an authoritative link-crawl of the built export
surfaced links the file-existence scan couldn't see (same-page anchors,
a directory-without-index, a markdown footnote).

test_static:
- regenerate docs/public/static/error-codes.json: the docs-correctness
  guard added two MUI X-prefixed error messages (287/288) that were
  never extracted

docs:build / netlify link-check:
- basics/messages: remove the slot jump list — it linked to H4 (####)
  headings, which the docs don't assign anchor ids, so all five anchors
  (#avatar/#author-label/#content/#meta/#inline-meta) were dead
- sources-and-citations demo: the message text used a markdown footnote
  ([^1]) with no definition, rendering a broken #1 link; use [1]
- add a 301 from /x/react-chat/customization/ to .../customization/
  overview/: the ChatBox API page links the overview as the section
  landing (MUI overview=landing convention) but it is routed at /overview/

Verified by re-crawling the export: the 12 real issues (5 from the prior
commit + these 7) are the complete set; remaining crawl 'issues' are a
local-server artifact (no _redirects handling for /).
processStream requires a messageId on `start`, which forced every adapter to
synthesize one when the backend omits it (the AI SDK ships bare
`{ type: 'start' }`). Synthesizing it uniquely is a footgun: an adapter that
reused an id across sends made processStream key every reply to the same
assistant message and merge them into one bubble.

Move the uniqueness guarantee into the core: the controller mints a unique
fallback id (createLocalId) per send/regenerate and passes it as
processStream's `messageId`. The `start` handler now keeps that fallback
unless the chunk supplies its own id (`chunk.messageId ?? targetMessageId`,
matching finish/abort), so a backend-supplied id still wins and reconnect
still binds to the resumed id. Regeneration is safe — the prior run is
removed before streaming, so a fresh id targets a new message.

This neutralizes the whole "adapter omitted/duplicated a synthetic id" class
for every adapter, present and future. Adapters keep emitting their own ids
(still correct if consumed standalone); this is the core safety net.

Tests: processStream binds to options.messageId when start omits one, and a
start id still overrides the fallback; sendMessageActions gives each id-less
response across sequential sends its own assistant message.
Animated dots shown while an assistant response is in flight, covering
two phases: a trailing row below the last message while waiting for the
stream to start, then inside the assistant bubble (below the streamed
content) until the response finishes.

- New `features.streamingIndicator?: boolean | 'auto'` flag (default
  'auto'): auto-detects assistant-backed conversations (assistant
  member/participant or an assistant message present) so human-to-human
  chats never show it; `true`/`false` force it on/off.
- New `streamingIndicator` slot (+ slotProps) on ChatBox and the
  standalone ChatMessageList; pass `null` to hide. Disabling the
  feature nulls the slot for the whole row pipeline.
- Material `ChatStreamingIndicator` (visual ported from x-copilot) with
  utility classes and theme augmentation; headless `StreamingIndicator`
  primitive and `useStreamingIndicatorVisibility()` hook for custom
  slots, subscribing to boolean-valued selectors so streamed chunks
  don't churn re-renders.
- `streamingConversationId` recorded on the store via
  `setStreaming(value, conversationId?)` so the indicator never shows
  in a different conversation than the in-flight stream.
- Dots are aria-hidden; the message list status live region already
  announces streaming transitions.
- Docs: new section + interactive demo on the streaming page, headless
  indicators page coverage, typing-indicators cross-link callout.
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jun 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

hasdfa added 3 commits June 12, 2026 17:03
Add `partProps.tool.defaultExpanded`: a per-tool-name map (boolean | resolver,
with a '*' fallback) controlling whether tool cards and their input/output
sections are expanded. Resolvers run on every state transition (return false to
collapse a card when its tool ends) and can read toolName, state, section, and
isMessageStreaming; undefined keeps the built-in default.

Open/close state is owned by the new internal useToolDisclosure hook (shared by
the card root and sections), with focus-safe auto-collapse. Adds a docs
playground, a Default expanded state section (incl. group/prefix matching), and
unit tests.
…iew-gallery

# Conflicts:
#	docs/public/static/error-codes.json
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jun 12, 2026
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jun 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jun 14, 2026
@hasdfa hasdfa changed the title [chat][docs] Add docs overview gallery and playground, harden message surfaces [chat][docs] Add docs overview gallery and playground Jun 15, 2026
@hasdfa
hasdfa merged commit d206b0e into mui:master Jun 15, 2026
21 of 22 checks passed
mbrookes pushed a commit to mbrookes/mui-x that referenced this pull request Jun 27, 2026
Signed-off-by: Vadym Raksha <hello@raksha.bio>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to the documentation. scope: chat Changes related to the AI chat. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants