Skip to content

Improve filtering #29

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 6 commits into from
Jun 15, 2025
Merged

Improve filtering #29

merged 6 commits into from
Jun 15, 2025

Conversation

fchastanet
Copy link
Owner

/fix #22

This update enhances the styling and structure of various components for better maintainability and consistency across the application.

- 🔧 Updated `TableStyle` and `EditorStyle` to use interfaces for better abstraction in `styles.go`.
- 🖥️ Refactored input components in `InputWrapper.go` and `TextAreaWrapper.go` to utilize new style methods.
- 📦 Introduced new constants for table dimensions in `constants.go`.
- 📝 Improved header rendering in `header.go` to use centralized styles.
- 🔄 Adjusted category adapter and tab styles to implement new interfaces for better flexibility.
- 📂 Updated multiple files including `category_styles.go`, `category_tabs.go`, and `style.go` to reflect these changes.
This update enhances the key mapping structure and improves the help system for better usability.

- 🛠️ Updated `KeyMaps` structure in `makers.go` and `model.go` for consistency.
- 🔧 Introduced `ChangeModeMsg` to manage mode changes in `help.go`.
- 📦 Refactored help bindings logic in `help.go` to streamline key bindings based on current mode.
- 🖥️ Improved `Model` initialization in `model.go` to include new key maps and help model.
- 📂 Files affected: `makers.go`, `model.go`, `help.go`, `structure/model.go`
Improved the help model with additional height management and refined logging in LoggerService for better error handling.

- 📦 Updated help model in `internal/models/top/help/help.go`:
  - Added `height` property to manage help display dimensions.
  - Refined `updateHelpBindings` to improve key binding updates.

- 🔧 Enhanced logging in `internal/services/LoggerService.go`:
  - Added panic recovery in `EnhancedLogTeaMsg` for safer logging.
  - Introduced `safeDump` method to handle nil pointers and prevent crashes.

- 📦 Introduced new resize message structure in `pkg/tui/teaCmds.go`:
  - Added `ResizeMsg` type and `GetResizeCmd` function for better window size management.
This update introduces a new Filter Score feature to enhance command filtering and sorting capabilities.

- 🆕 Added FilterScore field to Command model in `internal/services/models/command.go`
- 🔧 Updated matchFilter function to return a score in `internal/models/command/filter.go`
- 📊 Integrated Filter Score into sorting logic in `internal/models/command/sort_helpers.go`
- 📦 Included Filter Score in the command list display in `internal/models/command/command_list.go`
- 🔄 Adjusted column management to accommodate new Filter Score in `internal/models/command/command_list.go`
- 📝 Updated fields definition to include Filter Score in `internal/models/structure/fields.go`
- 📋 Modified category tabs to support Filter Score in `internal/models/top/tabs/category_adapter.go`
Copy link

deepsource-io bot commented Jun 15, 2025

Here's the code health analysis summary for commits 6a6f488..84238b5. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource Go LogoGo✅ SuccessView Check ↗
DeepSource Shell LogoShell✅ SuccessView Check ↗
DeepSource Secrets LogoSecrets✅ SuccessView Check ↗
DeepSource Docker LogoDocker✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

@fchastanet fchastanet requested a review from Copilot June 15, 2025 18:39
Copilot

This comment was marked as outdated.

@fchastanet fchastanet requested a review from Copilot June 15, 2025 19:24
Copilot

This comment was marked as outdated.

@fchastanet fchastanet requested a review from Copilot June 15, 2025 19:30
Copy link

@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 a filter-scoring mechanism to commands and integrates it into sorting and display, along with refactoring style interfaces.

  • Introduces FilterScore in Command and updates database/service layer to initialize it
  • Enhances matchFilter to return both match boolean and score, and surfaces score in the UI table
  • Refactors styling components to use interface-based implementations for tabs and tables

Reviewed Changes

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

