Reduce terminal drawer resize rerenders#2816
Draft
cursor[bot] wants to merge 3 commits into
Draft
Conversation
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
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.
What Changed
ThreadTerminalDrawerheight handling so prop-driven height changes render from the clamped source height directly instead of syncing throughsetStatein an effect.useThreadDrawerHeighthook.docs/perf/react-scan-terminal-drawer-before.webmdocs/perf/react-scan-terminal-drawer-after.webmWhy
React Doctor flagged
ThreadTerminalDrawerfor synchronous state updates in effects, which can create cascading renders and block React Compiler optimization. The new flow removes the prop-to-state effect from the component's hot resize path while preserving live drag behavior and terminal fit synchronization.React Doctor summary improved from 606 diagnostics / 141 errors to 605 diagnostics / 139 errors, with the targeted
ThreadTerminalDrawerset-state-in-effectfindings removed.UI Changes
No intentional UI appearance change. The before/after React Scan recordings above show the same terminal drawer height/visibility interaction with React Scan enabled.
Checklist
Validation:
bun fmtbun lint(passes with existing warnings)bun typecheckbunx react-doctor@latest --json --yes --offline --fail-on noneNote
Reduce rerenders in
ThreadTerminalDrawerduring resizeuseThreadDrawerHeighthook in ThreadTerminalDrawer.tsx that manages drawer height with a per-thread draft value, suppressing redundantonHeightChangecalls when the clamped height hasn't changed.resizeEpocheffect (triggered on visibility changes) with a derivedeffectiveResizeEpoch = resizeEpoch + (visible ? 1 : 0), reducing unnecessary re-renders ofTerminalViewportchildren.TerminalViewportinstances now always receive aresizeEpochincremented by 1 when the drawer is visible, rather than incrementing only on visibility transitions.Macroscope summarized c5320d7.