From 93443fc959be500cd2aba9906cd674e275876eee Mon Sep 17 00:00:00 2001 From: Sergey Kozyrenko Date: Tue, 14 Apr 2026 21:05:05 +0700 Subject: [PATCH] fix: lint (cherry picked from commit 2aac8ff0563483d01b16bb5ee8c191fafa8aff14) --- frontend/src/components/shared/markdown.tsx | 27 ++--- .../src/components/shared/monaco-terminal.tsx | 6 +- .../components/shared/terminal/use-xterm.ts | 5 +- frontend/src/components/ui/input-group.tsx | 2 +- frontend/src/components/ui/input.tsx | 2 +- frontend/src/components/ui/kbd.tsx | 46 ++++----- frontend/src/components/ui/textarea.tsx | 8 +- .../src/features/flows/agents/flow-agent.tsx | 15 +-- .../features/flows/messages/flow-message.tsx | 22 +++-- .../src/features/flows/tasks/flow-subtask.tsx | 21 ++-- .../src/features/flows/tasks/flow-task.tsx | 15 +-- .../src/features/flows/tools/flow-tool.tsx | 14 +-- .../flows/vector-stores/flow-vector-store.tsx | 14 +-- .../hooks/use-adaptive-column-visibility.ts | 4 +- frontend/src/lib/report-pdf.tsx | 4 +- frontend/src/lib/table-storage.ts | 20 ++-- frontend/src/lib/сlipboard.ts | 10 +- frontend/src/pages/flows/flow-report.tsx | 98 ++++++++++--------- frontend/src/pages/login.tsx | 5 +- .../pages/settings/settings-mcp-servers.tsx | 1 - .../src/pages/settings/settings-prompt.tsx | 2 - .../src/pages/settings/settings-prompts.tsx | 1 - .../src/pages/settings/settings-provider.tsx | 6 +- .../src/pages/settings/settings-providers.tsx | 1 - frontend/src/providers/theme-provider.tsx | 1 + frontend/src/styles/index.css | 12 +-- 26 files changed, 190 insertions(+), 172 deletions(-) diff --git a/frontend/src/components/shared/markdown.tsx b/frontend/src/components/shared/markdown.tsx index a3d32b6..8d37a41 100644 --- a/frontend/src/components/shared/markdown.tsx +++ b/frontend/src/components/shared/markdown.tsx @@ -147,8 +147,8 @@ const Markdown = ({ children, className, searchValue }: MarkdownProps) => { ); // Optimized helper function to process text nodes recursively - const processTextNode = useCallback( - (nodeChildren: any): any => { + const processTextNode = useMemo(() => { + const fn = (nodeChildren: any): any => { if (!processedSearch) { return nodeChildren; } @@ -163,15 +163,13 @@ const Markdown = ({ children, className, searchValue }: MarkdownProps) => { return createHighlightedText(child); } - // Avoid deep cloning React elements to prevent memory leaks - // Only process if it's a simple object with props if (child && typeof child === 'object' && child.props && child.props.children !== undefined) { return { ...child, key: child.key || `processed-${index}`, props: { ...child.props, - children: processTextNode(child.props.children), + children: fn(child.props.children), }, }; } @@ -180,7 +178,6 @@ const Markdown = ({ children, className, searchValue }: MarkdownProps) => { }); } - // Handle React elements safely if ( nodeChildren && typeof nodeChildren === 'object' && @@ -191,25 +188,31 @@ const Markdown = ({ children, className, searchValue }: MarkdownProps) => { ...nodeChildren, props: { ...nodeChildren.props, - children: processTextNode(nodeChildren.props.children), + children: fn(nodeChildren.props.children), }, }; } return nodeChildren; - }, - [processedSearch, createHighlightedText], - ); + }; + + return fn; + }, [processedSearch, createHighlightedText]); // Create a simple component renderer factory to avoid recreating functions const createComponentRenderer = useCallback( (ComponentName: string) => { - return ({ children: nodeChildren, ...props }: any) => { + const Component = ComponentName as React.ElementType; + + const Renderer = ({ children: nodeChildren, ...props }: Record) => { const processedChildren = processTextNode(nodeChildren); - const Component = ComponentName as any; return {processedChildren}; }; + + Renderer.displayName = `Highlighted(${ComponentName})`; + + return Renderer; }, [processTextNode], ); diff --git a/frontend/src/components/shared/monaco-terminal.tsx b/frontend/src/components/shared/monaco-terminal.tsx index 52b5e09..43c0a3f 100644 --- a/frontend/src/components/shared/monaco-terminal.tsx +++ b/frontend/src/components/shared/monaco-terminal.tsx @@ -67,7 +67,11 @@ const injectedColorClasses = new Set(); const rgbStringToHex = (rgb: string): string => rgb .split(',') - .map((part) => Math.min(255, Math.max(0, parseInt(part.trim(), 10))).toString(16).padStart(2, '0')) + .map((part) => + Math.min(255, Math.max(0, parseInt(part.trim(), 10))) + .toString(16) + .padStart(2, '0'), + ) .join(''); /** diff --git a/frontend/src/components/shared/terminal/use-xterm.ts b/frontend/src/components/shared/terminal/use-xterm.ts index 5153a97..0ebd1f2 100644 --- a/frontend/src/components/shared/terminal/use-xterm.ts +++ b/frontend/src/components/shared/terminal/use-xterm.ts @@ -102,10 +102,7 @@ export function useXterm({ theme }: { theme: 'dark' | 'light' | 'system' }): Use const openLink = (event: MouseEvent, uri: string) => { const uriLower = uri.toLowerCase(); - if ( - (mac ? event.metaKey : event.ctrlKey) && - SAFE_PROTOCOLS.some((p) => uriLower.startsWith(p)) - ) { + if ((mac ? event.metaKey : event.ctrlKey) && SAFE_PROTOCOLS.some((p) => uriLower.startsWith(p))) { window.open(uri, '_blank', 'noopener,noreferrer'); } }; diff --git a/frontend/src/components/ui/input-group.tsx b/frontend/src/components/ui/input-group.tsx index 31d91d2..6b4a104 100644 --- a/frontend/src/components/ui/input-group.tsx +++ b/frontend/src/components/ui/input-group.tsx @@ -121,7 +121,7 @@ function InputGroupText({ className, ...props }: React.ComponentProps<'span'>) { ); } -function InputGroupTextarea({ className, ...props }: React.ComponentProps<'textarea'>) { +function InputGroupTextarea({ className, ...props }: React.ComponentProps) { return (