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

fix:duplicate_handled_message #262

Merged
merged 6 commits into from
Oct 31, 2024
Merged

fix:duplicate_handled_message #262

merged 6 commits into from
Oct 31, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Oct 31, 2024

skill activation should be managed by core not skills, fully delegate this task to ovos-core

ovos.utterance.handled is now emitted by the fallback pipeline, the fallback skill class should not emit it or we get duplicate events

companion to OpenVoiceOS/ovos-core#571

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced event handling and response flow in the Common Query Skill for better user interaction.
    • Introduced a timeout handling method in the OVOS Skill to improve user experience during conversational interactions.
  • Bug Fixes

    • Removed the conditional message emission for handled utterances in the fallback handler, streamlining feedback for users. This change may affect how users perceive the handling status of their requests.

ovos.utterance.handled is now emitted by the fallback pipeline, the skill class should not emit it or we get duplicate events

noticed in end2end tests from OpenVoiceOS/ovos-core#571
Copy link

coderabbitai bot commented Oct 31, 2024

Warning

Rate limit exceeded

@JarbasAl has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 10 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 bd511e4 and 1257e6b.

Walkthrough

The changes in this pull request involve modifications to several classes within the ovos_workshop skills. The FallbackSkill class has had its _handle_fallback_request method altered to remove the emission of the "ovos.utterance.handled" message. The UniversalFallback class's create_universal_fallback_handler method has been simplified by removing success checks. The CommonQuerySkill class has updated its bind method to include additional parameters and removed a message emission in __handle_query_action. Lastly, the OVOSSkill class has removed the _conditional_activate method and added a new _on_timeout method.

Changes

File Path Change Summary
ovos_workshop/skills/fallback.py Removed emission of the message "ovos.utterance.handled" from _handle_fallback_request method.
ovos_workshop/skills/auto_translatable.py Simplified create_universal_fallback_handler by removing success checks; updated register_fallback to wrap handler with translation logic.
ovos_workshop/skills/common_query_skill.py Updated bind method to include additional parameters; removed emission of mycroft.skill.handler.complete from __handle_query_action; uncommented activate() call.
ovos_workshop/skills/ovos.py Removed _conditional_activate method; added _on_timeout method to handle conversation timeouts.

Possibly related PRs

  • fix:improve stop #260: The changes in the OVOSSkill class, particularly the removal of the _conditional_activate method, relate to the simplification of control flow in the main PR's FallbackSkill class, which also modifies how handlers are invoked without additional checks.

Suggested reviewers

  • goldyfruit

Poem

In the burrow where skills do play,
A message once bright has gone away.
No more the echoes of "handled" cheer,
Just silent whispers, calm and clear.
Fallbacks now dance without a sound,
In the world of skills, new paths are found. 🐇✨


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 the fix label Oct 31, 2024
Copy link

codecov bot commented Oct 31, 2024

Codecov Report

Attention: Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 51.38%. Comparing base (7c02206) to head (1257e6b).
Report is 65 commits behind head on dev.

Files with missing lines Patch % Lines
ovos_workshop/skills/auto_translatable.py 0.00% 1 Missing ⚠️
ovos_workshop/skills/ovos.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #262      +/-   ##
==========================================
- Coverage   53.41%   51.38%   -2.03%     
==========================================
  Files          37       36       -1     
  Lines        4362     4176     -186     
==========================================
- Hits         2330     2146     -184     
+ Misses       2032     2030       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot added fix and removed fix labels Oct 31, 2024
@github-actions github-actions bot added fix and removed fix labels Oct 31, 2024
@JarbasAl
Copy link
Member Author

marking this as a breaking change because if workshop is updated without updating core then some bus messages might be missing and we get a regression (bug where calling deactivate in converse doesnt work because skill is activated again afterwards)

Copy link

@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 (3)
ovos_workshop/skills/auto_translatable.py (1)

Line range hint 332-348: Update method documentation to reflect current behavior.

The docstring mentions that "If the fallback matched the skill is activated with the converse system", but this behavior has been removed. Please update the documentation to accurately reflect the current implementation.

ovos_workshop/skills/ovos.py (2)

Line range hint 807-811: Handle potential None value from dig_for_message() in _on_timeout

