diff --git a/src/core/task/BackgroundTaskRunner.ts b/src/core/task/BackgroundTaskRunner.ts index e7ed7127c2..638845198d 100644 --- a/src/core/task/BackgroundTaskRunner.ts +++ b/src/core/task/BackgroundTaskRunner.ts @@ -8,6 +8,16 @@ * - Are not added to the clineStack * * This is Phase 4 of the parallel execution roadmap: Background Read-Only Concurrency. + * + * Phase 6+ extension points: + * - To support write-capable background tasks, extend BACKGROUND_TASK_ALLOWED_TOOLS + * and add a file-locking mechanism to prevent conflicts with foreground edits. + * - For real-time progress streaming, add an `onProgressUpdate` callback to + * BackgroundTaskInfo and emit partial tool-call summaries from Task. + * - For persistent history across sessions, serialize completedTasks to global + * state via the TaskHistoryStore and restore on provider initialization. + * - For tab-based switching, expose the background task's clineMessages via + * getTasksStatus() so the webview can render a full conversation view. */ import { BackgroundTaskStatusInfo } from "@roo-code/types" diff --git a/webview-ui/src/components/chat/BackgroundTasksPanel.tsx b/webview-ui/src/components/chat/BackgroundTasksPanel.tsx index d431415165..1830e11866 100644 --- a/webview-ui/src/components/chat/BackgroundTasksPanel.tsx +++ b/webview-ui/src/components/chat/BackgroundTasksPanel.tsx @@ -1,4 +1,4 @@ -import React, { useState, useMemo } from "react" +import React, { useState, useCallback, useMemo } from "react" import type { BackgroundTaskStatusInfo } from "@roo-code/types" @@ -69,11 +69,20 @@ function getStatusColor(status: BackgroundTaskStatusInfo["status"]): string { function BackgroundTaskItem({ task }: { task: BackgroundTaskStatusInfo }) { const [showResult, setShowResult] = useState(false) + const [confirmingCancel, setConfirmingCancel] = useState(false) const isRunning = task.status === "running" - const handleCancel = () => { + const handleCancelClick = useCallback(() => { + if (!confirmingCancel) { + setConfirmingCancel(true) + // Auto-reset after 3 seconds if user doesn't confirm + setTimeout(() => setConfirmingCancel(false), 3000) + return + } + // Second click confirms cancellation + setConfirmingCancel(false) vscode.postMessage({ type: "cancelBackgroundTask", taskId: task.taskId }) - } + }, [confirmingCancel, task.taskId]) const shortId = task.taskId.slice(0, 8) @@ -102,10 +111,18 @@ function BackgroundTaskItem({ task }: { task: BackgroundTaskStatusInfo }) { )} {isRunning && ( )} @@ -123,6 +140,16 @@ function BackgroundTaskItem({ task }: { task: BackgroundTaskStatusInfo }) { * BackgroundTasksPanel shows active and recently completed background tasks * as a collapsible section in the chat sidebar. Only renders when there are * background tasks to display. + * + * Phase 6+ evolution notes: + * - This panel can be promoted to a tab-based view alongside the main chat + * by extracting the task list into a shared component and rendering it in + * both the sidebar panel and a dedicated "Background Tasks" tab. + * - For real-time progress streaming, each BackgroundTaskItem could accept + * a `progressMessages` prop with the last N tool-call summaries. + * - For conversation replay, clicking a completed task could open its full + * message history in a read-only chat view (reuse ChatView with a + * `readOnly` flag and the task's clineMessages). */ const BackgroundTasksPanel: React.FC = () => { const { backgroundTasks } = useExtensionState() @@ -155,7 +182,7 @@ const BackgroundTasksPanel: React.FC = () => { {tasks.length} total {!isCollapsed && ( -