Skip to content

Fix Clock/Search Icon show logic #3388

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

Merged
merged 8 commits into from
Mar 27, 2025

Conversation

onesounds
Copy link
Contributor

@onesounds onesounds commented Mar 26, 2025

What's the PR

Problem

Currently, there are the following issues in the dev branch:

image

  • When show is called while in a mode where the query remains, the clock and search icon are displayed.
  • When typing a query in a mode where the query remains, the animation no longer works.
  • The QuerySuggestionText overlaps with the clock.
  • The search icon overlaps with SearchIcon.

Fixes

image

  • The clock is no longer shown when show is called while in a mode where the query remains.
  • If the query-remaining mode is in an action keyword active state, the search icon is not shown when show is called.
  • The _isAnimating variable has been removed. It was used in the old animation system to prevent storing window coordinates while the window was moving. Since the new animation no longer moves the window, this variable is no longer needed.

Test Cases

  • The clock should not be displayed when in a query mode where the query remains.
  • The search icon should not be displayed when the query remains and an action keyword is active.
  • The clock should be displayed when the query text length is zero.
  • Each icon should behave according to whether animation is enabled or not.

ETC

With this change, modes where the query remains will no longer show the clock by default. I considered various approaches—like showing the clock while adjusting the length of QuerySuggestionText to fit the clock area—but ultimately, I think this is the right solution.

@prlabeler prlabeler bot added the bug Something isn't working label Mar 26, 2025
@onesounds onesounds self-assigned this Mar 26, 2025
@onesounds onesounds added kind/ui related to UI, icons, themes, etc Dev branch only An issue or fix for the Dev branch build labels Mar 26, 2025

This comment has been minimized.

Copy link
Contributor

coderabbitai bot commented Mar 26, 2025

📝 Walkthrough

Walkthrough

The changes remove the _animating field and its related logic from the MainWindow class, streamlining the animation flow. In MainWindow, both the location update and the window animation now execute without checking an animation flag, and the WindowAnimation method is made public. In MainViewModel, the Show and Hide methods have been updated to adjust the opacity and visibility of UI elements based on the UseAnimation setting and the state of the query text. Additionally, properties for improved rendering have been added to the SettingWindow.xaml.

Changes

File Path Change Summary
Flow.Launcher/MainWindow.xaml.cs Removed _animating state management from methods (OnLocationChanged, UpdatePosition, WindowAnimation). Changed WindowAnimation access from private to public and simplified opacity logic based on animation settings.
Flow.Launcher/ViewModel/MainViewModel.cs Updated Show and Hide methods to adjust UI element opacity and visibility (for ClockPanel and SearchIcon) based on UseAnimation and query text. Changed ChangeQueryText and Query methods to their asynchronous counterparts.
Flow.Launcher/SettingWindow.xaml Added properties SnapsToDevicePixels="True" and UseLayoutRounding="True" to enhance rendering quality and layout rounding.
Flow.Launcher/Resources/Dark.xaml Added new SolidColorBrush resource MouseOverWindowCloseButtonForegroundBrush with color #ffffff.
Flow.Launcher/Resources/Light.xaml Added new SolidColorBrush resource MouseOverWindowCloseButtonForegroundBrush with color #ffffff.

Suggested labels

enhancement, 5 min review

Suggested reviewers

  • taooceros

Poem

I’m a happy rabbit with a cheerful beat,
Hopping through code with a spring in my feet.
I chewed away old flags and set the stage anew,
With smoother flows and colors true.
Jumping high in a world so bright,
CodeRabbit’s magic makes it all just right! 🐰

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 (3)
Flow.Launcher/ViewModel/MainViewModel.cs (3)

1476-1477: Remove debug statement

The Debug.WriteLine("Call Animation") statement should be removed as it's not needed in production code.

-                        Debug.WriteLine("Call Animation");

1544-1546: Remove empty dispatcher invoke

