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

Add preserve last action keyword options #3118

Merged
merged 1 commit into from
Dec 22, 2024

Conversation

Yusyuriv
Copy link
Member

@Yusyuriv Yusyuriv commented Dec 8, 2024

Closes #3116. My IDE also removed a bunch of unnecessary whitespace when I edited these files. I thought it's not a big deal and that whitespace should have been removed anyway, so I didn't exclude those changes from the PR.

What it is

These changes introduce two new options to Last Query Style in settings: "Preserve Last Action Keyword" and "Select Last Action Keyword". They work just like "Preserve/Select Last Query", but only for action keywords, not for whole queries. With these options, when there is an action keyword, the next time the user opens Flow Launcher, the query is set to keyword (with a space after it, so the user can immediately begin typing). If the last query didn't have an action keyword, the query is set to an empty string.

Testing

I've tested:

  • That the previous options still work after my changes
  • New options work as expected:
    • Preserve Last Action Keyword before the window hides
      image
    • Preserve Last Action Keyword after the window hides and re-appears
      image
    • Select Last Action Keyword before the window hides
      image
    • Select Last Action Keyword after the window hides and re-appears
      image

@Yusyuriv Yusyuriv added the enhancement New feature or request label Dec 8, 2024
@Yusyuriv Yusyuriv self-assigned this Dec 8, 2024
@github-actions github-actions bot added this to the 1.20.0 milestone Dec 8, 2024
Copy link

github-actions bot commented Dec 8, 2024

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, or 📝 job summary for details.

❌ Errors Count
❌ forbidden-pattern 22
❌ ignored-expect-variant 1
⚠️ non-alpha-in-dictionary 19

See ❌ Event descriptions for more information.

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Copy link
Contributor

coderabbitai bot commented Dec 8, 2024

📝 Walkthrough

Walkthrough

The changes in this pull request involve modifications to the Settings class and the LastQueryMode enum in the Flow.Launcher.Infrastructure.UserSettings namespace, including the addition of a new property and two new enum values. Additionally, new string resources are introduced in the en.xaml file for localization purposes. The MainViewModel class is updated to handle the new enum values in the Hide method, allowing for improved query management functionality. Overall, the changes enhance user experience without altering existing logic significantly.

Changes

File Change Summary
Flow.Launcher.Infrastructure/UserSettings/Settings.cs Added property AlwaysStartEn and new enum values ActionKeywordPreserved, ActionKeywordSelected.
Flow.Launcher/Languages/en.xaml Added string resources LastQueryActionKeywordPreserved and LastQueryActionKeywordSelected.
Flow.Launcher/ViewModel/MainViewModel.cs Updated Hide method to handle new LastQueryMode values for improved query management.

Assessment against linked issues

Objective Addressed Explanation
Add "Preserve Last Action Keyword" to "Last Query Style" option (3116)

Possibly related PRs

Suggested labels

bug, kind/ui, Explorer Plugin

Suggested reviewers

  • jjw24

Poem

In the burrow where queries hop,
New options bloom, we can't stop!
With keywords preserved, we leap with glee,
Searching swiftly, just you and me! 🐇✨
Flowing through data, a joyful spree!


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.

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: 1

🧹 Outside diff range and nitpick comments (2)
Flow.Launcher.Infrastructure/UserSettings/Settings.cs (1)

373-375: Add XML documentation for enum values

The new enum values correctly implement the requested functionality for preserving/selecting last action keywords. To improve maintainability, consider adding XML documentation for all enum values:

    public enum LastQueryMode
    {
+       /// <summary>
+       /// The last query will be selected when Flow Launcher is shown
+       /// </summary>
        Selected,
+       /// <summary>
+       /// The query will be empty when Flow Launcher is shown
+       /// </summary>
        Empty,
+       /// <summary>
+       /// The last query will be preserved when Flow Launcher is shown
+       /// </summary>
        Preserved,
+       /// <summary>
+       /// Only the action keyword from the last query will be preserved when Flow Launcher is shown
+       /// </summary>
        ActionKeywordPreserved,
+       /// <summary>
+       /// Only the action keyword from the last query will be selected when Flow Launcher is shown
+       /// </summary>
        ActionKeywordSelected
    }
Flow.Launcher/ViewModel/MainViewModel.cs (1)

1404-1413: Refactor animation delay handling

The animation delay handling is duplicated across case blocks. Consider extracting it to make the code more maintainable.

Consider refactoring the animation delay handling:

+    private async Task HandleAnimationDelay()
+    {
+        if (Settings.UseAnimation)
+            await Task.Delay(100);
+    }
+
     case LastQueryMode.ActionKeywordPreserved or LastQueryMode.ActionKeywordSelected:
         var newQuery = _lastQuery?.ActionKeyword ?? string.Empty;
         if (!string.IsNullOrEmpty(newQuery))
             newQuery += " ";
         ChangeQueryText(newQuery);
-        if (Settings.UseAnimation)
-            await Task.Delay(100);
+        await HandleAnimationDelay();
         if (Settings.LastQueryMode == LastQueryMode.ActionKeywordSelected)
             LastQuerySelected = false;
         break;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1f81ea0 and 824befd.

📒 Files selected for processing (3)
  • Flow.Launcher.Infrastructure/UserSettings/Settings.cs (3 hunks)
  • Flow.Launcher/Languages/en.xaml (1 hunks)
  • Flow.Launcher/ViewModel/MainViewModel.cs (4 hunks)
🔇 Additional comments (3)
Flow.Launcher.Infrastructure/UserSettings/Settings.cs (2)

65-65: Formatting change only


190-190: Document the purpose of AlwaysStartEn property

This new property appears to be unrelated to the PR's objective of adding preserve last action keyword options. Please:

  1. Add XML documentation comments explaining its purpose
  2. Verify if this change should be part of this PR
+       /// <summary>
+       /// When true, Flow Launcher will always start with English input method
+       /// </summary>
        public bool AlwaysStartEn { get; set; } = false;
Flow.Launcher/Languages/en.xaml (1)

70-71: LGTM: String resources properly added

The new string resources for action keyword options are well-formatted and consistently named, following the existing pattern for LastQuery related strings.

Flow.Launcher/ViewModel/MainViewModel.cs Show resolved Hide resolved
@taooceros
Copy link
Member

Looks cool! I wonder maybe it would be interesting to allow custom hotkey to perform this action (so sometimes if we (don't) want to delete the query we could use a different hotkey).

@Yusyuriv
Copy link
Member Author

Yusyuriv commented Dec 9, 2024

Something like pressing Ctrl + NumpadPlus (just an example) instead of Enter if you want to perform the action, but want the query to be preserved despite having "Empty Query" selected in settings? And a hotkey for the opposite, for emptying the query after performing the action when you have it set to "Preserve Last Query" in settings?

If that's what you meant, this does sound like it could be useful to some people, but that feature is outside the scope of this PR.

newQuery += " ";
ChangeQueryText(newQuery);
if (Settings.UseAnimation)
await Task.Delay(100);
Copy link
Member

Choose a reason for hiding this comment

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

Why do we wait here?

Copy link
Member

Choose a reason for hiding this comment

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

Ok because using animation, think previously other options had some issues when animation is in process.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm actually not sure. It's mentioned here

case LastQueryMode.Empty:
ChangeQueryText(string.Empty);
await Task.Delay(100); //Time for change to opacity
break;
case LastQueryMode.Preserved:
if (Settings.UseAnimation)
await Task.Delay(100);
LastQuerySelected = true;
break;
case LastQueryMode.Selected:
if (Settings.UseAnimation)
await Task.Delay(100);
LastQuerySelected = false;
break;
and I added it in my code because this was present in all three other case branches, so it probably solves some old issue I don't know about.

@jjw24 jjw24 merged commit 06a9faf into dev Dec 22, 2024
17 of 20 checks passed
@jjw24 jjw24 deleted the add-preserve-last-action-keyword-option branch December 22, 2024 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add "Preserve Last Action Keyword" to "Last Query Style" option in settings
3 participants