Skip to content

Commit 3027256

Browse files
committed
auto scroll to bottom
1 parent 6685a69 commit 3027256

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

app/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default function Page() {
5252
return (
5353
<main data-lk-theme="default" className="h-full grid content-center bg-[var(--lk-bg)]">
5454
<RoomContext.Provider value={room}>
55-
<div className="lk-room-container">
55+
<div className="lk-room-container max-h-[90vh]">
5656
<SimpleVoiceAssistant onConnectButtonClicked={onConnectButtonClicked} />
5757
</div>
5858
</RoomContext.Provider>
@@ -77,7 +77,7 @@ function SimpleVoiceAssistant(props: { onConnectButtonClicked: () => void }) {
7777
Start a conversation
7878
</motion.button>
7979
)}
80-
<div className="w-3/4 lg:w-1/2 mx-auto">
80+
<div className="w-3/4 lg:w-1/2 mx-auto h-full">
8181
<TranscriptionView />
8282
</div>
8383
</AnimatePresence>

components/TranscriptionView.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
import useCombinedTranscriptions from "@/hooks/useCombinedTranscriptions";
2+
import * as React from "react";
23

34
export default function TranscriptionView() {
45
const combinedTranscriptions = useCombinedTranscriptions();
56

7+
// scroll to bottom when new transcription is added
8+
React.useEffect(() => {
9+
const transcription = combinedTranscriptions[combinedTranscriptions.length - 1];
10+
if (transcription) {
11+
const transcriptionElement = document.getElementById(transcription.id);
12+
if (transcriptionElement) {
13+
transcriptionElement.scrollIntoView({ behavior: "smooth" });
14+
}
15+
}
16+
}, [combinedTranscriptions]);
17+
618
return (
7-
<div className="flex flex-col gap-2 overflow-y-auto">
19+
<div className="h-full flex flex-col gap-2 overflow-y-auto">
820
{combinedTranscriptions.map((segment) => (
921
<div
22+
id={segment.id}
1023
key={segment.id}
1124
className={
1225
segment.role === "assistant"

0 commit comments

Comments
 (0)