There's an empty dispatcher invoke block that doesn't perform any operations. It should be removed to avoid confusion and unnecessary code.

-                Application.Current.Dispatcher.Invoke(() =>
-                {
-         
-                }, DispatcherPriority.Render);

1558-1559: Remove commented-out code

The commented-out mainWindow.SearchIcon.Visibility = Visibility.Hidden; line should be removed for cleaner code.

-                //mainWindow.SearchIcon.Visibility = Visibility.Hidden;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7c009d4 and b9f013e.

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

770-770: Method accessibility changed from private to public

The WindowAnimation method has been made public to allow it to be called from MainViewModel. This is necessary for the new animation approach, but changing method visibility is a significant API change.


774-783: Simplified icon visibility logic improves animation behavior

The conditional logic now directly controls the opacity of icons based on animation settings instead of using the removed _animating flag. This is a cleaner approach that addresses the issue where animation ceases to function when a query is being typed.


852-857: Animation sequencing simplified

The animation starting logic has been streamlined by removing the _animating flag checks and assignments. This removes the complexity that was causing issues with animation when in query-remaining mode.

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

1442-1469: Enhanced icon visibility logic in Show method

The updated logic correctly:

  1. Sets clock panel and search icon opacity based on animation settings
  2. Prevents the clock from appearing when a query exists
  3. Hides the search icon when a plugin-specific icon is shown

This addresses the overlapping issues with both the clock and search icons.


1510-1522: Explicit LastQueryMode handling improves code clarity

The commented-out block has been replaced with a cleaner case statement for handling empty query mode. This improves code readability and maintainability.


1547-1564: Improved Hide method icon handling

The enhanced logic in the Hide method properly:

  1. Controls icon opacity based on animation settings
  2. Sets appropriate visibility states
  3. Forces UI updates with UpdateLayout calls

This addresses issues where the UI state wasn't properly updated during hide operations.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link

gitstream-cm bot commented Mar 26, 2025

🥷 Code experts: Jack251970

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

See details

Flow.Launcher/MainWindow.xaml.cs

Activity based on git-commit:

onesounds Jack251970
MAR 310 additions & 120 deletions 729 additions & 741 deletions
FEB 8 additions & 4 deletions 1 additions & 1 deletions
JAN
DEC 5 additions & 10 deletions
NOV
OCT

Knowledge based on git-blame:
Jack251970: 56%
onesounds: 22%

Flow.Launcher/Resources/Dark.xaml

Activity based on git-commit:

onesounds Jack251970
MAR 8 additions & 8 deletions
FEB
JAN
DEC
NOV
OCT

Knowledge based on git-blame:
onesounds: 100%

Flow.Launcher/Resources/Light.xaml

Activity based on git-commit:

onesounds Jack251970
MAR 7 additions & 7 deletions
FEB
JAN
DEC
NOV
OCT

Knowledge based on git-blame:
onesounds: 100%

Flow.Launcher/SettingWindow.xaml

Activity based on git-commit:

onesounds Jack251970
MAR
FEB
JAN
DEC
NOV 1 additions & 0 deletions
OCT

Knowledge based on git-blame:
onesounds: 91%

Flow.Launcher/ViewModel/MainViewModel.cs

Activity based on git-commit:

onesounds Jack251970
MAR 236 additions & 183 deletions 302 additions & 259 deletions
FEB 23 additions & 25 deletions 63 additions & 21 deletions
JAN 17 additions & 21 deletions
DEC 59 additions & 63 deletions
NOV 39 additions & 15 deletions
OCT

Knowledge based on git-blame:
Jack251970: 21%
onesounds: 13%

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

This comment has been minimized.

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 Count
❌ forbidden-pattern 24
⚠️ ignored-expect-variant 1
⚠️ non-alpha-in-dictionary 19

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.

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 (2)
Flow.Launcher/ViewModel/MainViewModel.cs (2)

1480-1480: Consider removing commented-out code

This commented-out line appears to be old code that's no longer needed since the visibility logic has been refactored.

- //mainWindow.SearchIcon.Visibility = Visibility.Visible;

1560-1560: Consider removing commented-out code

Similar to the previous comment, this appears to be old code that's no longer needed with the new approach.

- //MainWindowOpacity = 0;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b88057c and 89c3cb1.

📒 Files selected for processing (2)
  • Flow.Launcher/MainWindow.xaml.cs (11 hunks)
  • Flow.Launcher/ViewModel/MainViewModel.cs (9 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
Flow.Launcher/ViewModel/MainViewModel.cs (5)
Flow.Launcher/MainWindow.xaml.cs (2)
  • MainWindow (30-1034)
  • MainWindow (70-82)
Flow.Launcher/PublicAPIInstance.cs (1)
  • ChangeQuery (55-58)
Flow.Launcher/App.xaml.cs (2)
  • App (28-339)
  • App (50-114)
Flow.Launcher.Core/Plugin/JsonRPCV2Models/JsonRPCPublicAPI.cs (1)
  • ChangeQuery (22-25)
Flow.Launcher.Infrastructure/Win32Helper.cs (2)
  • Win32Helper (19-491)
  • DWMSetCloakForWindow (30-39)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: gitStream.cm
🔇 Additional comments (10)
Flow.Launcher/MainWindow.xaml.cs (5)

768-773: Animation state simplification implemented correctly

The code now directly sets the opacity of UI elements based on the animation settings rather than using the old animation state tracking mechanism. This simplifies the animation flow and addresses the issue with animation ceasing to function when typing a query.


282-285: Proper initialization of icon states

Setting both ClockPanel and SearchIcon opacity to 0 here ensures that they start in a consistent hidden state before the animation or visibility logic takes effect, which helps prevent the icon overlapping issues mentioned in the PR objectives.


804-804: Good utility function for opacity retrieval

This helper function cleanly extracts opacity values from styles, supporting the more dynamic approach to UI element visibility management implemented in this PR.


815-815: Good utility function for margin retrieval

Similar to the opacity helper, this function cleanly extracts thickness values from styles, making the animation code more maintainable.


286-288: Clear comment explaining animation behavior

This comment provides important context about preventing extra hide calls when the animator is active, which would otherwise cause toggling issues.

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

633-660: Properly implemented asynchronous query handling

Converting the query handling to an asynchronous pattern is a good improvement that will make the UI more responsive. Using Dispatcher.InvokeAsync ensures that UI updates happen on the UI thread without blocking.

The implementation correctly maintains backward compatibility by having a synchronous method that calls the async version.


1028-1032: Async pattern consistently applied to Query method

The Query method now properly delegates to QueryAsync, following the same pattern as ChangeQueryText. This ensures consistency in how asynchronous operations are handled throughout the codebase.


1457-1478: Clock and search icon visibility logic properly implemented

This section addresses the core issues mentioned in the PR objectives:

  1. The clock panel visibility is now correctly tied to whether query text is present
  2. The search icon visibility is properly controlled based on whether a plugin icon is present

These changes effectively prevent the overlapping issues described in the PR objectives.


1512-1514: Async handling properly implemented for Hide() method

The Hide method now correctly awaits the ChangeQueryTextAsync method when in Empty mode, ensuring that UI updates are handled asynchronously and preventing potential race conditions.


1532-1549: Proper window hiding with DWM cloak

The use of DWM cloak to hide the window is a good approach as it provides a clean way to completely hide the window without affecting its state.

The order of operations is correct:

  1. First reset the UI elements
  2. Then apply the DWM cloak to hide the window

@onesounds onesounds merged commit e3a1489 into Flow-Launcher:dev Mar 27, 2025
6 checks passed
@Jack251970 Jack251970 added this to the 1.20.0 milestone Mar 27, 2025
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 kind/ui related to UI, icons, themes, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants