diff --git a/src/__tests__/extension.spec.ts b/src/__tests__/extension.spec.ts index 1803eb4d36..31e72e6648 100644 --- a/src/__tests__/extension.spec.ts +++ b/src/__tests__/extension.spec.ts @@ -162,6 +162,7 @@ vi.mock("../utils/autoImportSettings", () => ({ // Avoid filesystem access during activation by stubbing background purge vi.mock("../utils/task-history-retention", () => ({ startBackgroundRetentionPurge: vi.fn(), + startBackgroundCheckpointPurge: vi.fn(), })) // Ensure storage base path resolves to provided path to avoid touching VS Code config diff --git a/webview-ui/src/components/history/HistoryView.tsx b/webview-ui/src/components/history/HistoryView.tsx index 88b6551881..fb621f5ec0 100644 --- a/webview-ui/src/components/history/HistoryView.tsx +++ b/webview-ui/src/components/history/HistoryView.tsx @@ -1,14 +1,21 @@ import React, { memo, useState, useMemo } from "react" -import { ArrowLeft } from "lucide-react" +import { ArrowLeft, Settings } from "lucide-react" import { DeleteTaskDialog } from "./DeleteTaskDialog" import { BatchDeleteTaskDialog } from "./BatchDeleteTaskDialog" import { Virtuoso } from "react-virtuoso" +import { TASK_HISTORY_RETENTION_OPTIONS, type TaskHistoryRetentionSetting } from "@roo-code/types" + import { VSCodeTextField } from "@vscode/webview-ui-toolkit/react" +import { vscode } from "@/utils/vscode" +import { useExtensionState } from "@/context/ExtensionStateContext" import { Button, Checkbox, + Popover, + PopoverContent, + PopoverTrigger, Select, SelectContent, SelectItem, @@ -41,6 +48,7 @@ const HistoryView = ({ onDone }: HistoryViewProps) => { showAllWorkspaces, setShowAllWorkspaces, } = useTaskSearch() + const { taskHistoryRetention } = useExtensionState() const { t } = useAppTranslation() // Use grouped tasks hook @@ -51,6 +59,19 @@ const HistoryView = ({ onDone }: HistoryViewProps) => { const [isSelectionMode, setIsSelectionMode] = useState(false) const [selectedTaskIds, setSelectedTaskIds] = useState([]) const [showBatchDeleteDialog, setShowBatchDeleteDialog] = useState(false) + const [isRetentionPopoverOpen, setIsRetentionPopoverOpen] = useState(false) + + // Normalize retention setting to ensure it's valid + const normalizedRetention: TaskHistoryRetentionSetting = TASK_HISTORY_RETENTION_OPTIONS.includes( + taskHistoryRetention as TaskHistoryRetentionSetting, + ) + ? (taskHistoryRetention as TaskHistoryRetentionSetting) + : "never" + + // Handle retention setting change + const handleRetentionChange = (value: TaskHistoryRetentionSetting) => { + vscode.postMessage({ type: "updateSettings", updatedSettings: { taskHistoryRetention: value } }) + } // Get subtask count for a task const getSubtaskCount = useMemo(() => { @@ -116,20 +137,67 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {

{t("history:history")}

- - - +
+ + + + + + + +
+

{t("settings:aboutRetention.label")}

+ +

+ {t("settings:aboutRetention.description")} +

+

{t("settings:aboutRetention.warning")}

+
+
+
+ + + +
& { setTelemetrySetting: (setting: TelemetrySetting) => void debug?: boolean setDebug?: (debug: boolean) => void - taskHistoryRetention: TaskHistoryRetentionSetting - setTaskHistoryRetention: (value: TaskHistoryRetentionSetting) => void taskHistorySize?: TaskHistorySize } @@ -47,8 +45,6 @@ export const About = ({ setTelemetrySetting, debug, setDebug, - taskHistoryRetention, - setTaskHistoryRetention, taskHistorySize, className, ...props @@ -195,37 +191,6 @@ export const About = ({
- -

{t("settings:aboutRetention.label")}

-
- -
- {t("settings:aboutRetention.description")} -
-
{t("settings:aboutRetention.warning")}
-
-
- (({ onDone, t setTelemetrySetting={setTelemetrySetting} debug={cachedState.debug} setDebug={setDebug} - taskHistoryRetention={normalizedTaskHistoryRetention} - setTaskHistoryRetention={(value) => setCachedStateField("taskHistoryRetention", value)} taskHistorySize={taskHistorySize} /> )} diff --git a/webview-ui/src/components/settings/__tests__/About.spec.tsx b/webview-ui/src/components/settings/__tests__/About.spec.tsx index 92791b4ac5..b62b7c1358 100644 --- a/webview-ui/src/components/settings/__tests__/About.spec.tsx +++ b/webview-ui/src/components/settings/__tests__/About.spec.tsx @@ -31,8 +31,6 @@ describe("About", () => { const defaultProps: ComponentProps = { telemetrySetting: "enabled" as const, setTelemetrySetting: vi.fn(), - taskHistoryRetention: "never", - setTaskHistoryRetention: vi.fn(), } beforeEach(() => {