From c0b8e1aca376e7ecce609412fb15478ef04f2fe3 Mon Sep 17 00:00:00 2001 From: Siddharth Ganesan Date: Tue, 8 Jul 2025 20:30:14 -0700 Subject: [PATCH] Modal fixes --- .../copilot-modal/copilot-modal.tsx | 43 +++---------------- 1 file changed, 6 insertions(+), 37 deletions(-) diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-modal/copilot-modal.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-modal/copilot-modal.tsx index 4c04c4c469..1a10a96839 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-modal/copilot-modal.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-modal/copilot-modal.tsx @@ -41,45 +41,14 @@ interface CopilotModalMessage { // Modal-specific message component function ModalCopilotMessage({ message }: CopilotModalMessage) { - const renderCitations = ( - text: string, - citations?: Array<{ id: number; title: string; url: string }> - ) => { - if (!citations || citations.length === 0) return text - + const renderMarkdown = (text: string) => { let processedText = text - // Replace [1], [2], [3] etc. with clickable citation icons - processedText = processedText.replace(/\[(\d+)\]/g, (match, num) => { - const citationIndex = Number.parseInt(num) - 1 - const citation = citations?.[citationIndex] - - if (citation) { - return `↗` - } - - return match - }) - - // Also replace standalone ↗ symbols with clickable citation links - if (citations && citations.length > 0) { - let citationIndex = 0 - processedText = processedText.replace(/↗/g, () => { - if (citationIndex < citations.length) { - const citation = citations[citationIndex] - citationIndex++ - return `↗` - } - return '↗' - }) - } - - return processedText - } - - const renderMarkdown = (text: string) => { - // Handle citations first - let processedText = renderCitations(text, message.citations) + // Process markdown links: [text](url) + processedText = processedText.replace( + /\[([^\]]+)\]\(([^)]+)\)/g, + '$1' + ) // Handle code blocks processedText = processedText.replace(