@@ -156,12 +156,6 @@ function AskAIDialog({ initialQuery, isOpen, onOpenChange }: AskAIDialogProps) {
156156 ) ;
157157}
158158
159- type KapaChatProps = {
160- websiteId : string ;
161- onOpen ?: ( ) => void ;
162- onClose ?: ( ) => void ;
163- } ;
164-
165159function ChatMessages ( {
166160 conversation,
167161 isPreparingAnswer,
@@ -493,87 +487,6 @@ function ChatInterface({ initialQuery }: { initialQuery?: string }) {
493487 ) ;
494488}
495489
496- export function AskAI ( { websiteId, onOpen } : KapaChatProps ) {
497- const [ isOpen , setIsOpen ] = useState ( false ) ;
498- const [ initialQuery , setInitialQuery ] = useState < string | undefined > ( ) ;
499- const [ searchParams , setSearchParams ] = useSearchParams ( ) ;
500-
501- const handleOpen = useCallback ( ( ) => {
502- setIsOpen ( true ) ;
503- onOpen ?.( ) ;
504- } , [ onOpen ] ) ;
505-
506- // Handle URL param functionality
507- useEffect ( ( ) => {
508- const aiHelp = searchParams . get ( "aiHelp" ) ;
509- if ( aiHelp ) {
510- setSearchParams ( ( prev ) => {
511- prev . delete ( "aiHelp" ) ;
512- return prev ;
513- } ) ;
514-
515- const decodedAiHelp = decodeURIComponent ( aiHelp ) ;
516- setInitialQuery ( decodedAiHelp ) ;
517- handleOpen ( ) ;
518- }
519- } , [ searchParams , setSearchParams , handleOpen ] ) ;
520-
521- if ( ! websiteId ) return null ;
522-
523- return (
524- < KapaProvider
525- integrationId = { websiteId }
526- callbacks = { {
527- askAI : {
528- onQuerySubmit : ( ) => handleOpen ( ) ,
529- onAnswerGenerationCompleted : ( ) => handleOpen ( ) ,
530- } ,
531- } }
532- botProtectionMechanism = "hcaptcha"
533- >
534- < div className = "relative" >
535- < TooltipProvider disableHoverableContent >
536- < Tooltip >
537- < TooltipTrigger asChild >
538- < div className = "inline-flex" >
539- < Button
540- variant = "small-menu-item"
541- data-action = "ask-ai"
542- shortcut = { { modifiers : [ "mod" ] , key : "/" , enabledOnInputElements : true } }
543- hideShortcutKey
544- data-modal-override-open-class-ask-ai = "true"
545- onClick = { handleOpen }
546- >
547- < AISparkleIcon className = "size-5" />
548- </ Button >
549- </ div >
550- </ TooltipTrigger >
551- < TooltipContent
552- side = "top"
553- className = "flex items-center gap-1 py-1.5 pl-2.5 pr-2 text-xs"
554- >
555- Ask AI
556- < ShortcutKey shortcut = { { modifiers : [ "mod" ] , key : "/" } } variant = "medium/bright" />
557- </ TooltipContent >
558- </ Tooltip >
559- </ TooltipProvider >
560-
561- < Dialog open = { isOpen } onOpenChange = { setIsOpen } >
562- < DialogContent className = "animated-gradient-glow flex max-h-[90vh] min-h-fit w-full flex-col justify-between gap-0 px-0 pb-0 pt-0 sm:max-w-prose" >
563- < DialogHeader className = "flex h-[2.75rem] items-start justify-center rounded-t-md bg-background-bright pl-3" >
564- < div className = "flex items-center gap-1" >
565- < AISparkleIcon className = "size-5" />
566- < DialogTitle className = "text-sm font-medium text-text-bright" > Ask AI</ DialogTitle >
567- </ div >
568- </ DialogHeader >
569- < ChatInterface initialQuery = { initialQuery } />
570- </ DialogContent >
571- </ Dialog >
572- </ div >
573- </ KapaProvider >
574- ) ;
575- }
576-
577490function GradientSpinnerBackground ( {
578491 children,
579492 className,
0 commit comments