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:close application intent #11

Merged
merged 4 commits into from
Oct 17, 2024
Merged

feat:close application intent #11

merged 4 commits into from
Oct 17, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Oct 17, 2024

Summary by CodeRabbit

  • New Features
    • Added new voice commands for closing applications, including phrases like "close {application}" and "terminate {application}".
    • Enhanced application launching and closing capabilities through improved intent recognition.
  • Documentation
    • Updated the README to include an example for the "Close Firefox" command.
  • Chores
    • Added new dependency ovos-utils to the requirements.

Copy link
Contributor

coderabbitai bot commented Oct 17, 2024

Walkthrough

The pull request introduces several enhancements to the application launcher functionality. The README.md file now includes a new example for closing Firefox. The ApplicationLauncherSkill class in __init__.py has been updated with new methods for launching and closing applications, improved intent handling, and better language matching. Additionally, new intent phrases for closing applications have been added to the locale/en-us/close.intent and translations/en-us/intents.json files. The requirements.txt file has been updated to include a new dependency, ovos-utils.

Changes

File Change Summary
README.md Added new example "Close Firefox" under the "Examples" section.
init.py Enhanced ApplicationLauncherSkill with new methods launch_app and close_app, improved intent handling, and added imports for process management and language handling.
locale/en-us/close.intent Added new intent phrases: close {application}, terminate {application}, kill {application}, exit {application}, quit {application}.
translations/en-us/intents.json Introduced new intent close.intent with phrases for closing applications: "close {application}", "terminate {application}", "kill {application}", "exit {application}", "quit {application}".
requirements.txt Added package ovos-utils>=0.3.5.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ApplicationLauncherSkill
    participant IntentRecognizer
    participant ProcessManager

    User->>IntentRecognizer: "Close Firefox"
    IntentRecognizer->>ApplicationLauncherSkill: Recognize intent "close"
    ApplicationLauncherSkill->>ProcessManager: close_app("Firefox")
    ProcessManager->>ProcessManager: Find running processes
    ProcessManager-->>ApplicationLauncherSkill: Process found
    ApplicationLauncherSkill-->>User: "Firefox has been closed."
Loading

🐇 "In the land of code, where the bunnies play,
New commands to close apps have come our way.
With a hop and a click, we launch and we cease,
A joyful update, bringing us peace!
So let’s cheer for the changes, both big and small,
For a smoother experience, we’ll have a ball!" 🐇


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 Oct 17, 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: 3

🧹 Outside diff range and nitpick comments (6)
requirements.txt (2)

3-3: Approve the addition of ovos-utils and suggest version constraint improvement.

The addition of ovos-utils>=0.3.5 aligns with the PR objectives. To prevent potential compatibility issues with future major versions, consider specifying both minimum and maximum version constraints.

Consider updating the line to:

ovos-utils>=0.3.5,<1.0.0

This ensures compatibility with versions from 0.3.5 up to, but not including, 1.0.0.


4-4: Suggest adding version constraints for psutil.

While this line is unchanged, it's generally a good practice to specify version constraints for all dependencies to ensure reproducibility and prevent potential compatibility issues.

Consider updating the line to include version constraints. For example:

psutil>=5.8.0,<6.0.0

Replace 5.8.0 with the minimum version that includes the features you need, and adjust the upper bound accordingly.

locale/en-us/close.intent (1)

1-5: Overall: Well-structured intent file with good variety.

The close.intent file provides a good range of phrases for closing applications, catering to both casual and technical users. The use of the {application} placeholder allows for flexibility across different applications.

Suggestions for potential improvements:

  1. Consider adding phrases for specific types of applications (e.g., "close browser", "exit text editor").
  2. You might want to include phrases for closing multiple applications at once (e.g., "close all applications").
  3. Consider adding phrases that include politeness markers (e.g., "please close {application}") to cater to users who prefer more formal interactions.

Would you like me to propose additional intent phrases based on these suggestions?

translations/en-us/intents.json (1)

7-13: LGTM: "close.intent" is well-defined with comprehensive phrases.

The new "close.intent" section is correctly structured with appropriate phrases for closing an application. The {application} placeholder is used consistently across all phrases, and the verbs chosen (close, terminate, kill, exit, quit) cover a wide range of user expressions.

Consider adding "stop {application}" as an additional phrase, as some users might use this verb to express the intent of closing an application.

README.md (1)

17-17: Fix list style inconsistency.

The new list item uses an asterisk (*) while the existing items use dashes (-). To maintain consistency and address the static analysis warning, please update the list style.

Apply this change:

-* "Close Firefox"
+- "Close Firefox"
🧰 Tools
🪛 Markdownlint

17-17: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)

