From e634083465819cc7f90e5254cc668760b32a3308 Mon Sep 17 00:00:00 2001 From: Nicolas Varrot Date: Sun, 1 Mar 2026 09:03:10 +0000 Subject: [PATCH] refactor: deduplicate ReactMarkdown lazy import in ChatInput Replace standalone lazy import of ReactMarkdown + remark-gfm in ChatInput with the existing LazyMarkdown component, which already handles lazy loading with remark-gfm, remark-breaks, and rehype-highlight. Reduces code duplication and ensures consistent markdown rendering between chat messages and the input preview. --- src/components/ChatInput.tsx | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/components/ChatInput.tsx b/src/components/ChatInput.tsx index f40a62d..49130c8 100644 --- a/src/components/ChatInput.tsx +++ b/src/components/ChatInput.tsx @@ -1,14 +1,10 @@ -import { useState, useRef, useEffect, useCallback, lazy, Suspense } from 'react'; +import { useState, useRef, useEffect, useCallback } from 'react'; import { Send, Square, Paperclip, X, FileText, Eye, EyeOff, Reply } from 'lucide-react'; import { useT } from '../hooks/useLocale'; import { useSendShortcut } from '../hooks/useSendShortcut'; import { SlashCommandMenu } from './SlashCommands'; import { shouldShowSlashMenu } from '../lib/slashUtils'; - -const ReactMarkdown = lazy(() => import('react-markdown')); -const remarkGfm = import('remark-gfm').then(m => m.default); -let _remarkGfm: typeof import('remark-gfm').default | null = null; -remarkGfm.then(p => { _remarkGfm = p; }); +import { LazyMarkdown } from './LazyMarkdown'; interface FileAttachment { id: string; @@ -320,9 +316,7 @@ export function ChatInput({ onSend, onNewSession, onAbort, isGenerating, disable {/* Markdown preview */} {showPreview && text.trim() && (
- Loading…}> - {text} - + {text}
)}