Skip to content

refactor: Extract loadNodesFromDir() from NodesPool for reuse#5904

Merged
tianwei-liu merged 2 commits intomainfrom
refactor-nodespool
Mar 5, 2026
Merged

refactor: Extract loadNodesFromDir() from NodesPool for reuse#5904
tianwei-liu merged 2 commits intomainfrom
refactor-nodespool

Conversation

@tianwei-liu
Copy link
Contributor

Summary

  • Extract node-loading logic from NodesPool.initializeNodes() into a public loadNodesFromDir(dir) method
  • Enables enterprise extensions to load nodes from additional directories without duplicating filtering logic (DISABLED_NODES, skipCategories, community nodes)
  • Pure refactoring — no behavior change, no new dependencies

Test plan

  • pnpm build passes
  • All existing nodes still load correctly on startup
  • No behavior change for default usage

@gemini-code-assist
Copy link
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 refactors the node loading mechanism within the NodesPool class to enhance modularity and reusability. By extracting the node-loading and filtering logic into a dedicated public method, the system can now more easily support extensions that need to load nodes from various sources, without duplicating complex filtering rules. This change improves the maintainability and extensibility of the node management system without altering current functionality.

Highlights

  • Node Loading Refactoring: The core logic for loading and filtering nodes has been extracted from initializeNodes() into a new public method, loadNodesFromDir(dir).
  • Enhanced Reusability: This new loadNodesFromDir method is now available for reuse by enterprise extensions, allowing them to load nodes from additional directories while applying existing filtering logic.
  • No Behavior Change: The refactoring is purely structural, ensuring no changes to the existing behavior or introduction of new dependencies.
Changelog
  • packages/server/src/NodesPool.ts
    • Extracted node loading and filtering logic into a new public asynchronous method loadNodesFromDir(dir).
    • Updated initializeNodes() to call the new loadNodesFromDir() method for initial node population.
    • Modified the node assignment within the extracted logic to populate a local nodes object, which is then returned.
Activity
  • No review comments or specific activities have been recorded for this pull request yet.
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 refactors the node loading logic into a new public method loadNodesFromDir for better reusability. A security audit confirmed that this refactoring does not introduce any new security vulnerabilities, with loadNodesFromDir safely using require() for trusted paths. There is a suggestion to enhance loadNodesFromDir by reducing its side-effects and removing unnecessary await calls, making it return loaded data instead of directly modifying the class instance's state, which would improve predictability and testability, aligning with the principle of prioritizing code readability and understandability.

Move node-loading and filtering logic into a public loadNodesFromDir(dir)
method so extensions can load nodes from additional directories without
duplicating DISABLED_NODES, skipCategories, and community node checks.
@tianwei-liu tianwei-liu merged commit d8da27c into main Mar 5, 2026
7 checks passed
@yau-wd yau-wd deleted the refactor-nodespool branch March 5, 2026 06:46
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