MCPcopy Index your code
hub / github.com/simstudioai/sim / loadConsoleData

Function loadConsoleData

apps/sim/stores/terminal/console/storage.ts:60–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

58 * 3. Raw data: `{ workflowEntries: {...}, isOpen }` (current format)
59 */
60export async function loadConsoleData(): Promise<PersistedConsoleData | null> {
61 if (typeof window === 'undefined') return null
62
63 if (migrationPromise) {
64 await migrationPromise
65 }
66
67 try {
68 const raw = await get<string>(STORE_KEY)
69 if (!raw) return null
70
71 const parsed = typeof raw === 'string' ? JSON.parse(raw) : raw
72 if (!parsed || typeof parsed !== 'object') return null
73
74 const data = parsed.state ?? parsed
75
76 if (Array.isArray(data.entries) && !data.workflowEntries) {
77 const workflowEntries: Record<string, ConsoleEntry[]> = {}
78 for (const entry of data.entries) {
79 if (!entry?.workflowId) continue
80 const wfId = entry.workflowId
81 if (!workflowEntries[wfId]) workflowEntries[wfId] = []
82 workflowEntries[wfId].push(entry)
83 }
84 return { workflowEntries, isOpen: Boolean(data.isOpen) }
85 }
86
87 return {
88 workflowEntries: data.workflowEntries ?? {},
89 isOpen: Boolean(data.isOpen),
90 }
91 } catch (error) {
92 logger.warn('Failed to load console data from IndexedDB', { error })
93 return null
94 }
95}
96
97let activeWrite: Promise<void> | null = null
98

Callers 2

hydrateConsoleStoreFunction · 0.90
doWriteFunction · 0.85

Calls 3

parseMethod · 0.80
warnMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected