diff --git a/src/hooks/useSettingsState.ts b/src/hooks/useSettingsState.ts index 3540379..4fd97b7 100644 --- a/src/hooks/useSettingsState.ts +++ b/src/hooks/useSettingsState.ts @@ -246,6 +246,8 @@ export function useSettingsState() { backend: 'indexeddb' }) + // Full page reload is necessary here to reinitialize the database layer + // with the new backend after migration from Flask to IndexedDB window.location.reload() toast.success(`Successfully migrated ${snippets.length} snippets to IndexedDB`) diff --git a/src/lib/db-mapper.ts b/src/lib/db-mapper.ts index a25aa2d..b561c27 100644 --- a/src/lib/db-mapper.ts +++ b/src/lib/db-mapper.ts @@ -17,9 +17,18 @@ export function mapRowToObject(row: any[], columns: string[]): T { if (col === 'hasPreview' || col === 'isDefault') { obj[col] = value === 1 } - // Parse JSON string fields + // Parse JSON string fields with error handling else if (col === 'inputParameters') { - obj[col] = value ? JSON.parse(value as string) : undefined + if (value) { + try { + obj[col] = JSON.parse(value as string) + } catch (error) { + console.warn(`Failed to parse JSON for ${col}:`, error) + obj[col] = undefined + } + } else { + obj[col] = undefined + } } // All other fields pass through as-is else { diff --git a/src/lib/monaco-config.ts b/src/lib/monaco-config.ts index a69ab8a..d2bf314 100644 --- a/src/lib/monaco-config.ts +++ b/src/lib/monaco-config.ts @@ -7,6 +7,11 @@ import type { Monaco } from '@monaco-editor/react' /** * TypeScript compiler options for both TypeScript and JavaScript files + * Note: Values are enum numbers since Monaco enums aren't directly importable: + * - target: 2 = ScriptTarget.Latest + * - moduleResolution: 2 = ModuleResolutionKind.NodeJs + * - module: 99 = ModuleKind.ESNext + * - jsx: 2 = JsxEmit.React */ export const compilerOptions = { target: 2, // ScriptTarget.Latest