Skip to content

Comments

Cleanup extension update logic#10514

Merged
jakemac53 merged 6 commits intomainfrom
cleanup-extensions-logic
Oct 4, 2025
Merged

Cleanup extension update logic#10514
jakemac53 merged 6 commits intomainfrom
cleanup-extensions-logic

Conversation

@jakemac53
Copy link
Contributor

@jakemac53 jakemac53 commented Oct 3, 2025

TLDR

Avoids repeatedly checking for updates when we have already done so and leans into the reducer approach more heavily.

Dive deeper

Various cleanups to rely more heavily on the reducer, and handle all updates from within useExtensionUpdates - the slash command also just dispatches an event to the reducer now.

Also cleaned up the checkForExtensionUpdate function so it just returns an extension state instead of internally calling a function to update the state, this makes it more testable/portable outside of react.

checkForAllExtensionUpdates now also takes a current working directory, which fixes a potential bug in at least one place where we should have been flowing through the working dir from the context instead of using process.cwd().

This also paves the way for a future /extensions check command which can similarly just fire an event on a reducer.

We also have a centralized place handling all the update checks as well as actual updates, and this should help with any race conditions that may have existed before.

Testing Matrix

🍏 🪟 🐧
npm run
npx
Docker
Podman - -
Seatbelt - -

Linked issues / bugs

@jakemac53 jakemac53 requested a review from a team as a code owner October 3, 2025 22:06
@jakemac53 jakemac53 requested a review from jacob314 October 3, 2025 22:06
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jakemac53, 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 significantly refactors the extension update mechanism to enhance robustness, testability, and maintainability. By transitioning to a reducer-based approach for managing update states and scheduling, it centralizes the logic for checking and applying updates. This change also streamlines the API for individual update checks and ensures correct working directory context is consistently applied, paving the way for future command implementations.

Highlights

  • Refactored Extension Update Logic: The checkForExtensionUpdate function now directly returns an ExtensionUpdateState instead of using a callback, simplifying its usage and making it more testable.
  • Centralized Update Scheduling with Reducer: The useExtensionUpdates hook and the /extensions update command now leverage a reducer pattern to schedule and manage extension updates, avoiding repeated checks and centralizing state management.
  • Improved Working Directory Handling: The checkForAllExtensionUpdates function now explicitly accepts a cwd (current working directory) parameter, addressing a potential bug where process.cwd() was incorrectly used in some contexts.
  • Semantic Clarity in Update Status: The ExtensionUpdateStatus interface has been updated to use a notified flag instead of processed, providing clearer semantics for when an update has been communicated to 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 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 counter productive. 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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

Copy link
Contributor

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

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 is a great refactoring that centralizes the extension update logic using a reducer pattern, which significantly improves maintainability and testability. The checkForExtensionUpdate function is now purer by returning a value directly, and the slash command has been simplified to just dispatch actions. Overall, these are excellent changes that align well with modern state management practices. I've identified one critical syntax issue that would lead to a crash and a related high-severity logical flaw in the new reducer logic for handling concurrent updates. My review comments provide details and suggestions for fixes.

@github-actions
Copy link

github-actions bot commented Oct 3, 2025

Size Change: +970 B (+0.01%)

Total Size: 17.6 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 17.5 MB +970 B (+0.01%)
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB 0 B
./bundle/sandbox-macos-permissive-open.sb 830 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B

compressed-size-action

);
}, [
extensions,
extensionsUpdateState.extensionStatuses,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that this is a new dependency - but it doesn't create a render loop even though we also call dispatchExtensionStateUdpate - because these states are linear.

This ensures we don't keep checking for updates to extensions that we have already checked or are currently checking.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
if (action.type === 'SET_STATE') {
extensionState.set(action.payload.name, {
status: action.payload.state,
notified: true, // No need to process as we will force the update.
Copy link
Contributor

@jacob314 jacob314 Oct 3, 2025

Choose a reason for hiding this comment

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

update the comment to align with the code.
Optional nit: this is now a lie as we haven't notified.
to be overly pedantic we could label this
notificationRequested or something similar. Then it can be false here to exactly indicate the state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could also just remove this entirely, its not necessary in this code path, and this code path does not do any notifications of available updates, it always installs them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went ahead and just made that change, to just not indicate we notified. This code path is for the regular update command outside the CLI itself.

Copy link
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

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

Congrats on your first big reducer change! Approved once these comments are addressed.

@jakemac53 jakemac53 enabled auto-merge October 4, 2025 03:22
Copy link
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

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

lgtm

@jakemac53 jakemac53 added this pull request to the merge queue Oct 4, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 4, 2025
@jakemac53 jakemac53 added this pull request to the merge queue Oct 4, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 4, 2025
@jakemac53 jakemac53 added this pull request to the merge queue Oct 4, 2025
Merged via the queue into main with commit 7f8537a Oct 4, 2025
20 checks passed
@jakemac53 jakemac53 deleted the cleanup-extensions-logic branch October 4, 2025 04:19
thacio added a commit to thacio/auditaria that referenced this pull request Oct 7, 2025
chrstnb added a commit that referenced this pull request Oct 7, 2025
Co-authored-by: Jacob MacDonald <jakemac@google.com>
Co-authored-by: Adam Weidman <65992621+adamfweidman@users.noreply.github.com>
giraffe-tree pushed a commit to giraffe-tree/gemini-cli that referenced this pull request Oct 10, 2025
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants