Skip to content

Commit c2886a4

Browse files
authored
Revert "feat(platform): Integrate AI into search results (#12448)" (#12492)
This reverts commit 5ca4064.
1 parent 3d0b9a7 commit c2886a4

File tree

7 files changed

+53
-98
lines changed

7 files changed

+53
-98
lines changed

app/not-found.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default function NotFound() {
2424

2525
<div className="max-w-md pt-8">
2626
<p className="pb-4">Let's give it another shot:</p>
27-
<Search autoFocus path={pathname} searchPlatforms={[]} />
27+
<Search autoFocus path={pathname} searchPlatforms={[]} showChatBot={false} />
2828
</div>
2929
<div className="pt-8 flex gap-4">
3030
<Button variant="solid" size="3" asChild>

src/components/cutomIcons/magic.tsx

-18
This file was deleted.

src/components/header.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export function Header({pathname, searchPlatforms, noSearch}: Props) {
6262
</Link>
6363
{!noSearch && (
6464
<div className="hidden md:flex justify-center lg:justify-start w-full px-6">
65-
<Search path={pathname} searchPlatforms={searchPlatforms} />
65+
<Search path={pathname} searchPlatforms={searchPlatforms} showChatBot />
6666
</div>
6767
)}
6868
<div className="hidden lg-xl:flex justify-end flex-1 space-x-2 items-center min-w-fit">

src/components/mobileMenu/index.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ export function MobileMenu({pathname, searchPlatforms}: Props) {
3838
<DropdownMenu.Content className={styles.DropdownMenuContent} sideOffset={5}>
3939
<Box display={{xs: 'block', sm: 'none'}}>
4040
<DropdownMenu.Item className={styles.DropdownMenuItem} asChild>
41-
<Search path={pathname} searchPlatforms={searchPlatforms} />
41+
<Search path={pathname} searchPlatforms={searchPlatforms} showChatBot />
42+
</DropdownMenu.Item>
43+
44+
<DropdownMenu.Item className={styles.DropdownMenuItem} asChild>
45+
<Link href="#" className="mt-2 kapa-ai-class md:hidden">
46+
Ask AI
47+
</Link>
4248
</DropdownMenu.Item>
4349
<DropdownMenu.Separator className={styles.DropdownMenuSeparator} />
4450
</Box>

src/components/search/index.tsx

+43-33
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22

33
import {Fragment, useCallback, useEffect, useRef, useState} from 'react';
4-
import {ArrowRightIcon} from '@radix-ui/react-icons';
4+
import {Button} from '@radix-ui/themes';
55
import {captureException} from '@sentry/nextjs';
66
import {
77
Hit,
@@ -17,7 +17,6 @@ import {isDeveloperDocs} from 'sentry-docs/isDeveloperDocs';
1717

1818
import styles from './search.module.scss';
1919

20-
import {MagicIcon} from '../cutomIcons/magic';
2120
import {Logo} from '../logo';
2221

2322
import {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

src/components/search/search.module.scss

+1-41
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
appearance: none;
6161
padding: 0.25rem 0.75rem;
6262
// leave space for the hotkey icon
63-
padding-right: 3rem;
63+
padding-right: 2.5rem;
6464
font-size: 0.9rem;
6565
line-height: 1.8;
6666
border-radius: 0.25rem;
@@ -192,46 +192,6 @@
192192
}
193193
}
194194

195-
.sgs-ai {
196-
color: var(--sgs-color-hit-text);
197-
padding: 0.25rem;
198-
199-
&-button {
200-
padding: 0.75rem;
201-
display: flex;
202-
width: 100%;
203-
align-items: center;
204-
gap: 0.75rem;
205-
color: inherit;
206-
207-
&:hover,
208-
.sgs-ai-focused & {
209-
background-color: var(--sgs-color-hit-hover-background);
210-
}
211-
212-
&-content {
213-
display: flex;
214-
flex-direction: column;
215-
align-items: flex-start;
216-
flex: 1;
217-
218-
h6 {
219-
font-size: 0.875rem;
220-
line-height: 1.25rem;
221-
margin: 0;
222-
223-
span {
224-
color: var(--sgs-color-hit-highlight);
225-
}
226-
}
227-
}
228-
}
229-
230-
&-hint {
231-
color: var(--sgs-color-hit-context);
232-
}
233-
}
234-
235195
.sgs-hit-empty-state {
236196
display: block;
237197
text-decoration: none;

src/globals.d.ts

-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,5 @@ import type * as Sentry from '@sentry/browser';
33
declare global {
44
interface Window {
55
Sentry: typeof Sentry;
6-
Kapa?: {
7-
open: (options: {mode?: string; query?: string; submit?: boolean}) => void;
8-
};
96
}
107
}

0 commit comments

Comments
 (0)