Skip to content

Conversation

Jack251970
Copy link
Member

@Jack251970 Jack251970 commented Jun 7, 2025

Display notify icon before loading plugins to tell users that Flow is loading.

If plugin initialization causes much time, it could be helpful for users to know Flow has started already

Copy link

gitstream-cm bot commented Jun 7, 2025

🥷 Code experts: onesounds

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

See details

Flow.Launcher/App.xaml.cs

Activity based on git-commit:

Jack251970 onesounds
JUN
MAY 13 additions & 4 deletions
APR 73 additions & 40 deletions 3 additions & 0 deletions
MAR 168 additions & 94 deletions
FEB 79 additions & 40 deletions
JAN 86 additions & 66 deletions

Knowledge based on git-blame:
Jack251970: 67%

Flow.Launcher/MainWindow.xaml.cs

Activity based on git-commit:

Jack251970 onesounds
JUN 65 additions & 67 deletions 85 additions & 15 deletions
MAY 140 additions & 43 deletions 5 additions & 1 deletions
APR 69 additions & 45 deletions 5 additions & 1 deletions
MAR 1141 additions & 1076 deletions 327 additions & 141 deletions
FEB 1 additions & 1 deletions 8 additions & 4 deletions
JAN

Knowledge based on git-blame:
Jack251970: 67%

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

Copy link

gitstream-cm bot commented Jun 7, 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 the enhancement New feature or request label Jun 7, 2025

This comment has been minimized.

Copy link
Contributor

coderabbitai bot commented Jun 7, 2025

Warning

Rate limit exceeded

@Jack251970 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 13 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between da88fa4 and 736d96e.

📒 Files selected for processing (1)
  • Flow.Launcher/App.xaml.cs (5 hunks)
📝 Walkthrough

Walkthrough

The changes refactor the management of the application's system tray notify icon by moving its instantiation and configuration from the MainWindow class to a new static property in the App class. All notify icon references in MainWindow are updated to use this centralized static instance.

Changes

File(s) Change Summary
Flow.Launcher/App.xaml.cs Added static NotifyIcon property and InitializeNotifyIcon method; moved notify icon setup here.
Flow.Launcher/MainWindow.xaml.cs Removed instance _notifyIcon field; updated to use App.NotifyIcon; made _contextMenu static.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant MainWindow

    User->>App: Start application
    App->>App: InitializeNotifyIcon()
    App->>App: Set NotifyIcon properties and show icon
    App->>MainWindow: Create MainWindow
    MainWindow->>App: Use App.NotifyIcon for event handling and context menu
Loading

Suggested labels

Dev branch only

Suggested reviewers

  • jjw24
  • onesounds

Poem

In the tray a new icon glows,
Centralized where logic flows.
No more scattered, no more stray,
One static spot to rule the tray.
Rabbits cheer and hop with glee—
Refactored code for all to see!
🐇✨

✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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: 3

🔭 Outside diff range comments (1)
Flow.Launcher/MainWindow.xaml.cs (1)

664-684: 🛠️ Refactor suggestion

Add null check before attaching event handlers.

The method assumes App.NotifyIcon exists, but it could be null if initialization failed in the App class.

 private void InitializeNotifyIcon()
 {
+    if (App.NotifyIcon == null)
+    {
+        App.API.LogWarn(nameof(MainWindow), "App.NotifyIcon is null, cannot attach event handlers");
+        return;
+    }
+
     App.NotifyIcon.MouseClick += (o, e) =>
     {
         // ... existing event handler code
     };
 }
🧹 Nitpick comments (1)
Flow.Launcher/App.xaml.cs (1)

159-167: Consider adding error handling for NotifyIcon creation.

