LibreChat/client
Danny Avila c3882c09ad
🧵 perf: Stop Re-rendering and Re-styling the Thread on Stream Events and Run Boundaries (#18148)
* 🎞️ perf: Run the In-Flight Label Sweep on the Compositor

The sweep on a running tool call, streaming reasoning and the elapsed timer
animated `background-position` under `background-clip: text`, which no
browser can hand to the compositor. Every frame of it ran style, paint and
commit on the main thread, and each paint walked the transcript around the
label, so the cost of a frame grew with the conversation and the sweep
stuttered whenever the main thread was busy.

`Shimmer` in `@librechat/client` draws the same sweep from two transforms
that cancel: a masked band slides across the label while a second copy of the
text inside it slides back, so the glyphs hold still and only the gap in the
mask moves. The copy is generated content, so the label is still one text
node. Every in-flight label renders through it.

`e2e/benchmarks-fade` measures a frame and each kind of stream event inside
an exported conversation, from a Chromium trace of the built client.

* 🧪 test: Let the Frame Benchmark Open a Chat in a Chosen Theme

* 🧵 perf: Keep the Composer, Nav Rail and Row Toolbars Out of Every Stream Event

A streamed delta rewrites one row, but each one also re-rendered the composer
form (and re-measured its textarea), the message nav rail (re-translating a
label per message), the sidebar's chat provider and the pending-steers row,
because each subscribed to the whole streaming message or the whole messages
array to read something a delta never changes.

- The chat contract and steering read a projection of the branch tail (where it
  sits, whether the run is paused) and fetch the message itself when a turn is
  built, through `useBranchTailGetter`. `ChatTurnsParams` carries
  `getLatestMessage` in place of `latestMessage`.
- The compact action and pending steers select what they use of the tail.
- The URL-prompt hook observes the history only while a submission waits on it.
- The nav rail's ribs are memoized apart from the rail.
- A row's toolbar keeps one element per glyph and stable handlers, so a send
  and its completion no longer re-render every button of every row.

`e2e/benchmarks-fade` gains a render-reason probe (`FADE_PERF_WHY`), a whole-run
profile, and windows for the send and its confirming frame.

* 🫥 perf: Conceal Rerun During a Run Instead of Unmounting It on Every Row

A run starting or ending withholds, then restores, the rerun control on every
row of the thread at once. Unmounting and remounting a button on each row made
the browser re-style the whole transcript both times: the stylesheet holds
`:has(:disabled)` rules and a message row is a `:has()` anchor, so a button
entering, leaving or flipping `disabled` inside a row invalidates that row's
entire subtree. In a 250-message thread that was 80 to 100 ms inside the send
keypress and again inside the final frame.

The control now stays mounted for as long as the row has a rerun to offer and
is concealed by visibility while a run is in flight: no focus, no pointer, no
place in the accessibility tree, and no layout where the toolbar starts at the
row's edge. Below `lg`, where the toolbar is centered, it leaves the flow as
before. It is deliberately not also `disabled`. The reply being written still
mounts no controls at all.

* 🎯 perf: Write :has() Rules So a Change in a Row Does Not Re-style the Row

Two selector shapes in the stylesheet left the browser unable to tell which
elements a `:has()` rule could reach, so it re-styled the whole subtree of
every `:has()` anchor above any change:

- Tailwind's `group-has-[…]`, which compiles to
  `.x:is(:where(.group):has(…) *)`. Message rows and their toolbars are
  `group`s, so a button mounting or unmounting in a row re-styled the row.
- `theme-disabled-within:[&_*]:…`, which compiles to `…:has(:disabled) *`.
  With it in the sheet, a `disabled` flip did the same.

Either one alone was enough: flipping `disabled` on one button per row of a
250-message thread took 100 to 110 ms, and mounting one took 88 ms. A run
starting or ending did one of those on every row.

The row-hover reveal, the header label crossfade and the toolbar's
hover-active hold now use `grouped-*` custom variants that emit
`:where(.group):has(…) .x`: the same elements at the same specificity, with a
subject the browser can read. A wrapper's parts take the disabled fill from
classes the component adds while it is disabled, through `theme-disabled-fill`,
instead of from `:has(:disabled) *`. The same two changes now cost 25 to 42 ms
and 27 ms.

`has-selectors.spec.ts` reads the stylesheet the app ships and fails on either
shape; `restyle.perf.spec.ts` measures the cost.

* 📱 fix: Keep a Concealed Rerun Hidden on Narrow Screens

The narrow-screen stylesheet forces every toolbar button visible from outside
any cascade layer, so it outranked the utilities that conceal a rerun while a
run is in flight: below 1024px the button stayed on screen and in the tab
order, inert. A concealed button now carries `data-concealed`, and that rule
leaves it alone.

Covered at a narrow and a wide viewport by what the reader gets: the settled
reply's rerun is hidden and cannot take focus during a run, and is back after.

* 🧮 perf: Skip the Pause Scan in Pending Steers When None Are Pending

The pending-steers row follows the conversation's messages, so it renders for
every streamed delta, and it resolved the run's pause state before checking
whether it had anything to show. That check walks every part of every message.
It now runs only with a steer to display.
2026-11-14 12:15:48 -05:00
..
public 💬 feat: Redesign the Slack Channels Setup and Management UI (#18105) 2026-11-13 15:44:17 +01:00
src 🧵 perf: Stop Re-rendering and Re-styling the Thread on Stream Events and Run Boundaries (#18148) 2026-11-14 12:15:48 -05:00
sw
test ⏳ refactor: Render the Pending Turn and Steers From @librechat/chat by Default (#18134) 2026-11-14 17:01:27 +01:00
babel.config.cjs 🧹 chore: Clear the Whole-Repo Lint Errors on Dev (#17702) 2026-11-01 01:23:47 +01:00
check_updates.sh
index.html 📶 fix: Show Progress on Slow Connections and Name Offline Failures (#18107) 2026-11-13 17:22:22 +01:00
jest.config.cjs 🐣 chore: Prepare v0.8.9-rc1 Release (#17336) 2026-10-22 08:56:53 +00:00
jest.resolver.cjs
nginx.conf
package.json ⬆️ feat: Migrate to Zod v4 (#17442) 2026-10-26 14:16:22 +01:00
postcss.config.cjs
tailwind.config.cjs 📊 refactor: Move the Context Usage Popover Into @librechat/chat (#17799) 2026-11-05 22:36:51 +01:00
tsconfig.json
vite.config.ts 🖋️ perf: Keep the Markdown Renderer Out of Boot (#18131) 2026-11-14 01:52:59 +01:00