-
-
Notifications
You must be signed in to change notification settings - Fork 455
Code cleanup & Use Flow.Launcher.Localization to improve code quality #4009
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
Conversation
|
🥷 Code experts: no user but you matched threshold 10 Jack251970, jjw24 have most 🧠 knowledge in the files. See details
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame: ✨ Comment |
|
Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX. |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughRefactors several plugins to use a static PluginInitContext and centralized Localize-based i18n. Adds Flow.Launcher.Localization dependency and suppresses FLSG0007 in multiple csproj files. ProcessKiller and Sys plugins receive substantial structural updates and new/static utilities. Shell plugin internal flow adjusted. Minor formatting changes in Calculator. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant FL as Flow Launcher
participant PK as ProcessKiller.Main (static Context)
participant PH as ProcessHelper (static)
Note over FL,PK: Process search and kill flow
User->>FL: Enter "kill <query>"
FL->>PK: Query(query)
PK->>PH: GetMatchingProcesses()/GetProcessesWithNonEmptyWindowTitle()
PH-->>PK: Processes + titles
PK->>PK: Fuzzy match, group similar, insert "Kill all" when applicable
PK-->>FL: List<Result>
User->>FL: Select result
FL->>PH: TryKill(process) or for group: TryKill(each)
PH-->>FL: Success/Failure
FL->>PK: ReQuery()
sequenceDiagram
autonumber
actor User
participant FL as Flow Launcher
participant SYS as Sys.Main (static Context)
participant TS as ThemeSelector (public static)
Note over FL,SYS: System commands and theme selection
User->>FL: Enter "fltheme ..." or "sys cmd"
alt Theme selection
FL->>TS: Query(query)
TS->>FL: Theme results (with Localize subtitles)
User->>FL: Pick theme
FL->>TS: Action (SetCurrentTheme)
TS->>SYS: Context.API.SetCurrentTheme(...)
SYS->>FL: Context.API.ReQuery()
else System commands
FL->>SYS: Query(query)
SYS->>SYS: Build command list, fuzzy match
SYS-->>FL: Results (titles/subtitles via Localize)
User->>FL: Execute command
FL->>SYS: Action (via Context.API)
end
sequenceDiagram
autonumber
actor User
participant FL as Flow Launcher
participant SH as Shell.Main (static Context)
Note over FL,SH: Shell command execution
User->>FL: Type shell path/cmd
FL->>SH: Query(query)
SH->>SH: Resolve history/autocomplete, Localize titles
SH-->>FL: Results
User->>FL: Execute
FL->>SH: Execute(result)
SH->>SH: Prepare ProcessStartInfo
SH-->>FL: Start or error (localized)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this 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 implements a significant modernization of the Flow.Launcher plugin codebase by adopting the Flow.Launcher.Localization package and C# file-scoped namespace syntax. The changes eliminate direct API translation calls in favor of generated localization methods and apply consistent modern C# patterns throughout.
- Replaces
_context.API.GetTranslation()calls withLocalizemethods for type-safe localization - Adopts file-scoped namespaces and modern C# syntax patterns (primary constructors, collection expressions)
- Refactors static access patterns by converting instance context members to static properties
Reviewed Changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Flow.Launcher.Plugin.Sys/ThemeSelector.cs | Converts to static class with file-scoped namespace, replaces localization calls |
| Flow.Launcher.Plugin.Sys/SysSettings.xaml.cs | Removes context parameter, adopts file-scoped namespace |
| Flow.Launcher.Plugin.Sys/SettingsViewModel.cs | Converts to primary constructor pattern |
| Flow.Launcher.Plugin.Sys/Settings.cs | Updates collection initialization to modern syntax |
| Flow.Launcher.Plugin.Sys/Main.cs | Major refactor to static context access and Localize usage |
| Flow.Launcher.Plugin.Sys/Languages/en.xaml | Adds new theme selector localization strings |
| Flow.Launcher.Plugin.Sys/Flow.Launcher.Plugin.Sys.csproj | Adds Flow.Launcher.Localization package reference |
| Flow.Launcher.Plugin.Sys/CommandKeywordSetting.xaml.cs | Updates to use static context and Localize methods |
| Flow.Launcher.Plugin.Shell/Main.cs | Converts to static context pattern and modern syntax |
| Flow.Launcher.Plugin.ProcessKiller/* | Multiple files modernized with static context and localization updates |
| Flow.Launcher.Plugin.PluginIndicator/Main.cs | Refactored for static context and modern patterns |
| Flow.Launcher.Plugin.Calculator/* | Minor modernization updates |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
| namespace Flow.Launcher.Plugin.Calculator; | ||
|
|
||
| [EnumLocalize] | ||
| public enum DecimalSeparator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I don't like a change like this. It just removes braces and indent and messes up commit history.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I don't like a change like this. It just removes braces and indent and messes up commit history.
That makes sense. Let us revert it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VictoriousRaptor All related namespaces are reverted
|
Don't have much time today. If someone can merge it please do squash and merge. |
There was a problem hiding this 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (6)
Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs (2)
19-35: Make system-process check culture/Case-insensitive and drop ToLower().Use a HashSet with OrdinalIgnoreCase and compare ProcessName directly.
- private readonly HashSet<string> _systemProcessList = - [ + private readonly HashSet<string> _systemProcessList = new(StringComparer.OrdinalIgnoreCase) + { "conhost", "svchost", "idle", "system", "rundll32", "csrss", "lsass", "lsm", "smss", "wininit", "winlogon", "services", "spoolsv", - "explorer" - ]; + "explorer" + }; ... - private bool IsSystemProcessOrFlowLauncher(Process p) => - _systemProcessList.Contains(p.ProcessName.ToLower()) || + private bool IsSystemProcessOrFlowLauncher(Process p) => + _systemProcessList.Contains(p.ProcessName) || string.Equals(p.ProcessName, FlowLauncherProcessName, StringComparison.OrdinalIgnoreCase);Also applies to: 39-41
165-171: Wrong handle null check type. Use HANDLE.Null, not HWND.Null.This is a correctness/clarity bug; check against the correct handle type.
- var handle = PInvoke.OpenProcess(PROCESS_ACCESS_RIGHTS.PROCESS_QUERY_LIMITED_INFORMATION, false, (uint)p.Id); - if (handle == HWND.Null) + var handle = PInvoke.OpenProcess(PROCESS_ACCESS_RIGHTS.PROCESS_QUERY_LIMITED_INFORMATION, false, (uint)p.Id); + if (handle == HANDLE.Null) { return string.Empty; }Also applies to: 175-181
Plugins/Flow.Launcher.Plugin.Shell/Main.cs (2)
63-68: Remove duplicate Any() check in autocomplete filter.Redundant predicate repeats the same condition.
- .Where(o => o.StartsWith(cmd, StringComparison.OrdinalIgnoreCase) && - !results.Any(p => o.Equals(p.Title, StringComparison.OrdinalIgnoreCase)) && - !results.Any(p => o.Equals(p.Title, StringComparison.OrdinalIgnoreCase))).ToList(); + .Where(o => o.StartsWith(cmd, StringComparison.OrdinalIgnoreCase) && + !results.Any(p => o.Equals(p.Title, StringComparison.OrdinalIgnoreCase))) + .ToList();
218-229: Fix injected cmd string: stray “/c” after pause.Constructs “… && pause > nul /c”, which yields “‘/c’ is not recognized …”. Remove the trailing “/c”.
- info.ArgumentList.Add( - $"{command}" + - $"{(_settings.CloseShellAfterPress ? - $" && echo {notifyStr} && pause > nul /c" : - "")}"); + info.ArgumentList.Add( + $"{command}" + + $"{(_settings.CloseShellAfterPress ? + $" && echo {notifyStr} && pause > nul" : + "")}");Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs (1)
33-38: Use value equality for selected theme, not reference equality.GetCurrentTheme() returns a different instance than items in themes; ‘==’ will rarely match. Compare by identifier.
- if (theme == selectedTheme) + if (string.Equals(theme.FileNameWithoutExtension, selectedTheme?.FileNameWithoutExtension, StringComparison.OrdinalIgnoreCase)) { title = $"{theme.Name} ★"; // Set current theme to the top score = 2000; }Plugins/Flow.Launcher.Plugin.Sys/Main.cs (1)
134-144: Initialize localized command metadata before first query
UpdateLocalizedNameDescriptionis only invoked fromCreateSettingPanel, so until the settings UI is opened everyCommand.NameandCommand.Descriptionstaysnull. During the first search we overwrite eachResult.Titlewith that null, then immediately callContext.API.FuzzySearchwith a null string, which blows up (and even if it didn’t, the UI would render blank titles). Please hydrate the localized names insideInitright after loading_settingsso that every query runs against non-null data.Context = context; _settings = context.API.LoadSettingJsonStorage<Settings>(); _viewModel = new SettingsViewModel(_settings); + UpdateLocalizedNameDescription(force: false); foreach (string key in KeywordTitleMappings.Keys) { // Remove _cmd in the last of the strings KeywordDescriptionMappings[key] = KeywordTitleMappings[key][..^4]; }
🧹 Nitpick comments (3)
Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessResult.cs (1)
6-17: Primary constructor refactor LGTM; consider sealing the classThe refactor is clean. If inheritance isn’t needed, mark the class
sealedfor clarity and minor JIT benefits.-internal class ProcessResult(Process process, int score, string title, MatchResult match, string tooltip) +internal sealed class ProcessResult(Process process, int score, string title, MatchResult match, string tooltip)Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs (1)
186-188: Preserve scoring when ordering results.Sorting solely by Title discards the fuzzy/visibility Score. Sort by Score then Title.
- var sortedResults = results.OrderBy(x => x.Title).ToList(); + var sortedResults = results + .OrderByDescending(x => x.Score) + .ThenBy(x => x.Title) + .ToList();Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs (1)
19-20: Honor score when listing themes with no search.Sort by Score then Title so current theme surfaces as intended.
- return [.. themes.Select(x => CreateThemeResult(x, selectedTheme)).OrderBy(x => x.Title)]; + return [.. themes + .Select(x => CreateThemeResult(x, selectedTheme)) + .OrderByDescending(x => x.Score) + .ThenBy(x => x.Title)];
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (15)
Plugins/Flow.Launcher.Plugin.Calculator/DecimalSeparator.cs(1 hunks)Plugins/Flow.Launcher.Plugin.Calculator/Main.cs(8 hunks)Plugins/Flow.Launcher.Plugin.PluginIndicator/Main.cs(4 hunks)Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs(10 hunks)Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs(4 hunks)Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessResult.cs(1 hunks)Plugins/Flow.Launcher.Plugin.ProcessKiller/ViewModels/SettingsViewModel.cs(1 hunks)Plugins/Flow.Launcher.Plugin.Shell/Main.cs(18 hunks)Plugins/Flow.Launcher.Plugin.Shell/Settings.cs(2 hunks)Plugins/Flow.Launcher.Plugin.Shell/ShellSetting.xaml.cs(1 hunks)Plugins/Flow.Launcher.Plugin.Sys/CommandKeywordSetting.xaml.cs(2 hunks)Plugins/Flow.Launcher.Plugin.Sys/Main.cs(21 hunks)Plugins/Flow.Launcher.Plugin.Sys/SettingsViewModel.cs(1 hunks)Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml.cs(2 hunks)Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
- Plugins/Flow.Launcher.Plugin.Calculator/DecimalSeparator.cs
- Plugins/Flow.Launcher.Plugin.Sys/CommandKeywordSetting.xaml.cs
- Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml.cs
- Plugins/Flow.Launcher.Plugin.ProcessKiller/ViewModels/SettingsViewModel.cs
- Plugins/Flow.Launcher.Plugin.Sys/SettingsViewModel.cs
🧰 Additional context used
🧠 Learnings (10)
📓 Common learnings
Learnt from: Jack251970
PR: Flow-Launcher/Flow.Launcher#3854
File: Flow.Launcher/App.xaml.cs:246-262
Timestamp: 2025-07-21T09:19:49.684Z
Learning: In Flow Launcher's App.xaml.cs, the asynchronous plugin initialization task (containing AbstractPluginEnvironment.PreStartPluginExecutablePathUpdate, PluginManager.LoadPlugins, PluginManager.InitializePluginsAsync, and AutoPluginUpdates) does not require additional try-catch error handling according to maintainer Jack251970, as these operations are designed to handle exceptions internally.
Learnt from: jjw24
PR: Flow-Launcher/Flow.Launcher#2448
File: Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs:16-20
Timestamp: 2025-01-18T10:10:18.414Z
Learning: In Flow Launcher's plugin system, the PluginInitContext parameter passed to plugin constructors is guaranteed to be non-null by the plugin initialization system, making null checks unnecessary.
Learnt from: Jack251970
PR: Flow-Launcher/Flow.Launcher#3854
File: Flow.Launcher.Core/Plugin/PluginManager.cs:280-292
Timestamp: 2025-07-21T09:19:19.012Z
Learning: In Flow Launcher's PluginManager.cs, the post-initialization operations (RegisterResultsUpdatedEvent, UpdatePluginMetadataTranslation, RegisterPluginActionKeywords, DialogJump.InitializeDialogJumpPlugin, and AddPluginToLists) are designed to be exception-safe and do not require additional try-catch error handling according to the maintainer Jack251970.
Learnt from: Jack251970
PR: Flow-Launcher/Flow.Launcher#3573
File: Plugins/Flow.Launcher.Plugin.Shell/Main.cs:330-339
Timestamp: 2025-09-06T05:32:51.575Z
Learning: In Flow.Launcher Shell plugin's StartProcess method, the maintainer Jack251970 prefers not to propagate launch failures from Context.API.StartProcess or throw exceptions when the API call returns false. Silent failure handling is intentional for shell commands in this plugin.
Learnt from: Jack251970
PR: Flow-Launcher/Flow.Launcher#3791
File: Flow.Launcher.Core/Plugin/PluginManager.cs:293-295
Timestamp: 2025-07-01T05:46:13.251Z
Learning: In Flow.Launcher.Core/Plugin/PluginManager.cs, when checking if a plugin is modified within the PluginManager class itself, prefer using the internal static PluginModified(string id) method directly rather than going through API.PluginModified() for better performance and architectural design.
Learnt from: jjw24
PR: Flow-Launcher/Flow.Launcher#3932
File: Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs:48-55
Timestamp: 2025-09-04T11:52:29.096Z
Learning: In Flow Launcher's PluginsManifest.cs, when dealing with version parsing for the MinimumAppVersion feature, maintainer jjw24 prefers to keep the solution simple rather than implementing comprehensive helper methods for SemVer parsing normalization.
📚 Learning: 2025-09-23T04:39:31.981Z
Learnt from: Jack251970
PR: Flow-Launcher/Flow.Launcher#4009
File: Plugins/Flow.Launcher.Plugin.Shell/ShellSetting.xaml.cs:135-139
Timestamp: 2025-09-23T04:39:31.981Z
Learning: In Flow.Launcher plugin settings UI code, setting ComboBox.SelectedItem directly to an integer value after populating ItemsSource with a List<int> works correctly and doesn't require additional validation checks. User Jack251970 confirmed this pattern is acceptable in the codebase.
Applied to files:
Plugins/Flow.Launcher.Plugin.Shell/ShellSetting.xaml.cs
📚 Learning: 2025-09-13T06:04:26.977Z
Learnt from: Jack251970
PR: Flow-Launcher/Flow.Launcher#3593
File: Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml.cs:143-165
Timestamp: 2025-09-13T06:04:26.977Z
Learning: In Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml, the ListView_SizeChanged handler in the C# file assumes 5 GridViewColumns but the XAML may have more columns. The user Jack251970 indicated this mismatch doesn't need to be fixed when pointed out during PR #3593 review.
Applied to files:
Plugins/Flow.Launcher.Plugin.Shell/ShellSetting.xaml.cs
📚 Learning: 2025-01-18T10:10:18.414Z
Learnt from: jjw24
PR: Flow-Launcher/Flow.Launcher#2448
File: Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs:16-20
Timestamp: 2025-01-18T10:10:18.414Z
Learning: In Flow Launcher's plugin system, the PluginInitContext parameter passed to plugin constructors is guaranteed to be non-null by the plugin initialization system, making null checks unnecessary.
Applied to files:
Plugins/Flow.Launcher.Plugin.Sys/Main.csPlugins/Flow.Launcher.Plugin.PluginIndicator/Main.csPlugins/Flow.Launcher.Plugin.Shell/Main.cs
📚 Learning: 2025-07-21T09:19:49.684Z
Learnt from: Jack251970
PR: Flow-Launcher/Flow.Launcher#3854
File: Flow.Launcher/App.xaml.cs:246-262
Timestamp: 2025-07-21T09:19:49.684Z
Learning: In Flow Launcher's App.xaml.cs, the asynchronous plugin initialization task (containing AbstractPluginEnvironment.PreStartPluginExecutablePathUpdate, PluginManager.LoadPlugins, PluginManager.InitializePluginsAsync, and AutoPluginUpdates) does not require additional try-catch error handling according to maintainer Jack251970, as these operations are designed to handle exceptions internally.
Applied to files:
Plugins/Flow.Launcher.Plugin.Sys/Main.csPlugins/Flow.Launcher.Plugin.Shell/Main.cs
📚 Learning: 2024-11-03T07:40:11.014Z
Learnt from: Yusyuriv
PR: Flow-Launcher/Flow.Launcher#3057
File: Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs:0-0
Timestamp: 2024-11-03T07:40:11.014Z
Learning: In Flow Launcher, when using Windows Forms dialogs (e.g., in `JsonRPCPluginSettings.cs`), path validation is enabled by default in `OpenFileDialog` and `FolderBrowserDialog`, preventing users from selecting invalid paths, but it's possible to opt out of this validation on individual dialogs.
Applied to files:
Plugins/Flow.Launcher.Plugin.Sys/Main.cs
📚 Learning: 2025-07-01T05:46:13.251Z
Learnt from: Jack251970
PR: Flow-Launcher/Flow.Launcher#3791
File: Flow.Launcher.Core/Plugin/PluginManager.cs:293-295
Timestamp: 2025-07-01T05:46:13.251Z
Learning: In Flow.Launcher.Core/Plugin/PluginManager.cs, when checking if a plugin is modified within the PluginManager class itself, prefer using the internal static PluginModified(string id) method directly rather than going through API.PluginModified() for better performance and architectural design.
Applied to files:
Plugins/Flow.Launcher.Plugin.PluginIndicator/Main.csPlugins/Flow.Launcher.Plugin.Calculator/Main.csPlugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs
📚 Learning: 2025-09-06T05:32:51.575Z
Learnt from: Jack251970
PR: Flow-Launcher/Flow.Launcher#3573
File: Plugins/Flow.Launcher.Plugin.Shell/Main.cs:330-339
Timestamp: 2025-09-06T05:32:51.575Z
Learning: In Flow.Launcher Shell plugin's StartProcess method, the maintainer Jack251970 prefers not to propagate launch failures from Context.API.StartProcess or throw exceptions when the API call returns false. Silent failure handling is intentional for shell commands in this plugin.
Applied to files:
Plugins/Flow.Launcher.Plugin.Shell/Main.cs
📚 Learning: 2025-07-21T09:19:19.012Z
Learnt from: Jack251970
PR: Flow-Launcher/Flow.Launcher#3854
File: Flow.Launcher.Core/Plugin/PluginManager.cs:280-292
Timestamp: 2025-07-21T09:19:19.012Z
Learning: In Flow Launcher's PluginManager.cs, the post-initialization operations (RegisterResultsUpdatedEvent, UpdatePluginMetadataTranslation, RegisterPluginActionKeywords, DialogJump.InitializeDialogJumpPlugin, and AddPluginToLists) are designed to be exception-safe and do not require additional try-catch error handling according to the maintainer Jack251970.
Applied to files:
Plugins/Flow.Launcher.Plugin.Shell/Main.cs
📚 Learning: 2025-09-13T12:50:05.306Z
Learnt from: dcog989
PR: Flow-Launcher/Flow.Launcher#3971
File: Plugins/Flow.Launcher.Plugin.Calculator/Main.cs:67-67
Timestamp: 2025-09-13T12:50:05.306Z
Learning: NumberRegex pattern `-?[\d\.,]+` in Flow.Launcher Calculator will match function arguments like `2,3` in `min(2,3)`. The NormalizeNumber validation that checks for proper 3-digit thousand separator grouping is essential to avoid breaking function calls by incorrectly stripping commas from function arguments.
Applied to files:
Plugins/Flow.Launcher.Plugin.Calculator/Main.cs
🧬 Code graph analysis (5)
Plugins/Flow.Launcher.Plugin.Sys/Main.cs (4)
Flow.Launcher/PublicAPIInstance.cs (19)
System(159-222)List(251-251)List(530-530)LogError(282-283)GetTranslation(249-249)HideMainWindow(96-96)SaveAppAllSettings(108-117)ShowMsg(127-128)ShowMsg(130-133)RestartApp(77-90)OpenSettingDialog(143-149)CheckForNewUpdate(106-106)GetLogDirectory(622-622)OpenDirectory(330-410)OpenUrl(475-478)OpenUrl(480-483)GetDataDirectory(620-620)ToggleGameMode(495-498)ChangeQuery(72-75)Plugins/Flow.Launcher.Plugin.Sys/Settings.cs (2)
Settings(6-127)Settings(8-14)Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml.cs (2)
SysSettings(7-51)SysSettings(11-16)Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs (4)
List(11-26)Result(28-28)Result(30-87)ThemeSelector(7-88)
Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs (4)
Plugins/Flow.Launcher.Plugin.Sys/Main.cs (3)
List(66-110)List(196-513)Main(18-529)Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs (5)
List(177-177)List(445-445)ThemeData(451-451)SetCurrentTheme(460-460)ReQuery(399-399)Flow.Launcher.Core/Resource/Theme.cs (3)
List(396-409)ThemeData(333-365)ThemeData(385-394)Flow.Launcher.Plugin/SharedModels/ThemeData.cs (2)
ThemeData(8-77)ThemeData(33-39)
Plugins/Flow.Launcher.Plugin.Shell/Main.cs (3)
Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs (3)
List(24-24)List(26-72)List(74-86)Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs (2)
Result(28-28)Result(30-87)Plugins/Flow.Launcher.Plugin.Program/Programs/UWPPackage.cs (1)
Result(397-473)
Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs (1)
Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs (1)
Main(10-220)
Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs (6)
Plugins/Flow.Launcher.Plugin.ProcessKiller/Settings.cs (1)
Settings(3-8)Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs (4)
ProcessHelper(15-186)TryKill(145-159)GetProcessNameIdTitle(46-53)TryGetProcessFilename(161-185)Plugins/Flow.Launcher.Plugin.ProcessKiller/ViewModels/SettingsViewModel.cs (1)
SettingsViewModel(3-6)Plugins/Flow.Launcher.Plugin.Sys/Main.cs (2)
Init(134-144)GetTranslatedPluginDescription(520-523)Plugins/Flow.Launcher.Plugin.Calculator/Main.cs (2)
Init(34-47)GetTranslatedPluginDescription(417-420)Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessResult.cs (1)
ProcessResult(6-17)
🪛 GitHub Check: Check Spelling
Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs
[warning] 39-39:
processkiller is not a recognized word. (unrecognized-spelling)
[warning] 54-54:
processkiller is not a recognized word. (unrecognized-spelling)
[warning] 136-136:
processlist is not a recognized word. (unrecognized-spelling)
[warning] 198-198:
processkiller is not a recognized word. (unrecognized-spelling)
[warning] 197-197:
processkiller is not a recognized word. (unrecognized-spelling)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (14)
Plugins/Flow.Launcher.Plugin.Shell/ShellSetting.xaml.cs (2)
33-35: Null-safe check LGTMThe switch to
ShowOnlyMostUsedCMDs.IsChecked != trueis correct and clearer.
17-140: Guard against duplicate event subscriptions in LoadedLoaded can fire multiple times. Wrap handler wiring so it runs once to avoid stacked subscriptions.
Apply minimally:
public partial class CMDSetting : UserControl { private readonly Settings _settings; + private bool _eventsWired; @@ private void CMDSetting_OnLoaded(object sender, RoutedEventArgs re) { @@ - CloseShellAfterPress.Checked += (o, e) => - { - _settings.CloseShellAfterPress = true; - LeaveShellOpen.IsChecked = false; - LeaveShellOpen.IsEnabled = false; - }; + if (!_eventsWired) + { + CloseShellAfterPress.Checked += (o, e) => + { + _settings.CloseShellAfterPress = true; + LeaveShellOpen.IsChecked = false; + LeaveShellOpen.IsEnabled = false; + }; @@ - ShowOnlyMostUsedCMDsNumber.SelectionChanged += (o, e) => - { - _settings.ShowOnlyMostUsedCMDsNumber = (int)ShowOnlyMostUsedCMDsNumber.SelectedItem; - }; + ShowOnlyMostUsedCMDsNumber.SelectionChanged += (o, e) => + { + _settings.ShowOnlyMostUsedCMDsNumber = (int)ShowOnlyMostUsedCMDsNumber.SelectedItem; + }; + _eventsWired = true; + }Plugins/Flow.Launcher.Plugin.Shell/Settings.cs (4)
23-23: Modern collection expression LGTM
= [];is fine (C# 12).
27-31: TryAdd pattern LGTMClear and thread-safe enough for typical usage.
11-14: Consolidate opposing flags to a single source of truth
CloseShellAfterPressvsLeaveShellOpencan drift. Consider one field with an obsolete shim for back-compat.- public bool CloseShellAfterPress { get; set; } = false; - public bool LeaveShellOpen { get; set; } + public bool LeaveShellOpen { get; set; } + [System.Obsolete("Use LeaveShellOpen.", error: false)] + public bool CloseShellAfterPress + { + get => !LeaveShellOpen; + set => LeaveShellOpen = !value; + }
34-40: Brand casing: add PowerShell alias without breaking valuesKeep existing
Powershellfor compat; addPowerShell = Powershellalias.public enum Shell { Cmd = 0, - Powershell = 1, + Powershell = 1, + PowerShell = Powershell, RunCommand = 2, Pwsh = 3, }Plugins/Flow.Launcher.Plugin.Calculator/Main.cs (2)
29-29: Private setter for Context LGTMImproves encapsulation and prevents accidental reassignment.
239-241: Fix comment: log10 is base-10, not natural logUpdate the comment to avoid confusion.
- // log(x) -> log10(x) (natural log) + // log(x) -> log10(x) (base-10 log)Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs (1)
140-143: Guard empty paths and compare file paths case‑insensitively (Windows).Prevents accidental broad matches and aligns with OS semantics.
- public IEnumerable<Process> GetSimilarProcesses(string processPath) - { - return Process.GetProcesses().Where(p => !IsSystemProcessOrFlowLauncher(p) && TryGetProcessFilename(p) == processPath); - } + public IEnumerable<Process> GetSimilarProcesses(string processPath) + { + if (string.IsNullOrWhiteSpace(processPath)) + return Enumerable.Empty<Process>(); + + return Process.GetProcesses().Where(p => + !IsSystemProcessOrFlowLauncher(p) && + string.Equals(TryGetProcessFilename(p), processPath, StringComparison.OrdinalIgnoreCase)); + }Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs (2)
47-66: Don’t batch‑kill on empty path; materialize similar processes once.Avoids grouping unrelated items when SubTitle is empty and prevents double enumeration.
var menuOptions = new List<Result>(); var processPath = result.SubTitle; - // get all non-system processes whose file path matches that of the given result (processPath) - var similarProcesses = processHelper.GetSimilarProcesses(processPath); + if (string.IsNullOrWhiteSpace(processPath)) + return menuOptions; + + // get all non-system processes whose file path matches that of the given result (processPath) + var similarProcesses = processHelper.GetSimilarProcesses(processPath).ToList(); - if (similarProcesses.Any()) + if (similarProcesses.Count > 0) {
191-211: “Kill all” can appear without a valid path and target unrelated processes.Require non‑empty anchor path and use OrdinalIgnoreCase comparison.
- var firstResult = sortedResults.FirstOrDefault(x => !string.IsNullOrEmpty(x.SubTitle)); - if (processlist.Count > 1 && !string.IsNullOrEmpty(searchTerm) && sortedResults.All(r => r.SubTitle == firstResult?.SubTitle)) + var firstResult = sortedResults.FirstOrDefault(x => !string.IsNullOrEmpty(x.SubTitle)); + if (processlist.Count > 1 + && !string.IsNullOrEmpty(searchTerm) + && firstResult is not null + && !string.IsNullOrEmpty(firstResult.SubTitle) + && sortedResults.All(r => string.Equals(r.SubTitle, firstResult.SubTitle, StringComparison.OrdinalIgnoreCase))) {Plugins/Flow.Launcher.Plugin.Shell/Main.cs (1)
20-20: Initialize static Context to quiet nullability warnings.Matches pattern used elsewhere; avoids pre‑Init analyzer noise.
- internal static PluginInitContext Context { get; private set; } + internal static PluginInitContext Context { get; private set; } = null!;Plugins/Flow.Launcher.Plugin.PluginIndicator/Main.cs (2)
8-8: Initialize static Context to avoid nullability warnings.Consistent with other plugins.
- internal static PluginInitContext Context { get; private set; } + internal static PluginInitContext Context { get; private set; } = null!;
20-48: LGTM on localization and static Context usage.QueryResults pipeline and Localize.* integration look correct.
…#4009) * Use Flow.Launcher.Localization to improve code quality * Code cleanup * Improve code quality * Improve code quality * Use internal static Context & Improve code quality * Use Flow.Launcher.Localization to improve code quality * Code cleanup * Use Flow.Launcher.Localization to improve code quality * Improve code quality * Improve code quality * Use Flow.Launcher.Localization to improve code quality * Fix logic issue * Fix the variable name typo * Fix redundant boolean cast and ensure consistent default value handling * Use Flow.Launcher.Localization to improve code quality * Revert namespace styles * Fix indent format * Revert namespace style * Fix indent format * Fix namespace style * Fix indent format * Fix indent format
…Flow-Launcher#4009) * Use Flow.Launcher.Localization to improve code quality * Code cleanup * Improve code quality * Improve code quality * Use internal static Context & Improve code quality * Use Flow.Launcher.Localization to improve code quality * Code cleanup * Use Flow.Launcher.Localization to improve code quality * Improve code quality * Improve code quality * Use Flow.Launcher.Localization to improve code quality * Fix logic issue * Fix the variable name typo * Fix redundant boolean cast and ensure consistent default value handling * Use Flow.Launcher.Localization to improve code quality * Revert namespace styles * Fix indent format * Revert namespace style * Fix indent format * Fix namespace style * Fix indent format * Fix indent format
Code cleanup & Use
Flow.Launcher.Localizationto improve code qualityNo feature updates.