Address code review feedback: add error handling, clarify magic numbers, document reload usage

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-17 22:51:13 +00:00
parent f43c907ee2
commit 50d1d27a97
3 changed files with 18 additions and 2 deletions

View File

@@ -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`)

View File

@@ -17,9 +17,18 @@ export function mapRowToObject<T>(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 {

View File

@@ -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