The transcript force-scrolled to the bottom on every streamed delta because the auto-scroll effect ran unconditionally whenever the messages array identity changed. Scrolling up to read earlier messages was impossible — each token yanked the view back down. Implement a "stick to bottom" pattern in MessageList: - track whether the viewport is pinned to the bottom via a scroll listener (pinnedToBottomRef, BOTTOM_THRESHOLD = 40px); - only auto-scroll while pinned; a freshly sent user message always re-pins; - attach the scroll listener via a [hasScrollArea] dependency so a brand-new empty chat (whose ScrollArea mounts only after the first message) wires it up; - guard the effect's own scrollTop write (programmaticScrollRef) so it is not misread as a user scroll.
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