Skip to content

Fix search buttons in configure view#12

Merged
j4ys0n merged 1 commit intomainfrom
claude/fix-configure-search-click-011CUoi67F6C7LUgaTkmMc6N
Nov 4, 2025
Merged

Fix search buttons in configure view#12
j4ys0n merged 1 commit intomainfrom
claude/fix-configure-search-click-011CUoi67F6C7LUgaTkmMc6N

Conversation

@j4ys0n
Copy link
Contributor

@j4ys0n j4ys0n commented Nov 4, 2025

The search dialog was failing to open with "ValueError: Invalid value: -1" because NiceGUI's select component has validation issues when using numeric values with dict-based options and emit-value/map-options props.

Changed the direction select to use string values ('desc', 'asc') instead of integers (-1, 1) and updated _perform_search to convert the string back to the integer value expected by the HuggingFace service API.

Fixes the issue where clicking "Search Models" or "Search Datasets" in the configure view would crash instead of opening the search dialog.

The search dialog was failing to open with "ValueError: Invalid value: -1"
because NiceGUI's select component has validation issues when using numeric
values with dict-based options and emit-value/map-options props.

Changed the direction select to use string values ('desc', 'asc') instead
of integers (-1, 1) and updated _perform_search to convert the string back
to the integer value expected by the HuggingFace service API.

Fixes the issue where clicking "Search Models" or "Search Datasets" in the
configure view would crash instead of opening the search dialog.
Copilot AI review requested due to automatic review settings November 4, 2025 23:25
Copy link

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 refactors the direction selection in the HuggingFace search dialog to use string values ('desc', 'asc') instead of integer values (-1, 1), improving code readability and maintainability while preserving the same functionality.

Key Changes:

  • Updated the direction selector options to use string values ('desc', 'asc') instead of integers (-1, 1)
  • Added conversion logic to translate string direction values back to integers before passing to the HuggingFace service

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

@j4ys0n
Copy link
Contributor Author

j4ys0n commented Nov 4, 2025

Automated review 🤖

Summary of Changes
This PR fixes a crash in the configure view's search functionality by addressing a NiceGUI validation issue with numeric values in select components. The fix changes the direction select to use string values ('desc', 'asc') instead of integers (-1, 1) and adds conversion logic in the search function to maintain compatibility with the HuggingFace API.

Key Changes & Positives

  • 🟢 Replaced numeric values (-1, 1) with string values ('desc', 'asc') in direction select options to avoid NiceGUI validation issues
  • 🟢 Updated the search function to convert string direction back to integer values expected by HuggingFace API
  • 🟢 Maintained backward compatibility with existing API expectations

Potential Issues & Recommendations

  1. Issue / Risk: String comparison logic could be fragile if new direction values are added
    Impact: May cause unexpected behavior if direction values change
    Recommendation: Use a mapping dictionary for direction conversion instead of if-else
    Status: 🟡 Needs review

  2. Issue / Risk: Default value handling could be inconsistent with other components
    Impact: May cause unexpected default behavior in edge cases
    Status: 🟡 Needs review

Language/Framework Checks

  • Python: Code follows standard Python practices, uses proper type hints, and maintains existing function signatures
  • NiceGUI: Correctly handles component validation issues by changing data types, aligns with framework constraints

Security & Privacy

  • No security or privacy concerns introduced

Build/CI & Ops

  • No build or deployment changes required

Tests

  • No test changes included; should add tests for direction select value conversion and default behavior

Approval Recommendation
Approve with caveats

  • Consider using a mapping dictionary for direction conversion instead of if-else logic
  • Verify default value behavior consistency across all search components
  • Add tests for the direction conversion logic

@j4ys0n j4ys0n merged commit d7bc8c5 into main Nov 4, 2025
7 checks passed
@j4ys0n j4ys0n deleted the claude/fix-configure-search-click-011CUoi67F6C7LUgaTkmMc6N branch November 4, 2025 23:28
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.

3 participants