fix(vscode-ide-companion): restore terminal focus after closing diff tabs - #23215
fix(vscode-ide-companion): restore terminal focus after closing diff tabs#23215iiitutu wants to merge 8 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello, 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! This pull request addresses a user experience issue where the VS Code integrated terminal would lose focus after the Gemini CLI closed a diff tab. The change ensures that the terminal remains the active window, allowing users to continue interacting with the CLI without interruption and improving workflow efficiency. Highlights
Using Gemini Code AssistThe 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 by creating a comment using either
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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request addresses a user experience issue by restoring focus to the terminal after a diff tab is closed. The approach is sound, but the new command execution could lead to an unhandled promise rejection if it fails. I've added a suggestion to wrap it in a try...catch block to make it more robust.
| try { | ||
| await vscode.commands.executeCommand( | ||
| 'workbench.action.terminal.focus', | ||
| ); |
There was a problem hiding this comment.
This does what I think you want to do but it will always focus the terminal which may not be what the user actually wants. I don't know if it will be annoying for the user or not. This also will focus the terminal window including creating a new terminal session if the user has no active terminal sessions.
There was a problem hiding this comment.
I think the more correct & minimal fix is this one-liner that sets the 'maintainFocus' parameter to true when calling vscode.window.tabGroups.close:
I looked into this pretty extensively, and put up #22331 a couple weeks back. (In hindsight, that PR probably has too much testing for such a small fix.)
There was a problem hiding this comment.
@kschaab mind weighing in here?
Let's get the best fix in, it potentially may be Greg's suggestion. Worth taking a look
|
Hi there! Thank you for your interest in contributing to Gemini CLI. To ensure we maintain high code quality and focus on our prioritized roadmap, we have updated our contribution policy (see Discussion #17383). We only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'. All other community pull requests are subject to closure after 14 days if they do not align with our current focus areas. For this reason, we strongly recommend that contributors only submit pull requests against issues explicitly labeled as 'help-wanted'. This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding and for being part of our community! |
|
@gjuggler, apologies for the bot closing this PR! We have reopened it. Please sync your branch to the latest |
|
Yes, I think #22331 is a better fix. |
@iiitutu would you be willing to adopt that change in this PR? That's likely the faster route versus fighting the PR bots any further, haha. If the single-line fix will pass review, that's probably the ideal PR. (The unit tests in #22331 didn't actually do much, and the integration tests were messy and would likely add more maintenance burden than they're worth). |
Adopts fix from google-gemini#22331 - sets preserveFocus: true in tabGroups.close() to maintain terminal focus after closing diff tabs in VS Code.
|
Adopts the fix from #22331 - uses |
|
Hi there! Thank you for your contribution. To keep our backlog manageable, we are closing pull requests that haven't seen maintainer activity for 30 days. If you're still working on this, please let us know! |
Summary
Fixes a UX bug where the VS Code integrated terminal loses focus after approving a file change in the Gemini CLI.
When the CLI calls
openDiff, the VS Code companion extension opens a diff tab in the background (preserveFocus: true). Upon accepting the change, the CLI sends acloseDiffrequest. Closing this background diff tab causes VS Code to default its focus to the active editor area, stealing focus away from the integrated terminal where the user is actively working.This PR adds an explicit
workbench.action.terminal.focuscommand after closing the diff tab to ensure focus is restored to the terminal.Details
In
packages/vscode-ide-companion/src/diff-manager.ts, thecloseDiffEditormethod closes the diff tab usingvscode.window.tabGroups.close(tab). This change appends an API call to re-focus the terminal immediately afterward.Related Issues
Fixes #22193, Fixes #8635, Fixes #10956
How to Validate
npm run build -w packages/vscode-ide-companion[Proceed]in the terminal, press Enter.Pre-Merge Checklist