Show a summary per file
File Description
pkg/components/tabs/category_styles.go Replaced concrete styles implementation with interface
internal/services/models/command.go Added FilterScore field to Command
internal/services/LoggerService.go Enhanced logging with panic recovery and safe dumping
internal/services/DbService.go Initialized FilterScore when scanning commands
internal/models/top/tabs/category_adapter.go Updated sort state to include FieldFilterScore
internal/models/top/model.go Refactored model to use new structure and help updates
internal/models/top/makers.go Propagated new keyMaps interface to makers
internal/models/top/help/help.go Rewrote help component to react to mode and size changes
internal/models/top/header/header.go Simplified header rendering using style object
internal/models/styles/styles.go Added interface-based style factories for tables and tabs
internal/models/styles/constants.go Defined table header/filter height constants
internal/models/structure/model.go Introduced Mode, ChangeModeMsg, and shared keyMaps
internal/models/structure/fields.go Added FieldFilterScore constant
internal/models/command/sort_helpers.go Extended compareBySortField to handle FieldFilterScore
internal/models/command/inputs/TextAreaWrapper.go Injected style interface into text area wrapper
internal/models/command/inputs/InputWrapper.go Injected style interface into input wrapper
internal/models/command/filter.go Updated matchFilter signature to return score
internal/models/command/editor.go Passed new style interfaces into input constructors
internal/models/command/command_list.go Conditionally displays and widths filter score column
.golangci.yml Excluded lipgloss from linter rules
Comments suppressed due to low confidence (4)

internal/models/command/filter.go:11

  • The doc comment no longer matches the signature; update it to mention that the function returns both a match boolean and a score.
// matchFilter returns true if the item with the given ID matches the filter

internal/models/command/filter.go:13

  • This new filter scoring logic is critical and needs unit tests to cover cases for exact match, substring match, fuzzy match, and score boundaries.
func matchFilter(filterValue string, cmd *dbmodels.Command) (matched bool, score int) {

internal/services/LoggerService.go:90

  • The code uses fmt.Sprintf but the fmt package is not imported. Please add import "fmt" at the top.
            "value", fmt.Sprintf("%+v", msg))

internal/models/command/filter.go:13

  • The function now calls strconv.Atoi and strconv.Itoa but the strconv package is not imported. Please add import "strconv".
func matchFilter(filterValue string, cmd *dbmodels.Command) (matched bool, score int) {

Refactor the Filter Score field for consistency and improved sorting.

- Renamed "Filter Score" to "Score" in fields.go for clarity.
- Updated sorting logic in category_adapter.go to sort by Score and ID.
- Enhanced sorting state to include descending order for Score and ascending for ID.

These changes aim to streamline the user experience and improve the clarity of the displayed data.
Copy link

Package Line Rate Health
github.com/fchastanet/shell-command-bookmarker/app/application 0%
github.com/fchastanet/shell-command-bookmarker/internal/args 50%
github.com/fchastanet/shell-command-bookmarker/internal/models/command 0%
github.com/fchastanet/shell-command-bookmarker/internal/models/command/inputs 0%
github.com/fchastanet/shell-command-bookmarker/internal/models 0%
github.com/fchastanet/shell-command-bookmarker/internal/models/keys 0%
github.com/fchastanet/shell-command-bookmarker/internal/models/structure 0%
github.com/fchastanet/shell-command-bookmarker/internal/models/styles 0%
github.com/fchastanet/shell-command-bookmarker/internal/models/top/footer 0%
github.com/fchastanet/shell-command-bookmarker/internal/models/top/header 0%
github.com/fchastanet/shell-command-bookmarker/internal/models/top/help 0%
github.com/fchastanet/shell-command-bookmarker/internal/models/top 0%
github.com/fchastanet/shell-command-bookmarker/internal/models/top/tabs 0%
github.com/fchastanet/shell-command-bookmarker/internal/processors 87%
github.com/fchastanet/shell-command-bookmarker/internal/services 16%
github.com/fchastanet/shell-command-bookmarker/internal/services/executors 0%
github.com/fchastanet/shell-command-bookmarker/internal/services/models 0%
github.com/fchastanet/shell-command-bookmarker/internal/version 0%
github.com/fchastanet/shell-command-bookmarker/pkg/components/tabs 0%
github.com/fchastanet/shell-command-bookmarker/pkg/db 0%
github.com/fchastanet/shell-command-bookmarker/pkg/resource 0%
github.com/fchastanet/shell-command-bookmarker/pkg/search 25%
github.com/fchastanet/shell-command-bookmarker/pkg/sort 0%
github.com/fchastanet/shell-command-bookmarker/pkg/task 0%
github.com/fchastanet/shell-command-bookmarker/pkg/tui/filters 0%
github.com/fchastanet/shell-command-bookmarker/pkg/tui 3%
github.com/fchastanet/shell-command-bookmarker/pkg/tui/table 34%
github.com/fchastanet/shell-command-bookmarker/pkg/utils 0%
Summary 10% (634 / 6319)

@fchastanet fchastanet merged commit 92b061c into master Jun 15, 2025
14 checks passed
@fchastanet fchastanet deleted the improve_filtering branch June 15, 2025 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

improve filtering
1 participant