Fix timeline plot not updating on category change#44
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses a UI-state synchronization issue where changing the selected category didn’t reliably propagate to the underlying selection state used for plotting (notably the timeline plot).
Changes:
- Refresh
GroupBoxData.category_infofrom the PySide6 category combobox selection whenget_category_info()is called. - Fix
custom_age_rangesYAML schema mapping/typing inConfigDatato match the repository’s example/test YAML structure.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/midrc_react/gui/pyside6/dataselectiongroupbox.py |
Syncs category_info with the current combobox selection when queried. |
src/midrc_react/core/jsdconfig.py |
Updates custom_age_ranges alias/type to align with YAML config files. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if category_index >=0 and category_index < len(category_list): | ||
| self.data.update_category_list(category_list, category_index) |
There was a problem hiding this comment.
get_category_info() now refreshes self.data.category_info only when the combobox has a valid index; when currentIndex() is -1 (e.g., the combobox was cleared or an out-of-range index was set), this returns the previous/stale category_info, which can desync the model from the UI. Consider explicitly clearing/resetting self.data.category_info when the combobox has no valid selection (or clamping to a default index when items exist), so callers don’t keep using an outdated category.
| if category_index >=0 and category_index < len(category_list): | |
| self.data.update_category_list(category_list, category_index) | |
| if 0 <= category_index < len(category_list): | |
| self.data.update_category_list(category_list, category_index) | |
| else: | |
| # No valid selection in the category combobox; clear category_info | |
| self.data.category_info = {} |
| # Define fields based on expected YAML structure | ||
| data_sources: DataSourceConfigList = Field(..., alias='data sources') | ||
| custom_age_ranges: Optional[Dict[str, List[Union[int, float]]]] = Field(None, alias='custom_age_range') | ||
| custom_age_ranges: Optional[Dict[str, List[List[Union[int, float]]]]] = Field(None, alias='custom age ranges') |
There was a problem hiding this comment.
The updated custom_age_ranges schema uses List[List[Union[int, float]]], which allows ranges of arbitrary length, but downstream code assumes each range has exactly two elements (min, max). To fail fast on bad YAML, consider modeling each range as a fixed-length tuple (e.g., Tuple[Union[int, float], Union[int, float]]) so Pydantic validates the structure and prevents runtime IndexError/mislabeling later.
No description provided.