Skip to content
Merged
Show file tree
Hide file tree
Changes from 138 commits
Commits
Show all changes
179 commits
Select commit Hold shift + click to select a range
846116e
[chat] Scaffold x-chat package family
hasdfa Mar 6, 2026
612a8a6
[chat] Add core chat entity types
hasdfa Mar 6, 2026
bf65363
[chat] Extend x-chat type facade and augmentation model
hasdfa Mar 7, 2026
b12012f
[chat] Add extensible message part and tool types
hasdfa Mar 7, 2026
8a95090
[chat] Add stream contract types and shared type helpers
hasdfa Mar 7, 2026
a35ef49
[chat] Add headless adapter and runtime contracts
hasdfa Mar 8, 2026
cf9038e
[chat] Add normalized chat store
hasdfa Mar 9, 2026
0be1941
[chat] Add computed chat selectors
hasdfa Mar 9, 2026
9195b06
[chat] Add controlled state ownership layer
hasdfa Mar 9, 2026
f49599a
[chat] Add stream processor
hasdfa Mar 9, 2026
3ca9803
[chat] Simplify headless internals: deduplicate normalization, abort …
hasdfa Mar 9, 2026
cdae750
[chat] Close remaining M0 headless test gaps
hasdfa Mar 9, 2026
d454de8
[chat] Add provider and store contexts
hasdfa Mar 9, 2026
6253c4c
[chat] Add useChatStore escape hatch hook
hasdfa Mar 9, 2026
3a4daa4
[chat] Add selector hooks for messages and conversations
hasdfa Mar 9, 2026
77d29e9
[chat] Add useChat runtime hook
hasdfa Mar 10, 2026
b26d98a
[chat] Add useChatComposer hook
hasdfa Mar 11, 2026
a34c803
[chat] Add tool approval flow tests
hasdfa Mar 12, 2026
0be3c7a
[chat] Add remaining M1 headless tests
hasdfa Mar 12, 2026
9f7e0a4
[chat] Close M1 spec gaps: typing state, missing exports
hasdfa Mar 12, 2026
60b4b5c
[chat] Add unstyled chat conversation list
hasdfa Mar 13, 2026
f2b216f
[chat] Add unstyled chat composer and pending chat updates
hasdfa Mar 15, 2026
e5b58a2
[chat] Add live chat indicators
hasdfa Mar 15, 2026
5c93eb1
[chat] Define unstyled root exports
hasdfa Mar 15, 2026
8d569c9
[chat] Fix render isolation, hydration, and UX issues in headless exa…
hasdfa Mar 15, 2026
dbee5c5
[chat] Add M2 component coverage
hasdfa Mar 15, 2026
bab93ec
[chat] Add styled theme foundation
hasdfa Mar 15, 2026
1102d01
[chat] Add styled thread shell
hasdfa Mar 16, 2026
aa9830d
[chat] Add styled message components
hasdfa Mar 16, 2026
fa9d652
[chat] Add styled composer components
hasdfa Mar 16, 2026
22a733a
[chat] Add styled live indicators
hasdfa Mar 16, 2026
e37f1c7
[chat] Add pluggable markdown message renderer
hasdfa Mar 16, 2026
38e8098
[chat] Add styled AI part renderers
hasdfa Mar 16, 2026
a85b19f
Merge branch 'master' into chatbox/v2
hasdfa Mar 17, 2026
e9fda68
[chat] Add ChatBox one-liner API
hasdfa Mar 17, 2026
30234a5
chore: update pnpm-lock.yaml after rebase
hasdfa Mar 17, 2026
b1aa5ef
Merge branch 'master' into chatbox/v2
hasdfa Mar 17, 2026
be707e3
fix(chat): resolve ESLint, prettier, proptypes, and TypeScript CI fai…
hasdfa Mar 17, 2026
2c3f286
Revert all packages/x-charts* changes from this PR
hasdfa Mar 17, 2026
502aba3
fix
hasdfa Mar 17, 2026
7c12bfd
changes
hasdfa Mar 17, 2026
8a606e6
Rename Thread → Conversation and Composer → ConversationInput
hasdfa Mar 18, 2026
4a1f4bf
Update chat headless docs, examples, and API documentation
hasdfa Mar 18, 2026
c40c30c
Merge branch 'master' of github.com:hasdfa/mui-x into chatbox/v2
hasdfa Mar 18, 2026
d38b27e
Merge upstream/master and resolve conflicts in charts packages
hasdfa Mar 18, 2026
0c2d6d8
Fix docs build: resolve demo imports, add missing exports, and fix SS…
hasdfa Mar 18, 2026
fa05fae
fix(build): include upstream charts package changes missed during merge
hasdfa Mar 18, 2026
af162f2
fix(build): include upstream charts API docs changes missed during merge
hasdfa Mar 18, 2026
ce724a7
feat(chat): add granular error states, retry actions, and loading ind…
hasdfa Mar 18, 2026
9068969
fix pnpm lock
hasdfa Mar 18, 2026
9018619
fix(lint): resolve ESLint errors, regenerate API docs, and fix code q…
hasdfa Mar 18, 2026
bd02364
Merge branch 'master' into chatbox/v2
hasdfa Mar 18, 2026
013a1d9
fix build issues
hasdfa Mar 18, 2026
bdc9ee0
fix(netlify): increase Node.js heap limit to 6 GB
hasdfa Mar 18, 2026
b08e32e
feat(x-chat-unstyled): integrate Base UI primitives for accessibility
hasdfa Mar 20, 2026
a12f9e2
remove @mui/x-chat material implementation and docs
hasdfa Mar 20, 2026
eb243c6
feat(x-chat-unstyled): update ToolPart, MessageContent, MessageList, …
hasdfa Mar 21, 2026
9a437d8
feat(x-chat): add new Material UI chat package
hasdfa Mar 21, 2026
0be4c71
docs(chat): update unstyled examples, overview, and add material chat…
hasdfa Mar 21, 2026
e15e089
docs(chat): add Material chat documentation and demo pages
hasdfa Mar 21, 2026
fd6e7a6
chore: update pnpm lockfile for x-chat package dependencies
hasdfa Mar 21, 2026
cc66b5f
feat(x-chat): align message bubbles to a symmetric horizontal lane
hasdfa Mar 22, 2026
5f70117
feat(x-chat): add autoScroll feature with configurable buffer
hasdfa Mar 22, 2026
6be9fba
docs(chat): simplify agentic-code demos and update descriptions
hasdfa Mar 22, 2026
806443b
feat(x-chat-headless): refactor store context, hooks, and stream proc…
hasdfa Mar 22, 2026
310cb4f
feat(x-chat-unstyled): refactor component exports, indicators, and in…
hasdfa Mar 22, 2026
03dab0f
feat(x-chat): expand ChatBox API, split indicator classes, and add ne…
hasdfa Mar 22, 2026
72e7443
docs(chat): add ToolStylingC agentic demo and register x-chat TypeScr…
hasdfa Mar 22, 2026
0149647
feat(x-chat): add new components, examples, and stream helpers
hasdfa Mar 23, 2026
128f5b2
fix
hasdfa Mar 23, 2026
1456455
fix(x-chat-unstyled): convert re-exports to import+export so namespac…
hasdfa Mar 23, 2026
3c04f55
Merge upstream/master into chatbox/v2
hasdfa Mar 23, 2026
867b59d
fix packages
hasdfa Mar 23, 2026
ed114a6
remove screns
hasdfa Mar 23, 2026
890ee44
Merge branch 'master' into chatbox/v2
hasdfa Mar 23, 2026
ebcbc4d
Rename ConversationInput → Composer and split Material docs into subp…
hasdfa Mar 25, 2026
c247b32
Update chat docs, components, and examples
hasdfa Mar 25, 2026
d768be0
Update lockfile to include @mui/internal-markdown patch
hasdfa Mar 25, 2026
e8f84e9
Replace nanoid with custom randomId helper in demo files
hasdfa Mar 25, 2026
537292d
fix(docs): remove Chat* components from material docs frontmatter to …
hasdfa Mar 25, 2026
ae6ef22
Merge branch 'master' into chatbox/v2
hasdfa Mar 25, 2026
0d618f2
updates
hasdfa Mar 25, 2026
63d72ca
Merge branch 'chatbox/v2' of github.com:hasdfa/mui-x into chatbox/v2
hasdfa Mar 25, 2026
02bdac0
fix pnpm lock
hasdfa Mar 25, 2026
93e3b39
fix: add missing @babel/plugin-transform-modules-commonjs dependency …
hasdfa Mar 25, 2026
d8c092d
fix
hasdfa Mar 26, 2026
ef38f39
fix
hasdfa Mar 26, 2026
35d0ea5
fix
hasdfa Mar 26, 2026
238af11
fix: update chat packages with docs, tests, and component improvements
hasdfa Mar 28, 2026
0bdcb81
fix: clean up x-chat test files for consistency and quality
hasdfa Mar 28, 2026
8e5dfc0
feat(x-chat-unstyled): update composer, conversation-list, and messag…
hasdfa Apr 1, 2026
1cfd0e0
feat(x-chat): add new components and update existing chat material co…
hasdfa Apr 1, 2026
92b6d29
docs(chat): update headless documentation and examples
hasdfa Apr 1, 2026
30e2c25
docs(chat): update material documentation, examples, and add compact …
hasdfa Apr 1, 2026
f19fc2f
docs(chat): update unstyled documentation
hasdfa Apr 1, 2026
f954001
docs(chat): update overview, pages navigation, and broken links script
hasdfa Apr 1, 2026
e8e84a8
docs(chat): add getting started documentation page
hasdfa Apr 1, 2026
7cd031e
docs(chat): add overview page interactive demo components and themes
hasdfa Apr 1, 2026
592abb4
feat(x-chat): add density support, file MIME type filtering, and new …
hasdfa Apr 2, 2026
dba5434
docs(chat): update and add API translation files for new chat components
hasdfa Apr 2, 2026
3e8d551
docs(chat): add API reference pages and react-chat routing pages
hasdfa Apr 2, 2026
1838d51
docs(chat): add comprehensive documentation content for all chat sect…
hasdfa Apr 2, 2026
9109628
docs(chat): add public static docs, update navigation and overview demos
hasdfa Apr 2, 2026
9a58f56
refactor(x-chat): apply linting and formatting fixes across chat pack…
hasdfa Apr 2, 2026
6550a33
docs(chat): apply Prettier formatting to demos and markdown data files
hasdfa Apr 2, 2026
b2b418a
docs(chat): apply Prettier formatting to public documentation pages
hasdfa Apr 2, 2026
c848055
docs(chat): apply Prettier formatting to overview demo components
hasdfa Apr 2, 2026
23eb8b4
feat(x-chat): remove plan tier gates, simplify auto-scroll demo, and …
hasdfa Apr 2, 2026
703882e
refactor(x-chat): migrate x-chat-unstyled components into x-chat-head…
hasdfa Apr 5, 2026
90de186
feat(x-chat): refine message grouping and update chat demos
hasdfa Apr 5, 2026
d051b33
fix(docs): restore getting-started.md and update chat overview
hasdfa Apr 5, 2026
a14f374
feat(x-chat): refine message actions, grouping API, and layout
hasdfa Apr 6, 2026
c8c87ba
chore: merge origin/master into chatbox/v2 and resolve conflicts
hasdfa Apr 6, 2026
4dda285
fix(x-chat): suppress Base UI ScrollArea act() warnings in tests
hasdfa Apr 6, 2026
94efe71
fix(x-chat): address Codex review — stale guard in loadMoreHistory an…
hasdfa Apr 6, 2026
12008a4
feat(x-chat): restructure docs into core/headless sections and fix he…
hasdfa Apr 6, 2026
e9ec6c9
fix
hasdfa Apr 6, 2026
94b1dc7
Merge branch 'master' into chatbox/v2
hasdfa Apr 6, 2026
fd01e6a
fix(x-chat): resolve CI failures — lint, proptypes, and TypeScript er…
hasdfa Apr 6, 2026
2d594a5
removed orphan images
hasdfa Apr 7, 2026
abff01e
fix(x-chat): improve empty state typography and memoize icon components
hasdfa Apr 7, 2026
325fe51
Prettier
MBilalShafi Apr 7, 2026
f02191f
Lint
MBilalShafi Apr 7, 2026
45e55f4
Merge branch 'master' into chatbox/v2
hasdfa Apr 7, 2026
8d678a8
fix(x-chat): docs updates, responsive drawer, and component improvements
hasdfa Apr 7, 2026
05b2bf9
align with master
hasdfa Apr 7, 2026
789bf09
Merge remote-tracking branch 'origin/chatbox/v2' into chatbox/v2-clean
hasdfa Apr 7, 2026
b7c801c
remove plans
hasdfa Apr 7, 2026
2be0a4d
fix unrelated infra changes
hasdfa Apr 7, 2026
4805608
fix unrelated infra changes
hasdfa Apr 7, 2026
3f5a81c
Merge branch 'master' into chatbox/v2
hasdfa Apr 7, 2026
bf5a513
Increase NODE_OPTIONS max old space size to 6144
hasdfa Apr 7, 2026
36e9e2c
Merge branch 'mui:master' into chatbox/v2
hasdfa Apr 7, 2026
8f4c8f1
[chat] Fix broken getting-started links in API docs
hasdfa Apr 7, 2026
7371ffd
fix stylis
hasdfa Apr 7, 2026
9bc2a2b
remove stylis override
hasdfa Apr 8, 2026
acebed6
Merge branch 'master' into chatbox/v2
hasdfa Apr 8, 2026
49c48b6
fix lockfile
hasdfa Apr 8, 2026
07ffd94
Merge branch 'master' into chatbox/v2
hasdfa Apr 8, 2026
0d2b5e8
fix TypeScript errors in chat docs and demo files
hasdfa Apr 8, 2026
409e751
Fix chat overview demo links to use canonical /x/react-chat/ path
hasdfa Apr 8, 2026
95d41d4
[chat] Add productIdentifier for x-chat in docs
hasdfa Apr 8, 2026
5fbf661
fix: use globalThis.ResizeObserver for SSR compatibility in chat comp…
hasdfa Apr 8, 2026
af19aa2
Revert "fix: use globalThis.ResizeObserver for SSR compatibility in c…
hasdfa Apr 8, 2026
c340e0e
add readme files
hasdfa Apr 8, 2026
3059b9f
fix(docs): rename slot names in headless chat demo TSX files
hasdfa Apr 8, 2026
04ebca6
fix: guard ResizeObserver usage in ChatBoxContent for JSDOM compatibi…
hasdfa Apr 8, 2026
e108956
docs: consolidate @mui/x-chat-headless imports to @mui/x-chat
hasdfa Apr 8, 2026
8ebe068
fix lint
hasdfa Apr 8, 2026
3abc6c6
fix prettier
hasdfa Apr 8, 2026
2d778aa
fix eslint
hasdfa Apr 8, 2026
a358b23
Merge branch 'master' into chatbox/v2
hasdfa Apr 8, 2026
b06a30e
fix patch
hasdfa Apr 8, 2026
6595ea8
fix(x-chat-headless): add typingUserIdsForActiveConversation selector
hasdfa Apr 8, 2026
bdd40d3
fix(lint): update eslint-disable comments for import/export rule
hasdfa Apr 8, 2026
3b7d816
fix(prettier): reformat useStore call in advanced-store-access demo
hasdfa Apr 8, 2026
c2bf7e6
fix(lint): use eslint-disable-next-line for import/export rule
hasdfa Apr 8, 2026
0805673
fix
hasdfa Apr 8, 2026
8ebee7c
fix pnpm docs:api
hasdfa Apr 8, 2026
bde1172
Add chat packages to StackBlitz/CodeSandbox version config
hasdfa Apr 8, 2026
230e107
add new error codes
hasdfa Apr 8, 2026
1747180
fix add #formatErrorMessage
hasdfa Apr 8, 2026
758615d
Merge branch 'master' into chatbox/v2
hasdfa Apr 8, 2026
8402a83
Merge branch 'chatbox/v2' of github.com:hasdfa/mui-x into chatbox/v2
hasdfa Apr 8, 2026
d572208
[chat] Fix CI failures: import path, console.error mocks, browser tes…
hasdfa Apr 8, 2026
509fe75
fix prettier
hasdfa Apr 8, 2026
365c4df
Merge branch 'master' into chatbox/v2
hasdfa Apr 8, 2026
6af4193
remove package structure
hasdfa Apr 8, 2026
ead8739
Merge branch 'chatbox/v2' of github.com:hasdfa/mui-x into chatbox/v2
hasdfa Apr 8, 2026
ad07d36
[chat] Fix CI failures: import path, React 18 dedup, regression exclu…
hasdfa Apr 8, 2026
a574e60
[chat] Fix chatApiPages.ts import template to match repo convention
hasdfa Apr 8, 2026
b2cbba8
fix demo
hasdfa Apr 8, 2026
c545072
fix demo:
hasdfa Apr 8, 2026
a672982
Update config.yml
Janpot Apr 8, 2026
30ef1e9
Update config.yml
Janpot Apr 8, 2026
919ad11
Merge branch 'master' into chatbox/v2
hasdfa Apr 8, 2026
9a6f77d
[test] Add shouldClearNativeTimers to fake clock setup
hasdfa Apr 8, 2026
4c6e503
fix(pnpm valelint)
hasdfa Apr 8, 2026
c954bfe
fix pnpm docs:api
hasdfa Apr 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
175 changes: 175 additions & 0 deletions docs/data/chat/ai-and-agents/reasoning/reasoning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
---
productId: x-chat
title: Reasoning
packageName: '@mui/x-chat'
githubLabel: 'scope: chat'
components: ChatMessageContent
---

# Chat - Reasoning

<p class="description">Display the LLM's chain-of-thought or thinking trace using <code>ChatReasoningMessagePart</code> and the reasoning stream chunks.</p>

{{"component": "@mui/internal-core-docs/ComponentLinkHeader"}}

Many large language models expose a "thinking" or "reasoning" trace alongside their final response. The Chat component supports streaming and displaying this reasoning content through dedicated chunk types and a specialized message part.

## `ChatReasoningMessagePart`

When reasoning chunks arrive during streaming, the runtime creates a `ChatReasoningMessagePart` on the assistant message:

```ts
interface ChatReasoningMessagePart {
type: 'reasoning';
text: string;
state?: ChatMessagePartStatus; // 'streaming' | 'done'
}
```

| Field | Type | Description |
| :------ | :---------------------- | :-------------------------------------------- |
| `type` | `'reasoning'` | Identifies this as a reasoning part |
| `text` | `string` | The accumulated reasoning text |
| `state` | `'streaming' \| 'done'` | Whether the reasoning is still being streamed |

The `state` field transitions from `'streaming'` while deltas are arriving to `'done'` once the reasoning section is complete.

## Reasoning stream chunks

Reasoning content is streamed using a triplet of chunks, following the same pattern as text chunks:

| Chunk type | Fields | Description |
| :---------------- | :------------ | :-------------------------- |
| `reasoning-start` | `id` | Begin a reasoning part |
| `reasoning-delta` | `id`, `delta` | Append reasoning content |
| `reasoning-end` | `id` | Finalize the reasoning part |

