Skip to content

refactor: Introducing Event-Driven Architecture#212

Merged
kubrickcode merged 2 commits intomainfrom
develop/shlee/191
Dec 2, 2025
Merged

refactor: Introducing Event-Driven Architecture#212
kubrickcode merged 2 commits intomainfrom
develop/shlee/191

Conversation

@kubrickcode
Copy link
Owner

fix #191

Add event emission capabilities using EventBus infrastructure
- main.ts: Create EventBus instance and inject into all managers
- ConfigManager: Emit config:changed, configTarget:changed events
- ButtonSetManager: Emit buttonSet:created/deleted/renamed/switched events
- ImportExportManager: Emit import:completed events
- TerminalManager: Emit terminal:created events
- command-executor: Emit button:executed events and pass EventBus through call chain
@github-actions github-actions bot added the refactor Refactoring code label Dec 2, 2025
@kubrickcode
Copy link
Owner Author

/gemini review

@gemini-code-assist
Copy link

Summary of Changes

Hello @kubrickcode, 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 extension's internal architecture by introducing an event-driven pattern. The primary goal is to enhance modularity and maintainability by decoupling components, allowing them to communicate reactively through a central event bus rather than direct dependencies. This change impacts how various parts of the extension interact and update, leading to a more robust and scalable design.

Highlights

  • Event-Driven Architecture Implementation: The core change introduces an EventBus to facilitate decoupled communication between various components of the extension, such as the status bar, tree view, and webview. This replaces direct method calls with an event-based system.
  • Refactored Component Communication: Managers and providers like ButtonSetManager, ConfigManager, ImportExportManager, StatusBarManager, TerminalManager, CommandTreeProvider, and ConfigWebviewProvider have been updated to emit and subscribe to events via the new EventBus.
  • Enhanced Test Coverage: New unit tests have been added for StatusBarManager, CommandTreeProvider, and ConfigWebviewProvider to specifically validate the correct integration and behavior of the EventBus.
  • Simplified UI Refresh Logic: The logic for refreshing UI elements (status bar, tree view, webview) is now centralized through EventBus emissions, removing redundant direct refresh calls across the codebase.
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

@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 introduces a significant and well-executed refactoring to an event-driven architecture using an EventBus. This change successfully decouples major components like managers and UI providers, improving the overall structure and maintainability of the extension. State changes in managers now correctly emit events, and subscribers like StatusBarManager, CommandTreeProvider, and ConfigWebviewProvider react to these events to refresh their state. The implementation includes proper resource management for disposables and is accompanied by thorough tests for the new event-driven logic. My feedback focuses on minor improvements to enhance consistency and structure within the new architecture.

@kubrickcode
Copy link
Owner Author

/gemini review

Copy link

@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 significant and valuable refactoring that introduces an event-driven architecture using an EventBus. This change greatly improves the decoupling of components and enhances the maintainability of the codebase. My review focuses on ensuring this new architecture is applied consistently and correctly. I've identified several areas where event handling can be improved: some components are not listening to all relevant events, leading to potential UI synchronization issues, and in a few places, events are emitted redundantly or prematurely. I've also noted a minor violation of the repository's style guide regarding method ordering. Overall, this is a very positive change, and my suggestions aim to solidify the new event-driven pattern.

@kubrickcode
Copy link
Owner Author

/gemini review

Copy link

@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 introduces a significant and well-executed refactoring to an event-driven architecture using an EventBus. This is a great improvement for decoupling components like managers and providers, making the codebase more maintainable and scalable. The changes are consistently applied across the project. My review focuses on adhering to the repository's style guide, specifically regarding function argument patterns, to further improve code clarity.

@kubrickcode
Copy link
Owner Author

/gemini review

Copy link

@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 introduces a significant and beneficial refactoring to an event-driven architecture using an EventBus, decoupling components and improving modularity. The use of object-based arguments for create methods is also a great improvement for readability. I have a couple of suggestions to further improve consistency with the new architecture, such as using an event for initial UI refresh and reducing duplication in tests. Additionally, while handleWebviewMessage in webview-provider.ts is not part of this diff, I noticed it still contains direct UI refresh logic. Updating this function to rely on events would further improve the consistency and efficiency of the new architecture. Overall, this is a solid architectural improvement.

…calls

Event-Driven Architecture phase 3: UI components now subscribe to EventBus events for automatic refresh

- StatusBarManager: subscribe to config:changed, buttonSet:switched events
- CommandTreeProvider: implement Disposable and add event subscriptions
- ConfigWebviewProvider: separate event subscriptions to prevent memory leaks
- main.ts: remove refreshAllUIs() helper and direct refresh calls

fix #191
@kubrickcode kubrickcode merged commit e13d778 into main Dec 2, 2025
6 checks passed
@kubrickcode kubrickcode deleted the develop/shlee/191 branch December 2, 2025 08:25
@kubrickcode
Copy link
Owner Author

🎉 This PR is included in version 0.10.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

refactor Refactoring code released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introducing Event-Driven Architecture

1 participant