From 98c0c79ab28d81ac888d258162c4a83b81128e65 Mon Sep 17 00:00:00 2001 From: Berry Wahlberg Date: Wed, 19 Aug 2026 10:32:05 +0800 Subject: [PATCH] feat: implement artifact delete button with confirm + error banner - Add per-item delete button (stopPropagation, hover reveal) - Confirm via window.confirm before deleting - Surface delete failures in a role=alert banner instead of console.error --- .../src/pages/artifacts/ArtifactsPage.tsx | 51 ++++++++++++++++--- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/apps/desktop/src/pages/artifacts/ArtifactsPage.tsx b/apps/desktop/src/pages/artifacts/ArtifactsPage.tsx index b69cc52..2ceff07 100644 --- a/apps/desktop/src/pages/artifacts/ArtifactsPage.tsx +++ b/apps/desktop/src/pages/artifacts/ArtifactsPage.tsx @@ -1,11 +1,12 @@ import { useEffect, useState } from "react"; -import { FileText } from "lucide-react"; +import { FileText, Trash2 } from "lucide-react"; import { EmptyState, ErrorState, LoadingSpinner } from "@/components/common"; import { useWorkspaces } from "@/features/workspace/hooks/useWorkspaces"; import { useArtifacts, useDeleteArtifact } from "@/features/artifacts"; import { ArtifactViewer } from "@/features/artifacts/components/ArtifactViewer"; import { CompanyComparisonArtifactForm } from "@/features/plugins"; import { useLocale } from "@/lib/i18n/useLocale"; +import type { MessageKey } from "@/lib/i18n/locale"; import type { Artifact } from "@/lib/desktop-api/artifacts"; export function ArtifactsPage() { @@ -13,6 +14,7 @@ export function ArtifactsPage() { const workspaces = useWorkspaces(); const [workspaceId, setWorkspaceId] = useState(""); const [selectedArtifactId, setSelectedArtifactId] = useState(null); + const [deleteError, setDeleteError] = useState(null); const artifacts = useArtifacts(workspaceId); const deleteArtifact = useDeleteArtifact(); @@ -31,13 +33,17 @@ export function ArtifactsPage() { // Handle artifact deletion const handleDeleteArtifact = async (id: string) => { + if (!window.confirm(t("confirmDeleteArtifact"))) { + return; + } + setDeleteError(null); try { await deleteArtifact.mutateAsync(id); if (selectedArtifactId === id) { setSelectedArtifactId(null); } - } catch (error) { - console.error("Failed to delete artifact:", error); + } catch { + setDeleteError(t("failedToDeleteArtifact")); } }; @@ -102,6 +108,15 @@ export function ArtifactsPage() { + {deleteError && ( +
+ {deleteError} +
+ )} + void; _onDelete: () => void; - t: (key: any) => string; + t: (key: MessageKey) => string; } function ArtifactListItem({ @@ -176,7 +191,6 @@ function ArtifactListItem({ _onDelete, t, }: ArtifactListItemProps) { - void _onDelete; const getStatusColor = (status: string) => { switch (status) { case "completed": @@ -203,9 +217,18 @@ function ArtifactListItem({ }; return ( - - + ); }