Addresses the PR #138 review's architecture note (the deferred 'non-blocking' item). The brand-new -> persisted chat identity was spread across two separate useState slots (threadKey + liveThreadChatId) plus a render-phase guard, so the mount key and the live thread's chat id could in principle diverge. Consolidate them into ONE atomic state object { key, chatId } with pure, unit-tested transitions in thread-identity.ts: - newThread(newKey) — a brand-new id-less chat (fresh session key); - switchThread(chatId) — switch to an existing chat (key := chat id) -> remount; - adoptThread(prev, id) — a new chat learns its real id IN PLACE (key unchanged -> no remount, live useChat store preserved). The 'key vs chatId diverged' state is now unrepresentable. The render-phase reconciliation stays (the atom is also set externally, e.g. page-history's history-item opening a referenced chat), but adoption vs switch is now explicit. Behavior is unchanged; verified live: new-chat adopt + 2nd turn in the same row, no mid-conversation remount, the two-tab race stays leak-free, switch-to-existing remounts + reseeds, and reload restores full history. Adds thread-identity.test.ts. 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