Run biome check and add ChatError component

This commit is contained in:
James Blair 2026-05-08 20:33:24 +12:00
parent 6a5041be43
commit 08f45451bb
Signed by: james
SSH key fingerprint: SHA256:hsDR3ENI2ZMgh+CNb+0PrFsj29DI007R+BMKUVGi6zQ
13 changed files with 228 additions and 136 deletions

View file

@ -0,0 +1,14 @@
import { AlertTriangleIcon } from "lucide-react";
import { Alert, AlertDescription, AlertTitle } from "../ui/alert";
export function ChatError({ error }: { error?: Error }) {
if (!error) return null;
return (
<Alert variant="destructive">
<AlertTriangleIcon />
<AlertTitle>{error.name}</AlertTitle>
<AlertDescription>{error.message}</AlertDescription>
</Alert>
);
}

View file

@ -1,7 +1,7 @@
import { useState, type SubmitEvent } from "react";
import { ArrowUpIcon } from "lucide-react";
import { type SubmitEvent, useState } from "react";
import { Button } from "../ui/button";
import { Textarea } from "../ui/textarea";
import { ArrowUpIcon, SendIcon } from "lucide-react";
interface ChatFormProps {
onMessage: (message: { text: string }) => void;

View file

@ -1,5 +1,5 @@
import type { UIMessage } from "ai";
import { cn } from "@/lib/utils";
import { UIMessage } from "ai";
interface ChatMessagesProps {
messages: UIMessage[];

View file

@ -1,9 +1,10 @@
"use client";
import { ChatMessages } from "./chat-messages";
import { ChatForm } from "./chat-form";
import { DefaultChatTransport } from "ai";
import { useChat } from "@ai-sdk/react";
import { DefaultChatTransport } from "ai";
import { ChatError } from "./chat-error";
import { ChatForm } from "./chat-form";
import { ChatMessages } from "./chat-messages";
export function Chat() {
const { messages, sendMessage, status, error } = useChat({
@ -13,7 +14,8 @@ export function Chat() {
});
return (
<div className="max-w-2xl flex flex-col gap-2">
<div className="max-w-2xl flex flex-col gap-4">
<ChatError error={error} />
<ChatMessages messages={messages} />
<ChatForm
onMessage={sendMessage}