__init__.py (1)

49-49: Address the TODO: Expand parentheses handling in intent samples

There's a TODO comment indicating that parentheses should be expanded and not require one per line. If you need assistance implementing this feature, I can help.

Would you like assistance in enhancing the intent sample parsing to handle parentheses within the same line?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5821228 and 0eee8a2.

📒 Files selected for processing (5)
  • README.md (1 hunks)
  • init.py (4 hunks)
  • locale/en-us/close.intent (1 hunks)
  • requirements.txt (1 hunks)
  • translations/en-us/intents.json (1 hunks)
🧰 Additional context used
🪛 Markdownlint
README.md

17-17: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)

🪛 Ruff
__init__.py

50-50: Ambiguous variable name: l

(E741)


70-70: Ambiguous variable name: l

(E741)

🔇 Additional comments (14)
locale/en-us/close.intent (5)

1-1: LGTM: Clear and common phrase for closing applications.

The phrase "close {application}" is a straightforward and widely used command for closing applications. It's intuitive and likely to be used by users.


2-2: Approved: Technical alternative for closing applications.

The phrase "terminate {application}" provides a more technical alternative for closing applications. This is beneficial for users who prefer or are more familiar with technical terminology.


4-4: LGTM: User-friendly phrase for closing applications.

The phrase "exit {application}" is a clear, user-friendly term commonly used for closing applications. It's widely understood and aligns well with the intent.


5-5: LGTM: Another clear phrase for closing applications.

The phrase "quit {application}" is another clear and commonly used term for closing applications. It provides a good alternative to "exit" and enhances the variety of recognized intents.


3-3: Approved with suggestion: Consider clarifying the "kill" command behavior.

The phrase "kill {application}" is a valid technical term, often used in command-line interfaces. However, it might be perceived as aggressive by some users and could potentially lead to forceful termination of applications.

Consider clarifying how this command will be handled in the application. Will it perform a forceful termination or a graceful exit? You may want to add a comment in the code or documentation explaining the behavior.

To verify the implementation, you can run the following script:

✅ Verification successful

Verified: Clarification on the "kill" command behavior is implemented in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any implementation details or comments about the "kill" command

# Search for any mentions of "kill" in Python files
rg --type python "def.*kill" -C 5
rg --type python "# .*kill" -C 2

Length of output: 132


Script:

#!/bin/bash
# Description: Check for any implementation details or comments about the "kill" command

# Search for any mentions of "kill" in Python files
rg "def.*kill" --glob "*.py" -C 5
rg "# .*kill" --glob "*.py" -C 2

Length of output: 385

translations/en-us/intents.json (2)

2-6: LGTM: "launch.intent" is well-defined and consistent.

The "launch.intent" section is correctly structured with appropriate phrases for launching an application. The {application} placeholder is used consistently across all phrases.


1-14: LGTM: Overall structure and consistency are excellent.

The file is well-structured with consistent formatting. Both intents ("launch.intent" and "close.intent") follow the same pattern, making it easy to read and maintain. The JSON structure is valid, and the file location (translations/en-us/intents.json) correctly indicates its purpose for English (US) translations.

README.md (1)

17-17: LGTM! New example added successfully.

The addition of the "Close Firefox" example is consistent with the PR objectives and enhances the documentation by showcasing the new close application functionality.

🧰 Tools
🪛 Markdownlint

17-17: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)

__init__.py (6)

2-3: Imports are appropriate for the new functionality

The added imports subprocess and time are necessary for process management and timing functionality introduced in this PR.


7-8: Adding required imports for process management and language matching

The imports of psutil and closest_match are appropriate for the new methods close_app and improved language handling.


11-11: Importing parsing utilities for matching applications

The addition of match_one and fuzzy_match from ovos_utils.parse is suitable for the application's matching logic.


39-39: Including new intents 'close' and 'launch'

Adding close and launch to the list of intents enhances the skill's capability to handle more voice commands.


148-150: Verify the language match scoring logic

In the condition if score >= 10:, a higher score may indicate a poorer match, depending on the implementation of closest_match. Ensure that this threshold correctly determines when a language is unsupported.


170-174: Test cases demonstrate functionality across languages

The added test cases in the __main__ block effectively demonstrate the skill's ability to handle commands in different languages.

__init__.py Outdated Show resolved Hide resolved
__init__.py Show resolved Hide resolved
__init__.py Outdated Show resolved Hide resolved
JarbasAl and others added 2 commits October 17, 2024 01:19
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@JarbasAl JarbasAl merged commit 33d678d into dev Oct 17, 2024
5 checks passed
@JarbasAl JarbasAl deleted the fear/close_app branch October 17, 2024 00:25
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