Surfacing the stream error via useChat().error alone was not enough: on a brand-new chat the errored turn still fires onFinish -> onTurnFinished, which adopts the freshly-created chat id and changes the <ChatThread> key, remounting it with a fresh useChat whose transient `error` is gone. The thread re-seeds from persisted history, where the assistant row has empty parts and the error lives only in metadata.error — which was never rendered. Result: an empty "AI agent" row and no visible error. - Render the persisted metadata.error inline in MessageItem, so the error survives the remount and is also shown in reopened chat history. - Carry metadata.error onto the rebuilt UIMessage in rowToUiMessage. - Extract the error formatter into utils/error-message.ts (describeChatError) and reuse it for both the live Alert and the persisted error. - Add metadata.error to the IAiChatMessageRow type. Client-only; the server already persists metadata.error. No new i18n keys.
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