Skip to content

Commit d088dda

Browse files
author
aheizi
committed
batch clear history
1 parent 85775ce commit d088dda

File tree

4 files changed

+362
-176
lines changed

4 files changed

+362
-176
lines changed

src/core/webview/ClineProvider.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,15 @@ export class ClineProvider implements vscode.WebviewViewProvider {
10201020
case "deleteTaskWithId":
10211021
this.deleteTaskWithId(message.text!)
10221022
break
1023+
case "deleteMultipleTasksWithIds": {
1024+
const ids = message.ids
1025+
if (Array.isArray(ids)) {
1026+
for (const id of ids) {
1027+
await this.deleteTaskWithId(id)
1028+
}
1029+
}
1030+
break
1031+
}
10231032
case "exportTaskWithId":
10241033
this.exportTaskWithId(message.text!)
10251034
break

src/shared/WebviewMessage.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export type AudioType = "notification" | "celebration" | "progress_loop"
1111
export interface WebviewMessage {
1212
type:
1313
| "apiConfiguration"
14+
| "deleteMultipleTasksWithIds"
1415
| "currentApiConfigName"
1516
| "saveApiConfiguration"
1617
| "upsertApiConfiguration"
@@ -126,6 +127,7 @@ export interface WebviewMessage {
126127
payload?: WebViewMessagePayload
127128
source?: "global" | "project"
128129
requestId?: string
130+
ids?: string[]
129131
}
130132

131133
// Human relay related message types
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { useCallback } from "react"
2+
import {
3+
AlertDialog,
4+
AlertDialogAction,
5+
AlertDialogCancel,
6+
AlertDialogContent,
7+
AlertDialogDescription,
8+
AlertDialogFooter,
9+
AlertDialogHeader,
10+
AlertDialogTitle,
11+
Button,
12+
} from "@/components/ui"
13+
import { vscode } from "@/utils/vscode"
14+
import { AlertDialogProps } from "@radix-ui/react-alert-dialog"
15+
16+
interface BatchDeleteTaskDialogProps extends AlertDialogProps {
17+
taskIds: string[]
18+
}
19+
20+
export const BatchDeleteTaskDialog = ({ taskIds, ...props }: BatchDeleteTaskDialogProps) => {
21+
const { onOpenChange } = props
22+
23+
const onDelete = useCallback(() => {
24+
if (taskIds.length > 0) {
25+
vscode.postMessage({ type: "deleteMultipleTasksWithIds", ids: taskIds })
26+
onOpenChange?.(false)
27+
}
28+
}, [taskIds, onOpenChange])
29+
30+
return (
31+
<AlertDialog {...props}>
32+
<AlertDialogContent className="max-w-md">
33+
<AlertDialogHeader>
34+
<AlertDialogTitle>Delete Tasks</AlertDialogTitle>
35+
<AlertDialogDescription className="text-vscode-foreground">
36+
<div className="mb-2">
37+
Are you sure you want to delete <strong>{taskIds.length}</strong> selected tasks?
38+
</div>
39+
<div className="text-vscode-editor-foreground bg-vscode-editor-background p-2 rounded text-sm">
40+
This action cannot be undone. All selected tasks will be permanently deleted.
41+
</div>
42+
</AlertDialogDescription>
43+
</AlertDialogHeader>
44+
<AlertDialogFooter>
45+
<AlertDialogCancel asChild>
46+
<Button variant="secondary">Cancel</Button>
47+
</AlertDialogCancel>
48+
<AlertDialogAction asChild>
49+
<Button variant="destructive" onClick={onDelete}>
50+
<span className="codicon codicon-trash mr-1"></span>
51+
Delete {taskIds.length} items
52+
</Button>
53+
</AlertDialogAction>
54+
</AlertDialogFooter>
55+
</AlertDialogContent>
56+
</AlertDialog>
57+
)
58+
}

0 commit comments

Comments
 (0)