Skip to content

Commit 08110ae

Browse files
samhvw8mrubens
andauthored
Filter & Search Workspace Task History (#2526)
* Enhancement: Add 'Show all workspaces' feature to task history and update translations * Enhancement: Add Checkbox component and integrate it into HistoryPreview and HistoryView * Simplify the UX --------- Co-authored-by: Matt Rubens <[email protected]>
1 parent 628d232 commit 08110ae

File tree

22 files changed

+365
-47
lines changed

22 files changed

+365
-47
lines changed

webview-ui/package-lock.json

Lines changed: 213 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
},
2020
"dependencies": {
2121
"@radix-ui/react-alert-dialog": "^1.1.6",
22+
"@radix-ui/react-checkbox": "^1.1.5",
2223
"@radix-ui/react-collapsible": "^1.1.3",
2324
"@radix-ui/react-dialog": "^1.1.6",
2425
"@radix-ui/react-dropdown-menu": "^2.1.5",

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import { vscode } from "@/utils/vscode"
44
import { formatLargeNumber, formatDate } from "@/utils/format"
55
import { Button } from "@/components/ui"
66

7-
import { useExtensionState } from "../../context/ExtensionStateContext"
87
import { useAppTranslation } from "../../i18n/TranslationContext"
98
import { CopyButton } from "./CopyButton"
9+
import { useTaskSearch } from "./useTaskSearch"
1010

1111
type HistoryPreviewProps = {
1212
showHistoryView: () => void
1313
}
1414
const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => {
15-
const { taskHistory } = useExtensionState()
15+
const { tasks } = useTaskSearch()
1616
const { t } = useAppTranslation()
1717

1818
return (
@@ -26,7 +26,7 @@ const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => {
2626
{t("history:viewAll")}
2727
</Button>
2828
</div>
29-
{taskHistory.slice(0, 3).map((item) => (
29+
{tasks.slice(0, 3).map((item) => (
3030
<div
3131
key={item.id}
3232
className="bg-vscode-toolbar-hoverBackground/50 hover:bg-vscode-toolbar-hoverBackground/75 rounded-xs relative overflow-hidden opacity-90 hover:opacity-100 cursor-pointer"

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

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { BatchDeleteTaskDialog } from "./BatchDeleteTaskDialog"
44
import prettyBytes from "pretty-bytes"
55
import { Virtuoso } from "react-virtuoso"
66

7-
import { VSCodeTextField, VSCodeRadioGroup, VSCodeRadio, VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react"
7+
import { VSCodeTextField, VSCodeRadioGroup, VSCodeRadio } from "@vscode/webview-ui-toolkit/react"
88

99
import { vscode } from "@/utils/vscode"
1010
import { formatLargeNumber, formatDate } from "@/utils/format"
1111
import { cn } from "@/lib/utils"
12-
import { Button } from "@/components/ui"
12+
import { Button, Checkbox } from "@/components/ui"
1313
import { useAppTranslation } from "@/i18n/TranslationContext"
1414

1515
import { Tab, TabContent, TabHeader } from "../common/Tab"
@@ -24,7 +24,16 @@ type HistoryViewProps = {
2424
type SortOption = "newest" | "oldest" | "mostExpensive" | "mostTokens" | "mostRelevant"
2525

2626
const HistoryView = ({ onDone }: HistoryViewProps) => {
27-
const { tasks, searchQuery, setSearchQuery, sortOption, setSortOption, setLastNonRelevantSort } = useTaskSearch()
27+
const {
28+
tasks,
29+
searchQuery,
30+
setSearchQuery,
31+
sortOption,
32+
setSortOption,
33+
setLastNonRelevantSort,
34+
showAllWorkspaces,
35+
setShowAllWorkspaces,
36+
} = useTaskSearch()
2837
const { t } = useAppTranslation()
2938

3039
const [deleteTaskId, setDeleteTaskId] = useState<string | null>(null)
@@ -147,21 +156,36 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
147156
</VSCodeRadio>
148157
</VSCodeRadioGroup>
149158

159+
<div className="flex items-center gap-2" onClick={() => setShowAllWorkspaces(!showAllWorkspaces)}>
160+
<Checkbox
161+
checked={showAllWorkspaces}
162+
onCheckedChange={(checked) => setShowAllWorkspaces(checked === true)}
163+
variant="description"
164+
/>
165+
<span className="text-vscode-foreground">{t("history:showAllWorkspaces")}</span>
166+
</div>
167+
150168
{/* Select all control in selection mode */}
151169
{isSelectionMode && tasks.length > 0 && (
152170
<div className="flex items-center py-1 px-2 bg-vscode-editor-background rounded">
153-
<VSCodeCheckbox
154-
checked={tasks.length > 0 && selectedTaskIds.length === tasks.length}
155-
onChange={(e) => toggleSelectAll((e.target as HTMLInputElement).checked)}
156-
/>
157-
<span className="ml-2 text-vscode-foreground">
158-
{selectedTaskIds.length === tasks.length
159-
? t("history:deselectAll")
160-
: t("history:selectAll")}
161-
</span>
162-
<span className="ml-auto text-vscode-descriptionForeground text-xs">
163-
{t("history:selectedItems", { selected: selectedTaskIds.length, total: tasks.length })}
164-
</span>
171+
<div className="flex items-center gap-2">
172+
<Checkbox
173+
checked={tasks.length > 0 && selectedTaskIds.length === tasks.length}
174+
onCheckedChange={(checked) => toggleSelectAll(checked === true)}
175+
variant="description"
176+
/>
177+
<span className="text-vscode-foreground">
178+
{selectedTaskIds.length === tasks.length
179+
? t("history:deselectAll")
180+
: t("history:selectAll")}
181+
</span>
182+
<span className="ml-auto text-vscode-descriptionForeground text-xs">
183+
{t("history:selectedItems", {
184+
selected: selectedTaskIds.length,
185+
total: tasks.length,
186+
})}
187+
</span>
188+
</div>
165189
</div>
166190
)}
167191
</div>
@@ -203,11 +227,12 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
203227
onClick={(e) => {
204228
e.stopPropagation()
205229
}}>
206-
<VSCodeCheckbox
230+
<Checkbox
207231
checked={selectedTaskIds.includes(item.id)}
208-
onChange={(e) =>
209-
toggleTaskSelection(item.id, (e.target as HTMLInputElement).checked)
232+
onCheckedChange={(checked) =>
233+
toggleTaskSelection(item.id, checked === true)
210234
}
235+
variant="description"
211236
/>
212237
</div>
213238
)}
@@ -407,6 +432,13 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
407432
)}
408433
</div>
409434
)}
435+
436+
{showAllWorkspaces && item.workspace && (
437+
<div className="flex flex-row gap-1 text-vscode-descriptionForeground text-xs">
438+
<span className="codicon codicon-folder scale-80" />
439+
<span>{item.workspace}</span>
440+
</div>
441+
)}
410442
</div>
411443
</div>
412444
</div>

0 commit comments

Comments
 (0)