Skip to content

Support Placeholder Text & Toggle Resize Search Window Mode #3396

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 13 commits into from
Mar 29, 2025

Conversation

Jack251970
Copy link
Contributor

@Jack251970 Jack251970 commented Mar 29, 2025

Placeholder Text

Add placeholder text when query is empty

image

Fixed Window Size

Allow dragging to change window size

image

This comment has been minimized.

Copy link
Contributor

coderabbitai bot commented Mar 29, 2025

📝 Walkthrough

Walkthrough

This pull request introduces several UI and functionality changes across multiple modules. In the core theme file, property access levels are restricted, and methods for adjusting window border thickness are added. The obsolete ThemeManager is removed. New settings properties for placeholder display and window resizing are introduced, along with corresponding UI elements in XAML and adjustments to the MainWindow for placeholder management and resize mode. String resources in the language file are updated to reflect these changes.

Changes

File(s) Change Summary
Flow.Launcher.Core/Resource/Theme.cs Updated property access for BlurEnabled, changed property references for effects and margins, added new method SetResizeBorderThickness(WindowChrome, bool), and converted an existing static method to an instance method; updated dispatcher priority in async methods.
Flow.Launcher.Core/Resource/ThemeManager.cs Removed the ThemeManager class and its static Instance property.
Flow.Launcher.Infrastructure/UserSettings/Settings.cs Added new properties: ShowPlaceholder and PlaceholderText with corresponding backing fields and change notifications; refactored KeepMaxResults property.
Flow.Launcher/App.xaml.cs Removed a comment line referencing a future cleanup of ThemeManager.Instance.
Flow.Launcher/Languages/en.xaml Removed the "PositionResetToolTip"; added new string resources for query suggestions, backdrop types, placeholder text, and window resize options; rearranged some existing string resource declarations.
Flow.Launcher/MainWindow.xaml Added a new disabled TextBox (QueryTextPlaceholderBox) within the QueryBoxArea grid, configured as a placeholder with dynamic resource binding and collapsed visibility.
Flow.Launcher/MainWindow.xaml.cs Introduced a new region for placeholder text management (setup and event handlers for updating placeholder visibility) and a region for resize mode management (adjusts window resize mode and border thickness based on settings).
Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs Added new public properties ShowPlaceholder and PlaceholderText to proxy the corresponding settings values.
Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml Added two new cc:Card UI elements for "ShowPlaceholder" and "PlaceholderText" featuring toggle switches; updated comment casings in the file.

Sequence Diagram(s)

sequenceDiagram
    participant MW as MainWindow
    participant QTB as QueryTextBox
    participant QTSB as QueryTextSuggestionBox
    participant PTB as QueryTextPlaceholderBox
    participant Settings as Settings

    MW->>MW: SetupPlaceholderText()
    MW->>QTB: Subscribe to TextChanged event
    MW->>QTSB: Subscribe to TextChanged event
    QTB->>MW: TextChanged event triggered
    QTSB->>MW: TextChanged event triggered
    MW->>MW: SetPlaceholderText() updates PTB visibility
Loading
sequenceDiagram
    participant MW as MainWindow
    participant Settings as Settings
    participant Theme as Theme

    MW->>Settings: Retrieve ResizeWindow setting
    MW->>Theme: Call SetResizeBorderThickness(Thickness?)
    MW->>MW: Update window ResizeMode based on setting
Loading

Possibly related PRs

  • Fix main window resize border thickness issue #3232 – The changes in the main PR regarding the SetResizeBorderThickness method and the handling of resize border thickness are directly related to the modifications made in the retrieved PR, which also involves the SetResizeBoarderThickness method and adjustments to the window's resize border thickness.
  • Fix font select function #3377 – The changes in the main PR are related to those in the retrieved PR as both involve modifications to the Theme.cs file, specifically in the management of properties and methods related to theme functionality, including the introduction of new methods and adjustments to existing ones.

Suggested labels

kind/ui, 20 min review

Suggested reviewers

  • jjw24
  • onesounds

Poem

I'm a rabbit, hopping with glee,
Code changes sprout like carrots in a field,
Borders refined and placeholders set free,
UI and settings form a brighter yield,
With whiskers twitching in code harmony 🐰,
I celebrate clean lines and tweaks so real!
Hop on into the new feature reveal!

✨ 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 (1)
Flow.Launcher.Core/Resource/Theme.cs (1)

546-570: Fixed minor typo in method name.

The method name contains a typo: "Boarder" should be "Border". This appears to be consistent with the existing codebase and isn't introduced by this PR, but it might be worth correcting in a future update.

-private void SetResizeBoarderThickness(Thickness? effectMargin)
+private void SetResizeBorderThickness(Thickness? effectMargin)

Also applies to the method name on line 534.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 697fb72 and c74dd20.

📒 Files selected for processing (9)
  • Flow.Launcher.Core/Resource/Theme.cs (8 hunks)
  • Flow.Launcher.Core/Resource/ThemeManager.cs (0 hunks)
  • Flow.Launcher.Infrastructure/UserSettings/Settings.cs (1 hunks)
  • Flow.Launcher/App.xaml.cs (0 hunks)
  • Flow.Launcher/Languages/en.xaml (2 hunks)
  • Flow.Launcher/MainWindow.xaml (1 hunks)
  • Flow.Launcher/MainWindow.xaml.cs (5 hunks)
  • Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs (1 hunks)
  • Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml (5 hunks)
💤 Files with no reviewable changes (2)
  • Flow.Launcher/App.xaml.cs
  • Flow.Launcher.Core/Resource/ThemeManager.cs
🧰 Additional context used
🧬 Code Definitions (1)
Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs (1)
Flow.Launcher.Infrastructure/UserSettings/Settings.cs (1)
  • Settings (16-413)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: gitStream workflow automation
  • GitHub Check: gitStream.cm
🔇 Additional comments (24)
Flow.Launcher/MainWindow.xaml (1)

221-228: Well-structured implementation of placeholder text functionality

The new TextBox implementation provides a clean way to show placeholder text when the query box is empty. The control is properly configured with:

  • Appropriate binding to maintain consistent styling with the main query box
  • IsEnabled="False" to ensure it's just a visual element with no input capability
  • Visibility set to "Collapsed" by default, which will be toggled based on the ShowPlaceholder setting
Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs (2)

262-266: Clean implementation of ResizeWindow property

The property is correctly implemented with a simple getter and setter that interacts with the Settings object. This provides a clean way for the UI to bind to this setting.


268-272: Good implementation of ShowPlaceholder property

The property properly exposes the ShowPlaceholder setting from the Settings object, enabling the UI to toggle the placeholder text visibility.

Flow.Launcher.Infrastructure/UserSettings/Settings.cs (2)

116-125: Good implementation of ResizeWindow setting with default value

The ResizeWindow property is correctly implemented with:

  • Private backing field initialized to true (sensible default to enable window resizing)
  • Property change notification via OnPropertyChanged()
  • Clean getter and setter implementation

127-136: Well-implemented ShowPlaceholder setting with appropriate default

The ShowPlaceholder property is well-structured with:

  • Private backing field initialized to false (logical default - don't show placeholder until user enables it)
  • Property change notification properly implemented
  • Clean property implementation
Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml (4)

501-511: Good UI implementation for ResizeWindow setting

The Card element for the ResizeWindow setting is well-structured with:

  • Appropriate title and icon
  • Tooltip providing context via the "ResizeWindowTip" resource
  • ToggleSwitch properly bound to the ResizeWindow property
  • Consistent UI styling with other settings cards

544-554: Well-structured UI implementation for PlaceholderText setting

The Card element for the PlaceholderText setting is properly implemented with:

  • Clear title and appropriate icon
  • Tooltip providing context via the "PlaceholderTextTip" resource
  • ToggleSwitch correctly bound to the ShowPlaceholder property
  • Consistent UI styling with other settings cards

513-514: Minor comment improvement for consistency

Updated the comment to use lowercase "height" for consistency in the comments formatting throughout the file.


266-267: Minor comment improvement for consistency

Updated the comment to use lowercase "preview" for consistency in the comments formatting throughout the file.

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

14-14: Added System.Windows.Shell namespace.

This is a necessary addition to support the WindowChrome functionality used for the window resizing feature.


119-121: Good placement for placeholder text initialization.

The placeholder text setup is correctly initialized after the control elements are created but before the window is shown to the user.


153-157: Good sequencing of resize mode initialization.

Setting up the resize mode after theme frame refresh ensures that any theme-related border settings are applied correctly before configuring the resize behavior.


248-253: Proper property change notification handling.

The code correctly subscribes to property changes for the new settings and calls the appropriate setup methods when those settings change, enabling dynamic UI updates.


1045-1080: Well-structured placeholder text implementation.

The placeholder text implementation follows a clean pattern:

  1. The setup method adds/removes event handlers based on settings
  2. Event handlers update the placeholder visibility when text changes
  3. The visibility logic correctly checks both text boxes

1082-1093: Well-implemented resize mode functionality.

The resize mode implementation correctly:

  1. Sets the window's ResizeMode property based on user settings
  2. Updates the window chrome's border thickness using the theme object
  3. Accesses the theme functionality through the appropriate method call
Flow.Launcher.Core/Resource/Theme.cs (6)

27-27: Improved encapsulation by restricting the BlurEnabled property setter.

Changing the setter from public to private ensures that this property can only be modified within the Theme class, preventing unexpected changes from external code.


45-46: Added private field to store theme resize border thickness.

This field appropriately stores the theme-specific border thickness that's needed for the window resizing functionality.


468-469: Generalized property references.

Replacing Border-specific property references with more general UIElement and FrameworkElement references broadens their application scope and is more appropriate for the intended usage.

Also applies to: 483-484


513-514: Consistent property reference updates.

These property reference updates maintain consistency with the earlier changes and follow the same pattern of using more general property accessors.

Also applies to: 518-519


534-544: New method for configuring WindowChrome resize behavior.

This method cleanly implements the functionality to toggle the resize border thickness based on the user's preference. The conditional logic ensures that resize borders are only applied when the feature is enabled.


600-601: Changed dispatcher priority to improve UI responsiveness.

Changing the DispatcherPriority from Normal to Render may help ensure that UI updates related to theme changes happen at the most appropriate time in the rendering pipeline.

Also applies to: 614-615

Flow.Launcher/Languages/en.xaml (3)

42-42: Added placeholder text resource.

The "Type here to search" message provides clear guidance to users about the purpose of the search box.


198-202: Added backdrop type resources.

These resources provide localized strings for the different backdrop type options in the UI.


205-208: Added resources for new UI features.

These well-named resources provide clear and descriptive text for the placeholder and resize window features in the settings UI, including helpful tooltips that explain their functionality.

@Jack251970 Jack251970 requested review from onesounds and Copilot March 29, 2025 06:28
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 pull request introduces support for displaying placeholder text when the query is empty and enables users to toggle window resize mode. The changes include adding new settings properties for placeholder text and resize behavior, updating the main window logic to initialize these features, removing an obsolete ThemeManager, and enhancing theme-related logic in the application.

Reviewed Changes

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

Show a summary per file
File Description
Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs Added properties to expose ResizeWindow and ShowPlaceholder settings.
Flow.Launcher/MainWindow.xaml.cs Integrated initialization for placeholder text and resize mode with new setup methods.
Flow.Launcher/App.xaml.cs Removed an obsolete comment regarding ThemeManager usage.
Flow.Launcher.Infrastructure/UserSettings/Settings.cs Introduced backing fields and properties for ResizeWindow and ShowPlaceholder.
Flow.Launcher.Core/Resource/ThemeManager.cs Removed obsolete ThemeManager in favor of using DI for Theme.
Flow.Launcher.Core/Resource/Theme.cs Updated DropShadow effect settings and added methods for adjusting the resize border thickness.
Files not reviewed (3)
  • Flow.Launcher/Languages/en.xaml: Language not supported
  • Flow.Launcher/MainWindow.xaml: Language not supported
  • Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml: Language not supported
Comments suppressed due to low confidence (2)

Flow.Launcher.Core/Resource/Theme.cs:534

  • The method name 'SetResizeBoarderThickness' contains a misspelling; consider renaming it to 'SetResizeBorderThickness' for clarity.
public void SetResizeBoarderThickness(WindowChrome windowChrome, bool resizeWindow)

Flow.Launcher.Core/Resource/Theme.cs:548

  • The private method 'SetResizeBoarderThickness' has a typographical error in its name; it should be renamed to 'SetResizeBorderThickness' to match standard naming conventions.
private void SetResizeBoarderThickness(Thickness? effectMargin)

This comment has been minimized.

Copy link

gitstream-cm bot commented Mar 29, 2025

🥷 Code experts: onesounds

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

See details

Flow.Launcher.Core/Resource/Theme.cs

Activity based on git-commit:

Jack251970 onesounds
MAR 846 additions & 934 deletions 1159 additions & 895 deletions
FEB 64 additions & 28 deletions 333 additions & 17 deletions
JAN 7 additions & 4 deletions
DEC 2 additions & 96 deletions
NOV 2 additions & 2 deletions
OCT

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

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Activity based on git-commit:

Jack251970 onesounds
MAR 3 additions & 2 deletions 10 additions & 0 deletions
FEB 10 additions & 4 deletions
JAN 17 additions & 4 deletions
DEC 1 additions & 1 deletions
NOV
OCT

Knowledge based on git-blame:
onesounds: 25%
Jack251970: 7%

Flow.Launcher/App.xaml.cs

Activity based on git-commit:

Jack251970 onesounds
MAR 168 additions & 93 deletions
FEB 79 additions & 40 deletions
JAN 86 additions & 66 deletions
DEC
NOV
OCT

Knowledge based on git-blame:
Jack251970: 61%

Flow.Launcher/Languages/en.xaml

Activity based on git-commit:

Jack251970 onesounds
MAR 6 additions & 3 deletions 7 additions & 3 deletions
FEB 13 additions & 9 deletions
JAN 1 additions & 0 deletions
DEC
NOV
OCT

Knowledge based on git-blame:
onesounds: 43%
Jack251970: 3%

Flow.Launcher/MainWindow.xaml

Activity based on git-commit:

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

Knowledge based on git-blame:
onesounds: 87%
Jack251970: 4%

Flow.Launcher/MainWindow.xaml.cs

Activity based on git-commit:

Jack251970 onesounds
MAR 851 additions & 852 deletions 327 additions & 141 deletions
FEB 1 additions & 1 deletions 8 additions & 4 deletions
JAN
DEC 5 additions & 10 deletions
NOV
OCT

Knowledge based on git-blame:
Jack251970: 61%
onesounds: 18%

Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs

Activity based on git-commit:

Jack251970 onesounds
MAR 88 additions & 105 deletions 153 additions & 86 deletions
FEB 1 additions & 20 deletions 2 additions & 0 deletions
JAN 1 additions & 1 deletions
DEC
NOV 2 additions & 2 deletions
OCT

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

Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml

Activity based on git-commit:

Jack251970 onesounds
MAR 2 additions & 3 deletions 104 additions & 81 deletions
FEB
JAN
DEC
NOV
OCT

Knowledge based on git-blame:
onesounds: 79%

Flow.Launcher/ViewModel/MainViewModel.cs

Activity based on git-commit:

Jack251970 onesounds
MAR 459 additions & 422 deletions 293 additions & 201 deletions
FEB 63 additions & 21 deletions 23 additions & 25 deletions
JAN 17 additions & 21 deletions
DEC 59 additions & 63 deletions
NOV 39 additions & 15 deletions
OCT

Knowledge based on git-blame:
Jack251970: 26%
onesounds: 11%

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

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 (4)
Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml (2)

267-267: Improved comment format consistency.

Minor improvement to comment format for better consistency.


514-514: Improved comment format consistency.

Minor improvement to comment format for better consistency.

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

1049-1084: Well-structured placeholder text implementation.

The placeholder region provides a clean, organized implementation for the placeholder text functionality. Key observations:

  1. Good separation of concerns with distinct methods for setup, event handling, and visibility logic
  2. Proper event subscription/unsubscription based on settings
  3. Clear visibility logic checking both text inputs

Consider adding null checks for UI elements to prevent potential NullReferenceExceptions if called before UI initialization:

private void SetPlaceholderText()
{
    if (QueryTextBox == null || QueryTextSuggestionBox == null || QueryTextPlaceholderBox == null)
        return;
        
    var queryText = QueryTextBox.Text;
    var suggestionText = QueryTextSuggestionBox.Text;
    QueryTextPlaceholderBox.Visibility = string.IsNullOrEmpty(queryText) && string.IsNullOrEmpty(suggestionText) ? Visibility.Visible : Visibility.Collapsed;
}

1086-1097: Clean resize mode implementation with minor spelling inconsistency.

The resize mode implementation is concise and effectively toggles the window's resize capability. However, there's a spelling inconsistency in the method name being called from Theme.cs - SetResizeBoarderThickness should be "Border" not "Boarder".

This is consistent with the misspelling in the Theme class itself, but it would be good to correct this spelling across the codebase in a future update.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c74dd20 and 84f2686.

📒 Files selected for processing (7)
  • Flow.Launcher.Infrastructure/UserSettings/Settings.cs (1 hunks)
  • Flow.Launcher/Languages/en.xaml (2 hunks)
  • Flow.Launcher/MainWindow.xaml (1 hunks)
  • Flow.Launcher/MainWindow.xaml.cs (5 hunks)
  • Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs (1 hunks)
  • Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml (6 hunks)
  • Flow.Launcher/ViewModel/MainViewModel.cs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • Flow.Launcher/MainWindow.xaml
  • Flow.Launcher/Languages/en.xaml
🧰 Additional context used
🧬 Code Definitions (3)
Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs (1)
Flow.Launcher.Infrastructure/UserSettings/Settings.cs (1)
  • Settings (16-423)
Flow.Launcher/ViewModel/MainViewModel.cs (2)
Flow.Launcher/App.xaml.cs (2)
  • App (28-338)
  • App (50-114)
Flow.Launcher/PublicAPIInstance.cs (1)
  • GetTranslation (158-158)
Flow.Launcher/MainWindow.xaml.cs (2)
Flow.Launcher.Infrastructure/UserSettings/Settings.cs (1)
  • Settings (16-423)
Flow.Launcher.Core/Resource/Theme.cs (2)
  • SetResizeBoarderThickness (534-544)
  • SetResizeBoarderThickness (548-570)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: gitStream workflow automation
  • GitHub Check: gitStream.cm
🔇 Additional comments (11)
Flow.Launcher/ViewModel/MainViewModel.cs (1)

768-784: Implementation of PlaceholderText looks good.

The property correctly handles the null/empty case by providing a localized default value, and properly implements property change notification. This approach ensures the UI will always have appropriate placeholder text to display.

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

262-278: Well-implemented settings properties.

The three new properties (ResizeWindow, ShowPlaceholder, and PlaceholderText) follow the established pattern in this class, correctly delegating to the corresponding properties in the Settings object. They are logically grouped together, making the code easy to understand and maintain.

Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml (2)

502-512: Good implementation of the window resize option UI.

The card for the "Resize Window" setting follows the established pattern with appropriate icon, tooltip, and binding to the view model. The UI element is positioned logically in the settings flow.


546-566: Well-structured placeholder text settings UI.

The card group for placeholder text settings provides a clean interface with both the toggle option and text input field. The implementation follows the established UI patterns with proper bindings, informative tooltips, and consistent styling.

Flow.Launcher.Infrastructure/UserSettings/Settings.cs (1)

116-146: Well-implemented settings properties with appropriate defaults.

The three new properties (ResizeWindow, ShowPlaceholder, and PlaceholderText) follow the established pattern in the Settings class with private backing fields and proper property change notification. The default values are sensible: window resizing is enabled by default while the placeholder feature is disabled by default with an empty placeholder text.

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

14-14: Appropriate addition of System.Windows.Shell namespace.

The added import is necessary for accessing the WindowChrome class, which is used in the resize mode implementation. Good practice to only add the namespaces that are needed.


119-121: Good initialization sequence for placeholder text.

The implementation properly initializes the placeholder text feature during window loading. The code sets up event handlers and updates the UI with the configured placeholder text from settings.


156-157: Proper sequencing of resize mode setup.

Setting up the resize mode after refreshing the theme frame is the correct approach, as it ensures that the theme's properties are fully initialized before configuring the resize behavior.


249-251: Appropriate property change handler for ShowPlaceholder.

The code correctly responds to changes in the ShowPlaceholder setting by calling SetupPlaceholderText(), which will add or remove the necessary event handlers.


252-254: Synchronizing PlaceholderText with ViewModel.

The implementation properly updates the ViewModel's PlaceholderText property when the setting changes, maintaining the data binding consistency.


255-257: Responsive window resize mode update.

The property change handler correctly calls SetupResizeMode() when the ResizeWindow setting changes, allowing for dynamic updates to the window's resize behavior.

@prlabeler prlabeler bot added the bug Something isn't working label Mar 29, 2025

This comment has been minimized.

This comment has been minimized.

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/MainWindow.xaml.cs (1)

1093-1104: Typo in method name referenced.

The implementation of the resize mode functionality is good, but there's a spelling error in the method name referenced.

In _theme.SetResizeBoarderThickness(), "Boarder" should be "Border":

-        _theme.SetResizeBoarderThickness(windowChrome, _settings.KeepMaxResults);
+        _theme.SetResizeBorderThickness(windowChrome, _settings.KeepMaxResults);

This should be fixed here and in the Theme class where the method is defined.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 91c5e84 and 10d4387.

📒 Files selected for processing (2)
  • Flow.Launcher/MainWindow.xaml (2 hunks)
  • Flow.Launcher/MainWindow.xaml.cs (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Flow.Launcher/MainWindow.xaml
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: gitStream.cm
🔇 Additional comments (7)
Flow.Launcher/MainWindow.xaml.cs (7)

14-14: Appropriate import for window chrome functionality.

The addition of the System.Windows.Shell namespace is necessary for accessing the WindowChrome class used in the new resize mode functionality.


119-122: Good initialization of placeholder text functionality.

The placeholder setup is appropriately placed in the window's loading sequence, ensuring it's initialized before the user interacts with the interface.


156-157: Proper sequencing of resize mode initialization.

The resize mode is correctly set up after the theme frame is refreshed, ensuring all visual elements are properly initialized before applying resize behavior.


249-257: Appropriate property change handlers for new settings.

The addition of these property change handlers ensures the UI correctly responds when the user changes placeholder or resize mode settings. This follows good reactive programming practices.


467-476: Good handling of shadow margins in size calculations.

The code now accounts for drop shadow effects when calculating the available space, which will provide more consistent UI sizing across different theme configurations.


492-496: Proper conditional width updating.

The code correctly updates the window width in the view model only when resizing is enabled, maintaining consistency with the application's settings.


1056-1091: Well-implemented placeholder text functionality.

The placeholder implementation follows good practices:

  1. Properly manages event subscriptions based on settings
  2. Uses a clean separation of concerns with dedicated methods
  3. Correctly determines visibility based on the state of both text boxes

This will improve user experience by providing guidance when the input is empty.

This comment has been minimized.

@Jack251970 Jack251970 added enhancement New feature or request and removed bug Something isn't working labels Mar 29, 2025
@Jack251970 Jack251970 added this to the 1.20.0 milestone Mar 29, 2025
onesounds
onesounds previously approved these changes Mar 29, 2025

This comment has been minimized.

@Jack251970 Jack251970 requested review from onesounds and Copilot March 29, 2025 08:36
onesounds
onesounds previously approved these changes Mar 29, 2025
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 introduces placeholder text functionality when the query is empty and enables toggling the fixed window size, along with updating related settings and UI behavior.

  • Updates width adjustment commands in the main view model.
  • Adds placeholder text properties and event handlers in both view model and view layers.
  • Refactors settings management and theme resource methods while removing an obsolete ThemeManager.

Reviewed Changes

Copilot reviewed 7 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Flow.Launcher/ViewModel/MainViewModel.cs Replaces direct Settings.WindowSize updates with MainWindowWidth and adds placeholder text support.
Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs Adds properties to control and display placeholder text options and tips.
Flow.Launcher/MainWindow.xaml.cs Integrates placeholder text setup, updates theme refresh, and initializes window resize mode.
Flow.Launcher/App.xaml.cs Removes an obsolete comment and retains theme change behavior.
Flow.Launcher.Infrastructure/UserSettings/Settings.cs Introduces properties for placeholder text and refactors the KeepMaxResults setting with proper change notifications.
Flow.Launcher.Core/Resource/ThemeManager.cs Removes the obsolete ThemeManager.
Flow.Launcher.Core/Resource/Theme.cs Refines drop shadow effect implementation and adds a new method for setting the resize border thickness.
Files not reviewed (6)
  • Flow.Launcher/Languages/en.xaml: Language not supported
  • Flow.Launcher/MainWindow.xaml: Language not supported
  • Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml: Language not supported
  • Flow.Launcher/Themes/Discord Dark.xaml: Language not supported
  • Flow.Launcher/Themes/League.xaml: Language not supported
  • Flow.Launcher/Themes/Pink.xaml: Language not supported

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

This comment has been minimized.

@Jack251970 Jack251970 requested a review from Copilot March 29, 2025 08:41
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 adds support for displaying placeholder text when the query is empty and enables toggling the window resize mode based on user settings. Key changes include updating the window width logic in the main view model, adding new properties and initialization for placeholder text in multiple view models and the main window, and refactoring theme management to update resize border thickness.

Reviewed Changes

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

Show a summary per file
File Description
Flow.Launcher/ViewModel/MainViewModel.cs Updates window width handling and adds a new PlaceholderText property.
Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs Introduces ShowPlaceholder and PlaceholderText properties, and provides a translated tip.
Flow.Launcher/MainWindow.xaml.cs Initializes placeholder text and sets up event handlers; adds support for toggling resize mode.
Flow.Launcher/App.xaml.cs Minor cleanup by removing a TODO comment.
Flow.Launcher.Infrastructure/UserSettings/Settings.cs Modifies property setters for ShowPlaceholder, PlaceholderText, and KeepMaxResults.
Flow.Launcher.Core/Resource/ThemeManager.cs Removes obsolete ThemeManager class.
Flow.Launcher.Core/Resource/Theme.cs Updates drop shadow effect and border margin properties, and adds logic to update resize border thickness.
Files not reviewed (6)
  • Flow.Launcher/Languages/en.xaml: Language not supported
  • Flow.Launcher/MainWindow.xaml: Language not supported
  • Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml: Language not supported
  • Flow.Launcher/Themes/Discord Dark.xaml: Language not supported
  • Flow.Launcher/Themes/League.xaml: Language not supported
  • Flow.Launcher/Themes/Pink.xaml: Language not supported
Comments suppressed due to low confidence (1)

Flow.Launcher.Core/Resource/Theme.cs:548

  • The method name 'SetResizeBoarderThickness' contains a typo ('Boarder' instead of 'Border'). Consider renaming it to 'SetResizeBorderThickness' for clarity and consistency.
private void SetResizeBoarderThickness(Thickness? effectMargin)

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
⚠️ 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: 1

🧹 Nitpick comments (3)
Flow.Launcher/MainWindow.xaml.cs (3)

468-473: Consider documenting the shadow margin magic number.

While the shadow margin calculation is correct, the value 32 appears to be a magic number without explanation.

// Get shadow margin
var shadowMargin = 0;
var (_, useDropShadowEffect) = _theme.GetActualValue();
if (useDropShadowEffect)
{
-    shadowMargin = 32;
+    // Shadow margin of 32 accounts for the drop shadow effect's visual overflow
+    shadowMargin = 32;
}

475-476: Document the formula for calculating max results.

The calculation formula includes magic numbers that would benefit from clarification for future maintainers.

// Calculate max results to show
-var itemCount = (Height - (_settings.WindowHeightSize + 14) - shadowMargin) / _settings.ItemHeightSize;
+// Height - (window header height + padding(14px)) - shadow margin divided by individual item height
+var itemCount = (Height - (_settings.WindowHeightSize + 14) - shadowMargin) / _settings.ItemHeightSize;

1056-1091: Consider using IsNullOrWhiteSpace for better placeholder behavior.

The placeholder implementation is well-structured, but consider using string.IsNullOrWhiteSpace() instead of string.IsNullOrEmpty() to handle cases where the text boxes contain only whitespace.

private void SetPlaceholderText()
{
    var queryText = QueryTextBox.Text;
    var suggestionText = QueryTextSuggestionBox.Text;
-    QueryTextPlaceholderBox.Visibility = string.IsNullOrEmpty(queryText) && string.IsNullOrEmpty(suggestionText) ? Visibility.Visible : Visibility.Collapsed;
+    QueryTextPlaceholderBox.Visibility = string.IsNullOrWhiteSpace(queryText) && string.IsNullOrWhiteSpace(suggestionText) ? Visibility.Visible : Visibility.Collapsed;
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 356f229 and cd01260.

📒 Files selected for processing (2)
  • Flow.Launcher.Core/Resource/Theme.cs (8 hunks)
  • Flow.Launcher/MainWindow.xaml.cs (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Flow.Launcher.Core/Resource/Theme.cs
🧰 Additional context used
🧬 Code Definitions (1)
Flow.Launcher/MainWindow.xaml.cs (4)
Flow.Launcher/ViewModel/MainViewModel.cs (1)
  • ResetPreview (980-995)
Flow.Launcher.Infrastructure/UserSettings/Settings.cs (1)
  • Settings (16-435)
Flow.Launcher.Infrastructure/Win32Helper.cs (1)
  • Win32Helper (19-491)
Flow.Launcher.Core/Resource/Theme.cs (1)
  • SetResizeBorderThickness (534-544)
🔇 Additional comments (6)
Flow.Launcher/MainWindow.xaml.cs (6)

14-14: Import added for window chrome customization.

The addition of the System.Windows.Shell namespace is necessary for utilizing the WindowChrome class in the resize mode functionality.


119-122: Good initialization of placeholder text functionality.

The placeholder functionality is correctly initialized during window loading, ensuring it's set up before the UI is shown to users. The view model is properly updated with the placeholder text from settings.


154-158: Proper sequencing of resize mode setup after theme refresh.

Setting up the resize mode after refreshing the theme frame ensures that all visual elements are properly initialized before configuring resizing behavior.


249-257: Well-structured property change handlers for new settings.

The added handlers react appropriately to changes in the relevant settings, ensuring UI synchronization with user preferences for placeholders and window resizing.


492-496: Width update conditional is properly implemented.

The width update properly respects the KeepMaxResults setting, only updating the view model's width property when resizing is allowed.


1093-1104: Clean implementation of resize mode toggle.

The resize mode functionality is well-implemented, appropriately setting the window's ResizeMode property and border thickness based on user settings. The null check on WindowChrome.GetWindowChrome(this) is a good defensive programming practice.

Comment on lines +1056 to +1072
#region Placeholder

private void SetupPlaceholderText()
{
if (_settings.ShowPlaceholder)
{
QueryTextBox.TextChanged += QueryTextBox_TextChanged;
QueryTextSuggestionBox.TextChanged += QueryTextSuggestionBox_TextChanged;
SetPlaceholderText();
}
else
{
QueryTextBox.TextChanged -= QueryTextBox_TextChanged;
QueryTextSuggestionBox.TextChanged -= QueryTextSuggestionBox_TextChanged;
QueryTextPlaceholderBox.Visibility = Visibility.Collapsed;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Consider event handler cleanup in Dispose method.

Event handlers are correctly added/removed based on settings, but consider also ensuring these handlers are detached in the Dispose method to prevent potential memory leaks.


🏁 Script executed:

#!/bin/bash
# Check if event handlers are properly cleaned up in Dispose method

echo "Checking MainWindow.xaml.cs for event handler cleanup in Dispose method..."
rg -A 5 -B 5 "Dispose\(bool disposing\)" Flow.Launcher/MainWindow.xaml.cs

Length of output: 708


Event Handler Cleanup in Dispose Method Needed

The setup in SetupPlaceholderText properly adds and removes the event handlers based on settings, but as verified, the Dispose(bool disposing) method does not currently include logic to detach these handlers. This omission could lead to memory leaks if the handlers remain attached even after disposal.

  • Action Item: Update the Dispose(bool disposing) method (in Flow.Launcher/MainWindow.xaml.cs) to remove the attached event handlers (e.g., detach QueryTextBox_TextChanged and QueryTextSuggestionBox_TextChanged) when disposing is true.

@Jack251970 Jack251970 merged commit a3ef6fa into dev Mar 29, 2025
4 of 5 checks passed
@Jack251970 Jack251970 deleted the placeholder_resize branch March 29, 2025 08:57
@Jack251970 Jack251970 added the kind/ui related to UI, icons, themes, etc label Mar 29, 2025
@@ -39,7 +39,7 @@
<system:String x:Key="GameMode">Game Mode</system:String>
<system:String x:Key="GameModeToolTip">Suspend the use of Hotkeys.</system:String>
<system:String x:Key="PositionReset">Position Reset</system:String>
<system:String x:Key="PositionResetToolTip">Reset search window position</system:String>
Copy link
Contributor

Choose a reason for hiding this comment

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

@Jack251970 Man~!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh no

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see #3448

@coderabbitai coderabbitai bot mentioned this pull request Apr 11, 2025
@jjw24 jjw24 changed the title Support Placeholder Text & Toggle Resize Mode Support Placeholder Text & Toggle Resize Search Window Mode May 8, 2025
@prlabeler prlabeler bot added the bug Something isn't working label May 8, 2025
@jjw24 jjw24 removed the bug Something isn't working label May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request kind/ui related to UI, icons, themes, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants