Skip to content

fix(microscopy): show the ROIs again when toggling their visibility - #6303

Merged
wayfarer3130 merged 3 commits into
OHIF:masterfrom
namespaceMarcello:fix/microscopy-toggle-rois
Oct 7, 2026
Merged

wayfarer3130 merged 3 commits into
OHIF:masterfrom
namespaceMarcello:fix/microscopy-toggle-rois

Conversation

@namespaceMarcello

@namespaceMarcello namespaceMarcello commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Context

MicroscopyService.toggleROIsVisibility hides the ROIs on the first call, but never shows them again:

this.isROIsVisible ? this.hideROIs() : this.showROIs;

The second branch reads the method and does not call it. The flag still flips, so after two toggles the service says the ROIs are visible while every viewer keeps them hidden. The toggleAnnotations command of the microscopy extension is the only caller.

CodeQL reports this line as js/useless-expression ("This expression has no effect").

Changes & Results

  • extensions/dicom-microscopy/src/services/MicroscopyService.ts: call this.showROIs().
  • extensions/dicom-microscopy/src/services/MicroscopyService.test.ts: new test. The first toggle calls hideROIs on the managed viewer and sets isROIsVisible to false. The second toggle calls showROIs and sets it back to true.
  • extensions/dicom-microscopy/jest.config.js: new, the same as extensions/dicom-pdf/jest.config.js. The extension had no Jest config, so the root projects glob did not pick up its tests.

Before: after a hide, toggleAnnotations cannot show the ROIs again.
After: toggleAnnotations alternates between hide and show.

Verified locally:

  • The new test fails on master: showROIs is called 0 times on the second toggle.
  • The test passes with the change.
  • Removing only the flag flip (this.isROIsVisible = !this.isROIsVisible) makes both tests fail, on isROIsVisible and on the hideROIs call count.
  • CodeQL 2.27.0 (the javascript-code-scanning and javascript-code-quality suites) on this branch against master: the js/useless-expression alert is gone, and there is no new alert.
  • pnpm run test:unit:ci, pnpm run lint:compiler:ci and pnpm run compiler:coverage:ci pass. Prettier passes on the changed files.

Testing

  1. cd extensions/dicom-microscopy && pnpm exec jest src/services/MicroscopyService.test.ts
  2. In the viewer, open a slide microscopy study, and run the toggleAnnotations command twice (for example from a hotkey bound to it). The ROIs hide, then show again.

Checklist

PR

  • My Pull Request title is descriptive, accurate and follows the
    semantic-release format and guidelines.

Code

  • My code has been well-documented (function documentation, inline comments,
    etc.)

Public Documentation Updates

  • The documentation page has been updated as necessary for any public API
    additions or removals. (No public API change.)

Tested Environment

  • OS: Windows 11
  • Node version: 24.13.0
  • Browser: not applicable (unit test)

Written by Claude Code (AI assistant) on behalf of @namespaceMarcello, who directs this work.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Restoring ROI visibility now correctly shows managed-viewer ROIs after they have been hidden. Toggling visibility off and then on again updates both the displayed ROIs and their visibility state. This fixes the behavior where ROIs could remain hidden after users attempted to restore them.

toggleROIsVisibility read this.showROIs without calling it, so the
toggleAnnotations command could hide the ROIs but never show them
again, while the isROIsVisible flag still flipped. CodeQL reports the
line as js/useless-expression.

The extension had no Jest config, so the new test comes with one, the
same as the dicom-pdf extension.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@netlify

netlify Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for ohif-dev ready!

Name Link
🔨 Latest commit 47f3ea6
🔍 Latest deploy log https://app.netlify.com/projects/ohif-dev/deploys/6ac54de6971d39000871a3e0
😎 Deploy Preview https://deploy-preview-6303--ohif-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c2a2ce06-5a29-468d-a374-e5269d5c246d
📥 Commits

Reviewing files that changed from the base of the PR and between 924b6aa and 47f3ea6.

📒 Files selected for processing (2)
  • extensions/dicom-microscopy/package.json
  • extensions/dicom-microscopy/src/helpers/formatDICOMDate.test.js
💤 Files with no reviewable changes (1)
  • extensions/dicom-microscopy/src/helpers/formatDICOMDate.test.js

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The microscopy ROI visibility toggle now calls showROIs() when restoring visibility. Tests cover both toggle states. Jest configuration and package scripts support unit testing, and the formatDICOMDate test was removed.

Changes

Microscopy ROI visibility

Layer / File(s) Summary
Toggle behavior and validation
extensions/dicom-microscopy/src/services/MicroscopyService.ts, extensions/dicom-microscopy/src/services/MicroscopyService.test.ts, extensions/dicom-microscopy/jest.config.js, extensions/dicom-microscopy/package.json, extensions/dicom-microscopy/src/helpers/formatDICOMDate.test.js
The show branch now calls showROIs(). Tests verify that two toggles hide and then show managed-viewer ROIs and update visibility state. Jest configuration adds mappings for @ohif imports, and package scripts add unit test commands. The formatDICOMDate test was deleted.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: wayfarer3130

Merge Risk: ⚪ Minimal · up to 47f3e

ROI visibility can be restored after hiding, and the regression test is included in the configured Jest workflow. No actionable merge risk was identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main fix and follows the semantic-release format.
Description check ✅ Passed The description covers the context, changes, results, testing steps, and checklist. It also reports the tested environment and explains why no public documentation update was needed.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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.

CI runs `pnpm run test:unit:ci` in each package, and the microscopy
extension had no such script, so its tests never ran. Add the same
test:unit scripts that the cornerstone extension uses.

Remove formatDICOMDate.test.js: it only tested a re-export of the
@ohif/ui-next helper, which ui-next already tests, and importing the
whole ui-next barrel fails under the extension's Babel transform.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wayfarer3130
wayfarer3130 deployed to unrestricted October 6, 2026 19:38 — with GitHub Actions Active
@wayfarer3130
wayfarer3130 merged commit 56e0611 into OHIF:master Oct 7, 2026
9 checks passed

This branch was successfully deployed

1 active deployment
unrestricted — 47f3ea60 Deployed Oct 6, 2026 by wayfarer3130 via playwright-tests (24.15.0) #5181
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.

2 participants