From b70728254b182e028e736a785c030215e3df5f9e Mon Sep 17 00:00:00 2001 From: Haileyesus Dessie <118998054+blackmammoth@users.noreply.github.com> Date: Sat, 10 Jan 2026 14:36:58 +0300 Subject: [PATCH] fix: move safeJsonParse function to utils.js --- src/components/ChatInterface.jsx | 9 +-------- src/lib/utils.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/components/ChatInterface.jsx b/src/components/ChatInterface.jsx index 9320385..a9d5110 100644 --- a/src/components/ChatInterface.jsx +++ b/src/components/ChatInterface.jsx @@ -37,6 +37,7 @@ import Fuse from 'fuse.js'; import CommandMenu from './CommandMenu'; import { CLAUDE_MODELS, CURSOR_MODELS, CODEX_MODELS } from '../../shared/modelConstants'; +import { safeJsonParse } from '../lib/utils.js'; // Helper function to decode HTML entities in text function decodeHtmlEntities(text) { @@ -238,14 +239,6 @@ const safeLocalStorage = { const CLAUDE_SETTINGS_KEY = 'claude-settings'; -function safeJsonParse(value) { - if (!value || typeof value !== 'string') return null; - try { - return JSON.parse(value); - } catch { - return null; - } -} function getClaudeSettings() { const raw = safeLocalStorage.getItem(CLAUDE_SETTINGS_KEY); diff --git a/src/lib/utils.js b/src/lib/utils.js index ea14eef..234d8a3 100755 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -5,5 +5,11 @@ export function cn(...inputs) { return twMerge(clsx(inputs)) } -// TODO: Add safeJsonParse here -// \ No newline at end of file +export function safeJsonParse(value) { + if (!value || typeof value !== 'string') return null; + try { + return JSON.parse(value); + } catch { + return null; + } +}