fix: namespace localStorage keys to prevent multi-instance contention - #8
fix: namespace localStorage keys to prevent multi-instance contention#8samanthataylor3 wants to merge 1 commit into
Conversation
Resolves #5. Multiple Open MCT instances on the same host:port previously collided on localStorage keys (e.g. 'mct-recent-objects', 'notebook-storage'). - Add StorageManager utility that prefixes keys with an optional namespace - Register openmct.storage on the MCT instance; add setStorageNamespace() API - Refactor all 12+ localStorage call sites to use openmct.storage - Update LocalStorageObjectProvider to accept StorageManager - Default namespace is empty string for backward compatibility - Add unit tests for StorageManager prefix logic Co-Authored-By: Samantha Taylor <samantha.taylor@cognition.ai>
Original prompt from Samantha
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Closes #5
Describe your changes:
Multiple Open MCT instances running on the same
host:portpreviously collided on bare localStorage keys (e.g.mct-recent-objects,notebook-storage,tcHistory). This PR introduces a centralizedStorageManagerutility that optionally prefixes all keys with a configurable namespace.Architecture:
Key changes:
src/utils/StorageManager.js— new utility:_prefixKey(key)returnsnamespace ? namespace:key : keyopenmct.storageexposed on the MCT instance;openmct.setStorageNamespace(ns)API for configuration beforestart()openmct.storage.{getItem,setItem,removeItem}LocalStorageObjectProvidernow accepts theStorageManagerinstance for its space key operationsStylesManager,notebook-storage) accept storage viasetStorage()/setNotebookStorage()hooks called at plugin install timeStoragePersistence(user roles) refactored from a singleton to a class instantiated with storage''(empty string) → no prefix → fully backward compatibleFiles refactored:
mct-recent-objectssrc/ui/layout/RecentObjectsList.vuemct-tree-expandedsrc/ui/layout/MctTree.vuemct-pane-positionssrc/ui/layout/PaneContainer.vuemct-saved-stylessrc/plugins/inspectorViews/styles/StylesManager.jsopenmct-stored-view-prefssrc/ui/layout/BrowseBar.vue,src/ui/router/Browse.jsopenmct-shell-headsrc/ui/layout/AppLayout.vuenotebook-storagesrc/plugins/notebook/utils/notebook-storage.jsnotebook-snapshot-storagesrc/plugins/notebook/snapshot-container.jsACTIVE_USER_ROLEsrc/api/user/StoragePersistence.jstcHistory*src/plugins/timeConductor/ConductorHistory.vueopenmct-listview-sort-order/ storageKeysrc/plugins/folderView/components/ListView.vue,src/ui/components/List/ListView.vuemct(spaceKey)src/plugins/localStorage/LocalStorageObjectProvider.jsAll Submissions:
Author Checklist
type:label? Note: this is not necessarily the same as the original issue.Reviewer Checklist
Link to Devin session: https://app.devin.ai/sessions/9df1d5119fef4e4fbdd1b57e62809416
Requested by: @samanthataylor3
Devin Review