feat: add VCS integration toggle and gate Git features#88
feat: add VCS integration toggle and gate Git features#88n00ki wants to merge 1 commit intoerictli:mainfrom
Conversation
📝 WalkthroughWalkthroughA new per-folder Git visibility control feature is implemented. A Tauri backend command Changes
Sequence DiagramsequenceDiagram
participant User
participant GeneralSettingsSection
participant GitContext
participant NotesService
participant TauriCommand
participant Backend
User->>GeneralSettingsSection: Toggle Git Enable/Disable
GeneralSettingsSection->>GitContext: setGitEnabled(enabled)
GitContext->>GitContext: Update local state & request ID
GitContext->>NotesService: updateGitEnabled(enabled, folder)
NotesService->>TauriCommand: invoke "update_git_enabled"
TauriCommand->>Backend: validate folder & update Settings.git_enabled
Backend-->>TauriCommand: success/error
TauriCommand-->>NotesService: result
NotesService-->>GitContext: resolve/reject
alt Success
GitContext->>GitContext: Update gitEnabled state
GitContext->>GeneralSettingsSection: Context updated
GeneralSettingsSection->>User: Show success, toggle Git UI
else Error
GitContext->>GitContext: Revert gitEnabled state
GitContext->>GeneralSettingsSection: Context updated with error
GeneralSettingsSection->>User: Show error toast
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/context/GitContext.tsx (1)
17-42: Split GitContext into separate data and actions contexts to prevent unnecessary rerenders.GitContext combines state and action callbacks in a single context value (lines 17-42, 411-458), violating the dual-context performance pattern required by the coding guidelines. This causes components that only need actions (e.g.,
commit(),push()) to rerender whenever state changes likegitEnabledorstatus. Follow the NotesContext pattern with separateGitDataContextandGitActionsContext, each with their own provider and hook.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/context/GitContext.tsx` around lines 17 - 42, Split the current GitContextValue into two interfaces and contexts: a GitDataContext that contains only state fields (status, isLoading, isCommitting, isPushing, isPulling, isSyncing, isAddingRemote, gitAvailable, gitEnabled, isUpdatingGitEnabled, lastError) and a GitActionsContext that contains only the action methods (setGitEnabled, refreshStatus, initRepo, commit, push, pull, sync, addRemote, pushWithUpstream, clearError); update the provider component that currently supplies GitContext to instead render nested providers for GitDataContext and GitActionsContext and populate each with the appropriate values from the existing provider logic (preserve existing function implementations like commit, push, etc.), then add two hooks useGitData() and useGitActions() that read from the corresponding context and update all consumers to import the correct hook so components that only call actions won't rerender on state changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/context/GitContext.tsx`:
- Around line 17-42: Split the current GitContextValue into two interfaces and
contexts: a GitDataContext that contains only state fields (status, isLoading,
isCommitting, isPushing, isPulling, isSyncing, isAddingRemote, gitAvailable,
gitEnabled, isUpdatingGitEnabled, lastError) and a GitActionsContext that
contains only the action methods (setGitEnabled, refreshStatus, initRepo,
commit, push, pull, sync, addRemote, pushWithUpstream, clearError); update the
provider component that currently supplies GitContext to instead render nested
providers for GitDataContext and GitActionsContext and populate each with the
appropriate values from the existing provider logic (preserve existing function
implementations like commit, push, etc.), then add two hooks useGitData() and
useGitActions() that read from the corresponding context and update all
consumers to import the correct hook so components that only call actions won't
rerender on state changes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2c241ed7-c9cb-4fec-97c0-8d4fb4901471
📒 Files selected for processing (6)
src-tauri/src/lib.rssrc/components/command-palette/CommandPalette.tsxsrc/components/layout/Footer.tsxsrc/components/settings/GeneralSettingsSection.tsxsrc/context/GitContext.tsxsrc/services/notes.ts
Behavior
Implementation Notes
Maintainer Note
This PR intentionally keeps the default as ON to avoid breaking existing behavior.
I recommend considering OFF-by-default in a future release (with a release note) for a less intrusive first-run experience.
Summary by CodeRabbit
Release Notes
New Features
Improvements