### How chunks become parts

1. `reasoning-start` creates a new `ChatReasoningMessagePart` with `state: 'streaming'`.
2. `reasoning-delta` appends the `delta` text to the existing reasoning part.
3. `reasoning-end` sets `state: 'done'`.

Multiple `reasoning-delta` chunks are batched according to `streamFlushInterval` before being applied to the store, just like text deltas.

### Streaming example

```tsx
const adapter: ChatAdapter = {
async sendMessage({ message }) {
return new ReadableStream({
start(controller) {
controller.enqueue({ type: 'start', messageId: 'msg-1' });

// Reasoning section
controller.enqueue({ type: 'reasoning-start', id: 'reasoning-1' });
controller.enqueue({
type: 'reasoning-delta',
id: 'reasoning-1',
delta: 'The user is asking about weather in Paris. ',
});
controller.enqueue({
type: 'reasoning-delta',
id: 'reasoning-1',
delta: 'I should check the current forecast data.',
});
controller.enqueue({ type: 'reasoning-end', id: 'reasoning-1' });

// Text response
controller.enqueue({ type: 'text-start', id: 'text-1' });
controller.enqueue({
type: 'text-delta',
id: 'text-1',
delta: 'The weather in Paris is currently 22 degrees and sunny.',
});
controller.enqueue({ type: 'text-end', id: 'text-1' });

controller.enqueue({ type: 'finish', messageId: 'msg-1' });
controller.close();
},
});
},
};
```

