From b2b04453141bd09d34d5af4e9e50bda1bda56b9d Mon Sep 17 00:00:00 2001 From: Zeno Kapitein Date: Thu, 23 Oct 2025 18:52:40 +0200 Subject: [PATCH] Move the "Ask " to the bottom of search results if query is not a question --- .changeset/lazy-snails-warn.md | 5 +++++ packages/gitbook/src/components/Search/useSearchResults.ts | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/lazy-snails-warn.md 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 ?? [])), ]; }