Skip to content

feat: add AI Chat entry to sidebar nav for note-independent access#368

Open
VenkateshDas wants to merge 19 commits intorefactoringhq:mainfrom
VenkateshDas:main
Open

feat: add AI Chat entry to sidebar nav for note-independent access#368
VenkateshDas wants to merge 19 commits intorefactoringhq:mainfrom
VenkateshDas:main

Conversation

@VenkateshDas
Copy link
Copy Markdown

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 / toggleAIChat state 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: adds showAIChat / onToggleAIChat props, renders AI Chat NavItem when handler is provided
  • Sidebar: threads the two props through SidebarPropsSidebarNavigationPropsSidebarNavigationSidebarTopNav
  • App.tsx: passes dialogs.showAIChat and dialogs.toggleAIChat to <Sidebar>
  • All 12 locale files: adds sidebar.nav.aiChat translation key

Test plan

  • Open the app with no notes open — AI Chat item visible in sidebar top nav
  • Click AI Chat in sidebar — panel opens on the right without requiring a note
  • Click again — panel closes
  • Open a note, toggle AI Chat from the breadcrumb — sidebar item reflects active state
  • Toggle from sidebar — breadcrumb button reflects active state (both in sync)
  • Test with a non-English locale — label renders correctly

VenkateshDas and others added 19 commits April 27, 2026 22:14
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.
@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 656 complexity · 3 duplication

Metric Results
Complexity 656
Duplication 3

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

Copy link
Copy Markdown

@codacy-production codacy-production Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Suggested change
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",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ 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",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ 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",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ 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'.

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