diff --git a/.changeset/lazy-snails-warn.md b/.changeset/lazy-snails-warn.md new file mode 100644 index 0000000000..e2467abfea --- /dev/null +++ b/.changeset/lazy-snails-warn.md @@ -0,0 +1,5 @@ +--- +"gitbook": patch +--- + +Move the "Ask " to the bottom of search results if query is not a question diff --git a/packages/gitbook/src/components/Search/useSearchResults.ts b/packages/gitbook/src/components/Search/useSearchResults.ts index 563339d27a..25880f123d 100644 --- a/packages/gitbook/src/components/Search/useSearchResults.ts +++ b/packages/gitbook/src/components/Search/useSearchResults.ts @@ -13,6 +13,7 @@ import { import { type Assistant, useAI } from '@/components/AI'; import { useTrackEvent } from '../Insights'; +import { isQuestion } from './isQuestion'; import type { SearchScope } from './useSearch'; export type ResultType = @@ -198,13 +199,16 @@ function withAskTriggers( return without; } + const queryIsQuestion = isQuestion(query); + return [ + ...(queryIsQuestion ? [] : (without ?? [])), ...assistants.map((assistant, index) => ({ type: 'question' as const, id: `question-${index}`, query, assistant, })), - ...(without ?? []), + ...(!queryIsQuestion ? [] : (without ?? [])), ]; }