Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
bc9d768
fix(VirtualizedMessageList): report the first loaded message to items…
oliverlaz Nov 9, 2026
4cbb57b
fix(VirtualizedMessageList): keep the list key on mount and renew it …
oliverlaz Nov 9, 2026
ef6f720
fix(ThreadList): keep arrow-key navigation moving while an off-screen…
oliverlaz Nov 9, 2026
3e19164
chore(deps): upgrade react-virtuoso to v4
oliverlaz Nov 9, 2026
9c02d06
fix(VirtualizedMessageList): stay at the bottom while the content grows
oliverlaz Nov 9, 2026
682b9c3
test(VirtualizedMessageList): compare react-virtuoso 2 and 4 in a rea…
oliverlaz Nov 9, 2026
36f7f32
docs: document the react-virtuoso 4 upgrade
oliverlaz Nov 9, 2026
20a2aa3
chore(deps): bump react-virtuoso to ^4.18.22
oliverlaz Nov 18, 2026
e25f2c6
test(VirtualizedMessageList): align browser suite with the focus-sign…
oliverlaz Nov 18, 2026
ef5466a
ci: pin the browser test job to ubuntu-24.04
oliverlaz Nov 19, 2026
58a45ff
fix(ThreadList): keep Home and End focus in the list, and drop stale …
oliverlaz Nov 19, 2026
7401714
fix(VirtualizedMessageList): handle overlapping jumps, older windows …
oliverlaz Nov 19, 2026
e1a9475
fix(VirtualizedMessageList): keep the stick-to-bottom correction out …
oliverlaz Nov 19, 2026
75fec86
ci: gate the browser job on react-virtuoso 4 only
oliverlaz Nov 19, 2026
8118465
Merge remote-tracking branch 'origin/master' into chore/react-virtuos…
oliverlaz Nov 24, 2026
c26c10b
fix(VirtualizedMessageList): tighten the scroll corrections after review
oliverlaz Nov 24, 2026
551563f
feat(VirtualizedMessageList): show the loading indicator while the li…
oliverlaz Nov 24, 2026
b35141e
feat(VirtualizedMessageList): make the positioning UI a MessageListPo…
oliverlaz Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,51 @@ jobs:
verbose: true
use_oidc: true

browser-test:
# Pinned: Playwright installs Chromium only on the Ubuntu releases it supports, and
# `ubuntu-latest` can move to one it does not support yet (26.04 did).
runs-on: ubuntu-24.04
name: Browser tests (virtualized lists)
steps:
- uses: actions/checkout@v6

- uses: ./.github/actions/setup-node

- name: Cache Playwright browsers
uses: actions/cache@v5
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ hashFiles('yarn.lock') }}

# Install scripts are disabled (`enableScripts: false`), so the browser is installed here.
- name: Install Chromium
run: yarn playwright install --with-deps chromium

# The shipped runtime: invariants, scenarios and fuzz seeds must pass.
- name: Real-browser suites (react-virtuoso 4)
run: yarn vitest run --project browser-v4

# The react-virtuoso 2 reference and the trace comparison, recorded for review in the
# artifact below and not gating: on CI's slower runners v2 loses races it is known for
# (opening at the top, losing a jump), which local runs rarely hit. `yarn test:browser` runs
# all three locally, the comparison gating there.
- name: react-virtuoso 2 reference and trace comparison (informational)
continue-on-error: true
run: |
yarn vitest run --project browser-v2 || true
node scripts/compare-virtuoso-traces.mts

- name: Upload the trace comparison
if: always()
uses: actions/upload-artifact@v5
with:
name: virtuoso-traces
path: |
.virtuoso-traces/report.md
.virtuoso-traces/browser-v2
.virtuoso-traces/browser-v4
if-no-files-found: ignore

