fix(vscode-ide-companion): stop leaking gemini.diff.accept and onDidChangeWorkspaceFolders disposables - #28526
Conversation
…hangeWorkspaceFolders disposables The two context.subscriptions.push(...) calls wrapped a pair of registrations in a stray parenthesis pair, collapsing them into a comma expression whose value was only the last operand. As a result the `gemini.diff.accept` command Disposable and the `onDidChangeWorkspaceFolders` listener Disposable were created but never added to context.subscriptions, so they were never disposed on deactivation (re-activation then threw 'command already exists' and a stale listener kept firing). Remove the extra parentheses so each registration is its own argument to push(). Add a regression test that tags the created Disposables and asserts both land in context.subscriptions. Fixes google-gemini#27790
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 resource leak issue where specific command and listener registrations were not being added to the extension's subscription list due to incorrect syntax. By removing the stray parentheses, these objects are now correctly tracked, ensuring they are properly disposed of during extension deactivation and preventing duplicate registration errors on re-activation. 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/S
|
There was a problem hiding this comment.
Code Review
This pull request fixes a bug where certain VS Code command and listener registrations were wrapped in stray parentheses, causing them to be evaluated as comma expressions and preventing them from being tracked for disposal in context.subscriptions. A new test is added to verify that all created Disposables are correctly registered. The reviewer suggested using optional chaining when inspecting context.subscriptions in the test to avoid potential TypeError exceptions from undefined elements.
Per gemini-code-assist[bot] review on google-gemini#28526, the mocked VS Code APIs can push `undefined` entries into `context.subscriptions` by default in the test environment. Accessing `d.command`/`d.kind` directly therefore throws `TypeError: Cannot read properties of undefined`. Widen the element type to `{ command?; kind? } | undefined` and use optional chaining (`d?.command` / `d?.kind`) so the assertion tolerates `undefined` entries without changing what the test actually verifies.
|
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. |
|
Thanks for the guidance. I checked issue #27790: it currently has good first issue but not help wanted, and PR #28580 now covers the same bug. PR #28526 contains the registration fix plus a regression test, and its current checks pass. I am happy to follow the maintainers preferred PR and will not duplicate work. If #28526 should still be considered, please advise whether the issue should receive help wanted or whether I should defer to #28580 before the seven-day window. |
|
@DavidAPierce — apologies for the direct ping, and please ignore if this isn't your area. I noticed you've been the reviewer on essentially all recent This PR is scheduled for automatic closure tomorrow (Aug 8) under the "no Quick summary so a decision is cheap to make:
Two community PRs fix this (#28526 opened Jul 24, #28580 opened Jul 29) and three contributors have now proposed patches, so there's clearly appetite to help here — the only thing gating review is the missing label. Completely fine if the answer is "not a priority right now" — a one-line reply saying so would let everyone involved stop waiting, and I'd have no issue with this PR being closed. Thanks for your time either way. |
|
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. |
Summary
Fixes #27790.
The two
context.subscriptions.push(...)calls inactivate()wrapped a pair of registrations in a stray parenthesis pair, collapsing them into a comma expression whose value was only the last operand. As a result thegemini.diff.acceptcommand Disposable and theonDidChangeWorkspaceFolderslistener Disposable were created but never added tocontext.subscriptions, so they were never disposed on deactivation. On re-activation within the same extension host this threwcommand 'gemini.diff.accept' already exists, and the staleonDidChangeWorkspaceFolderslistener kept firingideServer.syncEnvVars()against a stoppedIDEServer.push().extension.test.tsthat tags the created Disposables and asserts bothgemini.diff.acceptandonDidChangeWorkspaceFoldersland incontext.subscriptions.Test plan
cd packages/vscode-ide-companion && npm test(vitest): new test inextension.test.tspasses; existing tests unaffected.