Skip to content

fix(vscode-ide-companion): track all activate() Disposables in subscriptions - #29190

Closed
Frank20021 wants to merge 1 commit into
google-gemini:mainfrom
Frank20021:fix/vscode-ide-companion-disposable-leak
Closed

Frank20021 wants to merge 1 commit into
google-gemini:mainfrom
Frank20021:fix/vscode-ide-companion-disposable-leak

Conversation

@Frank20021

Copy link
Copy Markdown

Summary

  • Fixes a comma-operator bug in activate() where wrapping two registrations in parentheses meant only the last Disposable of each pair was pushed to context.subscriptions.
  • Ensures gemini.diff.accept and onDidChangeWorkspaceFolders are disposed on deactivation (avoids "command already exists" on reload and stale workspace-folder listeners).
  • Adds a regression test that asserts those Disposables are present in context.subscriptions (existing toHaveBeenCalled() checks could not catch this).

Fixes #27790

Test plan

  • npm run test --workspace=gemini-cli-vscode-ide-companion -- src/extension.test.ts (12 passed)
  • Confirmed the new test fails when the comma-operator parentheses are restored
  • Reload the companion extension in VS Code and verify gemini.diff.accept does not throw "already exists"
  • Change workspace folders and confirm env sync still works after reload

Made with Cursor

…iptions

Comma expressions in context.subscriptions.push() dropped the
gemini.diff.accept command and onDidChangeWorkspaceFolders listener,
so they were never disposed on deactivation.

Co-authored-by: Cursor <[email protected]>
@Frank20021
Frank20021 requested a review from a team as a code owner September 3, 2026 18:17
@github-actions github-actions Bot added the size/m A medium sized PR label Sep 3, 2026
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

📊 PR Size: size/M

  • Lines changed: 138
  • Additions: +87
  • Deletions: -51
  • Files changed: 2

@google-cla

google-cla Bot commented Sep 3, 2026

Copy link
Copy Markdown

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.

@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 addresses a resource management bug in the VS Code extension activation logic. By removing incorrect grouping of registrations, it ensures that all command and workspace event listeners are properly registered and subsequently disposed of, preventing common VS Code extension issues like command name collisions and memory leaks during reload.

Highlights

  • Bug Fix: Corrected a comma-operator issue in the activate() function that prevented multiple Disposables from being correctly registered in context.subscriptions.
  • Resource Management: Ensured that gemini.diff.accept and onDidChangeWorkspaceFolders are properly disposed of on extension deactivation to prevent command registration conflicts and stale listeners.
  • Testing: Added a regression test to verify that all critical Disposables are correctly tracked within context.subscriptions.
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. ↩

@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 cleans up redundant parentheses around several VS Code API calls (such as registerCommand and onDidChangeWorkspaceFolders) when pushing them to context.subscriptions in extension.ts. Additionally, it updates the vscode mock in extension.test.ts to return mock disposable objects for these subscriptions and adds a new unit test to verify that the subscriptions are correctly tracked in the extension context. I have no feedback to provide.

@gemini-cli gemini-cli Bot added priority/p2 Important but can be addressed in a future release. area/core Issues related to User Interface, OS Support, Core Functionality labels Sep 3, 2026
@gemini-cli

gemini-cli Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

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 only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'.

This PR will be closed in 7 days if it remains without that designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding.

@gemini-cli

gemini-cli Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

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.

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

Labels

area/core Issues related to User Interface, OS Support, Core Functionality priority/p2 Important but can be addressed in a future release. size/m A medium sized PR status/pr-nudge-sent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(vscode-ide-companion): comma operator in activate() leaks two Disposables (gemini.diff.accept, onDidChangeWorkspaceFolders)

1 participant