store sync bugfix

This commit is contained in:
2026-04-17 22:27:06 -04:00
parent 9ca7908c0e
commit 7abbd2e5c7
9 changed files with 104 additions and 94 deletions

View File

@@ -91,7 +91,7 @@ export const DEFAULT_STORES: StoreConfig[] = [
{
name: 'shapes',
persistent: true,
initialState: () => ({}),
initialState: () => ({ shapes: {} }),
},
{
name: 'indicators',
@@ -285,7 +285,7 @@ export interface Shape {
/**
* Shapes store - persistent, stores TradingView drawings and annotations.
*/
export type ShapesStore = Record<string, Shape>;
export type ShapesStore = { shapes: Record<string, Shape> };
/**
* Parameter schema entry for a custom indicator.

View File

@@ -90,7 +90,14 @@ export class WorkspaceManager {
const states = await this.containerSync.loadAllStores(persistentStores);
for (const [storeName, state] of states) {
this.registry.setState(storeName, state);
let migratedState = state;
// Migrate shapes from old flat format { shapeId: {...} } to wrapped { shapes: { shapeId: {...} } }
if (storeName === 'shapes' && state && typeof state === 'object' && !('shapes' in (state as object))) {
migratedState = { shapes: state };
this.dirtyStores.add(storeName); // persist migrated format immediately
this.logger.info({ store: storeName }, 'Migrated shapes store to wrapped format');
}
this.registry.setState(storeName, migratedState);
this.logger.debug({ store: storeName }, 'Loaded persistent store');
}
}