fix(ToolGroupService): Centralize tool binding persistence and provide API to add and remove persisted bindings.#5989
Merged
Conversation
…e API to add and remove persisted bindings.
✅ Deploy Preview for ohif-dev canceled.
|
sedghi
approved these changes
Apr 30, 2026
Member
sedghi
left a comment
There was a problem hiding this comment.
see greptile review too please
Collaborator
Author
Yes I am looking at those now and they are significant. |
sedghi
approved these changes
May 5, 2026
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
ToolGroupService, which duplicated storage-key resolution and made persistence behavior harder to reason about.Changes & Results
ToolGroupServiceby adding:persistToolBindings(toolGroupId, toolName, bindings)removePersistedToolBindings(toolGroupId, toolName?)userPreferencesCustomization.tsxand routed persistence calls throughtoolGroupService.toolGroupService.persistToolBindings(...)toolGroupService.removePersistedToolBindings('mpr', 'Crosshairs')ToolGroupService:applyToolBindings(toolGroupId, toolName, options?)options.replaceExistingto reset existing active bindings before reapplying.applyToolBindings('mpr', 'Crosshairs', { replaceExisting: true })ToolGroupServicedocs to:setToolBindingsupdates internal service state, whileapplyToolBindingsapplies those bindings to runtime tool behavior.Testing
Test A - Previous preferences removed
Test B - Reset preferences restores tool group binding
Test C - Preference binding applied when Crosshair tool is active by default
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: 5.63 GB / 31.68 GB
Binaries:
Node: 20.9.0 - C:\Users\joebo\AppData\Local\fnm_multishells\24236_1777488400307\node.EXE
Yarn: 1.22.22 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 10.1.0 - C:\Users\joebo\AppData\Local\fnm_multishells\24236_1777488400307\npm.CMD
bun: 1.2.23 - C:\Users\joebo.bun\bin\bun.EXE
Browsers:
Chrome: 147.0.7727.117
Edge: Chromium (146.0.3856.84)
Internet Explorer: 11.0.26100.8115
Greptile Summary
This PR centralises tool-binding persistence in
ToolGroupService, replacing scatteredlocalStoragecalls in the UI layer with dedicated service methods (persistToolBindings,removePersistedToolBindings). It also captures default bindings at tool-group init time and applies persisted bindings immediately when a tool is already Active on load, closing several Crosshairs-specific regressions.ToolGroupService: addspersistToolBindings,removePersistedToolBindings,getDefaultToolBindings,applyToolBindingswithreplaceExistingsemantics, and_loadPersistedBindingsnow applies bindings immediately for Active tools;defaultToolBindingsMapcaptures initial bindings once and survives the session untildestroy().userPreferencesCustomization.tsx: removes duplicated storage-key resolution; reset path now callssetToolBindings+applyToolBindings({ replaceExisting: true })with the captured defaults before clearing the persisted preference, ensuring the runtime is immediately consistent without requiring a page reload.replaceExistingflag and the semantic distinction betweensetToolBindings(map update) andapplyToolBindings(runtime update).Confidence Score: 5/5
Safe to merge — the refactor is well-scoped, the new API is internally consistent, and the previously reported runtime-restore gap on reset has been addressed.
All three changed files are in good shape. The persistence centralisation is correct, the default-bindings capture is guarded against re-initialisation, and the replaceExisting path correctly clears stale modifier bindings before applying new ones. No data-loss or incorrect-runtime-state paths were found.
No files require special attention.
Important Files Changed
persistToolBindings/removePersistedToolBindings, captures default bindings on init, and applies persisted bindings immediately when the affected tool is already Active. Logic is correct and well-guarded.toolGroupService, and properly restores default runtime bindings on reset. Minor:getToolModifierandgetModifierFromBindingsshare identical predicate logic.replaceExistingoption and the distinction betweensetToolBindings(map update) andapplyToolBindings(runtime update).Comments Outside Diff (1)
extensions/default/src/customizations/userPreferencesCustomization.tsx, line 107-117 (link)onResetHandlerremoves the localStorage entry viaremovePersistedToolBindings, but neither callssetToolBindingswith the default modifier nor callsapplyToolBindingsto push that default back to the Cornerstone runtime. The Crosshairs tool continues operating with the custom binding for the rest of the current session — only a full page reload would restore the default. The save path performs all three steps (set map → apply runtime → persist); reset should symmetrically reverse them (set map to default → apply runtime → remove persisted).Prompt To Fix With AI
Prompt To Fix All With AI
Reviews (3): Last reviewed commit: "PR feedback." | Re-trigger Greptile