LibreChat/e2e/playwright.config.tree-perf.ts
Danny Avila 422f3a6f8d
🧶 feat: Flatten Active Message Threads Behind a Flag (#15633)
* 🧵 feat(client): Flat Message Thread Renderer Behind a Flag

Adds a keyed thread index and an O(depth) visible-path resolver so the
message list can render as a flat, memoized list instead of one React
level per message. The recursive MultiMessage path stays the default;
the flat path is enabled per page with the LC_FLAT_THREAD localStorage
key or VITE_FLAT_THREAD at build time.

Also adds a react-scan/CDP benchmark lane (e2e/benchmarks-tree) that
A/Bs both render paths on a seeded 240-row thread, plus a parity config
that runs the branch-sensitive mock specs with the flat path on.

* 🙈 chore: Ignore the Tree Benchmark Output Directory

* 🪢 refactor(client): Move Sibling Selection to Feature-Owned Jotai State

Codex round 1 on #15633. The message thread's sibling selection moves out
of the Recoil store into a Jotai atom family owned by the thread feature,
shared by the recursive and flat renderers, the share view, and the focus,
resume and clear writers. Consumers that watch several branch points read
them through one derived atom via useSyncExternalStore, so a token-only
cache write costs no render.

Also keeps the raw cache object as a thread row's reuse identity (file
hydration now happens on the row, keyed on the file map), sets the flat
flag before the parity config snapshots the server env, and gives the
seeded alternate branch consistent turn numbers.

* 🧹 style: Sort Imports in the Thread Renderer Files

* 📏 chore(e2e): Sample Renderer CPU and Post-GC Heap in the Tree Benchmark

Adds a CDP resource probe to each phase: renderer-process CPU time (all
threads), JS heap after a forced GC (retained memory rather than allocation
churn), DOM node and listener counts. Also lets TREE_PARITY_MATCH pick
which mock specs the parity config runs, and derives the deep-switch
phase label from the seeded thread size.
2026-09-06 14:30:50 -04:00

41 lines
1.2 KiB
TypeScript

import { defineConfig } from '@playwright/test';
import path from 'node:path';
import mockConfig from './playwright.config.mock';
import { getE2EServerAddress } from './setup/env';
/**
* Message-tree render benchmark config. Runs against the vite dev server so
* react-scan sees component names (the production minifier strips them).
*/
const rootPath = path.resolve(__dirname, '..');
const { host: backendHost, port: backendPort } = getE2EServerAddress();
const devHost = backendHost.includes(':') ? `[${backendHost}]` : backendHost;
const DEV_PORT = process.env.E2E_DEV_PORT || '3090';
const DEV_SERVER_URL = `http://${devHost}:${DEV_PORT}`;
const mockServers = [mockConfig.webServer ?? []].flat();
export default defineConfig({
...mockConfig,
testDir: 'benchmarks-tree',
outputDir: 'benchmarks-tree/.test-results',
timeout: 10 * 60 * 1000,
retries: 0,
reporter: [['line']],
use: {
...mockConfig.use,
baseURL: DEV_SERVER_URL,
},
webServer: [
...mockServers,
{
command: 'npm run frontend:dev',
cwd: rootPath,
env: { ...process.env, PORT: DEV_PORT, HOST: backendHost, BACKEND_PORT: backendPort },
url: DEV_SERVER_URL,
stdout: 'pipe',
timeout: 180_000,
reuseExistingServer: false,
},
],
});