11'use client' ;
22
3- import { Fragment , useCallback , useEffect , useRef , useState } from 'react' ;
4- import { Button } from '@radix-ui/themes ' ;
3+ import { useCallback , useEffect , useRef , useState } from 'react' ;
4+ import { ArrowRightIcon } from '@radix-ui/react-icons ' ;
55import { captureException } from '@sentry/nextjs' ;
66import {
77 Hit ,
@@ -17,6 +17,7 @@ import {isDeveloperDocs} from 'sentry-docs/isDeveloperDocs';
1717
1818import styles from './search.module.scss' ;
1919
20+ import { MagicIcon } from '../cutomIcons/magic' ;
2021import { Logo } from '../logo' ;
2122
2223import { SearchResultItems } from './searchResultItems' ;
@@ -61,10 +62,9 @@ type Props = {
6162 autoFocus ?: boolean ;
6263 path ?: string ;
6364 searchPlatforms ?: string [ ] ;
64- showChatBot ?: boolean ;
6565} ;
6666
67- export function Search ( { path, autoFocus, searchPlatforms = [ ] , showChatBot } : Props ) {
67+ export function Search ( { path, autoFocus, searchPlatforms = [ ] } : Props ) {
6868 const ref = useRef < HTMLDivElement > ( null ) ;
6969 const [ query , setQuery ] = useState ( `` ) ;
7070 const [ results , setResults ] = useState ( [ ] as Result [ ] ) ;
@@ -235,7 +235,7 @@ export function Search({path, autoFocus, searchPlatforms = [], showChatBot}: Pro
235235 < div className = { styles [ 'input-wrapper' ] } >
236236 < input
237237 type = "text"
238- placeholder = "Search Docs "
238+ placeholder = "Search or ask a question "
239239 aria-label = "Search"
240240 className = { styles [ 'search-input' ] }
241241 value = { query }
@@ -250,40 +250,36 @@ export function Search({path, autoFocus, searchPlatforms = [], showChatBot}: Pro
250250 { inputFocus ? 'esc' : '⌘K' }
251251 </ kbd >
252252 </ div >
253- { showChatBot && (
254- < Fragment >
255- < span className = "text-[var(--desatPurple10)] hidden md:inline" > or</ span >
256- < Button
257- asChild
258- variant = "ghost"
259- color = "gray"
260- size = "3"
261- radius = "medium"
262- className = "font-medium text-[var(--foreground)] py-2 px-3 uppercase cursor-pointer kapa-ai-class hidden md:flex"
263- >
264- < div >
265- < svg
266- xmlns = "http://www.w3.org/2000/svg"
267- fill = "none"
268- viewBox = "0 0 24 24"
269- strokeWidth = { 1.5 }
270- stroke = "currentColor"
271- className = "size-5"
272- >
273- < path
274- strokeLinecap = "round"
275- strokeLinejoin = "round"
276- 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"
277- />
278- </ svg >
279- < span > Ask AI</ span >
280- </ div >
281- </ Button >
282- </ Fragment >
283- ) }
284253 </ div >
285254 { query . length >= 2 && inputFocus && (
286255 < div className = { styles [ 'sgs-search-results' ] } >
256+ < div className = { styles [ 'sgs-ai' ] } >
257+ < button
258+ id = "ai-list-entry"
259+ className = { styles [ 'sgs-ai-button' ] }
260+ onClick = { ( ) => {
261+ if ( window . Kapa ?. open ) {
262+ // close search results
263+ setInputFocus ( false ) ;
264+ // open kapa modal
265+ window . Kapa . open ( { query : `Explain ${ query } ` , submit : true } ) ;
266+ }
267+ } }
268+ >
269+ < MagicIcon className = "size-6 text-[var(--sgs-color-hit-highlight)] flex-shrink-0" />
270+ < div className = { styles [ 'sgs-ai-button-content' ] } >
271+ < h6 >
272+ Ask Sentry about{ ' ' }
273+ < span > { query . length > 30 ? query . slice ( 0 , 30 ) + '...' : query } </ span >
274+ </ h6 >
275+ < div className = { styles [ 'sgs-ai-hint' ] } >
276+ Get an AI-powered answer to your question
277+ </ div >
278+ </ div >
279+ < ArrowRightIcon className = "size-5 text-[var(--sgs-color-hit-highlight)] ml-auto flex-shrink-0" />
280+ </ button >
281+ </ div >
282+
287283 { loading && < Logo loading /> }
288284
289285 { ! loading && totalHits > 0 && (
@@ -296,14 +292,6 @@ export function Search({path, autoFocus, searchPlatforms = [], showChatBot}: Pro
296292 />
297293 ) }
298294
299- { ! loading && totalHits === 0 && (
300- < div className = { styles [ 'sgs-hit-empty-state' ] } >
301- < button className = "kapa-ai-class font-bold" >
302- Can't find what you're looking for? Ask our AI!
303- </ button >
304- </ div >
305- ) }
306-
307295 { ! loading && ! showOffsiteResults && (
308296 < div className = { styles [ 'sgs-expand-results' ] } >
309297 < button
0 commit comments