fix(hotkeyBindings): consolidate Escape hotkey behavior for contour drawing tools#6104
fix(hotkeyBindings): consolidate Escape hotkey behavior for contour drawing tools#6104jbocce wants to merge 7 commits into
Conversation
✅ Deploy Preview for ohif-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds ChangesEscape cancellation for contour interactions
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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.
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 `@extensions/cornerstone/src/commandsModule.ts`:
- Around line 2055-2057: The cancel flow currently lets a preview failure from
rejectPreview stop cancelMeasurement from running, so update
cancelActiveOperation to guarantee measurement cancellation even if preview
rejection throws. Adjust the preview handling path in _handlePreviewAction so it
does not escape past the per-tool try/catch, or wrap the rejectPreview call
locally so cancelMeasurement still executes for the active annotation when
Escape is pressed.
🪄 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: 471220d7-52a7-4901-a89e-f8b762d3b00d
📒 Files selected for processing (11)
extensions/cornerstone/src/commandsModule.tsplatform/core/src/defaults/hotkeyBindings.tsplatform/docs/docs/migration-guide/3p12-to-3p13/escape-cancel-hotkey.mdplatform/ui-next/src/components/OHIFToolSettings/ToolSettings.tsxtests/BSplineContourSegmentation.spec.tstests/CatmullRomSplineContourSegmentation.spec.tstests/LinearSplineContourSegmentation.spec.tstests/Livewire.spec.tstests/LivewireContourSegmentation.spec.tstests/Spline.spec.tstests/pages/RightPanelPageObject.ts
wayfarer3130
left a comment
There was a problem hiding this comment.
extensions/cornerstone/src/commandsModule.ts:307 — cancelMeasurement duplicates existing cancel logic (reuse). The body (const element = _getActiveViewportEnabledElement()?.viewport?.element; if (element) cancelActiveManipulations(element);) is identical to initMeasurementService.ts:534-536. Two copies of the same "cancel active manipulations on the active viewport" snippet will drift independently; consider a shared helper. (Cost: duplicated logic, not a crash.)
Great catch. Resolved! |
Context
Fixes #6079
Pressing Esc while drawing a contour (Spline, Livewire, PlanarFreehand) did not cancel the in-progress annotation. Two separate commands were bound to the same esc key — cancelMeasurement and rejectPreview — but Mousetrap keeps only one handler per key, so the second binding silently shadowed the first and the cancel effectively did nothing.
Changes & Results
when its state isn't active, so running both is safe and order-independent.
drawing.
spline-type switching).
Result: a single Esc press now reliably discards whatever is in progress — a segmentation preview or an annotation being drawn.
Testing
Added Playwright E2E coverage asserting Esc cancels an in-progress drawing for each affected tool:
LivewireContourSegmentation.spec.ts
Manual check:
Checklist
PR
semantic-release format and guidelines.
Code
etc.)
Public Documentation Updates
additions or removals.
Tested Environment
System:
OS: Windows 11 10.0.26200
CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H
Memory: 8.83 GB / 31.68 GB
Binaries:
Node: 24.15.0 - C:\Users\joebo\AppData\Local\fnm_multishells\50148_1782198425052\node.EXE
Yarn: 1.22.22 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 11.12.1 - C:\Users\joebo\AppData\Local\fnm_multishells\50148_1782198425052\npm.CMD
pnpm: 11.5.2 - C:\Users\joebo\AppData\Local\pnpm\bin\pnpm.CMD
bun: 1.2.23 - C:\Users\joebo.bun\bin\bun.EXE
Browsers:
Chrome: 149.0.7827.115
Edge: Chromium (149.0.4022.80)
Internet Explorer: 11.0.26100.8115
Summary by CodeRabbit