fix(rtstruct): prevent viewport from becoming blank on second load#5996
fix(rtstruct): prevent viewport from becoming blank on second load#5996Belbin-GK wants to merge 12 commits into
Conversation
❌ Deploy Preview for ohif-dev failed. Why did it fail? →
|
|
@wayfarer3130 Could you please review the changes? |
c9aa6a8 to
3f6ae2a
Compare
|
@wayfarer3130 We have updated the review comments. Could you please take a look at the changes? |
|
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:
📝 WalkthroughWalkthrough
ChangesViewport-driven hydration for SEG/RTSTRUCT
🎯 2 (Simple) | ⏱️ ~12 minutes
🚥 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 |
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
…outer promise on timeout
531909a to
890f7c4
Compare
|
The Netlify builds for this PR are currently failing with the following error:
Based on the build logs, the failure occurs before the application build starts and appears to be related to the CI/build environment rather than the changes introduced in this PR. @sedghi , could you please take a look at this when you get a chance? cc: @sen-trenser |
Context
Hydration was being triggered before the viewport was fully initialized, which could lead to rendering issues such as a blank viewport, especially when loading RTSTRUCT multiple times.
Changes & Results
5996-rtstruct-viewport-blank-on-second-load.mp4
Testing
Checklist
PR
semantic-release format and guidelines.
Code
etc.)
Public Documentation Updates
additions or removals.
Tested Environment
Summary by CodeRabbit
Bug Fixes
Tests
Greptile Summary
This PR fixes blank viewport regressions when loading RTSTRUCT (and SEG) a second time by replacing the
setTimeout(0)deferral with a proper readiness check: ifgetCornerstoneViewportreturns null, hydration now waits for theVIEWPORT_DATA_CHANGEDevent (with a 5-second timeout) before invokinghydrateCallback.waitForViewportDataChangehelper subscribes toVIEWPORT_DATA_CHANGEDand properly rejects on timeout; the outerasyncexecutor wraps theawaitin a try/catch so timeout rejections correctly propagate to callers.VIEWPORT_DATA_CHANGEDpayload shape{ viewportData, viewportId }is consistent with how other subscribers in the codebase, confirming the viewport-ID comparison is correct.cornerstoneViewportServicein its mock, so the new waiting branch is never exercised; the vestigialwindow.setTimeoutspy inbeforeEachis also left over from the old implementation.Confidence Score: 5/5
The runtime fix is correct and the event payload shape is consistent with existing usage; the only gaps are missing test coverage for the new branch.
The core logic is sound: the event used to detect viewport readiness is the same one used throughout the codebase, the timeout/reject wiring is correct, and no prior-thread issues remain unaddressed. The test file does not cover the new code path, but this does not introduce a runtime defect.
extensions/cornerstone/src/utils/promptHydrationDialog.test.ts — the mock services manager should be extended to exercise the new waitForViewportDataChange branch.
Important Files Changed
Reviews (13): Last reviewed commit: "Merge branch 'master' into rtstruct-view..." | Re-trigger Greptile