11'use client' ;
22
33import { Fragment , useCallback , useEffect , useRef , useState } from 'react' ;
4- import { ArrowRightIcon } from '@radix-ui/react-icons ' ;
4+ import { Button } from '@radix-ui/themes ' ;
55import { captureException } from '@sentry/nextjs' ;
66import {
77 Hit ,
@@ -17,7 +17,6 @@ import {isDeveloperDocs} from 'sentry-docs/isDeveloperDocs';
1717
1818import styles from './search.module.scss' ;
1919
20- import { MagicIcon } from '../cutomIcons/magic' ;
2120import { Logo } from '../logo' ;
2221
2322import { SearchResultItems } from './searchResultItems' ;
@@ -62,9 +61,10 @@ type Props = {
6261 autoFocus ?: boolean ;
6362 path ?: string ;
6463 searchPlatforms ?: string [ ] ;
64+ showChatBot ?: boolean ;
6565} ;
6666
67- export function Search ( { path, autoFocus, searchPlatforms = [ ] } : Props ) {
67+ export function Search ( { path, autoFocus, searchPlatforms = [ ] , showChatBot } : 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 = []}: Props) {
235235 < div className = { styles [ 'input-wrapper' ] } >
236236 < input
237237 type = "text"
238- placeholder = "Search or ask a question "
238+ placeholder = "Search Docs "
239239 aria-label = "Search"
240240 className = { styles [ 'search-input' ] }
241241 value = { query }
@@ -250,38 +250,40 @@ export function Search({path, autoFocus, searchPlatforms = []}: Props) {
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+ ) }
253284 </ div >
254285 { query . length >= 2 && inputFocus && (
255286 < 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- focused ?. id === 'ai-list-entry' ? styles [ 'sgs-ai-focused' ] : ''
261- } `}
262- onClick = { ( ) => {
263- if ( window . Kapa ?. open ) {
264- // close search results
265- setInputFocus ( false ) ;
266- // open kapa modal
267- window . Kapa . open ( { query : `Explain ${ query } ` , submit : true } ) ;
268- }
269- } }
270- >
271- < MagicIcon className = "size-6 text-[var(--sgs-color-hit-highlight)] flex-shrink-0" />
272- < div className = { styles [ 'sgs-ai-button-content' ] } >
273- < h6 >
274- Ask Sentry about{ ' ' }
275- < span > { query . length > 30 ? query . slice ( 0 , 30 ) + '...' : query } </ span >
276- </ h6 >
277- < div className = { styles [ 'sgs-ai-hint' ] } >
278- Get an AI-powered answer to your question
279- </ div >
280- </ div >
281- < ArrowRightIcon className = "size-5 text-[var(--sgs-color-hit-highlight)] ml-auto flex-shrink-0" />
282- </ button >
283- </ div >
284-
285287 { loading && < Logo loading /> }
286288
287289 { ! loading && totalHits > 0 && (
@@ -294,6 +296,14 @@ export function Search({path, autoFocus, searchPlatforms = []}: Props) {
294296 />
295297 ) }
296298
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+
297307 { ! loading && ! showOffsiteResults && (
298308 < div className = { styles [ 'sgs-expand-results' ] } >
299309 < button
0 commit comments