Commit graph

3 commits

Author SHA1 Message Date
Danny Avila
b341f93805
🏎️ perf: Re-render Only the Tail Rows When a Message Is Sent (#16572)
Some checks are pending
Docker Dev Images Build / publish (push) Waiting to run
Sync Helm Chart Tags / Ignore non-main push (push) Waiting to run
Sync Helm Chart Tags / Sync chart tags (push) Waiting to run
Every send moved the thread's tail (isSubmitting, latestMessageId,
latestMessageDepth, and a handleContinue rebound per turn), and the memoized
row context listed all of them as dependencies, so each move handed every row
a new context object and re-rendered the whole thread: three commits of
~12,000 component renders on a 246-message thread, one of them inside the
Enter keypress.

- Keep the row context object stable; the tail values are ref-backed getters
  for call-time reads, and rows receive them as props that the row comparator
  (isSameTailRelation) only reacts to when the row enters or leaves the tail.
- Fork reads the split target through a getter at click time.
- HoverButtons subscribes to a boolean isSubmitting context and a stable
  operations context instead of the combined messages-view context; Fork and
  Feedback are memoized so the per-send toolbar pass stops there.
- Make handleContinue referentially stable.
- Cache the Intl formatters behind getMessageTimestamp per locale and clock.
- Add a submit-lag benchmark (e2e/benchmarks-tree) that reports long tasks,
  Enter-to-row latency, a CPU profile and per-commit render reasons.
2026-09-30 10:19:49 -04:00
Danny Avila
a5932cb039
🎖️ perf: Promote Flat Thread Rendering to Default (#15660)
* 🧵 feat(client): Make the Flat Thread Renderer the Default

The flat message-thread renderer becomes the default; the recursive
MultiMessage path stays reachable with VITE_FLAT_THREAD=false at build
time or LC_FLAT_THREAD=false in localStorage as an escape hatch.

* 🧪 test(e2e): Differential Check of the Two Thread Renderers

Builds one conversation through the real pipeline with the content shapes
the seeded benchmarks never produce (a regenerated branch, reasoning,
markdown with a table and code, a provider attachment) and one with
detached subagent activity, then renders each with the flat list and the
recursive tree in turn. Both must produce the same transcript, sibling
counters, attachments and activity groups, before and after cycling a
branch. Also adds a benchmark config that runs the tree lane against the
built client for production-minified numbers.
2026-09-06 18:31:08 +00:00
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