In the _on_timeout method, dig_for_message() may return None, which would cause message.forward() to raise an AttributeError. Consider adding a check to ensure message is not None or provide a fallback message to avoid potential exceptions.

Apply this diff to handle the case:

 def _on_timeout(self):
     """_handle_converse_request timed out and was forcefully killed by ovos-core"""
     message = dig_for_message()
+    if not message:
+        message = Message('')
     self.bus.emit(message.forward(
         f"{self.skill_id}.converse.killed",
         data={"error": "timed out"}))

Line range hint 1180-1180: Use LOG.exception() to include traceback in logs

In the exception handling block, consider using LOG.exception() instead of LOG.error(e) to include the traceback information in the logs for easier debugging.

Apply this diff to make the change:

-except Exception as e:
-    LOG.error(e)
+except Exception:
+    LOG.exception("Error occurred during converse handling")
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 016e5cb and bd511e4.

📒 Files selected for processing (4)
  • ovos_workshop/skills/auto_translatable.py (1 hunks)
  • ovos_workshop/skills/common_query_skill.py (1 hunks)
  • ovos_workshop/skills/fallback.py (1 hunks)
  • ovos_workshop/skills/ovos.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • ovos_workshop/skills/fallback.py
🔇 Additional comments (4)
ovos_workshop/skills/common_query_skill.py (2)

111-112: LGTM: Enhanced event handler configuration.

The additional parameters provide better control over the event handler behavior:

  • handler_info: Properly identifies the handler
  • activation: Ensures skill activation when handling the action
  • is_intent: Correctly marks this as an intent handler

Line range hint 1-300: Verify alignment with PR objectives.

The changes in this file appear to be supporting modifications rather than directly addressing the stated PR objective of fixing duplicate ovos.utterance.handled event emissions. Please verify if:

  1. The main fix is implemented in other files not provided for review
  2. These changes are necessary supporting changes
  3. The PR description needs to be updated to reflect all changes
ovos_workshop/skills/auto_translatable.py (1)

349-349: LGTM! Simplified fallback handler return.

The change correctly simplifies the fallback handler by directly returning the result from the handler without additional processing. This aligns with the PR objective of preventing duplicate ovos.utterance.handled event emissions, as the event is now handled by the fallback pipeline instead.

ovos_workshop/skills/ovos.py (1)

1173-1173: Ensure skill activation logic remains consistent after removing _conditional_activate

By directly calling self.converse(**kwargs), the activation logic previously handled by _conditional_activate is bypassed. Verify that the skill's activation state is managed correctly during conversational interactions and that the removal of _conditional_activate does not introduce unintended side effects.

Run the following script to confirm that _conditional_activate is no longer used elsewhere and to check for any potential issues with skill activation:

✅ Verification successful

No issues with removal of _conditional_activate

The codebase analysis shows that skill activation is properly managed through the standard activation mechanisms:

  1. Skills can be activated/deactivated via:

    • Direct calls to activate()/deactivate()
    • Intent service messages (intent.service.skills.activated/deactivated)
    • Skill-specific messages ({skill_id}.activate/deactivate)
  2. The converse() method is only called for active skills, and the activation state is tracked by the intent service, not by the individual skills.

The removal of _conditional_activate does not impact the skill's activation logic as it's handled by the proper activation mechanisms already in place.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for usages of `_conditional_activate` in the codebase
# Expected result: No occurrences of `_conditional_activate` remain

rg '_conditional_activate'

Length of output: 26


Script:

#!/bin/bash
# Let's analyze the skill activation logic more comprehensively
# 1. Search for converse method implementation
ast-grep --pattern 'def converse($$$)'

# 2. Look for any activation-related methods or patterns
rg -i "activate|activation" -A 3

# 3. Check the context around the converse call
rg "converse\(" -A 3 -B 3

Length of output: 20955

…e that does nothing

this was used only by the ipc display stuff that has been removed years ago and had its own concept of "active" skill
@JarbasAl JarbasAl merged commit 6649c4f into dev Oct 31, 2024
8 of 9 checks passed
@JarbasAl JarbasAl deleted the fix/duplicate_handled_message branch October 31, 2024 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant