Skip to content

Conversation

Jack251970
Copy link
Member

@Jack251970 Jack251970 commented Feb 20, 2025

Support removing duplicated Win32 apps in Program plugin

For Program plugin, we can get results with duplicated apps. (One is Win32 app, another is UWP app.)

Screenshot 2025-02-20 145447

So I add option to let us remove the duplicated apps.

I remove the Win32 apps instead of UWP apps because the name, description and some other properties of Win32 apps are always wrong if these apps are duplicated.

As you can see above, the top item is from Win32 app and its name is olk but actually this name should be Outlook (Classic) (same as bottom item which is from UWP app).

Test

Settings Panel:

image

Search:

image

This comment has been minimized.

Copy link

gitstream-cm bot commented Feb 20, 2025

🥷 Code experts: VictoriousRaptor, onesounds

Jack251970, taooceros have most 👩‍💻 activity in the files.
VictoriousRaptor, onesounds have most 🧠 knowledge in the files.

See details

Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml

Activity based on git-commit:

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

Knowledge based on git-blame:
onesounds: 25%
VictoriousRaptor: 24%

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

Activity based on git-commit:

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

Knowledge based on git-blame:
VictoriousRaptor: 16%

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

Activity based on git-commit:

Jack251970 taooceros
FEB
JAN
DEC
NOV
OCT
SEP

Knowledge based on git-blame:
VictoriousRaptor: 84%
onesounds: 1%

Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml

Activity based on git-commit:

Jack251970 taooceros
FEB
JAN
DEC
NOV
OCT
SEP

Knowledge based on git-blame:
onesounds: 81%
VictoriousRaptor: 6%

Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs

Activity based on git-commit:

Jack251970 taooceros
FEB
JAN
DEC
NOV 9 additions & 9 deletions
OCT
SEP

Knowledge based on git-blame:
VictoriousRaptor: 21%
onesounds: 4%

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

Copy link
Contributor

coderabbitai bot commented Feb 20, 2025

📝 Walkthrough

Walkthrough

The changes introduce a feature to hide duplicated Windows applications in the Flow Launcher program plugin. This includes the addition of new string resources for user interface labels and tooltips, a constant and filtering method in the main logic to detect duplicates, and a boolean property in the settings to control this feature. The user interface is also updated with a new checkbox and adjusted margin formatting to accommodate the new functionality.

Changes

File(s) Change Summary
Plugins/.../Languages/en.xaml Added two new string resources for the "Hide duplicated apps" option and its tooltip.
Plugins/.../Main.cs, Plugins/.../Settings.cs Introduced a new constant (WindowsAppPath) and a filtering method (HideDuplicatedWindowsAppFilter) in Main.cs to check for duplicates; added a new boolean property HideDuplicatedWindowsApp in Settings.cs to control the feature.
Plugins/.../ProgramSetting.xaml, Plugins/.../ProgramSetting.xaml.cs Updated the UI by adjusting margin formatting and adding a new CheckBox bound to the HideDuplicatedWindowsApp property; added a corresponding public property in the code-behind that updates settings and resets the cache.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI as ProgramSetting UI
    participant Settings
    participant Main

    User->>UI: Toggle "Hide duplicated apps" CheckBox
    UI->>Settings: Update HideDuplicatedWindowsApp property
    Settings->>UI: Reflect new settings value
    UI->>Main: Call ResetCache()
    Main->>Main: Filter programs using HideDuplicatedWindowsAppFilter
Loading

Suggested labels

bug, enhancement, kind/ui

Suggested reviewers

  • jjw24

Poem

I’m a bunny with a coding tune,
Hopping over bugs beneath the moon,
Duplicates hide as I tweak the lane,
New options bloom like carrots in rain,
Code and hop in sync for a brighter day! 🐰

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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.

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

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

171-171: Fix comment in code.

The comment "Ensure trailing slash" is incorrect as the code actually removes the trailing slash.

Apply this diff to fix the comment:

-            var location = program.Location.TrimEnd('\\'); // Ensure trailing slash
+            var location = program.Location.TrimEnd('\\'); // Remove trailing slash
Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs (1)

60-68: Fix typo in property name: "Dulplicated" should be "Duplicated".

The implementation follows the correct pattern for visibility settings, but there's a typo in the property name.

Apply this diff to fix the typo:

-        public bool HideDulplicatedWindowsApp
+        public bool HideDuplicatedWindowsApp
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1a54eed and 7ccfbca.

📒 Files selected for processing (5)
  • Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml (1 hunks)
  • Plugins/Flow.Launcher.Plugin.Program/Main.cs (3 hunks)
  • Plugins/Flow.Launcher.Plugin.Program/Settings.cs (1 hunks)
  • Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml (8 hunks)
  • Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: gitStream.cm

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 (2)
Plugins/Flow.Launcher.Plugin.Program/Main.cs (2)

95-101: Extract UWP directories collection into a separate method.

Consider extracting this logic into a dedicated method for better maintainability and reusability. This would also make the QueryAsync method more focused and easier to read.

