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

Make sure back to query results from context menu before changing query #3240

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

Jack251970
Copy link
Contributor

The ChangeQuery function fails to work when the selected item is from the context menu or history. To address this, we need to use BackToQueryResults (#3087) to ensure the function works correctly in such scenarios.

@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 adds calls to return to the query results view in various event handlers. Specifically, it introduces App.API.BackToQueryResults(); in the custom query and shortcut settings when testing a keyword or shortcut. The result list now invokes this method after a drag-and-drop move action, alongside updating the current query. Similar calls are incorporated in the plugin store and plugin deletion flows. There are no modifications or deletions to public entity declarations.

Changes

File(s) Change Summary
Flow.Launcher/CustomQueryHotkeySetting.xaml.cs
Flow.Launcher/CustomShortcutSetting.xaml.cs
Added App.API.BackToQueryResults(); in button click handlers to revert to query results before updating the query and adjusting the main window.
Flow.Launcher/ResultListBox.xaml.cs Inserted calls to App.API.BackToQueryResults(); and App.API.ChangeQuery(rawQuery, true); after a drag-and-drop move to update the state post-operation.
Flow.Launcher/ViewModel/PluginStoreItemViewModel.cs
Flow.Launcher/ViewModel/PluginViewModel.cs
Added invocation of BackToQueryResults() (via App.API or PluginManager.API) in methods that handle plugin command queries and deletion, ensuring a return to the query results before proceeding.
Flow.Launcher/ViewModel/MainViewModel.cs Added comments to clarify that the application should return to query results before changing the query when interacting with the context menu.
Plugins/Flow.Launcher.Plugin.PluginsManager/ContextMenu.cs Modified URL handling for creating new issues, ensuring it directs to the appropriate GitHub issues page based on the URL format.
Plugins/Flow.Launcher.Plugin.Shell/Main.cs Altered task initiation in the OnWinRPressed method to ignore the task result and added a call to context.API.BackToQueryResults(); after showing the main window.

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • taooceros
  • jjw24

Poem

I hopped in code with careful zest,
Adding lines to put queries to the test.
A touch of magic to return the view,
Ensuring every action feels fresh and new.
With swift moves like a bunny in flight,
I celebrate these changes with delight! 🐇


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
Contributor 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
Contributor 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
Contributor 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
Contributor 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.

@@ -146,6 +146,7 @@ private void OpenSourceCodeLink()
[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
Contributor 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.

Copy link

@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 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, Yusyuriv have most 🧠 knowledge in the files.

See details

Flow.Launcher/CustomQueryHotkeySetting.xaml.cs

Activity based on git-commit:

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

Knowledge based on git-blame:
Yusyuriv: 19%
jjw24: 17%

Flow.Launcher/CustomShortcutSetting.xaml.cs

Activity based on git-commit:

Jack251970
FEB
JAN
DEC
NOV 3 additions & 2 deletions
OCT
SEP

Knowledge based on git-blame:
Yusyuriv: 14%

Flow.Launcher/ResultListBox.xaml.cs

Activity based on git-commit:

Jack251970
FEB
JAN
DEC
NOV
OCT
SEP

Knowledge based on git-blame:
jjw24: 6%

Flow.Launcher/ViewModel/MainViewModel.cs

Activity based on git-commit:

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

Knowledge based on git-blame:
Yusyuriv: 3%
jjw24: 2%

Flow.Launcher/ViewModel/PluginStoreItemViewModel.cs

Activity based on git-commit:

Jack251970
FEB
JAN
DEC
NOV
OCT
SEP

Knowledge based on git-blame:
Yusyuriv: 18%

Flow.Launcher/ViewModel/PluginViewModel.cs

Activity based on git-commit:

Jack251970
FEB
JAN
DEC
NOV
OCT
SEP

Knowledge based on git-blame:
Yusyuriv: 29%
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.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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 min review bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants