Skip to content

fix(gsps): allow GSPS toggle when any viewport has overlay#29

Merged
timcogan merged 3 commits intomasterfrom
fix/gsps-group-toggle-availability
Mar 7, 2026
Merged

fix(gsps): allow GSPS toggle when any viewport has overlay#29
timcogan merged 3 commits intomasterfrom
fix/gsps-group-toggle-availability

Conversation

@timcogan
Copy link
Owner

@timcogan timcogan commented Mar 7, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved GSPS overlay detection so overlays on any loaded viewport are recognized; toggle now references the current image/group, clears stale errors on success, and preserves non-GSPS status when appropriate.
  • Tests
    • Added and updated tests covering overlay toggling across viewports and the revised availability/status messages.

@coderabbitai
Copy link

coderabbitai bot commented Mar 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 772a3510-2f40-4954-92e1-fbad9d9617d1

📥 Commits

Reviewing files that changed from the base of the PR and between 5a3ad67 and 43d5131.

📒 Files selected for processing (1)
  • src/app.rs

📝 Walkthrough

Walkthrough

Replaces the public active_gsps_overlay() accessor with has_available_gsps_overlay() that checks the active image and loaded MammoViewports for a GSPS overlay. Updates toggle logic, status messages, and tests. Adds a test-only DicomImage::test_stub() helper for constructing images with optional GSPS overlays.

Changes

Cohort / File(s) Summary
GSPS overlay logic
src/app.rs
Removed active_gsps_overlay() public accessor; added has_available_gsps_overlay(); updated toggle_gsps_overlay() and callers to use the new presence-check; adjusted status message wording; expanded/updated related tests.
Test utilities
src/dicom.rs
Added #[cfg(test)] pub(crate) fn test_stub(gsps_overlay: Option<GspsOverlay>) -> DicomImage to construct minimal test DicomImage instances with optional GSPS overlays.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through viewports, soft and spry,
Found overlays hiding, left and right,
Switched a flag, fixed tests with pride,
Stubbed a Dicom image for the ride,
Hooray — overlays now jump into sight! 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing has_active_gsps_overlay with has_available_gsps_overlay to allow GSPS overlay toggle when any viewport (not just the current one) has an overlay.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/gsps-group-toggle-availability

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/dicom.rs (1)

1228-1249: Make test_stub consistent with frame_count.

Right now the stub reports frame_count: 1, but both frame stores are empty, so frame_mono_pixels(0) always returns None. That makes the helper easy to misuse in tests that expect a minimal renderable image.

Proposed fix
 #[cfg(test)]
 impl DicomImage {
     pub(crate) fn test_stub(gsps_overlay: Option<GspsOverlay>) -> Self {
         Self {
             width: 1,
             height: 1,
-            mono_frames: MonoFrames::None,
+            mono_frames: MonoFrames::Eager(vec![Arc::<[i32]>::from(
+                vec![0].into_boxed_slice(),
+            )]),
             rgb_frames: RgbFrames::None,
             frame_count: 1,
             color_mode: ImageColorMode::Monochrome,
             samples_per_pixel: 1,
             invert: false,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/dicom.rs` around lines 1228 - 1249, The test_stub currently sets
frame_count: 1 while both MonoFrames and RgbFrames are empty, making
frame_mono_pixels(0) return None; update test_stub to set frame_count: 0 (or
alternatively populate MonoFrames/RgbFrames with a single 1x1 frame) so the
frame_count value matches the actual frame stores—modify the frame_count field
in the test_stub constructor to 0 (or add a minimal MonoFrames::OneFrame
containing a single pixel and keep frame_count as 1) and ensure consistency with
functions like frame_mono_pixels.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/app.rs`:
- Around line 323-329: The code sets self.status_line to an error when
!self.has_available_gsps_overlay(), but never clears that stale message when a
later successful toggle occurs; update the successful toggle path (the branch
where you currently flip self.gsps_overlay_visible = !self.gsps_overlay_visible)
to clear the error by resetting self.status_line (e.g. to an empty string) so
that when has_available_gsps_overlay() is true and you change
self.gsps_overlay_visible the old error is removed; ensure the change touches
the block containing has_available_gsps_overlay(), gsps_overlay_visible, and
status_line so the message is cleared only on a successful toggle.

---

Nitpick comments:
In `@src/dicom.rs`:
- Around line 1228-1249: The test_stub currently sets frame_count: 1 while both
MonoFrames and RgbFrames are empty, making frame_mono_pixels(0) return None;
update test_stub to set frame_count: 0 (or alternatively populate
MonoFrames/RgbFrames with a single 1x1 frame) so the frame_count value matches
the actual frame stores—modify the frame_count field in the test_stub
constructor to 0 (or add a minimal MonoFrames::OneFrame containing a single
pixel and keep frame_count as 1) and ensure consistency with functions like
frame_mono_pixels.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cfb91f62-54da-4f3d-aabe-2d7e6ec04b95

📥 Commits

Reviewing files that changed from the base of the PR and between 2a81f80 and 1f010ee.

📒 Files selected for processing (2)
  • src/app.rs
  • src/dicom.rs

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
src/app.rs (1)

323-330: ⚠️ Potential issue | 🟡 Minor

Only clear the stale GSPS error, not every status message.

self.status_line.clear() also removes unrelated messages like successful load/status text whenever the user toggles GSPS successfully. This should only clear the known “No GSPS overlay…” message.

Suggested change
     fn toggle_gsps_overlay(&mut self) {
+        const NO_GSPS_MESSAGE: &str =
+            "No GSPS overlay available for the current image or group.";
         if !self.has_available_gsps_overlay() {
             self.gsps_overlay_visible = false;
-            self.status_line =
-                "No GSPS overlay available for the current image or group.".to_string();
+            self.status_line = NO_GSPS_MESSAGE.to_string();
             return;
         }
-        self.status_line.clear();
+        if self.status_line == NO_GSPS_MESSAGE {
+            self.status_line.clear();
+        }
         self.gsps_overlay_visible = !self.gsps_overlay_visible;
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app.rs` around lines 323 - 330, When toggling GSPS overlay in the block
that checks has_available_gsps_overlay(), don't unconditionally clear
self.status_line; instead only clear that field if it currently equals the
specific "No GSPS overlay available for the current image or group." message so
other status text remains. Update the code around has_available_gsps_overlay(),
gsps_overlay_visible, and status_line to check the current value of
self.status_line before clearing it and leave it untouched otherwise.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@src/app.rs`:
- Around line 323-330: When toggling GSPS overlay in the block that checks
has_available_gsps_overlay(), don't unconditionally clear self.status_line;
instead only clear that field if it currently equals the specific "No GSPS
overlay available for the current image or group." message so other status text
remains. Update the code around has_available_gsps_overlay(),
gsps_overlay_visible, and status_line to check the current value of
self.status_line before clearing it and leave it untouched otherwise.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b20aa8c3-6bf4-4f6d-a8fd-fb72902f4ffc

📥 Commits

Reviewing files that changed from the base of the PR and between 1f010ee and 5a3ad67.

📒 Files selected for processing (2)
  • src/app.rs
  • src/dicom.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/dicom.rs

@timcogan
Copy link
Owner Author

timcogan commented Mar 7, 2026

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Mar 7, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@timcogan timcogan merged commit 36a2bea into master Mar 7, 2026
7 checks passed
@timcogan timcogan deleted the fix/gsps-group-toggle-availability branch March 7, 2026 04:05
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.

1 participant