Skip to content

Conversation

@ibetitsmike
Copy link
Contributor

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:

  • RightSidebar owned selectedTab state via usePersistedState
  • AIView listened to that state with { listener: true } and derived sidebarWidth

When 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

  1. Lift tab state to AIView - Now owns both selectedTab and width, passing them together to RightSidebar. This eliminates the render race where tab and width could be out of sync.

  2. Keep sidebar DOM mounted when collapsed - Changed from return null to rendering with width: 0px and isCollapsed prop. This preserves the CSS transition target so width changes animate smoothly.

  3. Return actual stored width from hook - useResizableSidebar now returns undefined when no custom width exists (allowing auto-wide mode for Review) and returns the stored custom width regardless of enabled state (keeping width stable during tab switches).

Testing

  • Rapidly switch between Review and Costs tabs
  • Verify smooth 200ms transition without visual jump
  • Confirm tab selection persists across page reload
  • Confirm custom widths (after drag-resize) persist per-tab

Generated with mux • Model: mux-gateway:anthropic/claude-opus-4-5 • Thinking: high

- AIView now owns selectedTab state (not RightSidebar)
- Tab and width update atomically in same render, preventing visual jank
- Replace loading text with spinner in ReviewPanel
@ibetitsmike ibetitsmike force-pushed the mike/fix-sidebar-tab-switch-jank branch from 65a5110 to e18d2dd Compare December 28, 2025 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant