11'use client' ;
22
33import { Fragment , useCallback , useEffect , useRef , useState } from 'react' ;
4- import { Button } from '@radix-ui/themes ' ;
4+ import { ArrowRightIcon } from '@radix-ui/react-icons ' ;
55import { captureException } from '@sentry/nextjs' ;
66import {
77 Hit ,
@@ -20,6 +20,7 @@ import {isDeveloperDocs} from 'sentry-docs/isDeveloperDocs';
2020
2121import styles from './search.module.scss' ;
2222
23+ import { MagicIcon } from '../cutomIcons/magic' ;
2324import { Logo } from '../logo' ;
2425
2526// Initialize Algolia Insights
@@ -69,10 +70,9 @@ type Props = {
6970 autoFocus ?: boolean ;
7071 path ?: string ;
7172 searchPlatforms ?: string [ ] ;
72- showChatBot ?: boolean ;
7373} ;
7474
75- export function Search ( { path, autoFocus, searchPlatforms = [ ] , showChatBot } : Props ) {
75+ export function Search ( { path, autoFocus, searchPlatforms = [ ] } : Props ) {
7676 const ref = useRef < HTMLDivElement > ( null ) ;
7777 const [ query , setQuery ] = useState ( `` ) ;
7878 const [ results , setResults ] = useState ( [ ] as Result [ ] ) ;
@@ -268,40 +268,38 @@ export function Search({path, autoFocus, searchPlatforms = [], showChatBot}: Pro
268268 { inputFocus ? 'esc' : '⌘K' }
269269 </ kbd >
270270 </ div >
271- { showChatBot && (
272- < Fragment >
273- < span className = "text-[var(--desatPurple10)] hidden md:inline" > or</ span >
274- < Button
275- asChild
276- variant = "ghost"
277- color = "gray"
278- size = "3"
279- radius = "medium"
280- className = "font-medium text-[var(--foreground)] py-2 px-3 uppercase cursor-pointer kapa-ai-class hidden md:flex"
281- >
282- < div >
283- < svg
284- xmlns = "http://www.w3.org/2000/svg"
285- fill = "none"
286- viewBox = "0 0 24 24"
287- strokeWidth = { 1.5 }
288- stroke = "currentColor"
289- className = "size-5"
290- >
291- < path
292- strokeLinecap = "round"
293- strokeLinejoin = "round"
294- d = "M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09ZM18.259 8.715 18 9.75l-.259-1.035a3.375 3.375 0 0 0-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 0 0 2.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 0 0 2.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 0 0-2.456 2.456ZM16.894 20.567 16.5 21.75l-.394-1.183a2.25 2.25 0 0 0-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 0 0 1.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 0 0 1.423 1.423l1.183.394-1.183.394a2.25 2.25 0 0 0-1.423 1.423Z"
295- />
296- </ svg >
297- < span > Ask AI</ span >
298- </ div >
299- </ Button >
300- </ Fragment >
301- ) }
302271 </ div >
303272 { query . length >= 2 && inputFocus && (
304273 < div className = { styles [ 'sgs-search-results' ] } >
274+ < div className = { styles [ 'sgs-ai' ] } >
275+ < button
276+ id = "ai-list-entry"
277+ className = { `${ styles [ 'sgs-ai-button' ] } ${
278+ focused ?. id === 'ai-list-entry' ? styles [ 'sgs-ai-focused' ] : ''
279+ } `}
280+ onClick = { ( ) => {
281+ if ( window . Kapa ?. open ) {
282+ // close search results
283+ setInputFocus ( false ) ;
284+ // open kapa modal
285+ window . Kapa . open ( { query : `Explain ${ query } ` , submit : true } ) ;
286+ }
287+ } }
288+ >
289+ < MagicIcon className = "size-6 text-[var(--sgs-color-hit-highlight)] flex-shrink-0" />
290+ < div className = { styles [ 'sgs-ai-button-content' ] } >
291+ < h6 >
292+ Ask Sentry about{ ' ' }
293+ < span > { query . length > 30 ? query . slice ( 0 , 30 ) + '...' : query } </ span >
294+ </ h6 >
295+ < div className = { styles [ 'sgs-ai-hint' ] } >
296+ Get an AI-powered answer to your question
297+ </ div >
298+ </ div >
299+ < ArrowRightIcon className = "size-5 text-[var(--sgs-color-hit-highlight)] ml-auto flex-shrink-0" />
300+ </ button >
301+ </ div >
302+
305303 { loading && < Logo loading /> }
306304
307305 { ! loading && totalHits > 0 && (
@@ -378,14 +376,6 @@ export function Search({path, autoFocus, searchPlatforms = [], showChatBot}: Pro
378376 </ div >
379377 ) }
380378
381- { ! loading && totalHits === 0 && (
382- < div className = { styles [ 'sgs-hit-empty-state' ] } >
383- < button className = "kapa-ai-class font-bold" >
384- Can't find what you're looking for? Ask our AI!
385- </ button >
386- </ div >
387- ) }
388-
389379 { ! loading && ! showOffsiteResults && (
390380 < div className = { styles [ 'sgs-expand-results' ] } >
391381 < button
0 commit comments