Skip to content

Commit a0ea69f

Browse files
authored
fix: auto scroll fix, scroll allow user to scroll up during ai response (#1299)
1 parent 2fe1f1d commit a0ea69f

File tree

3 files changed

+265
-259
lines changed

3 files changed

+265
-259
lines changed

app/components/chat/BaseChat.tsx

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
303303
data-chat-visible={showChat}
304304
>
305305
<ClientOnly>{() => <Menu />}</ClientOnly>
306-
<div ref={scrollRef} className="flex flex-col lg:flex-row overflow-y-auto w-full h-full">
306+
<div className="flex flex-col lg:flex-row overflow-y-auto w-full h-full">
307307
<div className={classNames(styles.Chat, 'flex flex-col flex-grow lg:min-w-[var(--chat-min-width)] h-full')}>
308308
{!chatStarted && (
309309
<div id="intro" className="mt-[16vh] max-w-chat mx-auto text-center px-4 lg:px-0">
@@ -317,39 +317,40 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
317317
)}
318318
<div
319319
className={classNames('pt-6 px-2 sm:px-6', {
320-
'h-full flex flex-col': chatStarted,
320+
'h-full flex flex-col pb-4 overflow-y-auto': chatStarted,
321321
})}
322322
ref={scrollRef}
323323
>
324324
<ClientOnly>
325325
{() => {
326326
return chatStarted ? (
327-
<Messages
328-
ref={messageRef}
329-
className="flex flex-col w-full flex-1 max-w-chat pb-6 mx-auto z-1"
330-
messages={messages}
331-
isStreaming={isStreaming}
332-
/>
327+
<div className="flex-1 w-full max-w-chat pb-6 mx-auto z-1">
328+
<Messages
329+
ref={messageRef}
330+
className="flex flex-col "
331+
messages={messages}
332+
isStreaming={isStreaming}
333+
/>
334+
</div>
333335
) : null;
334336
}}
335337
</ClientOnly>
336338
<div
337-
className={classNames('flex flex-col gap-4 w-full max-w-chat mx-auto z-prompt mb-6', {
339+
className={classNames('flex flex-col gap-4 w-full max-w-chat mx-auto z-prompt', {
338340
'sticky bottom-2': chatStarted,
341+
'position-absolute': chatStarted,
339342
})}
340343
>
341-
<div className="bg-bolt-elements-background-depth-2">
342-
{actionAlert && (
343-
<ChatAlert
344-
alert={actionAlert}
345-
clearAlert={() => clearAlert?.()}
346-
postMessage={(message) => {
347-
sendMessage?.({} as any, message);
348-
clearAlert?.();
349-
}}
350-
/>
351-
)}
352-
</div>
344+
{actionAlert && (
345+
<ChatAlert
346+
alert={actionAlert}
347+
clearAlert={() => clearAlert?.()}
348+
postMessage={(message) => {
349+
sendMessage?.({} as any, message);
350+
clearAlert?.();
351+
}}
352+
/>
353+
)}
353354
{progressAnnotations && <ProgressCompilation data={progressAnnotations} />}
354355
<div
355356
className={classNames(
@@ -583,26 +584,26 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
583584
</div>
584585
</div>
585586
</div>
586-
<div className="flex flex-col justify-center gap-5">
587-
{!chatStarted && (
587+
{!chatStarted && (
588+
<div className="flex flex-col justify-center mt-6 gap-5">
588589
<div className="flex justify-center gap-2">
589590
<div className="flex items-center gap-2">
590591
{ImportButtons(importChat)}
591592
<GitCloneButton importChat={importChat} className="min-w-[120px]" />
592593
</div>
593594
</div>
594-
)}
595-
{!chatStarted &&
596-
ExamplePrompts((event, messageInput) => {
595+
596+
{ExamplePrompts((event, messageInput) => {
597597
if (isStreaming) {
598598
handleStop?.();
599599
return;
600600
}
601601

602602
handleSendMessage?.(event, messageInput);
603603
})}
604-
{!chatStarted && <StarterTemplates />}
605-
</div>
604+
<StarterTemplates />
605+
</div>
606+
)}
606607
</div>
607608
<ClientOnly>{() => <Workbench chatStarted={chatStarted} isStreaming={isStreaming} />}</ClientOnly>
608609
</div>

0 commit comments

Comments
 (0)