fix(rtstruct): prevent viewport from becoming blank on second load#5996
Open
Belbin-GK wants to merge 6 commits into
Open
fix(rtstruct): prevent viewport from becoming blank on second load#5996Belbin-GK wants to merge 6 commits into
Belbin-GK wants to merge 6 commits into
Conversation
✅ Deploy Preview for ohif-dev canceled.
|
Contributor
Author
|
@wayfarer3130 Could you please review the changes? |
e1f10d2 to
2ab1602
Compare
…outer promise on timeout
c9aa6a8 to
3f6ae2a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Greptile Summary
This PR fixes a blank-viewport regression when RTSTRUCT is loaded a second time by replacing the old
setTimeout(0)deferral with an event-driven wait: ifgetCornerstoneViewportreturnsnullat hydration time, the code now subscribes toVIEWPORT_DATA_CHANGEDand waits up to 5 seconds before proceeding, rejecting the outer promise on timeout.waitForViewportDataChangeare correctly wired — the inner promise'srejectis used for the timer, and the outercatchblock calls the outerrejectbefore returning.waitForViewportDataChangebranch is entirely absent from tests becausemockServicesManagernever providescornerstoneViewportService; the happy path (viewport already ready), the wait path, and the timeout/reject path all go unexercised.window.setTimeoutspy and a stale test description ("with setTimeout") remain in the test file from the old implementation.Confidence Score: 5/5
The core fix is logically sound with correct timeout and rejection propagation; only test coverage is lacking.
The event-driven wait correctly handles both the success path (viewport becomes ready) and the failure path (5-second timeout rejects the outer promise). No new runtime error paths are introduced for production callers. The uncovered test paths are in the new branch only; all existing tested paths are unaffected.
extensions/cornerstone/src/utils/promptHydrationDialog.test.ts — the new waitForViewportDataChange branch is never entered by any test.
Important Files Changed
Prompt To Fix All With AI
Reviews (9): Last reviewed commit: "est: remove setTimeout expectation from ..." | Re-trigger Greptile