Skip to content

Commit 9b1e635

Browse files
committed
fix: prevent task deletion when clicking on history items
- Modified TaskItem component to prevent automatic task resumption on click - Added explicit Resume button to TaskItemFooter for intentional task resumption - Task items now only respond to clicks in selection mode for checkbox toggling - Added translation for "Resume Task" button - Preserves existing export functionality for non-destructive task viewing Fixes #6592
1 parent 8513263 commit 9b1e635

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,13 @@ const TaskItem = ({
3636
const handleClick = () => {
3737
if (isSelectionMode && onToggleSelection) {
3838
onToggleSelection(item.id, !isSelected)
39-
} else {
40-
vscode.postMessage({ type: "showTaskWithId", text: item.id })
4139
}
40+
// Removed the automatic showTaskWithId call
41+
}
42+
43+
const handleResumeClick = (e: React.MouseEvent) => {
44+
e.stopPropagation()
45+
vscode.postMessage({ type: "showTaskWithId", text: item.id })
4246
}
4347

4448
const isCompact = variant === "compact"
@@ -48,7 +52,8 @@ const TaskItem = ({
4852
key={item.id}
4953
data-testid={`task-item-${item.id}`}
5054
className={cn(
51-
"cursor-pointer group bg-vscode-editor-background rounded relative overflow-hidden hover:border-vscode-toolbar-hoverBackground/60",
55+
"group bg-vscode-editor-background rounded relative overflow-hidden hover:border-vscode-toolbar-hoverBackground/60",
56+
isSelectionMode ? "cursor-pointer" : "cursor-default",
5257
className,
5358
)}
5459
onClick={handleClick}>
@@ -84,7 +89,12 @@ const TaskItem = ({
8489
</div>
8590

8691
{/* Task Item Footer */}
87-
<TaskItemFooter item={item} variant={variant} isSelectionMode={isSelectionMode} />
92+
<TaskItemFooter
93+
item={item}
94+
variant={variant}
95+
isSelectionMode={isSelectionMode}
96+
onResumeClick={handleResumeClick}
97+
/>
8898

8999
{/* Workspace info */}
90100
{showWorkspace && item.workspace && (

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@ import prettyBytes from "pretty-bytes"
55
import { formatLargeNumber } from "@/utils/format"
66
import { CopyButton } from "./CopyButton"
77
import { ExportButton } from "./ExportButton"
8+
import { Button, StandardTooltip } from "@/components/ui"
9+
import { useAppTranslation } from "@/i18n/TranslationContext"
810

911
export interface TaskItemFooterProps {
1012
item: HistoryItem
1113
variant: "compact" | "full"
1214
isSelectionMode?: boolean
15+
onResumeClick?: (e: React.MouseEvent) => void
1316
}
1417

15-
const TaskItemFooter: React.FC<TaskItemFooterProps> = ({ item, variant, isSelectionMode = false }) => {
18+
const TaskItemFooter: React.FC<TaskItemFooterProps> = ({ item, variant, isSelectionMode = false, onResumeClick }) => {
19+
const { t } = useAppTranslation()
1620
return (
1721
<div className="text-xs text-vscode-descriptionForeground flex justify-between items-center mt-1">
1822
<div className="flex gap-2">
@@ -52,6 +56,17 @@ const TaskItemFooter: React.FC<TaskItemFooterProps> = ({ item, variant, isSelect
5256
{/* Action Buttons for non-compact view */}
5357
{!isSelectionMode && (
5458
<div className="flex flex-row gap-0 items-center opacity-50 hover:opacity-100">
59+
{onResumeClick && (
60+
<StandardTooltip content={t("history:resumeTask")}>
61+
<Button
62+
variant="ghost"
63+
size="icon"
64+
className="group-hover:opacity-100 transition-opacity"
65+
onClick={onResumeClick}>
66+
<span className="codicon codicon-play scale-80" />
67+
</Button>
68+
</StandardTooltip>
69+
)}
5570
<CopyButton itemTask={item.task} />
5671
{variant === "full" && <ExportButton itemId={item.id} />}
5772
</div>

webview-ui/src/i18n/locales/en/history.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"deleteTaskTitle": "Delete Task (Shift + Click to skip confirmation)",
1414
"copyPrompt": "Copy Prompt",
1515
"exportTask": "Export Task",
16+
"resumeTask": "Resume Task",
1617
"deleteTask": "Delete Task",
1718
"deleteTaskMessage": "Are you sure you want to delete this task? This action cannot be undone.",
1819
"cancel": "Cancel",

0 commit comments

Comments
 (0)