fix: LaserAFConfig defaults from _def.py & status bar height stability#517
Conversation
…tus bar height changes 1) LaserAFConfig had hardcoded defaults that diverged from _def.py: - spot_detection_mode: DUAL_RIGHT vs DUAL_LEFT - min_peak_prominence: 0.25 vs 0.20 - correlation_threshold: 0.9 vs 0.7 - focus_camera_exposure_time_ms: 0.2 vs 2.0 Now uses default_factory referencing _def.py constants so they stay in sync. 2) Status bar WarningErrorWidget could grow taller when error messages contained newlines. Fixed by collapsing whitespace in display text and setting a fixed height on the message label. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR aligns LaserAFConfig model defaults with the canonical laser autofocus constants in control/_def.py, and hardens the status bar warning/error widget so multi-line messages don’t increase the status bar height.
Changes:
- Update
LaserAFConfigdefaults to reference_def.pyconstants and extend tests to assert the defaults match_def.py. - Prevent status bar height growth by collapsing newlines in displayed messages and constraining the message label height.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| software/control/models/laser_af_config.py | Swaps hardcoded Laser AF defaults for _def.py-driven defaults via default_factory. |
| software/tests/control/test_acquisition_config_models.py | Updates the LaserAFConfig default test to validate against _def.py constants. |
| software/control/widgets.py | Makes status bar message display single-line and height-stable when incoming log messages contain newlines. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| default_factory=lambda: float(_def.LASER_AF_SPOT_SPACING), description="Expected spot spacing" | ||
| ) | ||
| filter_sigma: Optional[float] = Field( | ||
| default_factory=lambda: _def.LASER_AF_FILTER_SIGMA, description="Gaussian filter sigma (-1 to disable)" |
There was a problem hiding this comment.
The field description says "Gaussian filter sigma (-1 to disable)", but _def.LASER_AF_FILTER_SIGMA is None and utils.find_spot_location() only applies filtering when filter_sigma is not None and filter_sigma > 0. Update the description (or the sentinel) so the docs match the actual disable behavior (e.g., "None or <= 0 to disable").
| default_factory=lambda: _def.LASER_AF_FILTER_SIGMA, description="Gaussian filter sigma (-1 to disable)" | |
| default_factory=lambda: _def.LASER_AF_FILTER_SIGMA, | |
| description="Gaussian filter sigma (None or <= 0 to disable)", |
| # Message text | ||
| # Message text – fixed height so newlines / long text can't grow the status bar | ||
| self.label_text = QLabel() | ||
| self.label_text.setFixedHeight(20) |
There was a problem hiding this comment.
Hard-coding setFixedHeight(20) can clip the message text when users run with larger fonts / DPI scaling (accessibility), since the widget height is now fixed regardless of font metrics. Consider computing the fixed height from QFontMetrics(self.label_text.font()).height() (plus margins) or tying it to self.label_icon.height() so the status bar stays single-line without truncating glyphs.
| self.label_text.setFixedHeight(20) | |
| # Compute height from font metrics and icon size to avoid clipping with larger fonts/DPI | |
| text_height = self.label_text.fontMetrics().height() | |
| icon_height = self.label_icon.sizeHint().height() | |
| self.label_text.setFixedHeight(max(text_height, icon_height)) |
…FConfig - spot_detection_mode: remove incomplete enum list from description - filter_sigma: fix description to say "None to disable" (not -1) - Add 8 missing default_factory field assertions to test Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…mber Addresses Copilot review comment: hardcoded setFixedHeight(20) could clip text with larger fonts/DPI. Now computed from font metrics. Also hide unimplemented MULTI_SECOND_RIGHT spot detection mode from UI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
_def.pyconstants instead of hardcoded values. Several defaults had diverged (e.g.spot_detection_modewasDUAL_RIGHTinstead ofDUAL_LEFT,correlation_thresholdwas0.9vs0.7,focus_camera_exposure_time_mswas0.2vs2.0).Test plan
🤖 Generated with Claude Code