Expand description
StorageProvider: persists extension and workspace state blobs.
§StorageProvider (Environment)
Implements the StorageProvider trait for MountainEnvironment. Contains
the core logic for Memento storage: reading from and writing to JSON
storage files on disk.
§Storage scopes
- Global (
IsGlobalScope = true) - application-level key-value store shared across all workspaces; persisted toGlobalMementoPath. Used for user preferences, extension state. - Workspace (
IsGlobalScope = false) - workspace-specific state; persisted toWorkspaceMementoPath(reloaded on workspace change viaUpdateWorkspaceMementoPathAndReload). Used for workspace configs.
§Storage operations
GetStorageValue(scope, key)- reads from in-memoryHashMap; returnsNonefor missing or empty keys; rejects keys > 1 024 chars.UpdateStorageValue(scope, key, value)- inserts or removes key; rejects values > 10 MB; spawns asyncSaveStorageToDiskafter each mutation.GetAllStorage(scope)- returns the full in-memory map as JSON.SetAllStorage(scope, state)- overwrites the full map and persists.
§Async persistence
All disk writes go through SaveStorageToDisk, which is spawned via
tokio::spawn so the trait call returns immediately. The function creates
parent directories as needed and logs errors without propagating them
(fire-and-forget pattern). Writes are NOT yet atomic (temp+rename); that
is a known TODO.
§VS Code reference
vs/platform/storage/common/storageService.tsvs/platform/storage/common/memento.ts
Functions§
- Save
Storage 🔒ToDisk - An internal helper function to asynchronously write the storage map to a file.