Files
Sybil-2/web/src/components/chat/chat-messages-panel.tsx

47 lines
2.0 KiB
TypeScript
Raw Normal View History

2026-02-14 00:22:19 -08:00
import { cn } from "@/lib/utils";
import type { Message } from "@/lib/api";
2026-02-14 20:51:52 -08:00
import { MarkdownContent } from "@/components/markdown/markdown-content";
2026-02-14 00:22:19 -08:00
type Props = {
messages: Message[];
isLoading: boolean;
isSending: boolean;
};
export function ChatMessagesPanel({ messages, isLoading, isSending }: Props) {
return (
<>
{isLoading && messages.length === 0 ? <p className="text-sm text-muted-foreground">Loading messages...</p> : null}
<div className="mx-auto max-w-3xl space-y-6">
{messages.map((message) => {
const isUser = message.role === "user";
const isPendingAssistant = message.id.startsWith("temp-assistant-") && isSending;
return (
<div key={message.id} className={cn("flex", isUser ? "justify-end" : "justify-start")}>
<div
className={cn(
2026-02-14 20:51:52 -08:00
"max-w-[85%]",
isUser ? "rounded-2xl bg-violet-900/80 px-4 py-3 text-sm leading-6 text-fuchsia-50" : "text-base leading-7 text-fuchsia-100"
2026-02-14 00:22:19 -08:00
)}
>
2026-02-14 20:51:52 -08:00
{isPendingAssistant ? (
<span className="inline-flex items-center gap-1" aria-label="Assistant is typing" role="status">
<span className="inline-block h-1.5 w-1.5 animate-bounce rounded-full bg-white [animation-delay:0ms]" />
<span className="inline-block h-1.5 w-1.5 animate-bounce rounded-full bg-white [animation-delay:140ms]" />
<span className="inline-block h-1.5 w-1.5 animate-bounce rounded-full bg-white [animation-delay:280ms]" />
</span>
) : (
<MarkdownContent
markdown={message.content}
className={cn("[&_a]:text-inherit [&_a]:underline", isUser ? "leading-[1.78] text-fuchsia-50" : "leading-[1.82] text-fuchsia-100")}
/>
)}
2026-02-14 00:22:19 -08:00
</div>
</div>
);
})}
</div>
</>
);
}