Add delete button to history items

Adds a Trash2 icon button to each conversation in the test prompt history to delete conversations via handleDeleteConversation, updating TestPrompt.tsx accordingly.
This commit is contained in:
gpt-engineer-app[bot]
2025-11-11 20:13:32 +00:00
parent 70fb1e9d40
commit 55cb7c0ae6
+20 -5
View File
@@ -4,7 +4,7 @@ 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, RotateCcw, MessageSquare, Plus } from "lucide-react"; import { Send, Bot, User, RotateCcw, MessageSquare, Plus, Trash2 } from "lucide-react";
import { useToast } from "@/hooks/use-toast"; import { useToast } from "@/hooks/use-toast";
import { import {
Select, Select,
@@ -188,16 +188,19 @@ export default function TestPrompt() {
</div> </div>
) : ( ) : (
conversations.map((conversation) => ( conversations.map((conversation) => (
<button <div
key={conversation.id} key={conversation.id}
onClick={() => handleSelectConversation(conversation.id)} className={`group relative rounded-lg transition-colors ${
className={`w-full text-left p-3 rounded-lg transition-colors ${
currentConversationId === conversation.id currentConversationId === conversation.id
? "bg-primary/10 border border-primary/20" ? "bg-primary/10 border border-primary/20"
: "hover:bg-muted" : "hover:bg-muted"
}`} }`}
> >
<div className="flex items-start gap-2"> <button
onClick={() => handleSelectConversation(conversation.id)}
className="w-full text-left p-3"
>
<div className="flex items-start gap-2 pr-8">
<MessageSquare className="h-4 w-4 mt-1 flex-shrink-0 text-muted-foreground" /> <MessageSquare className="h-4 w-4 mt-1 flex-shrink-0 text-muted-foreground" />
<div className="flex-1 min-w-0"> <div className="flex-1 min-w-0">
<p className="text-sm font-medium text-foreground truncate"> <p className="text-sm font-medium text-foreground truncate">
@@ -214,6 +217,18 @@ export default function TestPrompt() {
</div> </div>
</div> </div>
</button> </button>
<Button
variant="ghost"
size="icon"
onClick={(e) => {
e.stopPropagation();
handleDeleteConversation(conversation.id);
}}
className="absolute right-2 top-2 h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity"
>
<Trash2 className="h-4 w-4 text-destructive" />
</Button>
</div>
)) ))
)} )}
</div> </div>