Skip to content

feat: add VCS integration toggle and gate Git features#88

Open
n00ki wants to merge 1 commit intoerictli:mainfrom
n00ki:feat/vcs-integration-toggle
Open

feat: add VCS integration toggle and gate Git features#88
n00ki wants to merge 1 commit intoerictli:mainfrom
n00ki:feat/vcs-integration-toggle

Conversation

@n00ki
Copy link

@n00ki n00ki commented Mar 5, 2026

  • add an On/Off toggle to Settings > Version Control for Git integration visibility
  • hide Git-specific UI/actions when disabled:
    • sidebar footer Git status + quick actions
    • command palette Git commands
    • detailed Version Control section content in Settings
  • gate Git background work when disabled (status refresh, polling, file-change-triggered refresh)
  • add a dedicated backend command (update_git_enabled) and frontend service wrapper to persist this setting safely

Behavior

  • default remains ON for backward compatibility (existing users keep current behavior)
  • missing gitEnabled is treated as enabled
  • when toggled OFF, Git UI and actions are hidden holistically across the app
  • when toggled ON, existing Git behavior is unchanged

Implementation Notes

  • GitContext is now the single source of truth for gitEnabled
  • added isUpdatingGitEnabled to prevent rapid-toggle races and keep UI state consistent
  • added request/folder guards to avoid stale async updates and cross-folder state bleed

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

    • Added a toggle in General Settings to enable or disable Git functionality per notes folder.
    • Git-related UI elements (status indicators, commit, and sync buttons) now respect the Git enabled/disabled state.
  • Improvements

    • Enhanced command palette and footer to conditionally display Git commands based on Git enablement status.
    • Improved Git context management for per-folder Git visibility control.

@coderabbitai
Copy link

coderabbitai bot commented Mar 5, 2026

📝 Walkthrough

Walkthrough

A new per-folder Git visibility control feature is implemented. A Tauri backend command update_git_enabled validates the folder and persists git enablement state. The Git context gains gitEnabled, isUpdatingGitEnabled, and setGitEnabled to manage visibility. UI components conditionally display Git features based on enablement status.

Changes

Cohort / File(s) Summary
Backend Git Command
src-tauri/src/lib.rs
New update_git_enabled Tauri command validates the expected folder, updates in-memory settings, and persists via save_settings. Error handling added for folder mismatch. write_file error mapping standardized.
Git State Management
src/context/GitContext.tsx
Added gitEnabled, isUpdatingGitEnabled, and setGitEnabled to GitContextValue. Implemented state initialization from settings, async toggle logic with staleness detection via request IDs, and ref-based validation. refreshStatus and polling now skip operations when gitEnabled is false.
Service Layer
src/services/notes.ts
New exported function updateGitEnabled(enabled: boolean, expectedFolder: string): Promise<void> invokes the Tauri command with transformed payload (null for true, false for false).
UI Components
src/components/command-palette/CommandPalette.tsx, src/components/layout/Footer.tsx, src/components/settings/GeneralSettingsSection.tsx
CommandPalette conditionally includes git commands when gitEnabled is true. Footer gates git buttons (Commit, Sync) behind gitEnabled check. GeneralSettingsSection adds a Git On/Off toggle with error handling and clears remote inputs on disable. All components destructure gitEnabled from Git context and update memoization dependencies.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • erictli

Poem

🐰 A toggle's born, a folder's choice,
Git whispers quiet, finds its voice.
Enable, disable, on a whim—
Per-folder magic, status trim! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add VCS integration toggle and gate Git features' directly and clearly summarizes the main changes: adding a toggle control for Git integration and implementing conditional visibility/execution of Git features throughout the application.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 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 like gitEnabled or status. Follow the NotesContext pattern with separate GitDataContext and GitActionsContext, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 3331c1e and 0de6f40.

📒 Files selected for processing (6)
  • src-tauri/src/lib.rs
  • src/components/command-palette/CommandPalette.tsx
  • src/components/layout/Footer.tsx
  • src/components/settings/GeneralSettingsSection.tsx
  • src/context/GitContext.tsx
  • src/services/notes.ts

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