Skip to content

fix(vscode-ide-companion): restore terminal focus when closing diff#28070

Closed
aniruddhaadak80 wants to merge 1 commit into
google-gemini:mainfrom
aniruddhaadak80:fix/vscode-terminal-focus
Closed

fix(vscode-ide-companion): restore terminal focus when closing diff#28070
aniruddhaadak80 wants to merge 1 commit into
google-gemini:mainfrom
aniruddhaadak80:fix/vscode-terminal-focus

Conversation

@aniruddhaadak80

Copy link
Copy Markdown
Contributor

Closes #22193

@aniruddhaadak80 aniruddhaadak80 requested a review from a team as a code owner June 21, 2026 05:33
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 resolves an issue where the terminal loses focus after closing a diff view in the VS Code IDE companion. By programmatically triggering the terminal focus command upon tab closure, the developer workflow is maintained without requiring manual intervention.

Highlights

  • Terminal Focus Restoration: Implemented a command to automatically refocus the terminal after a diff tab is closed, ensuring a smoother transition for the user.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .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 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

  1. 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.

@github-actions github-actions Bot added the size/xs An extra small PR label Jun 21, 2026
@github-actions

Copy link
Copy Markdown

📊 PR Size: size/XS

  • Lines changed: 3
  • Additions: +3
  • Deletions: -0
  • Files changed: 1

@github-actions

Copy link
Copy Markdown

You already have 7 pull requests open. Please work on getting existing PRs merged before opening more.

@github-actions github-actions Bot closed this Jun 21, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 updates the VS Code companion's diff manager to automatically focus the terminal after closing a diff tab. The review feedback suggests wrapping this new command execution in a try-catch block to ensure that any potential failures in focusing the terminal do not block the core diff acceptance or rejection workflow.

Comment on lines +251 to +253
await vscode.commands.executeCommand(
'workbench.action.terminal.focus',
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

If vscode.commands.executeCommand('workbench.action.terminal.focus') throws an error (e.g., in headless environments, during tests, or if the command is temporarily unavailable), the rejection will propagate up and prevent the rest of the acceptDiff or cancelDiff operations from completing. This would block the ide/diffAccepted or ide/diffRejected notifications from being fired, causing the CLI to hang or miss the user's action.

To ensure robustness, wrap the terminal focus command in a try-catch block so that any failure in focusing the terminal does not block the core diff acceptance/rejection workflow.

          try {
            await vscode.commands.executeCommand(
              'workbench.action.terminal.focus',
            );
          } catch (error) {
            this.log('Failed to focus terminal: ' + (error instanceof Error ? error.message : String(error)));
          }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xs An extra small PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gemini CLI doesn't maintain keyboard focus when VS Code extension closes a diff

1 participant