fix(vscode-ide-companion): restore terminal focus when closing diff#28070
fix(vscode-ide-companion): restore terminal focus when closing diff#28070aniruddhaadak80 wants to merge 1 commit into
Conversation
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 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
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
|
|
📊 PR Size: size/XS
|
|
You already have 7 pull requests open. Please work on getting existing PRs merged before opening more. |
There was a problem hiding this comment.
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.
| await vscode.commands.executeCommand( | ||
| 'workbench.action.terminal.focus', | ||
| ); |
There was a problem hiding this comment.
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)));
}
Closes #22193