Skip to content

fix(vscode-ide-companion): register Disposables leaked by comma operators#28100

Open
ianfigueroa wants to merge 1 commit into
google-gemini:mainfrom
ianfigueroa:fix/27790-workspace-disposable-leak
Open

fix(vscode-ide-companion): register Disposables leaked by comma operators#28100
ianfigueroa wants to merge 1 commit into
google-gemini:mainfrom
ianfigueroa:fix/27790-workspace-disposable-leak

Conversation

@ianfigueroa

Copy link
Copy Markdown

Summary

activate() in extension.ts has two context.subscriptions.push(...) calls where a comma operator wrapped a pair of Disposables in parentheses as (A, B). A comma expression evaluates to its last operand, so each (A, B) collapsed to just B. The first Disposable of each pair was therefore never passed to push(), never added to context.subscriptions, and never disposed on deactivate().

Two Disposables leaked:

  • (registerCommand('gemini.diff.accept', ...), registerCommand('gemini.diff.cancel', ...)) leaked the gemini.diff.accept command registration.
  • (onDidChangeWorkspaceFolders(...), onDidGrantWorkspaceTrust(...)) leaked the onDidChangeWorkspaceFolders handler.

The fix removes the wrapping parentheses so every Disposable is passed as a separate argument to context.subscriptions.push(), which is the variadic API it was always meant to use.

Test plan

  • Added two regression tests asserting that the gemini.diff.accept and onDidChangeWorkspaceFolders Disposables end up in context.subscriptions. Both fail against the old (A, B) code and pass with the fix.
  • npx vitest run src/extension.test.ts in packages/vscode-ide-companion: 13/13 pass.
  • eslint and prettier --check clean on both changed files.

Fixes #27790

…tors

Two comma operators in activate() wrapped pairs of Disposables as
`(A, B)`, which evaluates to only the last operand (B). The first
Disposable of each pair was never added to context.subscriptions, so it
leaked and was never disposed on deactivate:

- `(registerCommand('gemini.diff.accept', ...), registerCommand('gemini.diff.cancel', ...))`
  leaked the gemini.diff.accept command.
- `(onDidChangeWorkspaceFolders(...), onDidGrantWorkspaceTrust(...))`
  leaked the onDidChangeWorkspaceFolders handler.

Remove the wrapping parentheses so every Disposable is passed as a
separate argument to context.subscriptions.push(). Add regression tests
asserting both Disposables are registered.

Fixes google-gemini#27790
@ianfigueroa ianfigueroa requested a review from a team as a code owner June 22, 2026 21:12
@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 leak in the extension activation logic where comma operators were incorrectly grouping Disposables, causing the first item in each pair to be discarded. By removing the wrapping parentheses, all Disposables are now correctly passed to the subscription manager, ensuring they are properly disposed of upon extension deactivation.

Highlights

  • Fixing Disposable Leaks: Removed incorrect comma operator usage in context.subscriptions.push() calls that were causing some Disposables to be ignored and leaked.
  • Regression Testing: Added new unit tests to verify that specific Disposables are correctly registered in the extension's subscription list.
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/s A small PR label Jun 22, 2026
@github-actions

Copy link
Copy Markdown

📊 PR Size: size/S

  • Lines changed: 37
  • Additions: +33
  • Deletions: -4
  • Files changed: 2

@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 fixes a bug in the VS Code companion extension where certain event and command disposables were not properly registered in context.subscriptions due to an accidental use of the comma operator inside parentheses. Specifically, it removes the redundant wrapping parentheses around vscode.commands.registerCommand and vscode.workspace.onDidChangeWorkspaceFolders calls, ensuring all disposables are correctly added to the subscriptions array and disposed of on deactivation. Additionally, regression tests have been added to verify that both onDidChangeWorkspaceFolders and gemini.diff.accept disposables are properly registered. There are no review comments, so 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 Jun 22, 2026
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/s A small PR

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