Skip to content

Conversation

Jack251970
Copy link
Member

Improve code quality

  • Remove obsoleted InternationalizationManager.Instance and use api function App.API.GetTranslation instead.
  • Remove Notification.Show and use api function App.API.ShowMsg instead.
  • Small fixes and improments.

@prlabeler prlabeler bot added the bug Something isn't working label Apr 9, 2025
Copy link

gitstream-cm bot commented Apr 9, 2025

🚨 Warning: Approaching Monthly Automation Limit

Monthly PRs automated: 227/250

Your organization has used over 90% of its monthly quota for gitStream automations. Once the quota is reached, new pull requests for this month will not trigger gitStream automations and will be marked as “Skipped”.

To avoid interruptions, consider optimizing your automation usage or upgrading your plan by contacting LinearB.

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.

Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (4)

Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs:20

  • [nitpick] Consider renaming '_translater' to '_translator' for clarity and consistency with common terminology.
private readonly Internationalization _translater;

Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs:21

  • [nitpick] Consider renaming '_translater' to '_translator' to use standard naming conventions.
private readonly Internationalization _translater = Ioc.Default.GetRequiredService<Internationalization>();

Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs:121

  • Review the decision to make _portableMode static; if multiple instances of SettingsPaneGeneralViewModel are created, this may lead to shared mutable state issues.
private static bool _portableMode = DataLocation.PortableDataLocationInUse();

Flow.Launcher/Plugin/PluginManager.cs:208

  • Ensure that 'ClassName' is defined and holds the correct class identifier; otherwise, reverting to nameof(PluginManager) might improve clarity and reliability in logging.
Log.Exception(ClassName, "Fail to Init plugin: {pair.Metadata.Name}", e);

Copy link

gitstream-cm bot commented Apr 9, 2025

🥷 Code experts: Yusyuriv

Jack251970, jjw24 have most 👩‍💻 activity in the files.
Jack251970, Yusyuriv have most 🧠 knowledge in the files.

See details

Flow.Launcher.Core/Plugin/PluginManager.cs

Activity based on git-commit:

Jack251970 jjw24
APR 33 additions & 41 deletions
MAR 42 additions & 37 deletions
FEB 276 additions & 198 deletions
JAN 5 additions & 5 deletions
DEC
NOV 1 additions & 1 deletions

Knowledge based on git-blame:
Jack251970: 23%
Yusyuriv: 2%

Flow.Launcher.Core/Updater.cs

Activity based on git-commit:

Jack251970 jjw24
APR 21 additions & 9 deletions
MAR
FEB 22 additions & 22 deletions
JAN 25 additions & 22 deletions
DEC
NOV 7 additions & 7 deletions

Knowledge based on git-blame:
Jack251970: 24%

Flow.Launcher/ActionKeywords.xaml.cs

Activity based on git-commit:

Jack251970 jjw24
APR
MAR
FEB 102 additions & 61 deletions
JAN 1 additions & 1 deletions
DEC
NOV 2 additions & 1 deletions

Knowledge based on git-blame:
Jack251970: 54%

Flow.Launcher/App.xaml.cs

Activity based on git-commit:

Jack251970 jjw24
APR 17 additions & 5 deletions
MAR 168 additions & 94 deletions
FEB 79 additions & 40 deletions
JAN 86 additions & 66 deletions
DEC
NOV

Knowledge based on git-blame:
Jack251970: 63%

Flow.Launcher/Converters/TextConverter.cs

Activity based on git-commit:

Jack251970 jjw24
APR
MAR
FEB
JAN
DEC
NOV

Knowledge based on git-blame:
Yusyuriv: 60%

Flow.Launcher/CustomQueryHotkeySetting.xaml.cs

Activity based on git-commit:

Jack251970 jjw24
APR
MAR
FEB 15 additions & 15 deletions
JAN 2 additions & 5 deletions
DEC
NOV 2 additions & 2 deletions

Knowledge based on git-blame:
Jack251970: 18%
Yusyuriv: 9%

Flow.Launcher/CustomShortcutSetting.xaml.cs