+        private static string[] GetUwpDirectories(UWPApp[] uwps, bool hideDuplicates)
+        {
+            if (!hideDuplicates)
+                return null;
+                
+            return uwps
+                .Where(uwp => !string.IsNullOrEmpty(uwp.Location))
+                .Where(uwp => uwp.Location.StartsWith(WindowsAppPath, StringComparison.OrdinalIgnoreCase))
+                .Select(uwp => uwp.Location.TrimEnd('\\'))
+                .Distinct(StringComparer.OrdinalIgnoreCase)
+                .ToArray();
+        }

         public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
         {
             var result = await cache.GetOrCreateAsync(query.Search, async entry =>
             {
                 var resultList = await Task.Run(() =>
                 {
                     try
                     {
-                        // Collect all UWP Windows app directories
-                        var uwpsDirectories = _settings.HideDuplicatedWindowsApp ? _uwps
-                            .Where(uwp => !string.IsNullOrEmpty(uwp.Location)) // Exclude invalid paths
-                            .Where(uwp => uwp.Location.StartsWith(WindowsAppPath, StringComparison.OrdinalIgnoreCase)) // Keep system apps
-                            .Select(uwp => uwp.Location.TrimEnd('\\')) // Remove trailing slash
-                            .Distinct(StringComparer.OrdinalIgnoreCase)
-                            .ToArray() : null;
+                        var uwpsDirectories = GetUwpDirectories(_uwps, _settings.HideDuplicatedWindowsApp);

171-171: Fix misleading comments.

The comments need correction:

  1. Line 171: The comment "Ensure trailing slash" is incorrect as the code is removing the trailing slash.
  2. Line 178: The comment has grammatical issues.
-            var location = program.Location.TrimEnd('\\'); // Ensure trailing slash
+            var location = program.Location.TrimEnd('\\'); // Remove trailing slash

-            // Check if the any Win32 executable directory contains UWP Windows app location matches 
+            // Check if any Win32 executable directory matches a UWP Windows app location
             return !uwpsDirectories.Any(uwpDirectory =>
                 location.StartsWith(uwpDirectory, StringComparison.OrdinalIgnoreCase));

Also applies to: 178-180

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7ccfbca and 097633e.

📒 Files selected for processing (5)
  • Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml (1 hunks)
  • Plugins/Flow.Launcher.Plugin.Program/Main.cs (3 hunks)
  • Plugins/Flow.Launcher.Plugin.Program/Settings.cs (1 hunks)
  • Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml (8 hunks)
  • Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • Plugins/Flow.Launcher.Plugin.Program/Settings.cs
  • Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs
  • Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml
  • Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
🔇 Additional comments (1)
Plugins/Flow.Launcher.Plugin.Program/Main.cs (1)

75-75: Use system environment for Windows app path.

The hardcoded path might not work on all systems. Consider using Environment.GetFolderPath or similar system APIs to get the correct path.

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

🧹 Nitpick comments (2)
Plugins/Flow.Launcher.Plugin.Program/Main.cs (2)

95-102: Improve readability of the LINQ chain.

While the logic is correct, the LINQ chain could be more readable by:

  1. Extracting the filtering conditions into descriptive variables
  2. Adding more detailed comments explaining the purpose of each filter

Consider this refactoring:

-                        // Collect all UWP Windows app directories
+                        // Collect unique UWP Windows app directories for duplicate detection
+                        // Only consider valid system apps from the WindowsApps directory
                         var uwpsDirectories = _settings.HideDuplicatedWindowsApp ? _uwps
-                            .Where(uwp => !string.IsNullOrEmpty(uwp.Location)) // Exclude invalid paths
-                            .Where(uwp => uwp.Location.StartsWith(WindowsAppPath, StringComparison.OrdinalIgnoreCase)) // Keep system apps
-                            .Select(uwp => uwp.Location.TrimEnd('\\')) // Remove trailing slash
+                            .Where(uwp => !string.IsNullOrEmpty(uwp.Location))
+                            .Where(uwp => 
+                                uwp.Location.StartsWith(WindowsAppPath, StringComparison.OrdinalIgnoreCase))
+                            .Select(uwp => uwp.Location.TrimEnd('\\'))
                             .Distinct(StringComparer.OrdinalIgnoreCase)
                             .ToArray() : null;

334-347: Improve error handling in StartProcess method.

The catch block catches all exceptions but only shows a generic error message. Consider:

  1. Logging the specific exception
  2. Providing more detailed error information to help diagnose issues
         public static void StartProcess(Func<ProcessStartInfo, Process> runProcess, ProcessStartInfo info)
         {
             try
             {
                 runProcess(info);
             }
-            catch (Exception)
+            catch (Exception ex)
             {
+                Log.Exception("Failed to start process", ex, typeof(Main));
                 var title = Context.API.GetTranslation("flowlauncher_plugin_program_disable_dlgtitle_error");
                 var message = string.Format(Context.API.GetTranslation("flowlauncher_plugin_program_run_failed"),
                     info.FileName);
-                Context.API.ShowMsg(title, string.Format(message, info.FileName), string.Empty);
+                Context.API.ShowMsg(title, string.Format(message, info.FileName), ex.Message);
             }
         }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 097633e and 79bcf8b.

📒 Files selected for processing (1)
  • Plugins/Flow.Launcher.Plugin.Program/Main.cs (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
🔇 Additional comments (1)
Plugins/Flow.Launcher.Plugin.Program/Main.cs (1)

75-75: LGTM! Robust path handling implementation.

The use of Path.Combine with Environment.GetFolderPath ensures correct path handling across different Windows installations.

@Jack251970 Jack251970 added the enhancement New feature or request label Feb 22, 2025
@jjw24 jjw24 enabled auto-merge February 22, 2025 12:02
@jjw24 jjw24 merged commit e028ed3 into Flow-Launcher:dev Feb 22, 2025
6 checks passed
@jjw24 jjw24 added this to the 1.20.0 milestone Feb 22, 2025
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.

2 participants