feat: add AI Chat entry to sidebar nav for note-independent access#368
feat: add AI Chat entry to sidebar nav for note-independent access#368VenkateshDas wants to merge 19 commits intorefactoringhq:mainfrom
Conversation
The AI chat panel was only reachable via the breadcrumb bar button inside the editor, which meant opening it required a note to be open first. The panel itself already works without an active note, so this was a UI entrypoint gap rather than a capability gap. Adds an "AI Chat" nav item (Sparkle icon) to the sidebar top nav section, alongside All Notes, Inbox, and Archive. Clicking it toggles the existing AI chat panel. The item highlights when the panel is open, stays in sync with the breadcrumb toggle, and is fully i18n-keyed across all 12 supported locales.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 656 |
| Duplication | 3 |
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull Request Overview
This PR successfully introduces the 'AI Chat' entry to the sidebar, facilitating note-independent access to the AI panel and maintaining state synchronization with existing UI elements. While the implementation meets the functional requirements and Codacy identifies the PR as being up to standards, there are significant structural concerns regarding complexity and maintainability.
The App.tsx and Sidebar.tsx files are flagged as high-risk due to extreme cyclomatic complexity and an excessive number of props (38 in SidebarNavigation). This PR adds further logic to these already strained areas without adding any automated tests to verify the multi-layer prop drilling or the state synchronization logic. Addressing the suggested localization adjustments for German, French, and Spanish is also required for UI consistency.
About this PR
- The PR introduces new state synchronization logic and props across four layers of components (App -> Sidebar -> SidebarNavigation -> SidebarTopNav) without accompanying automated tests. This increases the risk of regression in the navigation and panel toggle functionality.
1 comment outside of the diff
src/components/Sidebar.tsx
line 103🟡 MEDIUM RISK
Suggestion: This component accepts 38 parameters, and this PR adds two more. This exceeds maintainability thresholds and makes the component difficult to test. Consider grouping related callbacks (e.g., folder actions, view actions, and AI state) into cohesive objects or using a context provider to reduce prop drilling.Note: This file is currently flagged as a complex file with no test coverage.
Test suggestions
- Verify the AI Chat NavItem renders in the SidebarTopNav with the Sparkle icon.
- Verify that clicking the AI Chat NavItem triggers the onToggleAIChat callback.
- Verify the NavItem 'isActive' prop correctly reflects the global 'showAIChat' state.
- Verify the 'sidebar.nav.aiChat' translation key is correctly retrieved and rendered for different locales.
- Add unit tests for SidebarTopNav to ensure the onClick handler does not pass the MouseEvent to the global state setter.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify the AI Chat NavItem renders in the SidebarTopNav with the Sparkle icon.
2. Verify that clicking the AI Chat NavItem triggers the onToggleAIChat callback.
3. Verify the NavItem 'isActive' prop correctly reflects the global 'showAIChat' state.
4. Verify the 'sidebar.nav.aiChat' translation key is correctly retrieved and rendered for different locales.
5. Add unit tests for SidebarTopNav to ensure the onClick handler does not pass the MouseEvent to the global state setter.
TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback
| icon={Sparkle} | ||
| label={translate(locale, 'sidebar.nav.aiChat')} | ||
| isActive={showAIChat} | ||
| onClick={onToggleAIChat} |
There was a problem hiding this comment.
🟡 MEDIUM RISK
Suggestion: Wrap the onClick handler in an arrow function to prevent passing the React MouseEvent to the toggle function. This also maintains consistency with the other NavItems in this component.
| onClick={onToggleAIChat} | |
| onClick={() => onToggleAIChat()} |
| "sidebar.nav.inbox": "Bandeja de entrada", | ||
| "sidebar.nav.allNotes": "Todas las notas", | ||
| "sidebar.nav.archive": "Archivar", | ||
| "sidebar.nav.aiChat": "AI Chat", |
There was a problem hiding this comment.
⚪ LOW RISK
Suggestion: The term 'AI Chat' is inconsistent with the 'IA' terminology used elsewhere in the Spanish locales (e.g., 'Agentes de IA'). Consider using 'Chat IA'.
| "sidebar.nav.inbox": "Boîte de réception", | ||
| "sidebar.nav.allNotes": "Toutes les notes", | ||
| "sidebar.nav.archive": "Archiver", | ||
| "sidebar.nav.aiChat": "AI Chat", |
There was a problem hiding this comment.
⚪ LOW RISK
Suggestion: The term 'AI Chat' is inconsistent with the 'IA' terminology used elsewhere in the French locale (e.g., 'Agents d'IA'). Consider using 'Chat IA'.
| "sidebar.nav.inbox": "Posteingang", | ||
| "sidebar.nav.allNotes": "Alle Notizen", | ||
| "sidebar.nav.archive": "Archivieren", | ||
| "sidebar.nav.aiChat": "AI Chat", |
There was a problem hiding this comment.
⚪ LOW RISK
Suggestion: The term 'AI Chat' is inconsistent with the 'KI' terminology used elsewhere in the German locale (e.g., 'KI-Agents'). Consider using 'KI-Chat'.
Problem
The AI chat panel was only reachable via the sparkle button in the editor breadcrumb bar, which only renders when a note is open. The panel itself already works without an active note — context is built from all vault entries, not just the open one — but users had no way to open it without first opening a note.
Solution
Adds an AI Chat nav item (Sparkle icon) to the sidebar top nav section, alongside All Notes, Inbox, and Archive. Clicking it toggles the existing AI chat panel using the same
showAIChat/toggleAIChatstate already wired to the breadcrumb toggle, so both stay in sync.The item highlights when the panel is open, matching the visual language of the other nav items. No new state, no new panel — just a new entrypoint.
Changes:
SidebarTopNav: addsshowAIChat/onToggleAIChatprops, renders AI ChatNavItemwhen handler is providedSidebar: threads the two props throughSidebarProps→SidebarNavigationProps→SidebarNavigation→SidebarTopNavApp.tsx: passesdialogs.showAIChatanddialogs.toggleAIChatto<Sidebar>sidebar.nav.aiChattranslation keyTest plan