From e2b2468475c7c73ff51508da25e23267cd562627 Mon Sep 17 00:00:00 2001 From: Zeno Kapitein Date: Wed, 21 May 2025 15:13:22 +0200 Subject: [PATCH] More layout tweaks --- .../src/components/Search/SearchChat.tsx | 69 +++++++++++-------- .../src/components/Search/SearchModal.tsx | 2 +- 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/packages/gitbook/src/components/Search/SearchChat.tsx b/packages/gitbook/src/components/Search/SearchChat.tsx index d0017c471..c209aca1b 100644 --- a/packages/gitbook/src/components/Search/SearchChat.tsx +++ b/packages/gitbook/src/components/Search/SearchChat.tsx @@ -28,6 +28,8 @@ export function SearchChat(props: { query: string }) { const containerRef = useRef(null); const latestMessageRef = useRef(null); + const isExpanded = searchState?.mode === 'chat'; + useEffect(() => { let cancelled = false; @@ -65,6 +67,7 @@ export function SearchChat(props: { query: string }) { fetching: true, }, ]); + setFollowupQuestions([]); (async () => { const stream = await streamAISearchAnswer({ @@ -108,19 +111,15 @@ export function SearchChat(props: { query: string }) { }, [messages]); return ( -
+
{searchState?.mode === 'chat' ? ( -
+
) : null} -
-
+
+
Summary of what you've read @@ -172,9 +177,9 @@ export function SearchChat(props: { query: string }) { key={message.content} ref={index === messages.length - 1 ? latestMessageRef : null} className={tcls( - 'flex scroll-mt-20 scroll-mb-[100%] flex-col gap-1', + 'mx-auto flex w-full max-w-prose flex-col gap-1', message.role === 'user' && 'items-end gap-1 self-end', - index === messages.length - 1 && 'mb-[45vh]' + index === messages.length - 1 && 'min-h-full' )} > {message.role === 'user' ? ( @@ -209,25 +214,33 @@ export function SearchChat(props: { query: string }) { {message.content}
)} + + {index === messages.length - 1 && + followupQuestions && + followupQuestions.length > 0 && ( +
+ {followupQuestions?.map((question) => ( +
+ {question} +
+ ))} +
+ )}
))}
{query ? ( -
+
- {followupQuestions && followupQuestions.length > 0 && ( -
- {followupQuestions?.map((question) => ( -
- {question} -
- ))} -
- )}