Add clear chat button

Add a button to clear the chat conversation on the Test Agent screen. This button will also trigger a toast notification to confirm the action.
This commit is contained in:
gpt-engineer-app[bot]
2025-11-07 20:00:01 +00:00
parent 7b01dd2e55
commit b642c5be8b
+25 -1
View File
@@ -4,7 +4,8 @@ import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input"; import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label"; import { Label } from "@/components/ui/label";
import { ScrollArea } from "@/components/ui/scroll-area"; import { ScrollArea } from "@/components/ui/scroll-area";
import { Send, Bot, User } from "lucide-react"; import { Send, Bot, User, RotateCcw } from "lucide-react";
import { useToast } from "@/hooks/use-toast";
import { import {
Select, Select,
SelectContent, SelectContent,
@@ -25,6 +26,7 @@ export default function TestPrompt() {
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const [selectedAgent, setSelectedAgent] = useState(""); const [selectedAgent, setSelectedAgent] = useState("");
const scrollRef = useRef<HTMLDivElement>(null); const scrollRef = useRef<HTMLDivElement>(null);
const { toast } = useToast();
// Mock data de agentes // Mock data de agentes
const agents = [ const agents = [
@@ -76,6 +78,14 @@ export default function TestPrompt() {
} }
}; };
const handleClearChat = () => {
setMessages([]);
toast({
title: "Conversa limpa",
description: "O histórico de mensagens foi limpo com sucesso.",
});
};
return ( return (
<div className="animate-fade-in h-full flex flex-col max-w-5xl mx-auto"> <div className="animate-fade-in h-full flex flex-col max-w-5xl mx-auto">
<div className="mb-4 md:mb-6"> <div className="mb-4 md:mb-6">
@@ -88,6 +98,8 @@ export default function TestPrompt() {
<Card className="flex-1 flex flex-col overflow-hidden"> <Card className="flex-1 flex flex-col overflow-hidden">
{/* Selector de Agente */} {/* Selector de Agente */}
<div className="p-4 border-b border-border"> <div className="p-4 border-b border-border">
<div className="flex items-end justify-between gap-4">
<div className="flex-1">
<Label htmlFor="agent-select" className="mb-2 block"> <Label htmlFor="agent-select" className="mb-2 block">
Selecione o Agente Selecione o Agente
</Label> </Label>
@@ -104,6 +116,18 @@ export default function TestPrompt() {
</SelectContent> </SelectContent>
</Select> </Select>
</div> </div>
<Button
variant="outline"
size="default"
onClick={handleClearChat}
disabled={messages.length === 0}
className="gap-2"
>
<RotateCcw className="h-4 w-4" />
<span className="hidden sm:inline">Nova Conversa</span>
</Button>
</div>
</div>
{/* Chat Area */} {/* Chat Area */}
<ScrollArea className="flex-1 p-4" ref={scrollRef}> <ScrollArea className="flex-1 p-4" ref={scrollRef}>