fix(sidebar): ensure consistent highlight mutex behavior across all navigation buttons #198
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 & Why
What: Fix inconsistent highlight mutual exclusion behavior across sidebar navigation buttons by ensuring all buttons properly clear previous selections.
Why: Some sidebar buttons (History, Settings) were missing
selectItem()calls, causing dual highlighting where multiple buttons could be highlighted simultaneously, creating visual confusion and inconsistent user experience.Fixes #197
Pre-PR Checklist
Run these:
pnpm type-checkpnpm format:checkpnpm lintpnpm buildpnpm i18n:check(if applicable)Type
Technical Details
Core Problem
The sidebar had inconsistent state management patterns:
Working correctly (with
selectItem()calls):selectItem('chat', chatId, true)selectItem('app', appId)selectItem('chat', null, true)Broken (missing
selectItem()calls):router.push('/chat/history')router.push('/settings')This caused dual highlighting where previous selections persisted when navigating to History or Settings.
Fix Applied
Added consistent
selectItem(null, null)calls to clear previous selections:History Button (
sidebar-header.tsx):Settings Button (
sidebar-footer.tsx):Unified Pattern
All sidebar buttons now follow consistent state management:
Selection Buttons (set specific state):
selectItem('chat', chatId, true)- Chat itemsselectItem('app', appId)- AppsNavigation Buttons (clear state):
selectItem('chat', null, true)- New ChatselectItem(null, null)- History, SettingsTest Coverage
Added comprehensive test suite validating:
Zero Breaking Changes
This fix ensures a consistent, predictable sidebar navigation experience with proper mutual exclusion behavior across all navigation components.