Skip to content

Commit

Permalink
[app] Auto-scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhancock committed Nov 26, 2024
1 parent cfba969 commit 14dc240
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions ui/desktop/src/ChatWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,22 +175,28 @@ function ChatContent({
{messages.length === 0 ? (
<Splash append={append} />
) : (
<ScrollArea className="flex-1 px-[10px]">
<ScrollArea className="flex-1 px-[10px]" id="chat-scroll-area">
<div className="block h-10" />
{messages.map((message) => (
<div key={message.id}>
{message.role === 'user' ? (
<UserMessage message={message} />
) : (
<GooseMessage
message={message}
messages={messages}
metadata={messageMetadata[message.id]}
append={append}
/>
)}
</div>
))}
<div ref={(el) => {
if (el) {
el.scrollIntoView({ behavior: 'smooth', block: 'end' });
}
}}>
{messages.map((message) => (
<div key={message.id}>
{message.role === 'user' ? (
<UserMessage message={message} />
) : (
<GooseMessage
message={message}
messages={messages}
metadata={messageMetadata[message.id]}
append={append}
/>
)}
</div>
))}
</div>
{isLoading && (
<div className="flex items-center justify-center p-4">
<LoadingGoose />
Expand Down

0 comments on commit 14dc240

Please sign in to comment.