Activity based on git-commit:

Jack251970 jjw24
APR
MAR
FEB 8 additions & 9 deletions
JAN 2 additions & 2 deletions
DEC
NOV 3 additions & 2 deletions

Knowledge based on git-blame:
Yusyuriv: 14%
Jack251970: 6%

Flow.Launcher/Helper/HotKeyMapper.cs

Activity based on git-commit:

Jack251970 jjw24
APR
MAR
FEB 4 additions & 5 deletions 84 additions & 22 deletions
JAN 1 additions & 1 deletions
DEC
NOV 2 additions & 2 deletions

Knowledge based on git-blame:
Yusyuriv: 36%
Jack251970: 3%

Flow.Launcher/HotkeyControl.xaml.cs

Activity based on git-commit:

Jack251970 jjw24
APR
MAR 150 additions & 37 deletions 2 additions & 2 deletions
FEB 10 additions & 1 deletions
JAN
DEC
NOV

Knowledge based on git-blame:
Jack251970: 42%
Yusyuriv: 16%

Flow.Launcher/HotkeyControlDialog.xaml.cs

Activity based on git-commit:

Jack251970 jjw24
APR
MAR 4 additions & 3 deletions
FEB 27 additions & 2 deletions
JAN
DEC
NOV

Knowledge based on git-blame:
Yusyuriv: 78%
Jack251970: 2%

Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs

Activity based on git-commit:

Jack251970 jjw24
APR
MAR 8 additions & 7 deletions
FEB
JAN
DEC
NOV

Knowledge based on git-blame:
Jack251970: 20%

Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs

Activity based on git-commit:

Jack251970 jjw24
APR 24 additions & 10 deletions
MAR 77 additions & 55 deletions
FEB 17 additions & 8 deletions
JAN 33 additions & 3 deletions
DEC
NOV

Knowledge based on git-blame:
Yusyuriv: 78%
Jack251970: 19%

Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs

Activity based on git-commit:

Jack251970 jjw24
APR
MAR
FEB
JAN 8 additions & 9 deletions
DEC
NOV 12 additions & 11 deletions

Knowledge based on git-blame:
Yusyuriv: 93%
Jack251970: 7%

Flow.Launcher/SettingPages/ViewModels/SettingsPaneProxyViewModel.cs

Activity based on git-commit:

Jack251970 jjw24
APR
MAR
FEB
JAN 1 additions & 1 deletions
DEC
NOV 1 additions & 2 deletions

Knowledge based on git-blame:
Yusyuriv: 98%
Jack251970: 2%

Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml.cs

Activity based on git-commit:

Jack251970 jjw24
APR
MAR 7 additions & 4 deletions
FEB
JAN
DEC
NOV

Knowledge based on git-blame:
Yusyuriv: 41%
Jack251970: 26%

Flow.Launcher/ViewModel/MainViewModel.cs

Activity based on git-commit:

Jack251970 jjw24
APR 2 additions & 10 deletions
MAR 695 additions & 628 deletions
FEB 63 additions & 21 deletions
JAN 17 additions & 21 deletions
DEC 59 additions & 63 deletions
NOV 39 additions & 15 deletions

Knowledge based on git-blame:
Jack251970: 29%
Yusyuriv: 3%

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

This comment has been minimized.

Copy link

gitstream-cm bot commented Apr 9, 2025

Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX.

@Jack251970 Jack251970 added Code Quality and removed bug Something isn't working labels Apr 9, 2025
@Jack251970 Jack251970 requested a review from Copilot April 9, 2025 13:27
Copy link
Contributor

coderabbitai bot commented Apr 9, 2025

📝 Walkthrough

Walkthrough

This set of changes standardizes logging and translation retrieval across multiple components. Modifications include variable renaming, removal of an obsolete class, and method signature updates to utilize dependency injection and centralized App.API calls. Unused namespaces are removed and asynchronous operations are introduced for hotkey dialog handling. Overall, the control flow remains largely intact while the refactoring improves consistency and streamlines internationalization and user feedback methods.

Changes

Files Change Summary
Flow.Launcher.Core/Plugin/PluginManager.cs Logging statement in InitializePluginsAsync now uses a private static variable (ClassName) instead of nameof(PluginManager).
Flow.Launcher.Core/Resource/InternationalizationManager.cs The obsolete InternationalizationManager class has been removed; translation access now relies on dependency injection.
Flow.Launcher.Core/Updater.cs Removed unused using directives; JSON deserialization simplified; NewVersionTips changed from static to instance and now uses _api.GetTranslation.
Flow.Launcher/ActionKeywords.xaml.cs Private fields renamed (plugin_plugin, pluginViewModel_pluginViewModel); translation calls updated to use App.API.GetTranslation.
Flow.Launcher/App.xaml.cs In OnSecondAppStarted, replaced retrieval of MainViewModel with a direct call to App.API.ShowMainWindow.
Several files in Flow.Launcher (e.g., Converters/TextConverter.cs, CustomQueryHotkeySetting.xaml.cs, CustomShortcutSetting.xaml.cs, Helper/HotKeyMapper.cs) Replaced calls to InternationalizationManager.Instance.GetTranslation with App.API.GetTranslation; cleaned up unused directives; adjusted UI display calls (e.g., ShowMainWindow).
Flow.Launcher/HotkeyControl.xaml.cs and Flow.Launcher/HotkeyControlDialog.xaml.cs Updated translation handling to use App.API.GetTranslation, renamed OpenHotkeyDialog to OpenHotkeyDialogAsync, and improved hotkey variable initialization and error handling.
Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs Changed internationalization access from singleton to dependency injection via Ioc.Default.GetRequiredService<Internationalization>().
Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs, SettingsPaneHotkeyViewModel.cs, SettingsPaneProxyViewModel.cs, and SettingPages/Views/SettingsPaneGeneral.xaml.cs Constructor and method signature updates to include an Internationalization dependency; error notifications now use App.API.ShowMsg with translations from App.API.GetTranslation; some methods refactored (e.g., GetFileFromDialog made static).
Flow.Launcher/ViewModel/MainViewModel.cs Removed an unused import and updated the success message display from Notification.Show to App.API.ShowMsg.

Sequence Diagram(s)

sequenceDiagram
  participant U as User
  participant HC as HotkeyControl
  participant HCD as HotkeyControlDialog
  participant API as App.API
  participant HM as HotKeyMapper

  U->>HC: Click "Set Hotkey"
  HC->>API: Retrieve translation ("none")
  HC->>HCD: OpenHotkeyDialogAsync()
  HCD-->>HC: Return selected hotkey
  HC->>HM: SetHotkey(selectedHotkey)
  HM->>API: Retrieve translations for feedback
  HM-->>HC: Return success or error status
  HC->>U: Display confirmation message
Loading

Possibly related PRs

Suggested labels

Documentation, Dev branch only

Suggested reviewers

  • taooceros

Poem

I'm a little rabbit in the code wood,
Hopping over changes, feeling good.
Logging refined and translations aligned,
Async dialogs keep the user defined.
With each small tweak, I cheer in delight! 🐇🌟


📜 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 5097054 and f476998.

📒 Files selected for processing (1)
  • Flow.Launcher/Helper/HotKeyMapper.cs (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Flow.Launcher/Helper/HotKeyMapper.cs
⏰ 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

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.

❤️ 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.Core/Plugin/PluginManager.cs (1)

207-211: Enhanced Exception Logging in Plugin Initialization
The update now leverages the centralized ClassName constant in the exception logging call (line 208), ensuring that all log messages consistently reference the class name without relying on inline usage of nameof(PluginManager). This standardization helps maintain uniform logging practices across the codebase. Optionally, consider including additional contextual information—such as the plugin ID—for deeper diagnostic insights in production environments.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2e740b1 and 5097054.

📒 Files selected for processing (17)
  • Flow.Launcher.Core/Plugin/PluginManager.cs (1 hunks)
  • Flow.Launcher.Core/Resource/InternationalizationManager.cs (0 hunks)
  • Flow.Launcher.Core/Updater.cs (2 hunks)
  • Flow.Launcher/ActionKeywords.xaml.cs (5 hunks)
  • Flow.Launcher/App.xaml.cs (1 hunks)
  • Flow.Launcher/Converters/TextConverter.cs (1 hunks)
  • Flow.Launcher/CustomQueryHotkeySetting.xaml.cs (2 hunks)
  • Flow.Launcher/CustomShortcutSetting.xaml.cs (2 hunks)
  • Flow.Launcher/Helper/HotKeyMapper.cs (4 hunks)
  • Flow.Launcher/HotkeyControl.xaml.cs (2 hunks)
  • Flow.Launcher/HotkeyControlDialog.xaml.cs (4 hunks)
  • Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs (2 hunks)
  • Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs (8 hunks)
  • Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs (4 hunks)
  • Flow.Launcher/SettingPages/ViewModels/SettingsPaneProxyViewModel.cs (1 hunks)
  • Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml.cs (2 hunks)
  • Flow.Launcher/ViewModel/MainViewModel.cs (1 hunks)
💤 Files with no reviewable changes (1)
  • Flow.Launcher.Core/Resource/InternationalizationManager.cs
🧰 Additional context used
🧬 Code Graph Analysis (10)
Flow.Launcher/App.xaml.cs (1)
Flow.Launcher/PublicAPIInstance.cs (1)
  • ShowMainWindow (91-91)
Flow.Launcher/Helper/HotKeyMapper.cs (1)
Flow.Launcher/App.xaml.cs (2)
  • App (27-350)
  • App (51-115)
Flow.Launcher/CustomQueryHotkeySetting.xaml.cs (2)
Flow.Launcher/App.xaml.cs (2)
  • App (27-350)
  • App (51-115)
Flow.Launcher/PublicAPIInstance.cs (1)
  • GetTranslation (181-181)
Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml.cs (1)
Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs (2)
  • SettingsPaneGeneralViewModel (15-270)
  • SettingsPaneGeneralViewModel (22-29)
Flow.Launcher.Core/Updater.cs (2)
Flow.Launcher/PublicAPIInstance.cs (1)
  • GetTranslation (181-181)
Flow.Launcher.Core/Resource/Internationalization.cs (1)
  • GetTranslation (242-254)
Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs (1)
Flow.Launcher.Core/Resource/Internationalization.cs (2)
  • ChangeLanguage (125-145)
  • PromptShouldUsePinyin (180-198)
Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs (2)
Flow.Launcher/App.xaml.cs (2)
  • App (27-350)
  • App (51-115)
Flow.Launcher/PublicAPIInstance.cs (1)
  • GetTranslation (181-181)
Flow.Launcher/HotkeyControlDialog.xaml.cs (1)
Flow.Launcher/Helper/HotKeyMapper.cs (1)
  • RemoveHotkey (90-113)
Flow.Launcher/ViewModel/MainViewModel.cs (4)
Flow.Launcher/App.xaml.cs (2)
  • App (27-350)
  • App (51-115)
Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs (3)
  • ShowMsg (114-114)
  • ShowMsg (123-123)
  • GetTranslation (136-136)
Flow.Launcher/PublicAPIInstance.cs (3)
  • ShowMsg (122-123)
  • ShowMsg (125-128)
  • GetTranslation (181-181)
Flow.Launcher.Core/Plugin/JsonRPCV2Models/JsonRPCPublicAPI.cs (3)
  • ShowMsg (82-85)
  • ShowMsg (87-90)
  • GetTranslation (97-100)
Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs (3)
Flow.Launcher/PublicAPIInstance.cs (5)
  • ShowMsg (122-123)
  • ShowMsg (125-128)
  • GetTranslation (181-181)
  • List (183-183)
  • List (367-367)
Flow.Launcher.Infrastructure/UserSettings/DataLocation.cs (2)
  • DataLocation (6-43)
  • PortableDataLocationInUse (20-26)
Flow.Launcher/SettingPages/ViewModels/DropdownDataGeneric.cs (1)
  • List (13-26)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
🔇 Additional comments (56)
Flow.Launcher/App.xaml.cs (1)

345-347: Good approach standardizing window display through the API

Replacing direct view model access with API.ShowMainWindow() centralizes UI operations and creates a more consistent codebase. The implementation in PublicAPIInstance.cs shows this is a direct wrapper around _mainVM.Show(), making this refactoring both cleaner and functionally equivalent.

Flow.Launcher/Converters/TextConverter.cs (1)

25-25: Consistent usage of centralized translation API

Replacing direct calls to InternationalizationManager.Instance.GetTranslation with App.API.GetTranslation improves codebase consistency and aligns with the PR objectives to standardize internationalization access.

Flow.Launcher/Helper/HotKeyMapper.cs (4)

58-60: Good standardization of translation retrieval

Replacing direct usage of InternationalizationManager.Instance with App.API.GetTranslation improves consistency across the codebase.


84-87: Consistent error handling with centralized API

Using App.API.GetTranslation for error messages and App.API.ShowMsgBox for displaying them creates a more consistent approach to internationalization and user feedback.


109-112: Standardized translation retrieval

Replacing direct usage of InternationalizationManager.Instance with App.API.GetTranslation maintains consistency with the rest of the codebase changes.


139-141: UI interaction standardization

Using App.API.ShowMainWindow() instead of directly calling _mainViewModel.Show() centralizes window management through the API, consistent with changes in other files.

Flow.Launcher/ActionKeywords.xaml.cs (9)

11-13: Improved private field naming convention

Renaming private fields to follow C# naming conventions (prefixed with underscore) improves code readability and maintainability.


17-19: Consistent field naming applied to constructor

The constructor properly assigns values to the renamed private fields, maintaining functionality while improving code style.


23-23: Updated field reference in method implementation

The method correctly uses the renamed _plugin field, ensuring consistent functionality after the refactoring.


34-35: Updated field reference in button click handler

The method correctly uses the renamed _plugin field, ensuring consistent functionality after the refactoring.


48-50: Updated field reference when replacing action keywords

The method correctly uses the renamed _plugin field for accessing metadata ID, maintaining functionality after refactoring.


58-59: Standardized translation and message display

Using App.API.ShowMsgBox and App.API.GetTranslation centralizes UI feedback and internationalization, consistent with the project's refactoring goals.


62-63: Updated field reference in conditional branch

The method correctly uses the renamed _plugin field for the metadata ID in the alternative execution path.


67-68: Consistent API usage for user feedback

Using App.API.ShowMsgBox with App.API.GetTranslation for displaying localized messages follows the standardized approach applied throughout the codebase.


83-84: Updated field reference when updating view model

The method correctly uses the renamed _pluginViewModel field when calling OnActionKeywordsChanged(), completing the consistent renaming throughout the class.

Flow.Launcher.Core/Updater.cs (2)

132-132: Clean code improvement: Simplified namespace usage

The removal of the explicit namespace prefix System.Text.Json. is a good simplification since the namespace is already imported at the top of the file.


147-149: Good refactoring: Improved dependency management

Changing from a static method to an instance method and using the injected _api instead of InternationalizationManager.Instance improves testability and aligns with dependency injection principles.

Flow.Launcher/SettingPages/ViewModels/SettingsPaneProxyViewModel.cs (1)

24-24: Good refactoring: Standardized translation and notification handling

Using App.API.ShowMsgBox and App.API.GetTranslation instead of the previous implementation centralizes these operations through the application API, making the code more consistent and maintainable.

Flow.Launcher/CustomShortcutSetting.xaml.cs (3)

42-42: Style improvement: Using lowercase string keyword

Using lowercase string instead of String follows C# coding conventions.


44-44: Good refactoring: Standardized translation and notification handling

Using App.API.ShowMsgBox and App.API.GetTranslation centralizes message display and translation handling, improving consistency across the application.


50-50: Good refactoring: Standardized translation and notification handling

Using App.API.ShowMsgBox and App.API.GetTranslation centralizes message display and translation handling, consistent with other similar changes in this PR.

Flow.Launcher/CustomQueryHotkeySetting.xaml.cs (3)

1-1: Clean code improvement: Removed unused import

Removed the import for Flow.Launcher.Core.Resource which is no longer needed after the refactoring.


61-61: Good refactoring: Standardized translation and notification handling

Using App.API.ShowMsgBox and App.API.GetTranslation centralizes message display and translation handling, improving consistency across the application.


69-69: Good refactoring: Standardized translation handling

Using App.API.GetTranslation for retrieving translations is consistent with the PR's goal of standardizing internationalization across the application.

Flow.Launcher/HotkeyControlDialog.xaml.cs (6)

36-36: Translation retrieval now uses App.API

The code now uses the centralized App.API for translation retrieval instead of the obsolete InternationalizationManager.Instance.


44-44: Translation consistency maintained for window title

The code correctly uses the centralized App.API for the window title translation.


142-144: Consistent translation strategy for hotkey descriptions

The translation for registered hotkey descriptions now uses App.API, maintaining consistent translation retrieval throughout the codebase.


149-151: Editable hotkey message uses centralized translation

Translation for editable hotkey message now correctly uses the centralized App.API.


161-163: Uneditable hotkey message uses centralized translation

Translation for uneditable hotkey message now correctly uses the centralized App.API.


178-178: Unavailable hotkey message uses centralized translation

Translation for unavailable hotkey message now correctly uses the centralized App.API.

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

276-278: Notification display uses App.API now

The code now uses App.API.ShowMsg instead of Notification.Show, aligning with the PR objectives to standardize user message display through a centralized API.

Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml.cs (2)

5-5: Added Resource namespace import

Added import for Flow.Launcher.Core.Resource to access the Internationalization service.


22-23: Dependency injection for Internationalization

The code now correctly retrieves the Internationalization service through dependency injection and passes it to the ViewModel, enabling proper translation support without relying on singleton access.

Flow.Launcher/HotkeyControl.xaml.cs (4)

227-227: Translation retrieval now uses App.API

The EmptyHotkey property now uses the centralized App.API for translation retrieval instead of InternationalizationManager.Instance.


233-236: Improved asynchronous handling

The dialog opening method is now asynchronous, and the call uses proper async pattern with task discarding to prevent compiler warnings.


238-238: Method made asynchronous

The OpenHotkeyDialog method has been renamed to OpenHotkeyDialogAsync and now properly returns a Task, improving asynchronous behavior.


265-265: Variable initialization improved

Removed unnecessary initialization of hotkeyAvailable variable since it's properly assigned in all code paths before use.

Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs (6)

43-43: Good refactoring to use the new translation API.
This replacement ensures consistency with the new approach (App.API.ShowMsgBox(...)). No issues identified.


68-68: Consistent message box usage.
This change simplifies the code and clearly shows the translation usage. Looks good.


89-89: Consistent message box usage for shortcut selection.
Well-aligned with the new approach. No concerns here.


113-113: Appropriate translation-based prompt for item selection.
No issues found.


95-97:

✅ Verification successful

Ensure matching placeholder for shortcut keys.
Like the hotkey warning, confirm that the resource string deleteCustomShortcutWarning has placeholders to insert item.Key and item.Value correctly.


🏁 Script executed:

#!/bin/bash
# Description: Verify placeholders in resource files for deleteCustomShortcutWarning
rg "deleteCustomShortcutWarning"

Length of output: 4353


Verified: Correct Placeholders for Shortcut Keys

The resource string deleteCustomShortcutWarning in all language files has been confirmed to include the correct placeholders ({0} and {1}) matching item.Key and item.Value. No changes are needed in this section of the code.

  • Confirmed usage in Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs correctly passes the parameters.
  • All translations (e.g., in Flow.Launcher/Languages/*.xaml) display the two required placeholders.

49-51:

✅ Verification successful

String formatting check.
Verify the corresponding resource string (deleteCustomHotkeyWarning) has the appropriate placeholder to accommodate item.Hotkey. Otherwise, the message might end up partially displayed or missing the dynamic component.


🏁 Script executed:

#!/bin/bash
# Description: Verify placeholders in resource files for deleteCustomHotkeyWarning
rg "deleteCustomHotkeyWarning"

Length of output: 4291


String Formatting Verification Confirmed

The resource string deleteCustomHotkeyWarning consistently uses the {0} placeholder across all translations (including the English version: "Are you sure you want to delete {0} plugin hotkey?"). This confirms that item.Hotkey will be correctly interpolated at runtime, and there’s no risk of the dynamic component being omitted or improperly displayed.

Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs (2)

21-22: Dependency injection usage.
Replacing the static call with Ioc.Default.GetRequiredService<Internationalization>() improves testability and decouples from a singleton pattern. Good change.


35-37: Refactored to use injected internationalization.
Leveraging _translater.ChangeLanguage(value) and _translater.PromptShouldUsePinyin(value) aligns with the new injection approach. No issues found.

Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs (11)

20-20: New private field declared for dependency injection.
Adopting _translater as a readonly field fosters better testability than referencing a static manager.


22-27: Constructor injection improvement.
Introducing Internationalization translater aligns with the broader removal of InternationalizationManager. Great for maintainability.


63-63: Consistent error messaging approach.
Using App.API.ShowMsg plus a translated string provides uniform user feedback.


90-90: Uniform error handling method.
Again, good shift to App.API.ShowMsg, ensuring standardized error messages.


121-121: Static field for portable mode.
This field is now static, which can be fine if concurrency is not a concern. Verify that it’s not mutated concurrently from different threads.


173-175: Injected language change logic.
Using _translater.ChangeLanguage(value) and _translater.PromptShouldUsePinyin(value) keeps the code consistent with the new design. No immediate issues.


188-188: Load languages from injected translater.
Dependence on _translater instead of a global manager is a welcome change, aligning with the new architecture.


191-191: Retrieving translation for tooltips.
Switch to App.API.GetTranslation("AlwaysPreviewToolTip") is consistent. Looks correct.


195-195: Method now static.
This method becoming static is a small but neat refactor for globally reusable utility logic.


237-237:

✅ Verification successful

Use new translation key for Python selection dialog.
The approach is consistent; just verify that "selectPythonExecutable" exists in resources.


🏁 Script executed:

#!/bin/bash
rg "selectPythonExecutable"

Length of output: 3294


Translation key "selectPythonExecutable" verified across resource files
The key is present in all language files, and its usage in SettingsPaneGeneralViewModel.cs (line 237) is consistent with our updated approach.


249-249:

✅ Verification successful

Use new translation key for Node selection dialog.
Matches the established pattern. Confirm that "selectNodeExecutable" exists in resources.


🏁 Script executed:

#!/bin/bash
rg "selectNodeExecutable"

Length of output: 3478


Translation key confirmed across resources.
I've verified that "selectNodeExecutable" exists in multiple language resource files and the usage in Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs follows the established pattern. No further changes are required.

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.

Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs:121

  • Changing _portableMode to static may lead to unintended shared state issues if instances of SettingsPaneGeneralViewModel are expected to maintain separate states. Please verify that this change is intentional.
private static bool _portableMode = DataLocation.PortableDataLocationInUse();

Flow.Launcher/HotkeyControl.xaml.cs:265

  • The variable 'hotkeyAvailable' is declared without an initial value, which may lead to unpredictable behavior. Consider initializing it (e.g., to false) to ensure consistent logic.
bool hotkeyAvailable;

Copy link

github-actions bot commented Apr 9, 2025

@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 enabled auto-merge April 9, 2025 13:30
@Jack251970 Jack251970 requested a review from onesounds April 9, 2025 13:36
@Jack251970
Copy link
Member Author

I think it is good to go since it does not change any data models.

@Jack251970 Jack251970 merged commit 0444141 into dev Apr 9, 2025
13 checks passed
@Jack251970 Jack251970 deleted the dependency_code_quality_1 branch April 9, 2025 13:55
@Jack251970 Jack251970 added this to the 1.20.0 milestone Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Code Quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants