Skip to content

Conversation

Jack251970
Copy link
Member

@Jack251970 Jack251970 commented Apr 15, 2025

Revert delegate to fields to fix compatibility issue

Flow.Launcher.Core.ExternalPlugins.FlowPluginException: Field not found: 'Flow.Launcher.Plugin.Result.Icon'.
 ---> System.MissingFieldException: Field not found: 'Flow.Launcher.Plugin.Result.Icon'.
   at Flow.Launcher.Plugin.ClipboardPlus.ClipboardPlus.GetResultFromClipboardData(ClipboardDataPair clipboardDataPair)
   at Flow.Launcher.Plugin.ClipboardPlus.ClipboardPlus.Query(Query query, CancellationToken token)
   at Flow.Launcher.Plugin.ClipboardPlus.ClipboardPlus.QueryAsync(Query query, CancellationToken token)
   at Flow.Launcher.Core.Plugin.PluginManager.<>c__DisplayClass30_0.<<QueryForPluginAsync>b__0>d.MoveNext() in C:\projects\flow-launcher\Flow.Launcher.Core\Plugin\PluginManager.cs:line 285
--- End of stack trace from previous location ---
   at Flow.Launcher.Infrastructure.Stopwatch.DebugAsync(String className, String message, Func`1 action, String methodName) in C:\projects\flow-launcher\Flow.Launcher.Infrastructure\Stopwatch.cs:line 31
   at Flow.Launcher.Core.Plugin.PluginManager.QueryForPluginAsync(PluginPair pair, Query query, CancellationToken token) in C:\projects\flow-launcher\Flow.Launcher.Core\Plugin\PluginManager.cs:line 284
   --- End of inner exception stack trace ---
   at Flow.Launcher.Core.Plugin.PluginManager.<>c__DisplayClass30_1.<QueryForPluginAsync>b__1(ActionContext _) in C:\projects\flow-launcher\Flow.Launcher.Core\Plugin\PluginManager.cs:line 313
   at Flow.Launcher.Plugin.Result.ExecuteAsync(ActionContext context) in /_/Flow.Launcher.Plugin/Result.cs:line 267
   at Flow.Launcher.ViewModel.MainViewModel.OpenResultAsync(String index) in C:\projects\flow-launcher\Flow.Launcher\ViewModel\MainViewModel.cs:line 425
   at CommunityToolkit.Mvvm.Input.AsyncRelayCommand.AwaitAndThrowIfFailed(Task executionTask)
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Improve process killer performance & Add option to let process killer show window title

  • Use concurrent to improve process killer performance.
  • Add option to show window title in process killer.

Test

  • All things were tested.

@Jack251970 Jack251970 added the Dev branch only An issue or fix for the Dev branch build label Apr 15, 2025
@Jack251970 Jack251970 added this to the 1.20.0 milestone Apr 15, 2025
@Jack251970 Jack251970 self-assigned this Apr 15, 2025
@prlabeler prlabeler bot added the bug Something isn't working label Apr 15, 2025
@Jack251970 Jack251970 requested a review from onesounds April 15, 2025 12:46
@Jack251970 Jack251970 enabled auto-merge April 15, 2025 12:46
@Jack251970
Copy link
Member Author

Tested and good to go.

This comment has been minimized.

Copy link

gitstream-cm bot commented Apr 15, 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 Apr 15, 2025

📝 Walkthrough

Walkthrough

The Result class in the Flow.Launcher.Plugin namespace was updated by changing the Icon and BadgeIcon members from auto-implemented properties with getters and setters to public fields initialized to null. The ProcessKiller plugin received several enhancements: a new boolean setting ShowWindowTitle was added to control whether processes with visible windows show their window titles; the UI was updated to include a checkbox for this setting; the process retrieval logic was modified to conditionally fetch window titles based on this setting; and the method for obtaining processes with non-empty window titles was refactored to use parallel processing and thread-safe collections for improved concurrency and efficiency.

Changes

File(s) Change Summary
Flow.Launcher.Plugin/Result.cs Changed Icon and BadgeIcon from public properties to public fields initialized to null.
Plugins/Flow.Launcher.Plugin.ProcessKiller/Settings.cs Added new boolean property ShowWindowTitle with default true.
Plugins/Flow.Launcher.Plugin.ProcessKiller/ViewModels/SettingsViewModel.cs Added ShowWindowTitle property to expose the setting in the view model.
Plugins/Flow.Launcher.Plugin.ProcessKiller/Views/SettingsControl.xaml Added a checkbox bound to ShowWindowTitle with localized label; adjusted grid layout accordingly.
Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs Modified process window title retrieval to be conditional on Settings.ShowWindowTitle.
Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs Refactored GetProcessesWithNonEmptyWindowTitle to collect visible windows first, then process them in parallel with thread-safe dictionaries to avoid duplicates and improve concurrency.
Plugins/Flow.Launcher.Plugin.ProcessKiller/Languages/en.xaml Added new localization string key flowlauncher_plugin_processkiller_show_window_title with value "Show title for processes with visible windows".

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SettingsViewModel
    participant Settings
    participant Main
    participant ProcessHelper

    User->>SettingsViewModel: Toggle ShowWindowTitle checkbox
    SettingsViewModel->>Settings: Update ShowWindowTitle value
    User->>Main: Query processes
    Main->>Settings: Check ShowWindowTitle
    alt ShowWindowTitle == true
        Main->>ProcessHelper: GetProcessesWithNonEmptyWindowTitle()
        ProcessHelper->>ProcessHelper: Collect visible windows
        ProcessHelper->>ProcessHelper: Parallel process window handles
        ProcessHelper-->>Main: Dictionary<int, string> with window titles
    else ShowWindowTitle == false
        Main->>Main: Use empty dictionary for window titles
    end
    Main->>User: Display filtered and scored process results
Loading

Possibly related PRs

  • Result Badge #3438: Modifies the same Result class by adding badge-related properties and converting Icon and BadgeIcon from fields to properties, directly related to the changes reversing the property/field declarations here.

Poem

🐇✨
Icons once hidden, now fields in the light,
Process titles shown or hidden just right.
Parallel hops through windows we take,
Faster and cleaner, no duplicates make.
Settings to toggle, a checkbox to see,
A better launcher, from me to thee!
🌿🐰


📜 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 814afc7 and 0cbd7ba.

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

🪧 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.
  • @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: 0

🧹 Nitpick comments (1)
Flow.Launcher.Plugin/Result.cs (1)

131-136: Consider adding annotations to prevent future regressions.

Since these fields are critical for backwards compatibility, consider adding annotations or comments to explicitly warn future developers not to convert these back to properties.

        /// <summary>
        /// Delegate to load an icon for this result.
        /// </summary>
+       /// <remarks>
+       /// IMPORTANT: This must remain a field (not a property) for plugin compatibility.
+       /// Some plugins access this through reflection expecting a field.
+       /// </remarks>
        public IconDelegate Icon = null;

        /// <summary>
        /// Delegate to load an icon for the badge of this result.
        /// </summary>
+       /// <remarks>
+       /// IMPORTANT: This must remain a field (not a property) for plugin compatibility.
+       /// Some plugins access this through reflection expecting a field.
+       /// </remarks>
        public IconDelegate BadgeIcon = null;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7d6fceb and f583041.

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

131-131: Reverting property to field correctly addresses the MissingFieldException.

This change from property public IconDelegate Icon { get; set; } to field public IconDelegate Icon = null; resolves the mentioned compatibility issue with the ClipboardPlus plugin. The plugin was looking for a field through reflection but couldn't find it after it had been changed to a property.

This change breaks encapsulation but is necessary for backward compatibility. Consider documenting this design decision for future maintainers so this field isn't accidentally changed back to a property.


136-136: Converting BadgeIcon property to field for consistency.

Similarly to the Icon property, this change converts BadgeIcon from an auto-implemented property to a field with an explicit null initialization. This maintains consistency with the Icon field and helps prevent future compatibility issues.

@Jack251970 Jack251970 disabled auto-merge April 15, 2025 13:09
@Jack251970 Jack251970 removed the bug Something isn't working label Apr 15, 2025
@Jack251970 Jack251970 added the enhancement New feature or request label Apr 15, 2025
@prlabeler prlabeler bot added the bug Something isn't working label Apr 15, 2025
@Jack251970 Jack251970 enabled auto-merge April 15, 2025 13:23

This comment has been minimized.

Copy link

gitstream-cm bot commented Apr 15, 2025

🥷 Code experts: no user but you matched threshold 10

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

See details

Flow.Launcher.Plugin/Result.cs

Activity based on git-commit:

Jack251970
APR 111 additions & 68 deletions
MAR
FEB 2 additions & 3 deletions
JAN 17 additions & 0 deletions
DEC 10 additions & 0 deletions
NOV

Knowledge based on git-blame:
Jack251970: 32%

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

Activity based on git-commit:

Jack251970
APR
MAR 6 additions & 3 deletions
FEB
JAN
DEC
NOV

Knowledge based on git-blame:
Jack251970: 40%

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

Activity based on git-commit:

Jack251970
APR
MAR 122 additions & 56 deletions
FEB
JAN
DEC
NOV

Knowledge based on git-blame:
Jack251970: 52%

Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs

Activity based on git-commit:

Jack251970
APR 3 additions & 1 deletions
MAR 76 additions & 69 deletions
FEB
JAN
DEC 27 additions & 32 deletions
NOV

Knowledge based on git-blame:
Jack251970: 44%

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

Activity based on git-commit:

Jack251970
APR
MAR 7 additions & 0 deletions
FEB
JAN
DEC
NOV

Knowledge based on git-blame:
Jack251970: 100%

Plugins/Flow.Launcher.Plugin.ProcessKiller/ViewModels/SettingsViewModel.cs

Activity based on git-commit:

Jack251970
APR
MAR 18 additions & 0 deletions
FEB
JAN
DEC
NOV

Knowledge based on git-blame:
Jack251970: 100%

Plugins/Flow.Launcher.Plugin.ProcessKiller/Views/SettingsControl.xaml

Activity based on git-commit:

Jack251970
APR
MAR 22 additions & 0 deletions
FEB
JAN
DEC
NOV

Knowledge based on git-blame:
Jack251970: 100%

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

@Jack251970 Jack251970 disabled auto-merge April 15, 2025 15:34
@Jack251970 Jack251970 enabled auto-merge April 15, 2025 15:42
@Jack251970 Jack251970 requested a review from Copilot April 15, 2025 15:42
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR reverts delegate properties to fields in Result.cs to address a compatibility issue while also enhancing process killer performance and providing a new option to display window titles.

  • Revert delegate properties to fields in Result.cs
  • Introduce a new ShowWindowTitle setting in Settings and SettingsViewModel
  • Improve process enumeration performance with concurrent processing in ProcessHelper and update ProcessResult creation in Main.cs

Reviewed Changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Plugins/Flow.Launcher.Plugin.ProcessKiller/ViewModels/SettingsViewModel.cs Added a new ShowWindowTitle property exposing the setting.
Plugins/Flow.Launcher.Plugin.ProcessKiller/Settings.cs Added the ShowWindowTitle property with a default value.
Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs Refactored enumeration to use concurrent processing for window handles.
Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs Updated ProcessResult creation to conditionally display window titles.
Flow.Launcher.Plugin/Result.cs Reverted Icon and BadgeIcon from properties to fields to fix compatibility.
Files not reviewed (2)
  • Plugins/Flow.Launcher.Plugin.ProcessKiller/Languages/en.xaml: Language not supported
  • Plugins/Flow.Launcher.Plugin.ProcessKiller/Views/SettingsControl.xaml: Language not supported
Comments suppressed due to low confidence (1)

Flow.Launcher.Plugin/Result.cs:131

  • [nitpick] Reverting from a property to a field fixes the compatibility issue, but please ensure that any logic depending on property setter side effects is no longer required.
public IconDelegate Icon = null;

Comment on lines +111 to +113
catch
{
// Handle exceptions (e.g., process exited)
Copy link
Preview

Copilot AI Apr 15, 2025

Choose a reason for hiding this comment

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

Consider logging or otherwise capturing the caught exception to facilitate debugging, rather than silently ignoring it.

Copilot uses AI. Check for mistakes.

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
⚠️ 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.

@Jack251970 Jack251970 merged commit 5cc3124 into dev Apr 15, 2025
12 checks passed
@Jack251970 Jack251970 deleted the revert_property branch April 15, 2025 19:37
@jjw24 jjw24 removed bug Something isn't working Dev branch only An issue or fix for the Dev branch build 5 min review labels May 3, 2025
@jjw24 jjw24 changed the title Revert delegate to fields Improve process killer performance & Add option to let process killer show window title May 3, 2025
@prlabeler prlabeler bot added the bug Something isn't working label May 3, 2025
@jjw24 jjw24 removed the bug Something isn't working label May 3, 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.

3 participants