perf(desktop): stop idle chat re-renders — memo ChatView + stable tile props (salvage #38470) - #77661
Merged
kshitijk4poor merged 1 commit intoAug 3, 2026
Conversation
… props, gated adapter re-sync Re-derive of PR NousResearch#38470 on today's main (its target file desktop-controller.tsx no longer exists after the contrib/ refactor; the three surviving ideas are applied at their new homes): - incremental-external-store-runtime: the dep-less setAdapter effect ran every render; gate on [runtime, store] — behavior-preserving because __internal_setAdapter early-exits on identical store. - ChatView is now memo()d, and session-tile hoists its inline arrow props to useCallbacks/module constants so the memo actually holds. - Render-count regression test (mocked Thread) proves an unrelated parent re-render no longer re-renders the chat shell. Credit: idea and original implementation by @hdd69 in NousResearch#38470.
3 tasks
kshitijk4poor
enabled auto-merge (rebase)
August 3, 2026 12:40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Idle chat surfaces were re-rendering constantly: a dep-less
useEffect(() => runtime.setAdapter(store))ran on EVERY render of the chat surface, andChatView— the whole chat shell — was un-memoized while its tile caller passed fresh inline arrow props on each render, so every idle tick (now-tickers, unrelated store updates) re-rendered the entire chat tree. WHO: everyone with a chat open; the cost scales with tiles/panes mounted.What this does
[runtime, store]— behavior-preserving because__internal_setAdapterearly-exits when the store is unchanged (verified at the early-exit site); the effect now simply skips the call instead of making a no-op one every render.ChatViewinmemo()and hoists session-tile's inline arrow props (onAddUrl, onPasteClipboardImage, onPick*, onRemoveAttachment, onRetryResume, noop pin/delete handlers, the transcribe wrapper) to useCallbacks/module constants so the memo actually holds.Provenance
Re-derive of #38470 by @hdd69 (authorship preserved on the commit; attribution mapping merged in #77641). The original PR is unpickable — its main target file
desktop-controller.tsxno longer exists after the contrib/ surfaces refactor, and its branch carries 3 merge commits — but all three of its ideas are alive on today's main and are applied here at their new homes (session-tile.tsx now owns the ChatView call site).Measured impact
Render-count proof at the test level (stated substitution for CPU%): the new test fails on main (unrelated parent render re-renders the chat shell) and passes with the memo chain — that delta is the entire class of idle re-renders eliminated. 8 tests green across chat/index + incremental-external-store-runtime; mutation check: reverting index.tsx fails the render-count test, restore green.
Closes #38470.