On long agent runs (dozens of tool calls) the desktop app froze at 100% CPU with no user interaction: useChat updated state on every streamed token, and MessageItem/ReasoningBlock re-parsed the whole transcript's markdown (the marked pipeline + DOMPurify) on every delta. Per-turn work grew quadratically and saturated the main thread; the SSE stream drove it, so it hung "on its own". - chat-thread: pass experimental_throttle (50ms) to useChat so the streamed messages state re-renders at most ~20 Hz instead of once per token. - message-item: memoize MessageItem on a cheap per-message content signature (the streaming tail still re-renders as it grows; finalized rows are skipped), and render each text part via a memoized MarkdownPart so finalized parts are not re-parsed. The signature includes usage.reasoningTokens so the authoritative "Thinking - N tokens" count still snaps in at finish-step. - reasoning-block: memoize the markdown render (useMemo on the text) and wrap the component in React.memo. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
React + TypeScript + Vite
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- @vitejs/plugin-react uses Babel for Fast Refresh
- @vitejs/plugin-react-swc uses SWC for Fast Refresh
Expanding the ESLint configuration
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
- Configure the top-level
parserOptionsproperty like this:
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
},
- Replace
plugin:@typescript-eslint/recommendedtoplugin:@typescript-eslint/recommended-type-checkedorplugin:@typescript-eslint/strict-type-checked - Optionally add
plugin:@typescript-eslint/stylistic-type-checked - Install eslint-plugin-react and add
plugin:react/recommended&plugin:react/jsx-runtimeto theextendslist