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
This commit is contained in:
Roo Code 2025-08-02 09:16:54 +00:00
parent 8513263a67
commit 9b1e6359c1
3 changed files with 31 additions and 5 deletions

View file

@ -36,9 +36,13 @@ const TaskItem = ({
const handleClick = () => {
if (isSelectionMode && onToggleSelection) {
onToggleSelection(item.id, !isSelected)
} else {
vscode.postMessage({ type: "showTaskWithId", text: item.id })
}
// Removed the automatic showTaskWithId call
}
const handleResumeClick = (e: React.MouseEvent) => {
e.stopPropagation()
vscode.postMessage({ type: "showTaskWithId", text: item.id })
}
const isCompact = variant === "compact"
@ -48,7 +52,8 @@ const TaskItem = ({
key={item.id}
data-testid={`task-item-${item.id}`}
className={cn(
"cursor-pointer group bg-vscode-editor-background rounded relative overflow-hidden hover:border-vscode-toolbar-hoverBackground/60",
"group bg-vscode-editor-background rounded relative overflow-hidden hover:border-vscode-toolbar-hoverBackground/60",
isSelectionMode ? "cursor-pointer" : "cursor-default",
className,
)}
onClick={handleClick}>
@ -84,7 +89,12 @@ const TaskItem = ({
</div>
{/* Task Item Footer */}
<TaskItemFooter item={item} variant={variant} isSelectionMode={isSelectionMode} />
<TaskItemFooter
item={item}
variant={variant}
isSelectionMode={isSelectionMode}
onResumeClick={handleResumeClick}
/>
{/* Workspace info */}
{showWorkspace && item.workspace && (

View file

@ -5,14 +5,18 @@ import prettyBytes from "pretty-bytes"
import { formatLargeNumber } from "@/utils/format"
import { CopyButton } from "./CopyButton"
import { ExportButton } from "./ExportButton"
import { Button, StandardTooltip } from "@/components/ui"
import { useAppTranslation } from "@/i18n/TranslationContext"
export interface TaskItemFooterProps {
item: HistoryItem
variant: "compact" | "full"
isSelectionMode?: boolean
onResumeClick?: (e: React.MouseEvent) => void
}
const TaskItemFooter: React.FC<TaskItemFooterProps> = ({ item, variant, isSelectionMode = false }) => {
const TaskItemFooter: React.FC<TaskItemFooterProps> = ({ item, variant, isSelectionMode = false, onResumeClick }) => {
const { t } = useAppTranslation()
return (
<div className="text-xs text-vscode-descriptionForeground flex justify-between items-center mt-1">
<div className="flex gap-2">
@ -52,6 +56,17 @@ const TaskItemFooter: React.FC<TaskItemFooterProps> = ({ item, variant, isSelect
{/* Action Buttons for non-compact view */}
{!isSelectionMode && (
<div className="flex flex-row gap-0 items-center opacity-50 hover:opacity-100">
{onResumeClick && (
<StandardTooltip content={t("history:resumeTask")}>
<Button
variant="ghost"
size="icon"
className="group-hover:opacity-100 transition-opacity"
onClick={onResumeClick}>
<span className="codicon codicon-play scale-80" />
</Button>
</StandardTooltip>
)}
<CopyButton itemTask={item.task} />
{variant === "full" && <ExportButton itemId={item.id} />}
</div>

View file

@ -13,6 +13,7 @@
"deleteTaskTitle": "Delete Task (Shift + Click to skip confirmation)",
"copyPrompt": "Copy Prompt",
"exportTask": "Export Task",
"resumeTask": "Resume Task",
"deleteTask": "Delete Task",
"deleteTaskMessage": "Are you sure you want to delete this task? This action cannot be undone.",
"cancel": "Cancel",