Fix: Segmentation Hide All fails when switching from 2D to 3D fourUp#5995
Conversation
✅ Deploy Preview for ohif-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@sedghi Could you please take a look at this PR and provide your feedback? |
|
@wayfarer3130 Could you please review this PR? |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2245ecf to
06408d2
Compare
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe segmentation representation type selection is refactored to explicitly check target viewport dimensionality. For 3D viewports it forces Surface. For non-3D viewports it preserves explicitly requested representations (including Contour) when present and non-Surface, otherwise defaults to Labelmap. The related integration test is updated with an explicit asynchronous synchronization wait to account for labelmap volume propagation timing. ChangesSegmentation Representation Hydration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
extensions/cornerstone/src/services/SyncGroupService/createHydrateSegmentationSynchronizer.ts (1)
96-102: ⚡ Quick winSimplify the conditional logic by removing the redundant Contour check.
The explicit check for
Contouron lines 98-99 is redundant because whenrequestedRepresentation === Contour, it will also satisfy the condition on line 100 (requestedRepresentation && requestedRepresentation !== Surface). Both branches return the same value for Contour requests.♻️ Proposed simplification
const type: Enums.SegmentationRepresentations = is3D ? Surface - : requestedRepresentation === Contour - ? Contour - : requestedRepresentation && requestedRepresentation !== Surface + : requestedRepresentation && requestedRepresentation !== Surface ? requestedRepresentation : Labelmap;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@extensions/cornerstone/src/services/SyncGroupService/createHydrateSegmentationSynchronizer.ts` around lines 96 - 102, The ternary that computes the `type` in `createHydrateSegmentationSynchronizer` is redundant: remove the explicit `requestedRepresentation === Contour ? Contour :` branch and simplify the expression to first choose `Surface` when `is3D` is true, otherwise return `requestedRepresentation` if it exists and is not `Surface`, and fall back to `Labelmap`; update the `const type: Enums.SegmentationRepresentations` assignment accordingly (references: `type`, `is3D`, `requestedRepresentation`, `Surface`, `Contour`, `Labelmap`, `Enums.SegmentationRepresentations`).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@extensions/cornerstone/src/services/SyncGroupService/createHydrateSegmentationSynchronizer.ts`:
- Around line 96-102: The ternary that computes the `type` in
`createHydrateSegmentationSynchronizer` is redundant: remove the explicit
`requestedRepresentation === Contour ? Contour :` branch and simplify the
expression to first choose `Surface` when `is3D` is true, otherwise return
`requestedRepresentation` if it exists and is not `Surface`, and fall back to
`Labelmap`; update the `const type: Enums.SegmentationRepresentations`
assignment accordingly (references: `type`, `is3D`, `requestedRepresentation`,
`Surface`, `Contour`, `Labelmap`, `Enums.SegmentationRepresentations`).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: e7bdc94f-7219-414e-b10a-8faf1647a136
📒 Files selected for processing (1)
extensions/cornerstone/src/services/SyncGroupService/createHydrateSegmentationSynchronizer.ts
6f7f140 to
e1e5456
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/SEGHydrationFrom3DFourUp.spec.ts`:
- Around line 63-65: The waitForViewportsRendered function call at line 65 uses
the default 15 second timeout, which is insufficient given that the test
scenario documents multi-viewport render times of up to 240 seconds (as shown in
the earlier assertions). To prevent test flakiness under slower CI conditions,
add an explicit longer timeout parameter to the waitForViewportsRendered(page)
call to match or exceed the documented render times in the test.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 7fe81a63-fb40-48e6-839d-2467736aba4c
⛔ Files ignored due to path filters (1)
tests/screenshots/chromium/SEGHydrationFrom3DFourUp.spec.ts/threeDFourUpAfterSegHydrated.pngis excluded by!**/*.png
📒 Files selected for processing (1)
tests/SEGHydrationFrom3DFourUp.spec.ts
Context
Fix issue: #5948
After loading a segmentation file in the 2D viewport, switching to the 3D four-up viewport causes the "Hide All" functionality to stop working. When the user selects "Hide All", the segmentations remain visible instead of being hidden.
Changes & Results
Refactor segmentation type selection to use explicit viewport-based logic.
For 3D viewports, enforce
Surface; for 2D, allowContouror default toLabelmap.This change will ensure consistent behavior and prevent unsupported types from propagating
Seg-3d-four-up-hide-error.mp4
Testing
Checklist
PR
semantic-release format and guidelines.
Code
etc.)
Public Documentation Updates
additions or removals.
Tested Environment
Summary by CodeRabbit
Bug Fixes
Greptile Summary
This PR fixes a bug where "Hide All" segmentation control stops working after switching from a 2D viewport to a 3D four-up layout. The root cause was that the
SEGMENTATION_REPRESENTATION_MODIFIEDsynchronizer was propagating theSurfacerepresentation type (produced by the 3D viewport) to 2D MPR target viewports, leaving those viewports in an unsupported state.createHydrateSegmentationSynchronizer.tsnow explicitly rejectsSurfaceas a fallback for non-3D viewports, usingLabelmapinstead, while still preservingContourwhen that is the requested type.waitForViewportsRenderedguard to account for the asynchronous nature of labelmap propagation to MPR viewports after the first render cycle.Confidence Score: 5/5
Safe to merge; the fix is narrowly scoped to representation-type selection and does not touch rendering pipelines or data loading.
The logic change is small and correct: it adds a single additional guard (requestedRepresentation !== Surface) so 2D MPR viewports never receive a Surface representation they cannot handle. The existing fallback chain is otherwise preserved. The test update mirrors the async behaviour that already existed in production and the screenshot baseline matches the fixed output.
No files require special attention.
Important Files Changed
Reviews (14): Last reviewed commit: "Merge branch 'master' into fix-seg-load-..." | Re-trigger Greptile