Skip to content

Conversation

Jack251970
Copy link
Member

@Jack251970 Jack251970 commented Apr 17, 2025

Fix Possible Window Popup During Startup

If FL enabled both logon task and registry, Hide Flow Launcher on startup will not work since the later one will trigger main window show event. So we need to check both because if both of them are enabled.

Follow on with #3218.

Fix Store Plugin List Refresh Issue

Use null as flag to return value so that we can handle plugin source issue.

Follow on with #3460.

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

gitstream-cm bot commented Apr 17, 2025

🚨 Warning: Approaching Monthly Automation Limit

Monthly PRs automated: 245/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.

Pull Request Overview

This PR fixes an issue with a potential window popup during startup when both logon task and registry methods are enabled, and it also resolves a plugin store list refresh issue by returning null as a failure flag.

  • Refactors auto-startup logic by replacing direct enable/disable calls with a side-effect method (CheckIsEnabled).
  • Removes unused logger imports from helper files.
  • Adjusts asynchronous plugin fetch logic to use null as a flag for failure.

Reviewed Changes

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

Show a summary per file
File Description
Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs Switches to new AutoStartup API calls for startup configuration.
Flow.Launcher/Helper/HotKeyMapper.cs Removes unused logger import to clean up dependencies.
Flow.Launcher/Helper/AutoStartup.cs Refactors startup check to a void method that performs enable/disable.
Flow.Launcher/App.xaml.cs Updates auto-startup logic to use the new CheckIsEnabled method.
Flow.Launcher.Core/ExternalPlugins/CommunityPluginStore.cs Modifies task result handling in plugin fetching logic.
Flow.Launcher.Core/ExternalPlugins/CommunityPluginSource.cs Returns null on failure to refresh plugin source as intended.
Comments suppressed due to low confidence (2)

Flow.Launcher/Helper/AutoStartup.cs:19

  • [nitpick] The method name 'CheckIsEnabled' suggests a boolean check, but it now performs enabling/disabling actions. Consider renaming it to better reflect its side-effect behavior, for example 'EnsureAutoStartupState'.
public static void CheckIsEnabled(bool useLogonTaskForStartup)

Flow.Launcher.Core/ExternalPlugins/CommunityPluginSource.cs:73

  • Ensure that all callers of FetchAsync are updated to handle a null return value, and add unit tests to verify proper handling of the plugin source failure scenario.
return null;

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.

Copy link

gitstream-cm bot commented Apr 17, 2025

🥷 Code experts: no user but you matched threshold 10

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

See details

Flow.Launcher.Core/ExternalPlugins/CommunityPluginSource.cs

Activity based on git-commit:

Jack251970 jjw24
APR 57 additions & 35 deletions
MAR
FEB
JAN
DEC
NOV

Knowledge based on git-blame:
Jack251970: 50%

Flow.Launcher.Core/ExternalPlugins/CommunityPluginStore.cs

Activity based on git-commit:

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

Knowledge based on git-blame:
Jack251970: 2%

Flow.Launcher/App.xaml.cs

Activity based on git-commit:

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

Knowledge based on git-blame:
Jack251970: 64%

Flow.Launcher/Helper/AutoStartup.cs

Activity based on git-commit:

Jack251970 jjw24
APR 8 additions & 6 deletions
MAR
FEB 36 additions & 8 deletions
JAN 112 additions & 8 deletions
DEC
NOV

Knowledge based on git-blame:
Jack251970: 74%
Yusyuriv: 15%

Flow.Launcher/Helper/HotKeyMapper.cs

Activity based on git-commit:

Jack251970 jjw24
APR 15 additions & 14 deletions
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: 34%
Jack251970: 12%

Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs

Activity based on git-commit:

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

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

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

Copy link

gitstream-cm bot commented Apr 17, 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 requested a review from onesounds April 17, 2025 23:21
@Jack251970 Jack251970 added Dev branch only An issue or fix for the Dev branch build and removed bug Something isn't working labels Apr 17, 2025
@Jack251970 Jack251970 added this to the 1.20.0 milestone Apr 17, 2025
@Jack251970
Copy link
Member Author

Tested and I think it is good to go.

Copy link
Contributor

coderabbitai bot commented Apr 17, 2025

📝 Walkthrough

Walkthrough

This set of changes refactors the application's auto-startup logic by consolidating the enabling and disabling mechanisms for starting the application on system startup. The AutoStartup class is overhauled, replacing separate methods for enabling via logon task or registry with a unified method that enforces the appropriate startup mechanism based on user settings. Several method calls and property checks throughout the codebase are updated to use this new approach. Additionally, minor adjustments are made to plugin fetching logic and code cleanliness, such as improved null handling and removal of unused imports.

Changes

File(s) Change Summary
Flow.Launcher.Core/ExternalPlugins/CommunityPluginSource.cs Modified FetchAsync to return null instead of the current plugins list on HTTP failure or exception. Reordered the ClassName field.
Flow.Launcher.Core/ExternalPlugins/CommunityPluginStore.cs Updated plugin fetching logic to only assign results and cancel other tasks if the completed fetch result is not null.
Flow.Launcher/App.xaml.cs Simplified the AutoStartup method to always call CheckIsEnabled based on settings, removing redundant state checks and consolidating enabling logic.
Flow.Launcher/Helper/AutoStartup.cs Major refactor: removed IsEnabled property and separate enabling methods; added CheckIsEnabled(bool) to enforce correct startup mode; added private CheckRegistry(); redefined DisableViaLogonTaskAndRegistry(); removed unused logger import.
Flow.Launcher/Helper/HotKeyMapper.cs Removed unused import for the logger.
Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs Replaced calls to old enabling methods with new ChangeToViaLogonTask() and ChangeToViaRegistry() methods in the startup setting property setter.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SettingsPaneGeneralViewModel
    participant AutoStartup
    participant SystemStartup

    User->>SettingsPaneGeneralViewModel: Enable/disable "Start on system startup"
    SettingsPaneGeneralViewModel->>AutoStartup: ChangeToViaLogonTask()/ChangeToViaRegistry()/DisableViaLogonTaskAndRegistry()
    AutoStartup->>SystemStartup: Enable/disable via logon task or registry as needed
Loading
sequenceDiagram
    participant App
    participant AutoStartup

    App->>AutoStartup: CheckIsEnabled(useLogonTaskForStartup)
    AutoStartup->>AutoStartup: Check and enforce correct startup mode (logon task or registry)
Loading

Possibly related PRs

  • Flow-Launcher/Flow.Launcher#3218: Introduced the methods for enabling/disabling startup via logon task or registry, which this PR now refactors and consolidates.

Suggested reviewers

  • jjw24
  • onesounds

Poem

A bunny hops through startup code,
Tidying up the launcher's load.
No more toggles, just one way—
To start at dawn or end the day.
With registry or logon task,
The rabbit makes your wishes last!
🐇✨


📜 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 a088e42 and dd61ab4.

📒 Files selected for processing (6)
  • Flow.Launcher.Core/ExternalPlugins/CommunityPluginSource.cs (3 hunks)
  • Flow.Launcher.Core/ExternalPlugins/CommunityPluginStore.cs (1 hunks)
  • Flow.Launcher/App.xaml.cs (1 hunks)
  • Flow.Launcher/Helper/AutoStartup.cs (2 hunks)
  • Flow.Launcher/Helper/HotKeyMapper.cs (0 hunks)
  • Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs (1 hunks)
💤 Files with no reviewable changes (1)
  • Flow.Launcher/Helper/HotKeyMapper.cs
🧰 Additional context used
🧬 Code Graph Analysis (1)
Flow.Launcher/App.xaml.cs (2)
Flow.Launcher.Infrastructure/Helper.cs (1)
  • Helper (7-31)
Flow.Launcher/Helper/AutoStartup.cs (2)
  • AutoStartup (11-205)
  • CheckIsEnabled (19-51)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream workflow automation
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
🔇 Additional comments (10)
Flow.Launcher.Core/ExternalPlugins/CommunityPluginStore.cs (1)

43-51: Improved null handling enhances plugin fetch reliability

This change adds proper null-check handling for plugin fetch results, which works in tandem with the changes made in CommunityPluginSource. Now, when a source returns null (indicating a fetch failure), the code will continue trying other sources instead of immediately canceling all remaining requests.

This is a good defensive programming practice that improves the reliability of plugin source fetching, especially in environments with unreliable connectivity or when primary sources are temporarily unavailable.

Flow.Launcher.Core/ExternalPlugins/CommunityPluginSource.cs (3)

19-20: Minor code organization improvement

Moving the static readonly field above the API property is a small but beneficial change for code organization and readability.


73-73: Appropriate error signaling with null return

Changing the return value from plugins to null in the error case is a better approach for signaling that the fetch operation failed. This allows the calling code in CommunityPluginStore to make informed decisions about continuing with other sources.


86-86: Consistent error handling with null return value

Similarly, returning null in the exception handling case provides a clear indication of failure. This is more appropriate than returning the potentially stale or incomplete plugins list, as it accurately represents that the current fetch attempt did not succeed.

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

51-51: Method name update improves intent clarity

The code now uses ChangeToViaLogonTask() instead of the previous EnableViaLogonTask(), which better communicates that this method both enables the logon task method and disables other startup methods.


55-55: Method name update improves intent clarity

Similar to the previous change, using ChangeToViaRegistry() instead of EnableViaRegistry() more accurately describes the behavior of the method, as it switches to registry-based startup while ensuring other startup methods are disabled.

Flow.Launcher/App.xaml.cs (1)

205-209: Simplified startup logic addresses window popup issue

The updated code now directly calls CheckIsEnabled(_settings.UseLogonTaskForStartup) rather than having separate conditional checks. This change supports the PR objective of fixing the window popup issue by ensuring only one startup method is active at a time.

Flow.Launcher/Helper/AutoStartup.cs (3)

19-51: Solid fix for window popup during startup

This implementation effectively addresses the issue where the main window would unexpectedly pop up when both startup methods were enabled. The new method CheckIsEnabled ensures only one startup method (either logon task or registry) is active at a time, preventing the conflicting behavior that was causing the window to show even when it should be hidden.

The comment on lines 21-22 clearly explains the root cause, which helps with maintainability.


80-94: Good separation of concerns with CheckRegistry method

The new private method encapsulates the registry checking logic, which improves code organization and maintainability. It properly handles potential exceptions and logs errors without disrupting the application flow.


96-100: Clean implementation of disable functionality

The updated DisableViaLogonTaskAndRegistry method now uses the internal Disable method for both startup mechanisms, creating a more consistent API and reducing code duplication.

✨ Finishing Touches
  • 📝 Generate Docstrings

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

@onesounds onesounds merged commit d30fdbb into dev Apr 18, 2025
16 checks passed
@onesounds onesounds deleted the startup_window_popup branch April 18, 2025 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Dev branch only An issue or fix for the Dev branch build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants