Skip to content

Conversation

@ry2x
Copy link
Owner

@ry2x ry2x commented Jan 19, 2026

This pull request refactors the main application logic to improve maintainability and extensibility, especially around UI state management, keyboard navigation, and theme/CSS handling. The most significant change is the introduction of the AppFlags struct to group related boolean flags, which simplifies state handling and reduces code duplication. Additionally, several UI and logic functions are modularized for clarity, and custom theme/CSS support is enhanced with more robust parsing and default handling.

Refactoring and State Management:

  • Introduced the AppFlags struct to encapsulate related boolean UI state flags (such as show_options_window, zen_mode, show_zen_info_modal, and export_request), replacing scattered individual fields in KeybindsApp and updating all relevant logic to access these flags through the new struct. [1] [2] [3] [4] [5] [6]
  • Refactored the main app logic by extracting UI and event-handling code into dedicated methods (e.g., handle_zen_mode_shortcuts, handle_search_bar_focus, apply_theme_or_css, handle_keyboard_navigation, etc.), leading to a cleaner and more modular update function. [1] [2] [3] [4] [5] [6]

UI and Interaction Improvements:

  • Improved keyboard navigation logic by moving it into its own method (handle_keyboard_navigation), simplifying row selection and making behavior more consistent and easier to maintain. [1] [2]
  • Updated the options window and modal handling to use the new AppFlags structure, and refactored options state passing to use a struct for better extensibility.

Theme and CSS Handling:

  • Enhanced CSS variable parsing by adding dedicated parsing functions for radius and spacing (parse_radius, parse_spacing), using clamping and type safety to avoid overflows and errors. Also added default constants for these values. [1] [2]
  • Improved error handling and string formatting throughout the theme and config code for consistency and clarity. [1] [2] [3]

Code Quality and Consistency:

  • Applied minor code quality improvements, such as using more idiomatic Rust string formatting and updating clippy lints. [1] [2] [3]

These changes collectively make the codebase easier to extend and maintain, especially as new UI flags or configuration options are added.

@ry2x ry2x requested review from Copilot and removed request for Copilot January 19, 2026 17:04
@ry2x ry2x assigned ry2x and Copilot Jan 19, 2026
@ry2x ry2x added the enhancement New feature or request label Jan 19, 2026
@ry2x ry2x linked an issue Jan 19, 2026 that may be closed by this pull request
Copy link
Contributor

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 refactors the main application code to improve maintainability by introducing the AppFlags struct to group related boolean UI flags, extracting logic into dedicated methods, and applying various clippy-suggested improvements including better string formatting, const fn annotations, and more idiomatic Rust patterns.

Changes:

  • Introduced AppFlags struct to consolidate UI state flags (show_options_window, zen_mode, show_zen_info_modal, export_request)
  • Refactored monolithic update method into smaller, focused methods for better code organization
  • Enhanced CSS parsing with dedicated type-safe functions for radius and spacing values

Reviewed changes

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

Show a summary per file
File Description
src/app.rs Introduced AppFlags struct, extracted update logic into helper methods, improved state management
src/ui/options.rs Created OptionsState struct, extracted section rendering into separate functions
src/ui/table.rs Removed unused variable, added helper functions for table column building, improved let-chain syntax
src/ui/header.rs Refactored gradient text color calculations, updated parameter types, improved string formatting
src/parser.rs Simplified error handling with io::Error::other, updated string formatting
src/models.rs Applied const fn to constructors, replaced empty string literals with String::new()
src/main.rs Updated string formatting to use inline format syntax
src/icons.rs Simplified iterator usage in tests
src/css.rs Added parse_radius and parse_spacing functions with proper type safety, improved error handling
src/config.rs Simplified error handling with io::Error::other

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

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

Copilot reviewed 39 out of 40 changed files in this pull request and generated 10 comments.

Comments suppressed due to low confidence (4)

src/config/user.rs:40

  • The use of io::Error::other is not available in stable Rust. Use io::Error::new(io::ErrorKind::Other, e.to_string()) instead for stable compatibility.
    src/ui/styling/css.rs:37
  • The parse_radius function uses floor() which truncates toward negative infinity, but this is converting from f32 to u8 which should be non-negative. Using round() would provide more accurate conversion. For example, 6.8 would become 6 with floor but should become 7 for better accuracy.
    src/hyprland/models.rs:36
  • The new method cannot be const because it accepts String parameters. String is not a const-constructible type in Rust, and this will cause a compilation error. The const keyword should be removed.
    src/ui/styling/css.rs:45
  • The parse_spacing function uses floor() which truncates values. For negative values close to zero (e.g., -0.4), this would result in -1 instead of 0. Using round() would provide more intuitive behavior for CSS spacing values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ry2x ry2x requested a review from Copilot January 20, 2026 23:32
Copy link
Contributor

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

Copilot reviewed 39 out of 40 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

src/hyprland/models.rs:36

  • The const fn new declaration cannot accept String arguments in Rust. String is not a const-constructible type because it involves heap allocation. This function should be changed to a regular pub fn new instead of pub const fn new.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Owner Author

@ry2x ry2x left a comment

Choose a reason for hiding this comment

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

Bump up version to 0.1.4

@ry2x ry2x merged commit 3075883 into master Jan 20, 2026
1 check passed
@ry2x ry2x deleted the refactor/clippy branch January 22, 2026 16:55
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.

Introduce Development Tooling for Rust Project Add hyprbind --help / hyprbind -h to display CLI help information

2 participants