From c6e8b04b86386588efa3014bbee04859bc8f6bc4 Mon Sep 17 00:00:00 2001 From: Dimosthenis Kaponis Date: Fri, 16 May 2025 07:38:53 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20Enhance=20HistoryPreview=20component=20?= =?UTF-8?q?with=20collapsible/expandable=20ta=E2=80=A6=20(#3534)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Enhance HistoryPreview component with collapsible/expandable task history view * fix: Update font size for empty state/'No recent tasks' message in HistoryPreview component --- .changeset/cold-dingos-run.md | 5 + .../src/components/history/HistoryPreview.tsx | 213 +++++++++++------- 2 files changed, 132 insertions(+), 86 deletions(-) create mode 100644 .changeset/cold-dingos-run.md diff --git a/.changeset/cold-dingos-run.md b/.changeset/cold-dingos-run.md new file mode 100644 index 00000000..00d17378 --- /dev/null +++ b/.changeset/cold-dingos-run.md @@ -0,0 +1,5 @@ +--- +"claude-dev": minor +--- + +Recent task list is now collapsible, allowing users to hide their recent tasks (e.g. when sharing their screen). diff --git a/webview-ui/src/components/history/HistoryPreview.tsx b/webview-ui/src/components/history/HistoryPreview.tsx index 226edfb0..c62b46f3 100644 --- a/webview-ui/src/components/history/HistoryPreview.tsx +++ b/webview-ui/src/components/history/HistoryPreview.tsx @@ -1,7 +1,7 @@ import { VSCodeButton } from "@vscode/webview-ui-toolkit/react" import { useExtensionState } from "@/context/ExtensionStateContext" import { vscode } from "@/utils/vscode" -import { memo } from "react" +import { memo, useState } from "react" import { TaskServiceClient } from "@/services/grpc-client" import { formatLargeNumber } from "@/utils/format" @@ -11,10 +11,16 @@ type HistoryPreviewProps = { const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => { const { taskHistory } = useExtensionState() + const [isExpanded, setIsExpanded] = useState(true) + const handleHistorySelect = (id: string) => { TaskServiceClient.showTaskWithId({ value: id }).catch((error) => console.error("Error showing task:", error)) } + const toggleExpanded = () => { + setIsExpanded(!isExpanded) + } + const formatDate = (timestamp: number) => { const date = new Date(timestamp) return date @@ -48,16 +54,31 @@ const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => { opacity: 1; pointer-events: auto; } + .history-header { + cursor: pointer; + user-select: none; + } + .history-header:hover { + opacity: 0.8; + } `}
+ {
-
- {taskHistory - .filter((item) => item.ts && item.task) - .slice(0, 3) - .map((item) => ( -
handleHistorySelect(item.id)}> -
-
- - {formatDate(item.ts)} - -
- {item.isFavorited && ( + {isExpanded && ( +
+ {taskHistory.filter((item) => item.ts && item.task).length > 0 ? ( + <> + {taskHistory + .filter((item) => item.ts && item.task) + .slice(0, 3) + .map((item) => ( +
handleHistorySelect(item.id)}> +
+
+ + {formatDate(item.ts)} + +
+ {item.isFavorited && ( +
+ +
+ )} + +
+ {item.task} +
+
+ + Tokens: ↑{formatLargeNumber(item.tokensIn || 0)} ↓ + {formatLargeNumber(item.tokensOut || 0)} + + {!!item.cacheWrites && ( + <> + {" • "} + + Cache: +{formatLargeNumber(item.cacheWrites || 0)} →{" "} + {formatLargeNumber(item.cacheReads || 0)} + + + )} + {!!item.totalCost && ( + <> + {" • "} + API Cost: ${item.totalCost?.toFixed(4)} + + )} +
+
+
+ ))} +
+ showHistoryView()} + style={{ + opacity: 0.9, + }}>
- + View all history
- )} - -
- {item.task} -
-
- - Tokens: ↑{formatLargeNumber(item.tokensIn || 0)} ↓{formatLargeNumber(item.tokensOut || 0)} - - {!!item.cacheWrites && ( - <> - {" • "} - - Cache: +{formatLargeNumber(item.cacheWrites || 0)} →{" "} - {formatLargeNumber(item.cacheReads || 0)} - - - )} - {!!item.totalCost && ( - <> - {" • "} - API Cost: ${item.totalCost?.toFixed(4)} - - )} -
+
-
- ))} -
- showHistoryView()} - style={{ - opacity: 0.9, - }}> + + ) : (
- View all history + No recent tasks
-
+ )}
-
+ )}
) }