Skip to content

Commit 5a43f86

Browse files
committed
This commit replaces the VSCode native dialog with a Radix AlertDialog component for task deletion confirmation. The change provides a more consistent user experience by using the same design system as the rest of the application.
Changes: Add new DeleteTaskDialog component using Radix UIs AlertDialog Update HistoryView to manage dialog state and task deletion flow Remove VSCode native dialog from ClineProvider.ts
1 parent 2fd3431 commit 5a43f86

File tree

3 files changed

+67
-11
lines changed

3 files changed

+67
-11
lines changed

src/core/webview/ClineProvider.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2309,16 +2309,6 @@ export class ClineProvider implements vscode.WebviewViewProvider {
23092309
}
23102310

23112311
async deleteTaskWithId(id: string) {
2312-
const answer = await vscode.window.showInformationMessage(
2313-
"Are you sure you want to delete this task? This action cannot be undone.",
2314-
{ modal: true },
2315-
"Delete",
2316-
)
2317-
2318-
if (answer !== "Delete") {
2319-
return
2320-
}
2321-
23222312
if (id === this.cline?.taskId) {
23232313
await this.clearTask()
23242314
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import React from "react"
2+
import {
3+
AlertDialog,
4+
AlertDialogAction,
5+
AlertDialogCancel,
6+
AlertDialogContent,
7+
AlertDialogDescription,
8+
AlertDialogFooter,
9+
AlertDialogHeader,
10+
AlertDialogTitle,
11+
} from "@/components/ui/alert-dialog"
12+
import { Button } from "@/components/ui"
13+
import { vscode } from "@/utils/vscode"
14+
15+
interface DeleteTaskDialogProps {
16+
taskId: string
17+
open: boolean
18+
onOpenChange: (open: boolean) => void
19+
}
20+
21+
export const DeleteTaskDialog = ({ taskId, open, onOpenChange }: DeleteTaskDialogProps) => {
22+
const handleDelete = () => {
23+
vscode.postMessage({ type: "deleteTaskWithId", text: taskId })
24+
onOpenChange(false)
25+
}
26+
27+
return (
28+
<AlertDialog open={open} onOpenChange={onOpenChange}>
29+
<AlertDialogContent>
30+
<AlertDialogHeader>
31+
<AlertDialogTitle>Delete Task</AlertDialogTitle>
32+
<AlertDialogDescription>
33+
Are you sure you want to delete this task? This action cannot be undone.
34+
</AlertDialogDescription>
35+
</AlertDialogHeader>
36+
<AlertDialogFooter>
37+
<AlertDialogCancel asChild>
38+
<Button variant="secondary">Cancel</Button>
39+
</AlertDialogCancel>
40+
<AlertDialogAction asChild>
41+
<Button variant="destructive" onClick={handleDelete}>
42+
Delete
43+
</Button>
44+
</AlertDialogAction>
45+
</AlertDialogFooter>
46+
</AlertDialogContent>
47+
</AlertDialog>
48+
)
49+
}

webview-ui/src/components/history/HistoryView.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { memo, useMemo, useState, useEffect } from "react"
2+
import { DeleteTaskDialog } from "./DeleteTaskDialog"
23
import { Fzf } from "fzf"
34
import prettyBytes from "pretty-bytes"
45
import { Virtuoso } from "react-virtuoso"
@@ -37,8 +38,12 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
3738
vscode.postMessage({ type: "showTaskWithId", text: id })
3839
}
3940

41+
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false)
42+
const [taskToDelete, setTaskToDelete] = useState<string | null>(null)
43+
4044
const handleDeleteHistoryItem = (id: string) => {
41-
vscode.postMessage({ type: "deleteTaskWithId", text: id })
45+
setTaskToDelete(id)
46+
setDeleteDialogOpen(true)
4247
}
4348

4449
const formatDate = (timestamp: number) => {
@@ -398,6 +403,18 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
398403
)}
399404
/>
400405
</div>
406+
{taskToDelete && (
407+
<DeleteTaskDialog
408+
taskId={taskToDelete}
409+
open={deleteDialogOpen}
410+
onOpenChange={(open) => {
411+
setDeleteDialogOpen(open)
412+
if (!open) {
413+
setTaskToDelete(null)
414+
}
415+
}}
416+
/>
417+
)}
401418
</div>
402419
)
403420
}

0 commit comments

Comments
 (0)