Fix: Debounce baseline saves to reduce I/O and improve git operation detection#2
Merged
khaledesmail merged 6 commits intomainfrom Feb 8, 2026
Merged
Conversation
When performing git operations like pull, merge, checkout, or rebase, files are updated on disk but should not be flagged as AI-generated code. Changes: - Add `isGitOperation` flag to track git-originated changes - Add `recentTextChanges` map for deduplication logic - When file is tracked AND has no diff vs HEAD, detect as git operation - Skip AI detection for git operations (only update baseline) - Process external changes to open files (with deduplication to prevent double counting) Fixes issues where: 1. Git pull triggered false AI detection leading to automatic version bump 2. Git checkout/merge on open files were missed entirely 3. AI agents modifying open files externally were missed The fix handles all cases: - Git operations (pull, merge, checkout, rebase, commit) → Skip AI - AI agents modifying files (with uncommitted changes) → Detect AI - New untracked files → Detect AI - Non-git repos → Use baseline tracking
The workflow was automatically bumping the patch version on every push to main, which was causing unintended version increases even for non-release changes like bug fixes. This removes the automatic version bumping. Future releases will need to be done manually.
…detection - Add debounced saving for persisted baselines (1 second delay) to reduce unnecessary disk I/O during rapid file changes - Improve git operation detection by checking FETCH_HEAD and MERGE_HEAD file modification times to detect recent pull/merge/checkout operations - Remove unnecessary debug logging and comments for cleaner code - Re-enable logging in BaseTracker for production debugging This prevents false AI detection when git operations trigger text change events as VS Code reloads files, and reduces disk I/O from excessive baseline saving.
Contributor
There was a problem hiding this comment.
Thank you for opening your first pull request! We're excited to review your contribution.
Please ensure:
- Tests pass (
npm test) - Linter passes (
npm run lint) - You've updated documentation if needed
- You've added tests for new features
A maintainer will review your PR as soon as possible.
- Fix BaseTracker test to expect logging output (logging is now enabled) - Add proper timeout handling for git operation detection tests - Fix execSync mock to handle encoding parameter correctly - Add debounce wait periods for tests that call file change handler multiple times All tests now pass (1396 passed, 18 skipped).
The test was failing because exactly 1 hour (3600000ms) could become 59 minutes during test execution due to timing. Added 1 minute buffer (3660000ms total) to ensure the status always shows 'hour'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Fix: Debounce baseline saves to reduce I/O and improve git operation detection
unnecessary disk I/O during rapid file changes
file modification times to detect recent pull/merge/checkout operations
This prevents false AI detection when git operations trigger text change
events as VS Code reloads files, and reduces disk I/O from excessive
baseline saving.
Related Issue
Fixes #(issue number)
Type of Change
Testing
npm testand all tests passnpm run lintand fixed all issuesTest Instructions
Screenshots
Checklist
Additional Notes