deploy-vite-example:
concurrency:
cancel-in-progress: true
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,4 @@ shared
# On-demand translator/TMS catalog export (`yarn i18n:export`). Generated from the t() call
# sites and src/i18n/runtimeDefaults.ts, so it is never checked in.
/en.json
.virtuoso-traces/
22 changes: 19 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This is the **v15** line, developed on `master` and published under npm `latest`
- **Package manager:** Yarn 4 (Berry). The binary is committed under `.yarn/releases/` and activated via `yarnPath` in `.yarnrc.yml`. Any globally installed `yarn` (even classic 1.x) acts only as a launcher — no Corepack required.
- **Workspaces:** Yarn workspaces monorepo (`examples/*`)
- **Dependency versions:** read them from `package.json` (`peerDependencies`, `dependencies`, `devDependencies`). They change with every release, so they are not repeated here.
- **Testing:** Vitest + React Testing Library (+ `vitest-axe` for a11y). There is no Jest and no Playwright/e2e suite in this repo.
- **Testing:** Vitest + React Testing Library (+ `vitest-axe` for a11y), in jsdom; a real-browser suite for the virtualized lists runs in Vitest Browser Mode on Playwright Chromium (see Testing). There is no Jest and no end-to-end suite.
- **Bundler:** Vite 8 / Rolldown (library mode); `tsc` emits declarations only
- **Styles:** Sass compiled to `dist/css/`. Consumers override via CSS layers (see README) — never edit compiled CSS.
- **i18n:** the runtime is `@stream-io/i18n` (a regular dependency); this package owns only its key catalog and bindings
Expand Down Expand Up @@ -55,7 +55,8 @@ yarn start # tsc -p tsconfig.lib.json --watch (emit .d.ts on chan
yarn start:css # watch + recompile SCSS

