The "copy chat" button serialized `messageRows` (persisted rows loaded via `useAiChatMessagesQuery`), which were incomplete in two ways, so the exported Markdown dropped messages (e.g. "Messages: 2" for a multi-turn chat). - Exhaust pagination: `useAiChatMessagesQuery` is a useInfiniteQuery that only ever loaded the first page (server page size 50, oldest-first), silently truncating longer chats. Add an effect that calls `fetchNextPage()` until `hasNextPage` is false. Guard on `isFetchNextPageError` so a failed page fetch does not loop on the app's global `retry: false`. - Re-sync after each turn: `onTurnFinished` invalidated only the chat-list query, never the per-chat messages query, so `messageRows` went stale during a live session. Also invalidate `AI_CHAT_MESSAGES_RQ_KEY(activeChatId)` so the export and token counters reflect the just-finished turn. - Avoid tearing down the live thread: a render-phase latch (`historyLoadedKeyRef`) keeps the history loader gating the FIRST mount only, so the post-turn background refetch (which can transiently flip `hasNextPage` for a chat whose message count is an exact multiple of the page size) no longer unmounts the open thread and loses its in-progress useChat state. 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