11'use client'
22
3- import { type KeyboardEvent , useEffect , useRef , useState } from 'react'
4- import { ArrowUp , Bot , User , X } from 'lucide-react'
3+ import { type KeyboardEvent , useEffect , useRef } from 'react'
4+ import { ArrowUp , Bot , X } from 'lucide-react'
55import { Button } from '@/components/ui/button'
66import { Input } from '@/components/ui/input'
77import { createLogger } from '@/lib/logs/console-logger'
@@ -26,7 +26,10 @@ interface CopilotModalMessage {
2626
2727// Modal-specific message component
2828function ModalCopilotMessage ( { message } : CopilotModalMessage ) {
29- const renderCitations = ( text : string , citations ?: Array < { id : number ; title : string ; url : string } > ) => {
29+ const renderCitations = (
30+ text : string ,
31+ citations ?: Array < { id : number ; title : string ; url : string } >
32+ ) => {
3033 if ( ! citations || citations . length === 0 ) return text
3134
3235 let processedText = text
@@ -52,12 +55,24 @@ function ModalCopilotMessage({ message }: CopilotModalMessage) {
5255 )
5356
5457 // Handle inline code
55- processedText = processedText . replace ( / ` ( [ ^ ` ] + ) ` / g, '<code class="bg-muted px-1 rounded text-sm">$1</code>' )
58+ processedText = processedText . replace (
59+ / ` ( [ ^ ` ] + ) ` / g,
60+ '<code class="bg-muted px-1 rounded text-sm">$1</code>'
61+ )
5662
5763 // Handle headers
58- processedText = processedText . replace ( / ^ # # # ( .* $ ) / gm, '<h3 class="text-lg font-semibold mt-4 mb-2">$1</h3>' )
59- processedText = processedText . replace ( / ^ # # ( .* $ ) / gm, '<h2 class="text-xl font-semibold mt-4 mb-2">$1</h2>' )
60- processedText = processedText . replace ( / ^ # ( .* $ ) / gm, '<h1 class="text-2xl font-bold mt-4 mb-2">$1</h1>' )
64+ processedText = processedText . replace (
65+ / ^ # # # ( .* $ ) / gm,
66+ '<h3 class="text-lg font-semibold mt-4 mb-2">$1</h3>'
67+ )
68+ processedText = processedText . replace (
69+ / ^ # # ( .* $ ) / gm,
70+ '<h2 class="text-xl font-semibold mt-4 mb-2">$1</h2>'
71+ )
72+ processedText = processedText . replace (
73+ / ^ # ( .* $ ) / gm,
74+ '<h1 class="text-2xl font-bold mt-4 mb-2">$1</h1>'
75+ )
6176
6277 // Handle bold
6378 processedText = processedText . replace ( / \* \* ( .* ?) \* \* / g, '<strong>$1</strong>' )
@@ -94,8 +109,8 @@ function ModalCopilotMessage({ message }: CopilotModalMessage) {
94109 < div className = 'mx-auto max-w-3xl' >
95110 < div className = 'flex' >
96111 < div className = 'max-w-[80%]' >
97- < div
98- className = 'whitespace-pre-wrap break-words text-base leading-relaxed prose prose-sm max-w-none dark:prose-invert '
112+ < div
113+ className = 'prose prose-sm dark:prose-invert max-w-none whitespace-pre-wrap break-words text-base leading-relaxed'
99114 dangerouslySetInnerHTML = { { __html : renderMarkdown ( message . content ) } }
100115 />
101116 </ div >
@@ -115,14 +130,14 @@ interface CopilotModalProps {
115130 isLoading : boolean
116131}
117132
118- export function CopilotModal ( {
119- open,
120- onOpenChange,
121- copilotMessage,
133+ export function CopilotModal ( {
134+ open,
135+ onOpenChange,
136+ copilotMessage,
122137 setCopilotMessage,
123138 messages,
124139 onSendMessage,
125- isLoading
140+ isLoading,
126141} : CopilotModalProps ) {
127142 const messagesEndRef = useRef < HTMLDivElement > ( null )
128143 const messagesContainerRef = useRef < HTMLDivElement > ( null )
@@ -149,7 +164,7 @@ export function CopilotModal({
149164 try {
150165 await onSendMessage ( copilotMessage . trim ( ) )
151166 setCopilotMessage ( '' )
152-
167+
153168 // Ensure input stays focused
154169 if ( inputRef . current ) {
155170 inputRef . current . focus ( )
@@ -210,10 +225,11 @@ export function CopilotModal({
210225 < div className = 'space-y-2' >
211226 < h3 className = 'font-medium text-lg' > Welcome to Documentation Copilot</ h3 >
212227 < p className = 'text-muted-foreground text-sm' >
213- Ask me anything about Sim Studio features, workflows, tools, or how to get started.
228+ Ask me anything about Sim Studio features, workflows, tools, or how to get
229+ started.
214230 </ p >
215231 </ div >
216- < div className = 'space-y-2 text-left max-w-xs mx-auto ' >
232+ < div className = 'mx-auto max-w-xs space-y-2 text-left ' >
217233 < div className = 'text-muted-foreground text-xs' > Try asking:</ div >
218234 < div className = 'space-y-1' >
219235 < div className = 'rounded bg-muted/50 px-2 py-1 text-xs' >
@@ -230,9 +246,7 @@ export function CopilotModal({
230246 </ div >
231247 </ div >
232248 ) : (
233- messages . map ( ( message ) => (
234- < ModalCopilotMessage key = { message . id } message = { message } />
235- ) )
249+ messages . map ( ( message ) => < ModalCopilotMessage key = { message . id } message = { message } /> )
236250 ) }
237251
238252 { /* Loading indicator (shows only when loading) */ }
@@ -284,4 +298,4 @@ export function CopilotModal({
284298 </ div >
285299 </ div >
286300 )
287- }
301+ }
0 commit comments