🤖 fix: eliminate jank when switching sidebar tabs #1207
+66
−53
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.
Problem
When switching between Review and Costs tabs in the right sidebar, the sidebar would visually jump—appearing to briefly collapse before expanding to the correct width.
Root Cause
Race condition between two components sharing state:
RightSidebarownedselectedTabstate viausePersistedStateAIViewlistened to that state with{ listener: true }and derivedsidebarWidthWhen clicking a tab, RightSidebar rendered immediately with the new tab but stale width props from AIView (which had not re-rendered yet), causing a visual jump during the intermediate state.
Solution
Lift tab state to AIView - Now owns both
selectedTaband width, passing them together to RightSidebar. This eliminates the render race where tab and width could be out of sync.Keep sidebar DOM mounted when collapsed - Changed from
return nullto rendering withwidth: 0pxandisCollapsedprop. This preserves the CSS transition target so width changes animate smoothly.Return actual stored width from hook -
useResizableSidebarnow returnsundefinedwhen no custom width exists (allowing auto-wide mode for Review) and returns the stored custom width regardless ofenabledstate (keeping width stable during tab switches).Testing
Generated with
mux• Model:mux-gateway:anthropic/claude-opus-4-5• Thinking:high