## Displaying reasoning in a collapsible section

Reasoning content is typically displayed in a collapsible section above the main response text. Register a custom renderer for reasoning parts to control the presentation:

```tsx
import Accordion from '@mui/material/Accordion';
import AccordionSummary from '@mui/material/AccordionSummary';
import AccordionDetails from '@mui/material/AccordionDetails';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import Typography from '@mui/material/Typography';

const renderers: ChatPartRendererMap = {
reasoning: ({ part }) => (
<Accordion defaultExpanded={false} sx={{ my: 1, bgcolor: 'action.hover' }}>
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
<Typography variant="caption" color="text.secondary">
{part.state === 'streaming' ? 'Thinking...' : 'Reasoning'}
</Typography>
</AccordionSummary>
<AccordionDetails>
<Typography variant="body2" sx={{ whiteSpace: 'pre-wrap' }}>
{part.text}
</Typography>
</AccordionDetails>
</Accordion>
),
};

<ChatProvider adapter={adapter} partRenderers={renderers}>
<MyChat />
</ChatProvider>;
```

## Show/hide configuration

Control whether reasoning is visible to the user by filtering parts in your renderer. You can use a prop, a context value, or application state to toggle visibility:

```tsx
function ReasoningPart({ part, showReasoning }) {
if (!showReasoning) return null;

return (
<div style={{ opacity: 0.7, fontSize: '0.85em', fontStyle: 'italic' }}>
<details>
<summary>
{part.state === 'streaming' ? 'Thinking...' : 'Show reasoning'}
</summary>
<p>{part.text}</p>
</details>
</div>
);
}

// Register with a configurable toggle
const renderers: ChatPartRendererMap = {
reasoning: ({ part }) => (
<ReasoningPart part={part} showReasoning={userPreferences.showReasoning} />
),
};
```

## Reasoning alongside tool calls

Reasoning chunks can appear before, between, or after tool invocations in the same stream. The runtime handles interleaving correctly — each chunk type creates its own message part in the order it arrives:

```tsx
// Stream order:
// 1. reasoning-start -> reasoning-delta -> reasoning-end (thinking)
// 2. tool-input-start -> tool-input-available (tool call)
// 3. reasoning-start -> reasoning-delta -> reasoning-end (thinking about result)
// 4. tool-output-available (tool result)
// 5. text-start -> text-delta -> text-end (final answer)
```

This produces a message with five parts in order: reasoning, tool, reasoning, tool (updated), text.

## See also

- [Tool Calling](/x/react-chat/ai-and-agents/tool-calling/) for the tool invocation lifecycle.
- [Step Tracking](/x/react-chat/ai-and-agents/step-tracking/) for multi-step agent progress tracking.
- [Streaming](/x/react-chat/behavior/streaming/) for the full chunk protocol reference including reasoning chunks.
Loading
Loading