Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: forward some events to GUI clients #62

Merged
merged 4 commits into from
Nov 21, 2024
Merged

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Nov 21, 2024

allow GUIs to react to wakeword etc without needing a connection to the main bus

GUI clients are not supposed to connect to the main bus, only to the GUI bus, but in practice the QT gui has been connecting to both due to missing events

Summary by CodeRabbit

  • New Features

    • Enhanced namespace management for improved audio and visual interactions in the GUI.
    • Introduced a new method for forwarding messages related to system events.
  • Bug Fixes

    • Improved error handling and logging for namespace operations.
  • Chores

    • Updated import paths for FakeBus across multiple test files to reflect module reorganization.

allow GUIs to react to wakeword etc without needing a connection to the main bus

GUI clients are not supposed to connect to the main bus, only to the GUI bus, but in practice the QT gui has been connecting to both due to missing events
@JarbasAl JarbasAl requested review from mikejgray, NeonDaniel and a team November 21, 2024 17:10
Copy link
Contributor

coderabbitai bot commented Nov 21, 2024

Walkthrough

The changes in the ovos_gui/namespace.py file enhance the NamespaceManager class, focusing on managing message forwarding and improving error handling. A new method, _define_messages_to_forward, is introduced to facilitate communication between core messages and GUI clients. Additionally, logging has been added to the handle_delete_all_pages method, and error handling in the handle_show_page method has been refined. Import statements have been cleaned up to remove unnecessary imports, contributing to a more organized codebase. Similar modifications have been made across several test files regarding the import of FakeBus.

Changes

File Path Change Summary
ovos_gui/namespace.py - Added method _define_messages_to_forward for message forwarding.
- Updated handle_delete_all_pages for logging.
- Improved error handling in handle_show_page.
- Removed unnecessary imports.
test/unittests/test_extensions.py - Modified import statement for FakeBus from ovos_utils.messagebus to ovos_utils.fakebus.
test/unittests/test_homescreen.py - Modified import statement for FakeBus from ovos_utils.messagebus to ovos_utils.fakebus.
test/unittests/test_namespace.py - Modified import statement for FakeBus from ovos_utils.messagebus to ovos_utils.fakebus.

Poem

In the land of code where rabbits play,
New messages hop in a lively ballet.
With persistence and logs, the GUI shines bright,
As we dance through the namespaces, oh what a sight!
Hooray for the changes, let’s give a cheer,
For a smoother experience, we hold so dear! 🐇✨

Warning

Rate limit exceeded

@JarbasAl has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 36 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 1996f05 and fd5111a.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1996f05 and fd5111a.

📒 Files selected for processing (1)
  • ovos_gui/namespace.py (2 hunks)
🔇 Additional comments (3)
ovos_gui/namespace.py (3)

43-44: LGTM: Import changes are appropriate

The added imports support the file system operations and page management functionality.

Also applies to: 47-47, 58-59


461-505: LGTM: Well-structured message forwarding implementation

The implementation effectively forwards essential events to GUI clients, properly categorized into:

  • Audio Service events
  • Speech Service events (including wakeword detection)
  • Enclosure commands for eyes and mouth

This aligns with the PR objective of enabling GUI clients to respond to events without requiring a direct connection to the main bus.


507-520: ⚠️ Potential issue

Fix the @staticmethod decorator usage

The forward_to_gui method is decorated with @staticmethod but uses the self parameter. This will cause a TypeError at runtime since static methods don't receive the implicit self parameter.

Apply this fix:

-    @staticmethod
-    def forward_to_gui(self, message: Message):
+    def forward_to_gui(self, message: Message):
         """
         Forward a core Message to the GUI
         @param message: Core message to forward
         """

Likely invalid or redundant comment.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added feature and removed feature labels Nov 21, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between da4f11b and c70eeb5.

📒 Files selected for processing (1)
  • ovos_gui/namespace.py (2 hunks)
🔇 Additional comments (1)
ovos_gui/namespace.py (1)

43-44: Import statements are appropriate and necessary

The added import statements for join, dirname, exists, Message, MessageBusClient, and GuiPage are correct and essential for the new functionality introduced.

Also applies to: 47-47, 58-59

ovos_gui/namespace.py Show resolved Hide resolved
ovos_gui/namespace.py Outdated Show resolved Hide resolved
@github-actions github-actions bot added feature and removed feature labels Nov 21, 2024
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
ovos_gui/namespace.py (1)

461-505: LGTM: Well-structured message forwarding implementation.

The implementation effectively addresses the PR's objective of enabling GUI clients to respond to events without requiring direct connection to the main bus. The code:

  • Clearly categorizes messages by service type
  • Uses a clean loop pattern to register handlers
  • Includes all necessary events for GUI responsiveness

Consider adding a configuration option to selectively enable/disable forwarding of specific event categories, which could help optimize performance by reducing unnecessary message traffic.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c910a14 and 1996f05.

📒 Files selected for processing (1)
  • ovos_gui/namespace.py (2 hunks)
🔇 Additional comments (2)
ovos_gui/namespace.py (2)

43-44: LGTM: Import changes are well-organized and appropriate.

The changes to the imports are clean and follow best practices:

  • Using exists instead of isfile is more semantically correct for path checking
  • Imports are properly organized following PEP 8 guidelines

Also applies to: 47-59


506-519: Fix incorrect @staticmethod decorator usage.

The forward_to_gui method is marked as @staticmethod but is called as an instance method in _define_messages_to_forward. This will cause runtime errors.

@JarbasAl JarbasAl merged commit 1588fe9 into dev Nov 21, 2024
9 checks passed
@JarbasAl JarbasAl deleted the feat/forwardbusmsgs branch November 21, 2024 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant