fix(vscode-ide-companion): preserve terminal focus when closing diff tabs#28183
fix(vscode-ide-companion): preserve terminal focus when closing diff tabs#28183gaurav0107 wants to merge 1 commit into
Conversation
|
📊 PR Size: size/M
|
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 usability issue where closing a diff preview tab in the VS Code companion extension causes the editor to steal keyboard focus from the integrated terminal. By ensuring the 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 the 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 counterproductive. 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 updates the DiffManager to pass preserveFocus=true when closing background diff tabs, ensuring that keyboard focus remains in the integrated terminal. A new test suite is added to verify this behavior. The review feedback correctly points out that vscode.window.tabGroups.all should be reset in beforeEach to prevent test pollution and ensure proper test isolation.
…tabs Closing the background diff tab via tabGroups.close(tab) lets VS Code move keyboard focus into the editor area, stealing focus from the integrated terminal where the Gemini CLI runs. Pass preserveFocus=true so focus stays put, letting users step through edits without re-clicking the terminal pane. Adds a regression test asserting tabGroups.close is invoked with preserveFocus=true when a diff tab is closed. Fixes google-gemini#22193
c9f4074 to
ff24aa9
Compare
Summary
When using the VS Code companion extension, approving a file edit in the
Gemini CLI closes the background diff preview and steals keyboard focus from
the integrated terminal. The user then has to click back into the terminal
before every subsequent edit. This change keeps focus in the terminal by
passing VS Code's
preserveFocusflag when the diff tab is closed.Details
The companion opens the diff preview as a background tab (
vscode.diffwithpreserveFocus: true) while the user works in the terminal where the GeminiCLI runs. On
closeDiff,DiffManager.closeDiffEditorinpackages/vscode-ide-companion/src/diff-manager.tscloses that tab withvscode.window.tabGroups.close(tab). VS Code's default behavior when a tab isclosed is to move focus into the editor area. Passing the second positional
argument to
TabGroups.close(tabs, preserveFocus?)astruekeeps focus inits current position (the terminal):
This is a one-line behavioral fix plus a focused regression test.
It resurrects the one-line fix that was reviewed and approved by @kschaab
in #23215, which was auto-closed by the 30-day inactivity bot rather than on
merits (the alternative #22331 is closed). #23215 shipped without a test; this
PR adds the missing regression coverage in
src/diff-manager.test.ts,asserting
tabGroups.closeis invoked withpreserveFocus = truewhen a difftab is closed (the test fails on the old
close(tab)call and passes with thefix).
Related Issues
Fixes #22193
How to Validate
Automated:
npm test -w packages/vscode-ide-companion— the newsrc/diff-manager.test.tspasses and the full package suite is green (41 passed, 1 skipped).
npm run lint -w packages/vscode-ide-companionandtsc --noEmitpass.Manual (validation steps from #23215):
npm run build -w packages/vscode-ide-companion[Proceed]in the terminal, press Enter.on the CLI instead of inserting a newline in an editor tab.
Pre-Merge Checklist