# Tests
yarn test # vitest run (single pass)
yarn test # vitest run --project jsdom (single pass)
yarn test:browser # real-browser suites on react-virtuoso 2 and 4, then compares their traces
yarn test MessageList # filter by file path substring
yarn test -t 'marks read' # filter by test name
yarn test:watch # watch mode
Expand Down Expand Up @@ -271,7 +272,7 @@ useMemo(

**Policy:** add or extend tests in the matching module's `__tests__/` folder. Cover React components, hooks, and utility functions. Reuse the repo's fakes/mocks instead of hand-rolling new ones.

**Runner:** Vitest (`vitest.config.ts`) — `globals: true` (no imports needed for `describe`/`it`/`expect`/`vi`), `jsdom`, `pool: 'forks'`, `testTimeout: 15000`, `css: false`, tests matched at `src/**/*.test.{js,jsx,ts,tsx}`. `resolve.dedupe` collapses `@stream-io/state-store`, `@stream-io/i18n`, `stream-chat`, `react` and `react-dom` onto one copy each. `vitest.setup.ts` forces `TZ=UTC`, registers `@testing-library/jest-dom/vitest` + `vitest-axe` matchers, and polyfills `crypto.getRandomValues`, `structuredClone`, `File`, `FileReader`, `URL.createObjectURL`, `matchMedia`, and canvas `getContext`.
**Runner:** Vitest (`vitest.config.ts`), project `jsdom` — `globals: true` (no imports needed for `describe`/`it`/`expect`/`vi`), `jsdom`, `pool: 'forks'`, `testTimeout: 15000`, `css: false`, tests matched at `src/**/*.test.{js,jsx,ts,tsx}`. `resolve.dedupe` collapses `@stream-io/state-store`, `@stream-io/i18n`, `stream-chat`, `react` and `react-dom` onto one copy each. `vitest.setup.ts` forces `TZ=UTC`, registers `@testing-library/jest-dom/vitest` + `vitest-axe` matchers, and polyfills `crypto.getRandomValues`, `structuredClone`, `File`, `FileReader`, `URL.createObjectURL`, `matchMedia`, and canvas `getContext`.

Import test helpers from `src/mock-builders` (also aliased as `mock-builders`):

Expand Down Expand Up @@ -310,6 +311,21 @@ render(

Mock modules with `vi.mock('../../EmptyStateIndicator', () => ({ … }))`; use `importOriginal<typeof import('…')>()` to partially mock. Mock methods on the channel/client, never replace the whole object.

### Virtualized lists: jsdom contract tests and the real-browser suite

jsdom lays nothing out, so react-virtuoso renders no items there. For the parts of its contract the SDK relies on (item indexes, keys across a prepend, `scrollerRef`, `scrollIntoView`'s `done`, the DOM attributes the styles target), render the real component inside `VirtuosoMockContext.Provider value={{ itemHeight, viewportHeight }}` — see `src/components/MessageList/__tests__/virtuosoContract.test.tsx`.

Scrolling, measuring, prepending and staying at the bottom are covered by `src/components/MessageList/__tests__/browser/*.browser.test.tsx`, run by `yarn test:browser` in headless Chromium (`npx playwright install chromium` once; install scripts are disabled) with the SDK's real styles:

- **Projects.** `browser-v4` runs the suites on the shipped react-virtuoso; `browser-v2` runs the same suites with `react-virtuoso` aliased to `react-virtuoso-v2` (2.19.1), kept while the v4 upgrade is verified. Same SDK source, different runtime.
- **Harness** (`harness.tsx`, `fakeBackend.ts`). A mocked client whose requests a seeded, in-memory history answers, so pages, jumps and sends go through the real `MessagePaginator`; a synthetic message UI of known heights; helpers to scroll, receive messages, grow a message and wait for the list to settle.
- **Probe and traces** (`virtuosoProbe.tsx`, `trace.ts`). `vi.mock('react-virtuoso')` wraps `Virtuoso` to record every callback between the SDK and Virtuoso (with `followOutput`'s answers); each settled step records geometry, the rendered items, DOM nodes replaced, requests, paginator calls and render counts.
- **Invariants** (`invariants.ts`, `scenario.ts`): the list is shown, items are contiguous and cover the viewport, the at-bottom state agrees with the geometry, a scroll moves the content by exactly the scrolled distance, a scroll to the bottom stays there. They fail the v4 project; on v2 they are recorded.
- **Scenarios and fuzzing.** `VirtualizedMessageList.scroll.browser.test.tsx` (B-xx), `OtherLists.browser.test.tsx` (ThreadList, Channel Detail), and `VirtualizedMessageList.fuzz.browser.test.tsx`: seeded operation sequences (`VIRTUOSO_FUZZ_SEEDS`, 25 by default).
- **Comparison.** `scripts/compare-virtuoso-traces.mts` diffs the two runtimes' traces in `.virtuoso-traces/`; every difference must match `__tests__/browser/expected-differences.json`, which says why the runtimes differ.
- **Gating.** `yarn test:browser` runs `browser-v4` first (it must pass), then `browser-v2` (recorded, not gating: v2 has known races), then the comparison, which gates locally. CI gates on `browser-v4` only and uploads the v2 run and the comparison as an artifact, since on slower runners v2 loses its races often enough to swamp the comparison.
- **Mutation checks.** `VIRTUOSO_MUTATION=<name> yarn vitest run --project browser-v4` injects a breakage between the SDK and Virtuoso (see `VirtuosoMutation` in `virtuosoProbe.tsx`); the comparison must then report it.

## Build system

`yarn build` = `yarn clean` + 4 steps in parallel via `concurrently`, each writing to a separate location:
Expand Down
27 changes: 26 additions & 1 deletion ai-docs/ai-migration-v14-v15.md
Original file line number Diff line number Diff line change
Expand Up @@ -2480,7 +2480,32 @@ Pass them to `react-virtuoso` through `additionalVirtuosoProps`. `react-virtuoso
| `overscan` | `additionalVirtuosoProps.overscan` |
| `scrollSeekPlaceHolder` | `additionalVirtuosoProps.scrollSeekConfiguration` and `additionalVirtuosoProps.components.ScrollSeekPlaceholder` |

In v14, `scrollSeekPlaceHolder` reached `react-virtuoso` as its deprecated `scrollSeek` prop, which logged a warning. `scrollSeekConfiguration` with `components.ScrollSeekPlaceholder` keeps the same behavior without the warning. `defaultItemHeight` and `scrollSeekPlaceHolder` used to win over `additionalVirtuosoProps`; now `additionalVirtuosoProps` is the only source.
In v14, `scrollSeekPlaceHolder` reached `react-virtuoso` as its deprecated `scrollSeek` prop, which logged a warning. `scrollSeekConfiguration` with `components.ScrollSeekPlaceholder` keeps the same behavior. react-virtuoso 4 removed `scrollSeek` and its other v0 aliases (`item`, `header`, `footer`, `emptyComponent`, `*Container`, …), so a value passed under one of those names now lands on the scroller element as an unknown DOM attribute. `defaultItemHeight` and `scrollSeekPlaceHolder` used to win over `additionalVirtuosoProps`; now `additionalVirtuosoProps` is the only source.

### The virtualized lists run on `react-virtuoso` 4

`VirtualizedMessageList`, `ThreadList` and the Channel Detail lists use `react-virtuoso` 4 (previously 2). Code that passes nothing to Virtuoso is not affected. Code that does — `VirtualizedMessageList`'s `additionalVirtuosoProps`, `ThreadList`'s `virtuosoProps`, custom Virtuoso components, tests that select Virtuoso's markup — should check the following.

- **Types.** `ItemProps` takes the item data type (`ItemProps<Data>`), and `Components` takes `<Data, Context>`. `VirtuosoProps` no longer has `react18ConcurrentRendering`, and types its DOM event handlers for `HTMLDivElement`. Custom components are typed as receiving a required `context` prop. A custom `Item` receives an `item` prop (`undefined` for `VirtualizedMessageList`, which renders by `totalCount`); do not spread it onto a DOM element.
- **Test IDs.** Virtuoso's `data-test-id` attributes are now `data-testid` (`virtuoso-scroller`, `virtuoso-item-list`, `virtuoso-top-item-list`). `data-virtuoso-scroller`, `data-viewport-type`, `data-index`, `data-item-index` and `data-known-size` are unchanged.
- **`followOutput`.** A `followOutput` function you pass must return `false` to not scroll: `undefined` and `null` now mean `'auto'`.
- **`scrollerRef`.** With `useWindowScroll` or `customScrollParent`, Virtuoso now calls `scrollerRef` with the window or the scroll parent (it used to call nothing).
- **`additionalVirtuosoProps` values of `undefined`.** Pass a prop or leave it out: an explicit `undefined` (for example `itemSize: undefined`) overrides the list's own value, and Virtuoso 4 does not fall back to its default.
- **Opening a list.** While it positions a freshly mounted list (opening a channel or thread, a jump to a message or to the latest messages), Virtuoso keeps the list hidden — about a quarter of a second — and shows it in place, where v2 showed it at once and moved it into position over the first frames. Meanwhile `VirtualizedMessageList` renders the `MessageListPositioningUI` slot over the list, which shows the `LoadingIndicator` by default. Set the slot in `WithComponents` to replace it, or to `null` to render nothing; a `LoadingIndicator` set to `null` hides the default too. The slot is rendered at all times with `isPositioning`, so a component can also animate the reveal:

```tsx
// A cover in the list's background color over the list, faded out with a CSS opacity
// transition once the list is positioned: the list appears to fade in.
const FadeIn = ({ isPositioning }: MessageListPositioningUIProps) => (
<div className={clsx('app-list-cover', !isPositioning && 'app-list-cover--hidden')} />
);

<WithComponents overrides={{ MessageListPositioningUI: FadeIn }}>…</WithComponents>;
```

- **Scroll position.** Scrolling up through messages not yet rendered keeps the content still; v2 could jump by the difference between estimated and real message heights.
- **Staying at the bottom.** A list scrolled to its bottom now stays there while its content grows: a message that measures taller than estimated, an image that loads late, a reply that streams in. Scrolled up by more than the at-bottom threshold, the list does not move. With `suppressAutoscroll`, new messages do not move the list until the reader scrolls; a message already shown that grows still keeps a reader at the bottom. A `followOutput` you pass in `additionalVirtuosoProps` alone decides whether new messages are followed. In a window of older messages (after a jump), a scroll to its end reaches the end and loads the next newer page, which is not followed.
- **Bundling.** The package is ES2022 with an `exports` map and no dependencies of its own. A build that targets older browsers must transpile it.

```tsx
// v14
Expand Down
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"react-player": "2.10.1",
"react-syntax-highlighter": "^16.1.0",
"react-textarea-autosize": "^8.5.9",
"react-virtuoso": "^2.19.1",
"react-virtuoso": "^4.18.22",
"remark-gfm": "^4.0.1",
"remark-parse": "^11.0.0",
"unified": "^11.0.5",
Expand Down Expand Up @@ -226,6 +226,7 @@
"@types/react-dom": "^19.2.3",
"@types/react-syntax-highlighter": "^15.5.13",
"@types/use-sync-external-store": "^1.5.0",
"@vitest/browser-playwright": "4.1.9",
"@vitest/coverage-v8": "^4.1.9",
"@vitest/eslint-plugin": "^1.6.20",
"concurrently": "^9.2.1",
Expand All @@ -241,9 +242,11 @@
"husky": "^9.1.7",
"jsdom": "^29.1.1",
"lint-staged": "^17.0.5",
"playwright": "1.60.0",
"prettier": "^3.8.3",
"react": "^19.2.6",
"react-dom": "^19.2.6",
"react-virtuoso-v2": "npm:react-virtuoso@2.19.1",
"sass": "^1.100.0",
"semantic-release": "^25.0.3",
"stream-chat": "^10.2.0",
Expand All @@ -259,7 +262,7 @@
"build": "yarn clean && concurrently 'yarn build-translations' 'vite build' 'tsc --project tsconfig.lib.json' 'yarn build-styling'",
"build-styling": "sass --no-charset src/styling/index.scss:dist/css/index.css src/styling/_emoji-replacement.scss:dist/css/emoji-replacement.css src/plugins/Emojis/styling/index.scss:dist/css/emoji-picker.css src/plugins/ChannelDetail/styling/index.scss:dist/css/channel-detail.css src/plugins/AIComponents/styling/index.scss:dist/css/ai-components.css; cp -r src/styling/assets dist/css/assets",
"build-translations": "node scripts/generate-i18n-keys.mts && prettier --write --log-level warn src/i18n/keys.ts",
"coverage": "vitest run --coverage",
"coverage": "vitest run --project jsdom --coverage",
"i18n:export": "node scripts/generate-i18n-keys.mts --json en.json",
"lint": "yarn prettier --list-different && yarn eslint",
"lint-fix": "yarn prettier-fix && yarn eslint-fix",
Expand All @@ -276,8 +279,9 @@
"start:cookbook": "yarn workspace @stream-io/stream-chat-react-cookbook dev",
"start:vite": "yarn workspace @stream-io/stream-chat-react-vite dev",
"postinstall": "node -e \"require('fs').existsSync('scripts/install-husky.mjs') && import('./scripts/install-husky.mjs')\"",
"test": "vitest run",
"test:watch": "vitest",
"test": "vitest run --project jsdom",
"test:browser": "vitest run --project browser-v4 && (vitest run --project browser-v2 || true) && node scripts/compare-virtuoso-traces.mts",
"test:watch": "vitest --project jsdom",
"types": "tsc -p tsconfig.lib.json --noEmit",
"types:tests": "tsc --project tsconfig.test.json --noEmit",
"validate-translations": "yarn build-translations && git diff --exit-code -- src/i18n/keys.ts",
Expand Down
Loading
Loading