Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
import { cn } from "../lib/utils";
import { useStickToBottom } from "../../hooks/useStickToBottom";
import { ChatMessage } from "./ChatMessage";
import type { Message } from "./types";
interface ChatMessagesProps {
messages: Message[];
emptyState?: React.ReactNode;
onOpenNote?: (noteId: number) => void;
/** Extra classes for the message column (e.g. a page-width cap); the scroll container stays full width. */
contentClassName?: string;
scrollClassName?: string;
/** Replies as plain text and the user's messages in a soft pill (the note chat, floating or docked). */
plainBubbles?: boolean;
}
export function ChatMessages({
messages,
emptyState,
onOpenNote,
contentClassName,
scrollClassName,
plainBubbles = false,
}: ChatMessagesProps) {
// Follow the stream only while the user is at the bottom; scrolling up to
// re-read must not be yanked back down by the next token.
const {
scrollRef,
handleScroll,
handleWheel,
handleTouchStart,
handleTouchMove,
handleTouchEnd,
} = useStickToBottom<HTMLDivElement>(messages);
return (
<div
ref={scrollRef}
onScroll={handleScroll}
onWheel={handleWheel}
onTouchStart={handleTouchStart}
onTouchMove={handleTouchMove}
onTouchEnd={handleTouchEnd}
// Keep focus in a focused composer: blurring it collapses it and slides a bottom-pinned
// conversation out from under the pointer before the click completes. Otherwise links
// keep their default press, so their text can still be selected or dragged.
onMouseDown={(event) => {
if (
document.activeElement instanceof HTMLTextAreaElement &&
(event.target as Element).closest("button, a")
) {
event.preventDefault();
}
}}
className={cn("min-h-0 flex-1 overflow-y-auto agent-chat-scroll px-3 py-2", scrollClassName)}
>
{messages.length === 0 ? (
(emptyState ?? null)
) : (
<div className={cn("flex flex-col gap-1.5", contentClassName)}>
{messages
.filter((msg) => msg.role !== "tool")
.map((msg) => (
<ChatMessage
key={msg.id}
messageId={msg.id}
role={msg.role as "user" | "assistant"}
content={msg.content}
isStreaming={msg.isStreaming}
toolCalls={msg.toolCalls}
error={msg.error}
onOpenNote={onOpenNote}
plain={plainBubbles}
/>
))}
</div>
)}
</div>
);
}