-
Notifications
You must be signed in to change notification settings - Fork 8k
[ide-mode] Hide diff options when active diff is not focused #5808
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @chrstnb, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
I've made changes to the IDE's diff mode to improve the user experience by ensuring that diff-specific options and behaviors are only active when a diff view is actually in focus. This prevents cluttering the UI or enabling unintended shortcuts when the user is working in other parts of the editor. My goal is to make the interface more intuitive and less distracting by dynamically adapting to the user's current context.
Highlights
- Contextual UI Visibility: I've implemented logic to dynamically control the visibility of diff-related UI elements and command availability based on whether an active diff editor is currently focused. This prevents showing irrelevant options when the user is not interacting with a diff.
- New Context Management Method: I introduced a new
updateDiffContextmethod that checks the active text editor. If it's a diff document managed by the system, a VS Code context variablegemini.diff.isVisibleis set totrue; otherwise, it's set tofalse. - Real-time Context Updates: The
updateDiffContextmethod is now called immediately uponDiffManagerinitialization and whenever the active text editor changes, ensuring the context is always up-to-date.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request aims to hide diff-related UI options when a diff view is not in focus. The implementation correctly uses VS Code's context mechanism to control UI visibility based on the active text editor. However, the change introduces a memory leak by not properly managing the lifecycle of an event listener. I've provided a high-severity comment detailing the issue and a recommended approach to fix it.
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also follow up with a test?
Co-authored-by: Jacob Richman <[email protected]>
Co-authored-by: Jacob Richman <[email protected]>
Co-authored-by: Jacob Richman <[email protected]>
Co-authored-by: Jacob Richman <[email protected]>
…gemini#5808) Co-authored-by: Jacob Richman <[email protected]>
…gemini#5808) Co-authored-by: Jacob Richman <[email protected]>
…gemini#5808) Co-authored-by: Jacob Richman <[email protected]>
…gemini#5808) Co-authored-by: Jacob Richman <[email protected]>
…gemini#5808) Co-authored-by: Jacob Richman <[email protected]>
TLDR
When the active diff is not focussed, we should not show the options in the toolbar nor be using cmd+s to accept changes.
Dive Deeper
Reviewer Test Plan
Screen.Recording.2025-08-07.at.6.16.11.PM.mov
Testing Matrix
Linked issues / bugs