The initialization logic is correct, but consider adding try-catch around NotifyIcon creation to handle potential failures gracefully.

 private void InitializeNotifyIcon()
 {
+    try
+    {
     NotifyIcon = new NotifyIcon
     {
         Text = Constant.FlowLauncherFullName,
         Icon = Constant.Version == "1.0.0" ? Launcher.Properties.Resources.dev : Launcher.Properties.Resources.app,
         Visible = !_settings.HideNotifyIcon
     };
+    }
+    catch (Exception ex)
+    {
+        API.LogException(ClassName, "Failed to initialize notify icon", ex);
+        // NotifyIcon will remain null, which should be handled elsewhere
+    }
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2a4b4de and 25c56f9.

📒 Files selected for processing (2)
  • Flow.Launcher/App.xaml.cs (4 hunks)
  • Flow.Launcher/MainWindow.xaml.cs (6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Report (PR)
  • GitHub Check: gitStream.cm
  • GitHub Check: build
🔇 Additional comments (5)
Flow.Launcher/App.xaml.cs (3)

27-27: LGTM! Good namespace alias practice.

Using an alias for System.Windows.Forms.NotifyIcon prevents potential namespace conflicts and makes the code more readable.


36-36: Good centralization approach.

The static property properly encapsulates the NotifyIcon instance and aligns with the PR objective of centralizing notify icon management.


199-200: Perfect implementation of the PR objective!

Displaying the notify icon before plugin loading directly addresses the user need to see that Flow Launcher is starting up. The timing and comment are excellent.

Flow.Launcher/MainWindow.xaml.cs (2)

1316-1316:

✅ Verification successful

Verify static NotifyIcon usage across the codebase.

The shift to static NotifyIcon management needs verification to ensure no other parts of the codebase are affected.


🏁 Script executed:

#!/bin/bash
# Check for any remaining _notifyIcon references that might have been missed
rg "_notifyIcon" --type cs

# Check for other NotifyIcon instantiations that might conflict
rg "new.*NotifyIcon" --type cs

# Check for other MainWindow dispose patterns
rg -A 10 -B 5 "\.Dispose\(\)" Flow.Launcher/MainWindow.xaml.cs

# Verify App.Dispose method handles NotifyIcon disposal
rg -A 15 -B 5 "protected virtual void Dispose" Flow.Launcher/App.xaml.cs

Length of output: 1987


Static NotifyIcon usage verified

– Searched for any private _notifyIcon references: none found.
– Only new NotifyIcon instantiation is in Flow.Launcher/App.xaml.cs.
– Disposal of App.NotifyIcon only occurs in MainWindow.Dispose(); there are no conflicting disposals in App.Dispose().

No further changes required.


50-50:

✅ Verification successful

Verify implications of static context menu.

Changing _contextMenu to static means all MainWindow instances share the same context menu. Ensure this doesn't cause issues with multiple windows or state persistence.


🏁 Script executed:

#!/bin/bash
# Search for other MainWindow instantiations or context menu usage patterns
rg -A 5 "new MainWindow|MainWindow.*=" 
rg -A 3 "_contextMenu\.|contextMenu\." --type cs

Length of output: 13487


🏁 Script executed:

#!/bin/bash
# Display the top of MainWindow.xaml.cs to inspect contextMenu declaration and constructor
sed -n '1,200p' Flow.Launcher/MainWindow.xaml.cs

Length of output: 6853


🏁 Script executed:

#!/bin/bash
# Locate and display the InitializeContextMenu method implementation
grep -R "InitializeContextMenu" -n Flow.Launcher/MainWindow.xaml.cs | head -n 5

Length of output: 222


🏁 Script executed:

#!/bin/bash
# Extract the InitializeContextMenu method implementation
sed -n '690,800p' Flow.Launcher/MainWindow.xaml.cs

Length of output: 4804


No issues with the static ContextMenu usage

Only one MainWindow instance is ever created (in App.xaml.cs), and the static _contextMenu is always re-initialized via InitializeContextMenu() on load or translation updates. All access occurs on the UI thread, so there are no threading or shared-state concerns. The change is safe as is.

@Jack251970 Jack251970 changed the title Display notify icon before loading plugins to tell users that Flow is loading Display notify icon before loading plugins Jun 7, 2025
@Jack251970 Jack251970 added this to the 1.20.1 milestone Jun 7, 2025

This comment has been minimized.

@Jack251970 Jack251970 requested review from Copilot and onesounds June 9, 2025 13:33
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 surfaces the tray icon earlier in the startup sequence so users immediately see that Flow is launching plugins.

  • Move NotifyIcon creation from MainWindow to App initialization
  • Update MainWindow to reference App.NotifyIcon for icon updates and click handling
  • Shift disposal of the notify icon into App.Dispose

Reviewed Changes

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

File Description
Flow.Launcher/MainWindow.xaml.cs Remove instance NotifyIcon, reference App.NotifyIcon, make context menu static
Flow.Launcher/App.xaml.cs Add static NotifyIcon property, initialize early in Main, dispose in App
Comments suppressed due to low confidence (1)

Flow.Launcher/MainWindow.xaml.cs:50

  • [nitpick] Making the window context menu static could introduce shared state if multiple windows are ever created; consider reverting to an instance field or documenting why it must be static.
private static readonly ContextMenu _contextMenu = new();

@Jack251970 Jack251970 enabled auto-merge June 10, 2025 03:52
@Jack251970 Jack251970 disabled auto-merge June 10, 2025 04:15
@Jack251970 Jack251970 modified the milestones: 1.20.1, Future, 2.0.0 Jun 10, 2025
NotifyIcon = new NotifyIcon
{
Text = Constant.FlowLauncherFullName,
Icon = Constant.Version == "1.0.0" ? Launcher.Properties.Resources.dev : Launcher.Properties.Resources.app,
Copy link
Member

Choose a reason for hiding this comment

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

Is there a way to not have this hardcoded? I am wary when moving to v2.0.0+ we need to bump this dev version too.

Copy link
Member Author

@Jack251970 Jack251970 Jun 16, 2025

Choose a reason for hiding this comment

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

I have not changed the original codes here. And I cannot think a better to do this. Dev branch version should be 1.0.0

Copy link
Member

Choose a reason for hiding this comment

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

Yeah ok.

I think it's more consistent if we raise this from 1.0.0 to 2.0.0. we can do this in separate PR.

@jjw24
Copy link
Member

jjw24 commented Jun 16, 2025

Can you provide a screenshot please

This comment has been minimized.

@Jack251970
Copy link
Member Author

Jack251970 commented Jun 16, 2025

Can you provide a screenshot please

? Just display a tray icon. And why we need a screenshot?

@jjw24
Copy link
Member

jjw24 commented Jun 16, 2025

I mean the notification icon

@Jack251970
Copy link
Member Author

I mean the notification icon

Here you go.

image

@jjw24
Copy link
Member

jjw24 commented Jun 16, 2025

Hmm I am not sure if this will communicate that flow is loading. @onesounds thoughts?

@Jack251970
Copy link
Member Author

Jack251970 commented Jun 16, 2025

Hmm I am not sure if this will communicate that flow is loading. @onesounds thoughts?

No. The click event is not registered until main window is loaded. This tray icon just displays there and left click or right click will not trigger anything

This comment has been minimized.

Copy link

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, or 📝 job summary for details.

❌ Errors and Warnings Count
❌ forbidden-pattern 24
⚠️ non-alpha-in-dictionary 13

See ❌ Event descriptions for more information.

Forbidden patterns 🙅 (1)

In order to address this, you could change the content to not match the forbidden patterns (comments before forbidden patterns may help explain why they're forbidden), add patterns for acceptable instances, or adjust the forbidden patterns themselves.

These forbidden patterns matched content:

s.b. workaround(s)

\bwork[- ]arounds?\b
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.

@onesounds
Copy link
Contributor

onesounds commented Jun 16, 2025

I've been looking at this PR for a while and honestly couldn't figure out what it's doing — but after reading your conversation, I finally get it. (Please write more detailed explanations in PR descriptions. You need to provide enough background so people can understand why the change is necessary. As it stands, I can't even tell how to properly test this.)

In my opinion, this approach isn't ideal. The way I understand this PR, Flow will not respond even if the tray icon is visible — but that could actually cause more user confusion. People might think "Flow is running, but clicking doesn't do anything." In fact, this might generate even more issue reports. (For example, when I debug, I usually interpret the tray icon as a definite signal that Flow is running and responsive. According to this PR, even if the tray icon is present, Flow may or may not be functional.)

I am a bit curious to see how Jack would suffer from conflicting issue reports if this PR gets merged... but I think this problem should be addressed differently, and in the following priority order:

  1. Flow startup should never be significantly delayed just because of plugin loading. This situation itself shouldn't exist.

  2. If solving no.1 is too difficult and we need to provide user feedback, simply showing the tray icon isn’t enough. We should consider a better way. (I'm not sure what the best approach is — maybe using an OS-level notification? Obviously we can't put a loading animation in the tray icon.)

  3. As I’ve said before: if Flow has to be frozen while plugins load, then it's better to just let it freeze.

If we absolutely need to implement this behavior, one idea would be:

Since the tray icon can be updated dynamically (like Discord does), we could display a different icon during the plugin loading phase.

When users click or right-click the icon, we could show a context flyout that says:
"Plugins are still loading. Please wait."

If Flow is triggered via a hotkey during this time, we could show a temporary OS notification.

This is just a suggestion. Honestly, if the loading time isn’t too long, this method wouldn’t be a big issue either.

@Jack251970 Jack251970 closed this Jun 17, 2025
@Jack251970
Copy link
Member Author

I've been looking at this PR for a while and honestly couldn't figure out what it's doing — but after reading your conversation, I finally get it. (Please write more detailed explanations in PR descriptions. You need to provide enough background so people can understand why the change is necessary. As it stands, I can't even tell how to properly test this.)

In my opinion, this approach isn't ideal. The way I understand this PR, Flow will not respond even if the tray icon is visible — but that could actually cause more user confusion. People might think "Flow is running, but clicking doesn't do anything." In fact, this might generate even more issue reports. (For example, when I debug, I usually interpret the tray icon as a definite signal that Flow is running and responsive. According to this PR, even if the tray icon is present, Flow may or may not be functional.)

I am a bit curious to see how Jack would suffer from conflicting issue reports if this PR gets merged... but I think this problem should be addressed differently, and in the following priority order:

  1. Flow startup should never be significantly delayed just because of plugin loading. This situation itself shouldn't exist.
  2. If solving no.1 is too difficult and we need to provide user feedback, simply showing the tray icon isn’t enough. We should consider a better way. (I'm not sure what the best approach is — maybe using an OS-level notification? Obviously we can't put a loading animation in the tray icon.)
  3. As I’ve said before: if Flow has to be frozen while plugins load, then it's better to just let it freeze.

If we absolutely need to implement this behavior, one idea would be:

Since the tray icon can be updated dynamically (like Discord does), we could display a different icon during the plugin loading phase.

When users click or right-click the icon, we could show a context flyout that says: "Plugins are still loading. Please wait."

If Flow is triggered via a hotkey during this time, we could show a temporary OS notification.

This is just a suggestion. Honestly, if the loading time isn’t too long, this method wouldn’t be a big issue either.

Alright, let us close it

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