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

Improve context menu item action response & Fix origin query null exception #3203

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

Conversation

Jack251970
Copy link
Contributor

Feature: Improve context menu item action response

Included actions

  • Pin / Unpin record to the topmost
  • Disable one program

Details

Originally, when you click one record to pin / unpin it to the topmost without closing the FL, the search bar will like this:

Screenshot 2025-01-26 195656

In this case, you must need to click esc to return back to the query list before any other actions.

Now with new API BackToQueryList (#3087 ), we can improve those actions.
E.g. After you clicked the one record to pin / unpin it to the topmost, it will automatically return back to the query list like this:

2025-01-26.20-44-08.mp4

More

To fulfill this feature, we need to remove the context menu cache feature, it can cause the cache of the original wrong context menu.

By the way, I do not think context menu caching is a good idea because the plugin with dynamic context menu will have a bad experience if user open the context menu of the same record twice.

Fix: Fix origin query null exception

This fix can make the test of the feature above work, so I include it here!

Problem

When user select the context menu item directly of one item from query list, the origin query is null. (No idea why this happens but it happens) And we need to add null check for this.

Screenshot 2025-01-26 202331

@prlabeler prlabeler bot added bug Something isn't working enhancement New feature or request labels Jan 26, 2025
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

gitstream-cm bot commented Jan 26, 2025

🥷 Code experts: no user matched threshold 10

jjw24 has most 🧠 knowledge in the files.

See details

Flow.Launcher.Plugin/Query.cs

Knowledge based on git-blame:
jjw24: 1%

Flow.Launcher/Storage/TopMostRecord.cs

Knowledge based on git-blame:
jjw24: 3%

Flow.Launcher/Storage/UserSelectedRecord.cs

Knowledge based on git-blame:
jjw24: 2%

Flow.Launcher/ViewModel/MainViewModel.cs

Knowledge based on git-blame:
jjw24: 2%

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

Knowledge based on git-blame:
jjw24: 56%

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

Knowledge based on git-blame:
jjw24: 11%

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

Copy link

gitstream-cm bot commented Jan 26, 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 Jan 26, 2025

📝 Walkthrough

Walkthrough

The pull request encompasses changes across multiple files in the Flow Launcher project, focusing on improving error handling, context menu interactions, and code simplification. The modifications include removing obsolete constructors, adding null checks, enhancing error handling in plugins, and streamlining context menu result management. These changes aim to make the application more robust and provide a smoother user experience by adding better error feedback and simplifying internal logic.

Changes

File Change Summary
Flow.Launcher.Plugin/Query.cs Removed obsolete constructor for Query class
Flow.Launcher/Storage/TopMostRecord.cs Added null checks for OriginQuery, removed Load method
Flow.Launcher/Storage/UserSelectedRecord.cs Added clarifying comment in GenerateQueryAndResultHashCode method
Flow.Launcher/ViewModel/MainViewModel.cs Removed lastContextMenuResult and lastContextMenuResults fields, simplified context menu handling
Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs Added error handling for FileNotFoundException in "Run as different user" context menu
Plugins/Flow.Launcher.Plugin.Program/Main.cs Added BackToQueryResults() and ReQuery() after disabling a program

Suggested Labels

kind/ui

Suggested Reviewers

  • jjw24
  • taooceros

Poem

🐰 A Rabbit's Code Review Delight

Null checks dancing, errors take flight,
Context menus polished, smooth and bright,
Constructors fade, simplicity gleams,
Flow Launcher evolves beyond our dreams!

Hop, hop, hooray! 🚀


📜 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 32bedde and 80f54ba.

📒 Files selected for processing (6)
  • Flow.Launcher.Plugin/Query.cs (1 hunks)
  • Flow.Launcher/Storage/TopMostRecord.cs (2 hunks)
  • Flow.Launcher/Storage/UserSelectedRecord.cs (1 hunks)
  • Flow.Launcher/ViewModel/MainViewModel.cs (4 hunks)
  • Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs (1 hunks)
  • Plugins/Flow.Launcher.Plugin.Program/Main.cs (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • Flow.Launcher/Storage/UserSelectedRecord.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 (9)
Flow.Launcher/Storage/TopMostRecord.cs (3)

15-16: LGTM! Clear documentation of null check rationale.

The comment clearly explains why OriginQuery can be null and the reasoning behind the null check.


29-34: LGTM! Consistent null check implementation.

The null check for OriginQuery is consistent with the pattern established in IsTopMost method.


41-46: LGTM! Consistent error handling across methods.

The null check implementation maintains consistency across all methods in the class.

Flow.Launcher.Plugin/Query.cs (1)

1-1: LGTM! Clean removal of obsolete code.

The removal of the deprecated constructor helps maintain code clarity and prevents usage of outdated patterns.

Plugins/Flow.Launcher.Plugin.Program/Main.cs (1)

267-268: LGTM! Enhanced user experience after disabling programs.

The addition of BackToQueryResults and ReQuery calls improves the UX by:

  1. Automatically returning to the query list instead of requiring manual ESC key press
  2. Refreshing the results to immediately reflect the disabled program
Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs (1)

245-245: LGTM! Improved error handling for "Run as different user" action.

The addition of return false after showing the error message properly indicates action failure to the UI.

Flow.Launcher/ViewModel/MainViewModel.cs (3)

402-407: LGTM! Well-implemented null check for origin query.

The null check properly prevents NullReferenceException when selecting context menu items directly from the query list, addressing the issue mentioned in the PR objectives.


992-994: LGTM! Improved context menu handling by removing caching.

The direct fetching of context menu results, without caching, ensures that dynamic plugins always show the correct context menu. This change aligns well with the PR objectives and improves the reliability of the feature.


1269-1270: LGTM! Enhanced user experience for pin/unpin actions.

The automatic return to query list after pin/unpin actions improves the user experience by eliminating the need for manual ESC key press. The implementation correctly updates the UI to reflect the changes.

Also applies to: 1287-1288


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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant