Skip to content

Conversation

Jack251970
Copy link
Member

@Jack251970 Jack251970 commented Feb 14, 2025

Fix ChangeQuery & ReQuery Work Issue When Results Are Not From Query Results

The ChangeQuery and ReQuery function fail to work when results are from the context menu or history. Now we will back to query results when we call these functions.

Test

  • Call ChangeQuery when results are from the context menu or history.
  • Call ReQuery when results are from the context menu or history.

@Jack251970 Jack251970 added the bug Something isn't working label Feb 14, 2025

This comment has been minimized.

Copy link

gitstream-cm bot commented Feb 14, 2025

Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX.

Copy link
Contributor

coderabbitai bot commented Feb 14, 2025

📝 Walkthrough

Walkthrough

This pull request introduces multiple minor adjustments across the codebase. The changes include a removed blank line in a view model, simplification of query re-entry logic by eliminating redundant condition checks and calls, adjustments to method visibility, and updates to documentation comments in the public API interface. Additionally, conditional URL modifications have been added for GitHub repositories in the context menu, and asynchronous call patterns have been clarified in the Shell plugin.

Changes

File(s) Change Summary
Flow.Launcher/.../PluginViewModel.cs Removed an extraneous blank line at the end of the SetActionKeywords method.
Flow.Launcher/.../MainViewModel.cs, Flow.Launcher/.../IPublicAPI.cs, Plugins/.../Program/Main.cs Simplified query handling by removing redundant conditionals and calls to BackToQueryResults, updated method visibility/signatures, and revised API documentation to reflect changes in query navigation.
Plugins/.../PluginsManager/ContextMenu.cs Modified URL construction logic: For GitHub URLs, strips trailing /tree/… segments and appends /issues; retains the original URL for non-GitHub cases.
Plugins/.../Shell/Main.cs Adjusted asynchronous invocation in OnWinRPressed by explicitly ignoring the task result and adding a comment regarding focus behavior on query results.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant MV as MainViewModel
    participant API as PublicAPI

    U->>MV: Trigger ReQuery(reselect)
    MV->>MV: Call BackToQueryResults()
    MV->>MV: Execute QueryResults(isReQuery: true, reSelect: reselect)
    MV->>API: Initiate re-query process
    API-->>MV: Return query results
Loading
sequenceDiagram
    participant CM as ContextMenu
    participant PM as PluginManifest

    CM->>PM: Retrieve UrlSourceCode
    alt URL starts with "https://github.com"
        PM-->>CM: Provide GitHub URL (with "/tree/..." segment)
        CM->>CM: Modify URL → Remove trailing segment and append "/issues"
    else
        PM-->>CM: Provide original URL
    end
Loading

Suggested labels

enhancement

Suggested reviewers

  • taooceros
  • jjw24

Poem

I'm a little rabbit, hopping through the code,
Finding tweaks and changes along every road.
I nibble on extra lines, and skip those redundant bytes,
Adjusting queries and URLs to bring delight.
With a twitch of my whiskers, I celebrate what's new,
Hoppy coding adventures for me and you!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aee5856 and 0f82246.

📒 Files selected for processing (3)
  • Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs (2 hunks)
  • Flow.Launcher/ViewModel/MainViewModel.cs (2 hunks)
  • Plugins/Flow.Launcher.Plugin.Shell/Main.cs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • Plugins/Flow.Launcher.Plugin.Shell/Main.cs
  • Flow.Launcher/ViewModel/MainViewModel.cs
  • Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@Jack251970 Jack251970 requested a review from jjw24 February 15, 2025 14:00
@taooceros
Copy link
Member

What would be the current behavior of change query under context menu? Directly change the query text under the context menu search text?

@Jack251970
Copy link
Member Author

What would be the current behavior of change query under context menu? Directly change the query text under the context menu search text?

As described in #3087, this is used to make sure FL will be back to query results so that ChangeQuery can work.

As for the current behavior, ChangeQuery will fail to work. (Around 0:00:10)

2025-02-17.14-45-11.mp4

@taooceros
Copy link
Member

What would be the current behavior of change query under context menu? Directly change the query text under the context menu search text?

As described in #3087, this is used to make sure FL will be back to query results so that ChangeQuery can work.

As for the current behavior, ChangeQuery will fail to work. (Around 0:00:10)

2025-02-17.14-45-11.mp4

I feel like ChangeQuery now simply behave weird when not at result. Should we fix that behavior (like make sure it change to Results before changing query or something)?

@Jack251970
Copy link
Member Author

What would be the current behavior of change query under context menu? Directly change the query text under the context menu search text?

As described in #3087, this is used to make sure FL will be back to query results so that ChangeQuery can work.
As for the current behavior, ChangeQuery will fail to work. (Around 0:00:10)
2025-02-17.14-45-11.mp4

I feel like ChangeQuery now simply behave weird when not at result. Should we fix that behavior (like make sure it change to Results before changing query or something)?

From my perspective, I believe we do not need to fix that behavior because, in most scenarios, ChangeQuery or Requery operates on query results. This is why I created that PR without modifying the ChangeQuery and Requery functions... Perhaps you could ask @jjw24 about his opinion. (He approves that PR.)

@Jack251970
Copy link
Member Author

@jjw24 Hello, what are your thoughts on the API function BackToQueryResults? Should we require devs to call this method before ChangeQuery and ReQuery, or should we integrate it directly into ChangeQuery & ReQuery?

@taooceros
Copy link
Member

I think if change query works fluently on context menu (i.e. change the query text for context menu) then we can skip that. If it will make the behavior of flow weird then we should fix the change query directly.

Backtoqueryresult can have other usage.

@Jack251970
Copy link
Member Author

I think if change query works fluently on context menu (i.e. change the query text for context menu) then we can skip that. If it will make the behavior of flow weird then we should fix the change query directly.

Backtoqueryresult can have other usage.

Well, I will do that.

This comment has been minimized.

@taooceros
Copy link
Member

I will take a look on how changequery work. We can proceed this first.

[RelayCommand]
private void OpenDeletePluginWindow()
{
PluginManager.API.BackToQueryResults();
Copy link
Member

Choose a reason for hiding this comment

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

Should we make it consistent to App.API? Similar to the following.

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 use PluginManager.API here because OpenDeletePluginWindow use it to get the api instance.

This comment has been minimized.

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

🧹 Nitpick comments (1)
Plugins/Flow.Launcher.Plugin.Shell/Main.cs (1)

381-381: Consider handling task exceptions.

The task result is explicitly discarded with _, but unhandled exceptions in the task could be silently swallowed. Consider wrapping the task body with try-catch or using proper error handling.

-            _ = Task.Run(() =>
+            _ = Task.Run(async () =>
+            {
+                try
+                {
+                    context.API.ShowMainWindow();
+                    context.API.BackToQueryResults();
+                    context.API.ChangeQuery($"{context.CurrentPluginMetadata.ActionKeywords[0]}{Plugin.Query.TermSeparator}");
+                }
+                catch (Exception ex)
+                {
+                    Log.Exception("Error in OnWinRPressed", ex);
+                }
+            });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ddbbd69 and 2843236.

📒 Files selected for processing (8)
  • Flow.Launcher/CustomQueryHotkeySetting.xaml.cs (1 hunks)
  • Flow.Launcher/CustomShortcutSetting.xaml.cs (1 hunks)
  • Flow.Launcher/ResultListBox.xaml.cs (1 hunks)
  • Flow.Launcher/ViewModel/MainViewModel.cs (2 hunks)
  • Flow.Launcher/ViewModel/PluginStoreItemViewModel.cs (1 hunks)
  • Flow.Launcher/ViewModel/PluginViewModel.cs (1 hunks)
  • Plugins/Flow.Launcher.Plugin.PluginsManager/ContextMenu.cs (0 hunks)
  • Plugins/Flow.Launcher.Plugin.Shell/Main.cs (1 hunks)
💤 Files with no reviewable changes (1)
  • Plugins/Flow.Launcher.Plugin.PluginsManager/ContextMenu.cs
✅ Files skipped from review due to trivial changes (1)
  • Flow.Launcher/ViewModel/MainViewModel.cs
🚧 Files skipped from review as they are similar to previous changes (5)
  • Flow.Launcher/ViewModel/PluginStoreItemViewModel.cs
  • Flow.Launcher/CustomQueryHotkeySetting.xaml.cs
  • Flow.Launcher/CustomShortcutSetting.xaml.cs
  • Flow.Launcher/ResultListBox.xaml.cs
  • Flow.Launcher/ViewModel/PluginViewModel.cs
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: gitStream.cm
🔇 Additional comments (1)
Plugins/Flow.Launcher.Plugin.Shell/Main.cs (1)

383-386: LGTM! Good addition of BackToQueryResults.

The addition of BackToQueryResults() before ChangeQuery ensures consistent behavior when items are selected from the context menu, aligning with the PR objectives.

Copy link

gitstream-cm bot commented Feb 19, 2025

🥷 Code experts: jjw24

Jack251970 has most 👩‍💻 activity in the files.
jjw24 has most 🧠 knowledge in the files.

See details

Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

Activity based on git-commit:

Jack251970
FEB
JAN 21 additions & 3 deletions
DEC 8 additions & 73 deletions
NOV 84 additions & 1 deletions
OCT
SEP

Knowledge based on git-blame:
jjw24: 17%

Flow.Launcher/ViewModel/MainViewModel.cs

Activity based on git-commit:

Jack251970
FEB 54 additions & 10 deletions
JAN 14 additions & 19 deletions
DEC 59 additions & 63 deletions
NOV 39 additions & 15 deletions
OCT
SEP

Knowledge based on git-blame:
jjw24: 2%

Flow.Launcher/ViewModel/PluginViewModel.cs

Activity based on git-commit:

Jack251970
FEB 1 additions & 1 deletions
JAN
DEC
NOV
OCT
SEP

Knowledge based on git-blame:
jjw24: 10%

Plugins/Flow.Launcher.Plugin.PluginsManager/ContextMenu.cs

Activity based on git-commit:

Jack251970
FEB
JAN
DEC
NOV
OCT
SEP

Knowledge based on git-blame:
jjw24: 78%

Plugins/Flow.Launcher.Plugin.Program/Main.cs

Activity based on git-commit:

Jack251970
FEB
JAN 60 additions & 8 deletions
DEC
NOV 23 additions & 12 deletions
OCT
SEP

Knowledge based on git-blame:
jjw24: 11%

Plugins/Flow.Launcher.Plugin.Shell/Main.cs

Activity based on git-commit:

Jack251970
FEB
JAN
DEC
NOV
OCT
SEP

Knowledge based on git-blame:
jjw24: 17%

To learn more about /:\ gitStream - Visit our Docs

@jjw24
Copy link
Member

jjw24 commented Feb 22, 2025

@jjw24 Hello, what are your thoughts on the API function BackToQueryResults? Should we require devs to call this method before ChangeQuery and ReQuery, or should we integrate it directly into ChangeQuery & ReQuery?

Both of you are correct. I would think though have change query and requery methods call it under the hood just makes it a little easier and more convenient for plugin devs when they use those two methods. Sorry I missed this part during the PR 3087 review.

This comment has been minimized.

@Jack251970 Jack251970 changed the title Make sure back to query results from context menu before changing query Fix ChangeQuery & ReQuery Work Issue When Results Are Not From Query Results Feb 22, 2025
@Jack251970
Copy link
Member Author

@taooceros Following jjw24's comments, now I remove #3087. When we call ChangeQuery & ReQuery, we will firstly back to query results when we call these functions. Already tested in desc.

@Jack251970 Jack251970 requested a review from taooceros February 22, 2025 11:38
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 comments (1)
Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs (1)

1-334: 💡 Verification agent

🧩 Analysis chain

⚠️ Breaking Change: Removal of BackToQueryResults method.

The removal of the BackToQueryResults method from the public API is a breaking change that could affect existing plugins. While this change aligns with the PR objectives by integrating the functionality into ChangeQuery and ReQuery, existing plugins may need to be updated.

Let's check for any existing usage of this method in plugins:


🏁 Script executed:

#!/bin/bash
# Search for any usage of BackToQueryResults in plugins
rg -i "BackToQueryResults" --type cs

Length of output: 273


Breaking Change: Removal of BackToQueryResults Method Requires Internal Updates

The removal of BackToQueryResults from the public API is intentional in favor of integrating its functionality into ChangeQuery and ReQuery. Our search did not reveal any external plugins using this method; however, we did find internal references in Flow.Launcher/ViewModel/MainViewModel.cs (three occurrences). Please update these internal calls to utilize the new query management logic to ensure consistency with the PR objectives.

  • In Flow.Launcher/ViewModel/MainViewModel.cs, replace calls to BackToQueryResults() with the appropriate new method (ChangeQuery or ReQuery).
🧹 Nitpick comments (1)
Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs (1)

20-21: Consider clarifying the documentation.

The documentation update explains the behavior well, but consider rephrasing to focus on the outcome rather than the implementation detail:

-        /// When current results is from context menu or history, we will back to query results before changing query.
+        /// When current results are from context menu or history, the query will be changed from the original query results.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2843236 and aee5856.

📒 Files selected for processing (7)
  • Flow.Launcher.Core/Plugin/JsonRPCV2Models/JsonRPCPublicAPI.cs (0 hunks)
  • Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs (2 hunks)
  • Flow.Launcher/PublicAPIInstance.cs (0 hunks)
  • Flow.Launcher/ViewModel/MainViewModel.cs (3 hunks)
  • Flow.Launcher/ViewModel/PluginViewModel.cs (0 hunks)
  • Plugins/Flow.Launcher.Plugin.Program/Main.cs (0 hunks)
  • Plugins/Flow.Launcher.Plugin.Shell/Main.cs (1 hunks)
💤 Files with no reviewable changes (4)
  • Flow.Launcher/ViewModel/PluginViewModel.cs
  • Flow.Launcher.Core/Plugin/JsonRPCV2Models/JsonRPCPublicAPI.cs
  • Plugins/Flow.Launcher.Plugin.Program/Main.cs
  • Flow.Launcher/PublicAPIInstance.cs
🚧 Files skipped from review as they are similar to previous changes (2)
  • Plugins/Flow.Launcher.Plugin.Shell/Main.cs
  • Flow.Launcher/ViewModel/MainViewModel.cs
🧰 Additional context used
🧠 Learnings (1)
Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs (1)
Learnt from: jjw24
PR: Flow-Launcher/Flow.Launcher#3087
File: Flow.Launcher/PublicAPIInstance.cs:321-322
Timestamp: 2024-11-23T09:16:05.648Z
Learning: In this codebase, documentation comments are not required in `PublicAPIInstance.cs` for methods like `BackToQueryResults()` if the same method is already documented in `IPublicAPI.cs`.
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
🔇 Additional comments (1)
Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs (1)

303-303: LGTM!

The documentation update maintains consistency with the ChangeQuery method's behavior.

@jjw24
Copy link
Member

jjw24 commented Feb 22, 2025

Sorry, I don't mean remove the back to query result API though, just have requery and change query call it before the rest of the code.

@Jack251970
Copy link
Member Author

Sorry, I don't mean remove the back to query result API though, just have requery and change query call it before the rest of the code.

Oh, sorry for misunderstanding.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@Jack251970
Copy link
Member Author

@jjw24 Ready for review.💪

This comment has been minimized.

Copy link

@check-spelling-bot Report

🔴 Please review

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

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

See ❌ Event descriptions for more information.

Pattern suggestions ✂️ (1)

You could add these patterns to .github/actions/spelling/patterns.txt:

# Automatically suggested patterns

# hit-count: 3 file-count: 1
# Non-English
[a-zA-Z]*[ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź][a-zA-Z]{3}[a-zA-ZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź]*

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
Member

@jjw24 jjw24 left a comment

Choose a reason for hiding this comment

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

👍

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants