Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: SCM More Actions menu auto-closes with Git autofetch and Copilot #233662

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

DrHazemAli
Copy link

Fix: SCM More Actions Menu Auto-closes with Git Autofetch and Copilot

I noticed that the Source Control "More Actions" menu was closing unexpectedly when Git autofetch and GitHub Copilot were enabled. This PR addresses that behavior (#233650).

The Issue

The menu would automatically close when Git autofetch was set to 1 second and GitHub Copilot was installed. This made it difficult to use the More Actions menu effectively.

Fixes Applied

I've improved how we handle menu focus in the SCMRepository class to make it more stable during Git autofetch operations. Here's what I did:

  • Added menu focus tracking with debouncing

    • Created a new _menuFocused state to track menu focus
    • Implemented debouncing to prevent rapid focus changes during autofetch
    • Set a 50ms delay to handle any potential race conditions
  • Ensured proper cleanup when disposing

    • Added cleanup for focus debouncer in the dispose method
    • Prevented any memory leaks from lingering timeouts
    • Maintained existing disposal logic for other resources
  • Created events to handle focus changes

    • Added a new _onDidChangeMenuFocus emitter
    • Exposed onDidChangeMenuFocus event for UI layer
    • Implemented setMenuFocus method to manage focus state changes

These changes work together to maintain menu focus even when Git autofetch operations are running frequently.

Testing

You can test this by:

  1. Installing GitHub Copilot
  2. Setting git.autofetchPeriod to 1
  3. Enabling git.autofetch
  4. Opening the Source Control panel
  5. Clicking the "More Actions" menu
  6. Confirming the menu stays open as expected

Related Issue

Fixes #233650

@DrHazemAli
Copy link
Author

@lszomoru Can you look into this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants