Skip to content

Fix spurious error when checking out a PR with untracked files and add "never show again" option#7306

Merged
alexr00 merged 5 commits intomainfrom
copilot/fix-7294
Aug 5, 2025
Merged

Fix spurious error when checking out a PR with untracked files and add "never show again" option#7306
alexr00 merged 5 commits intomainfrom
copilot/fix-7294

Conversation

Copy link
Contributor

Copilot AI commented Jul 16, 2025

The handleUncommittedChanges function was showing a warning dialog for all uncommitted changes, including untracked files. However, untracked files typically don't conflict with PR checkout unless the PR branch creates a file at the same path.

This caused unnecessary friction for users who commonly have untracked files in their workspace (like environment configs, temporary files, etc.) when switching between PRs.

Changes Made

  • Filter untracked files: Modified handleUncommittedChanges to filter out files with Status.UNTRACKED status before checking for conflicts
  • Updated logic: Only show the warning dialog when there are tracked changes that could actually cause conflicts
  • Safe operations: Updated stash/discard operations to only handle tracked files, leaving untracked files untouched
  • Never show again option: Added a "Don't show again" button that uses extension local state to permanently disable the warning dialog

Before vs After

Before: Warning appears for any uncommitted changes including untracked files
Warning dialog shown for untracked files

After:

  • Warning only appears for tracked changes that could cause conflicts
  • Users can permanently disable the warning with "Don't show again" option stored in extension local state
  • Dialog now shows three options: "Stash changes", "Discard changes", and "Don't show again"

Implementation Details

The "never show again" functionality uses the extension's PersistentState infrastructure:

  • PersistentState.fetch() checks if user has disabled warnings
  • PersistentState.store() saves the preference when user clicks "Don't show again"
  • Preference persists across VS Code sessions without exposing a user-configurable setting

Test Cases

Scenario Before Fix After Fix
No changes ✅ Proceed ✅ Proceed
Only untracked files ❌ Warning ✅ Proceed
Only tracked changes ❌ Warning ❌ Warning
Mixed tracked/untracked ❌ Warning ❌ Warning
User selects "Don't show again" N/A ✅ Future dialogs disabled

This is a minimal change that maintains existing behavior for legitimate conflicts while eliminating spurious warnings for untracked files and giving users control over the dialog experience.

Fixes #7294.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

…files

Co-authored-by: rebornix <876920+rebornix@users.noreply.github.com>
Copilot AI changed the title [WIP] Spurious error when checking out a PR with untracked files Fix spurious error when checking out a PR with untracked files Jul 16, 2025
Copilot AI requested a review from rebornix July 16, 2025 04:49
Copy link
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

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

@copilot good start. Can you:

  • Remove the test. It doesn't test any product code
  • Add a "never show again" option.

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 4, 2025

@copilot good start. Can you:

  • Remove the test. It doesn't test any product code
  • Add a "never show again" option.

Done! I've addressed both requests:

  1. Removed the test - The test file src/test/commands/handleUncommittedChanges.test.ts has been deleted as it wasn't testing the actual product code.

  2. Added "never show again" option - The warning dialog now includes a "Don't show again" button that:

    • Adds a new setting githubPullRequests.neverShowUncommittedChangesWarning (boolean, default: false)
    • When clicked, updates the setting globally to prevent future dialogs
    • Checks this setting before showing the dialog, so users who opt out won't see it again

The dialog now shows three options: "Stash changes", "Discard changes", and "Don't show again".

Changes committed in 5561d52.

Copilot AI changed the title Fix spurious error when checking out a PR with untracked files Fix spurious error when checking out a PR with untracked files and add "never show again" option Aug 4, 2025
Copilot AI requested a review from alexr00 August 4, 2025 16:31
Copy link
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

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

@copilot, don't use a setting, instead store in local state.

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 5, 2025

@copilot, don't use a setting, instead store in local state.

Done! Changed from VS Code setting to extension local state (PersistentState) for storing the "never show again" preference.

The implementation now:

  • Uses PersistentState.fetch() to check if user disabled warnings
  • Uses PersistentState.store() to save preference when user clicks "Don't show again"
  • Removed the githubPullRequests.neverShowUncommittedChangesWarning setting from package.json
  • Follows the same pattern as other "Don't show again" functionality in the codebase

Changes committed in dfdad79.

Copilot AI requested a review from alexr00 August 5, 2025 09:25
@alexr00 alexr00 marked this pull request as ready for review August 5, 2025 09:37
@alexr00 alexr00 enabled auto-merge (squash) August 5, 2025 09:38
@vs-code-engineering vs-code-engineering bot added this to the August 2025 milestone Aug 5, 2025
@alexr00 alexr00 merged commit bb05870 into main Aug 5, 2025
3 checks passed
@alexr00 alexr00 deleted the copilot/fix-7294 branch August 5, 2025 13:43
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.

Spurious error when checking out a PR with untracked files

4 participants