Skip to content

Commit f477ed8

Browse files
committed
feat: Add setting to show all workspace tasks by preference
1 parent 7a0a6de commit f477ed8

31 files changed

+235
-25
lines changed

packages/types/src/global-settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const globalSettingsSchema = z.object({
2727
lastShownAnnouncementId: z.string().optional(),
2828
customInstructions: z.string().optional(),
2929
taskHistory: z.array(historyItemSchema).optional(),
30+
showAllWorkspacesTasks: z.boolean().optional(),
3031

3132
condensingApiConfigId: z.string().optional(),
3233
customCondensingPrompt: z.string().optional(),

src/core/webview/ClineProvider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,7 @@ export class ClineProvider
14081408
profileThresholds,
14091409
alwaysAllowFollowupQuestions,
14101410
followupAutoApproveTimeoutMs,
1411+
showAllWorkspacesTasks,
14111412
} = await this.getState()
14121413

14131414
const telemetryKey = process.env.POSTHOG_API_KEY
@@ -1520,6 +1521,7 @@ export class ClineProvider
15201521
hasOpenedModeSelector: this.getGlobalState("hasOpenedModeSelector") ?? false,
15211522
alwaysAllowFollowupQuestions: alwaysAllowFollowupQuestions ?? false,
15221523
followupAutoApproveTimeoutMs: followupAutoApproveTimeoutMs ?? 60000,
1524+
showAllWorkspacesTasks: showAllWorkspacesTasks ?? false,
15231525
}
15241526
}
15251527

@@ -1672,6 +1674,7 @@ export class ClineProvider
16721674
codebaseIndexEmbedderModelId: "",
16731675
},
16741676
profileThresholds: stateValues.profileThresholds ?? {},
1677+
showAllWorkspacesTasks: stateValues.showAllWorkspacesTasks ?? false,
16751678
}
16761679
}
16771680

src/core/webview/__tests__/ClineProvider.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ describe("ClineProvider", () => {
491491
version: "1.0.0",
492492
clineMessages: [],
493493
taskHistory: [],
494+
showAllWorkspacesTasks: false,
494495
shouldShowAnnouncement: false,
495496
apiConfiguration: {
496497
apiProvider: "openrouter",

src/core/webview/webviewMessageHandler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,5 +2060,10 @@ export const webviewMessageHandler = async (
20602060
}
20612061
break
20622062
}
2063+
2064+
case "showAllWorkspacesTasks":
2065+
await updateGlobalState("showAllWorkspacesTasks", message.bool ?? false)
2066+
await provider.postStateToWebview()
2067+
break
20632068
}
20642069
}

src/shared/ExtensionMessage.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export interface ExtensionMessage {
105105
| "shareTaskSuccess"
106106
| "codeIndexSettingsSaved"
107107
| "codeIndexSecretStatus"
108+
| "showAllWorkspacesTasks"
108109
text?: string
109110
payload?: any // Add a generic payload for now, can refine later
110111
action?:
@@ -230,6 +231,7 @@ export type ExtensionState = Pick<
230231
version: string
231232
clineMessages: ClineMessage[]
232233
currentTaskItem?: HistoryItem
234+
showAllWorkspacesTasks: boolean
233235
apiConfiguration?: ProviderSettings
234236
uriScheme?: string
235237
shouldShowAnnouncement: boolean

src/shared/WebviewMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ export interface WebviewMessage {
185185
| "checkRulesDirectoryResult"
186186
| "saveCodeIndexSettingsAtomic"
187187
| "requestCodeIndexSecretStatus"
188+
| "showAllWorkspacesTasks"
188189
text?: string
189190
tab?: "settings" | "history" | "mcp" | "modes" | "chat" | "marketplace" | "account"
190191
disabled?: boolean

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import React, { memo, useState } from "react"
2+
3+
import { vscode } from "@/utils/vscode"
24
import { DeleteTaskDialog } from "./DeleteTaskDialog"
35
import { BatchDeleteTaskDialog } from "./BatchDeleteTaskDialog"
46
import { Virtuoso } from "react-virtuoso"
@@ -35,8 +37,8 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
3537
sortOption,
3638
setSortOption,
3739
setLastNonRelevantSort,
38-
showAllWorkspaces,
39-
setShowAllWorkspaces,
40+
showAllWorkspacesTasks,
41+
setShowAllWorkspacesTasks,
4042
} = useTaskSearch()
4143
const { t } = useAppTranslation()
4244

@@ -129,12 +131,19 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
129131
</VSCodeTextField>
130132
<div className="flex gap-2">
131133
<Select
132-
value={showAllWorkspaces ? "all" : "current"}
133-
onValueChange={(value) => setShowAllWorkspaces(value === "all")}>
134+
value={showAllWorkspacesTasks ? "all" : "current"}
135+
onValueChange={(value) => {
136+
const showAll = value === "all"
137+
setShowAllWorkspacesTasks(showAll)
138+
vscode.postMessage({
139+
type: "showAllWorkspacesTasks",
140+
bool: showAll,
141+
})
142+
}}>
134143
<SelectTrigger className="flex-1">
135144
<SelectValue>
136145
{t("history:workspace.prefix")}{" "}
137-
{t(`history:workspace.${showAllWorkspaces ? "all" : "current"}`)}
146+
{t(`history:workspace.${showAllWorkspacesTasks ? "all" : "current"}`)}
138147
</SelectValue>
139148
</SelectTrigger>
140149
<SelectContent>
@@ -238,7 +247,7 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
238247
key={item.id}
239248
item={item}
240249
variant="full"
241-
showWorkspace={showAllWorkspaces}
250+
showWorkspace={showAllWorkspacesTasks}
242251
isSelectionMode={isSelectionMode}
243252
isSelected={selectedTaskIds.includes(item.id)}
244253
onToggleSelection={toggleTaskSelection}

webview-ui/src/components/history/__tests__/useTaskSearch.spec.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ describe("useTaskSearch", () => {
5757
mockUseExtensionState.mockReturnValue({
5858
taskHistory: mockTaskHistory,
5959
cwd: "/workspace/project1",
60+
showAllWorkspacesTasks: false,
61+
setShowAllWorkspacesTasks: vi.fn(),
6062
} as any)
6163
})
6264

@@ -75,22 +77,22 @@ describe("useTaskSearch", () => {
7577
expect(result.current.tasks.every((task) => task.workspace === "/workspace/project1")).toBe(true)
7678
})
7779

78-
it("shows all workspaces when showAllWorkspaces is true", () => {
80+
it("shows all workspaces when showAllWorkspacesTasks is true", () => {
7981
const { result } = renderHook(() => useTaskSearch())
8082

8183
act(() => {
82-
result.current.setShowAllWorkspaces(true)
84+
result.current.setShowAllWorkspacesTasks(true)
8385
})
8486

8587
expect(result.current.tasks).toHaveLength(3)
86-
expect(result.current.showAllWorkspaces).toBe(true)
88+
expect(result.current.showAllWorkspacesTasks).toBe(true)
8789
})
8890

8991
it("sorts by newest by default", () => {
9092
const { result } = renderHook(() => useTaskSearch())
9193

9294
act(() => {
93-
result.current.setShowAllWorkspaces(true)
95+
result.current.setShowAllWorkspacesTasks(true)
9496
})
9597

9698
expect(result.current.sortOption).toBe("newest")
@@ -103,7 +105,7 @@ describe("useTaskSearch", () => {
103105
const { result } = renderHook(() => useTaskSearch())
104106

105107
act(() => {
106-
result.current.setShowAllWorkspaces(true)
108+
result.current.setShowAllWorkspacesTasks(true)
107109
result.current.setSortOption("oldest")
108110
})
109111

@@ -116,7 +118,7 @@ describe("useTaskSearch", () => {
116118
const { result } = renderHook(() => useTaskSearch())
117119

118120
act(() => {
119-
result.current.setShowAllWorkspaces(true)
121+
result.current.setShowAllWorkspacesTasks(true)
120122
result.current.setSortOption("mostExpensive")
121123
})
122124

@@ -129,7 +131,7 @@ describe("useTaskSearch", () => {
129131
const { result } = renderHook(() => useTaskSearch())
130132

131133
act(() => {
132-
result.current.setShowAllWorkspaces(true)
134+
result.current.setShowAllWorkspacesTasks(true)
133135
result.current.setSortOption("mostTokens")
134136
})
135137

@@ -145,7 +147,7 @@ describe("useTaskSearch", () => {
145147
const { result } = renderHook(() => useTaskSearch())
146148

147149
act(() => {
148-
result.current.setShowAllWorkspaces(true)
150+
result.current.setShowAllWorkspacesTasks(true)
149151
result.current.setSearchQuery("React")
150152
})
151153

@@ -252,7 +254,7 @@ describe("useTaskSearch", () => {
252254
const { result } = renderHook(() => useTaskSearch())
253255

254256
act(() => {
255-
result.current.setShowAllWorkspaces(true)
257+
result.current.setShowAllWorkspacesTasks(true)
256258
})
257259

258260
// Should only include tasks with both ts and task content
@@ -264,7 +266,7 @@ describe("useTaskSearch", () => {
264266
const { result } = renderHook(() => useTaskSearch())
265267

266268
act(() => {
267-
result.current.setShowAllWorkspaces(true)
269+
result.current.setShowAllWorkspacesTasks(true)
268270
result.current.setSearchQuery("nonexistent")
269271
})
270272

@@ -275,7 +277,7 @@ describe("useTaskSearch", () => {
275277
const { result } = renderHook(() => useTaskSearch())
276278

277279
act(() => {
278-
result.current.setShowAllWorkspaces(true)
280+
result.current.setShowAllWorkspacesTasks(true)
279281
result.current.setSearchQuery("test")
280282
result.current.setSortOption("mostRelevant")
281283
})

webview-ui/src/components/history/useTaskSearch.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ import { useExtensionState } from "@/context/ExtensionStateContext"
77
type SortOption = "newest" | "oldest" | "mostExpensive" | "mostTokens" | "mostRelevant"
88

99
export const useTaskSearch = () => {
10-
const { taskHistory, cwd } = useExtensionState()
10+
const { taskHistory, cwd, showAllWorkspacesTasks, setShowAllWorkspacesTasks } = useExtensionState()
1111
const [searchQuery, setSearchQuery] = useState("")
1212
const [sortOption, setSortOption] = useState<SortOption>("newest")
1313
const [lastNonRelevantSort, setLastNonRelevantSort] = useState<SortOption | null>("newest")
14-
const [showAllWorkspaces, setShowAllWorkspaces] = useState(false)
1514

1615
useEffect(() => {
1716
if (searchQuery && sortOption !== "mostRelevant" && !lastNonRelevantSort) {
@@ -25,11 +24,11 @@ export const useTaskSearch = () => {
2524

2625
const presentableTasks = useMemo(() => {
2726
let tasks = taskHistory.filter((item) => item.ts && item.task)
28-
if (!showAllWorkspaces) {
27+
if (!showAllWorkspacesTasks) {
2928
tasks = tasks.filter((item) => item.workspace === cwd)
3029
}
3130
return tasks
32-
}, [taskHistory, showAllWorkspaces, cwd])
31+
}, [taskHistory, showAllWorkspacesTasks, cwd])
3332

3433
const fzf = useMemo(() => {
3534
return new Fzf(presentableTasks, {
@@ -86,7 +85,7 @@ export const useTaskSearch = () => {
8685
setSortOption,
8786
lastNonRelevantSort,
8887
setLastNonRelevantSort,
89-
showAllWorkspaces,
90-
setShowAllWorkspaces,
88+
showAllWorkspacesTasks,
89+
setShowAllWorkspacesTasks,
9190
}
9291
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react"
2+
import { useAppTranslation } from "@src/i18n/TranslationContext"
3+
4+
import { ExtensionStateContextType } from "@/context/ExtensionStateContext"
5+
import { SetCachedStateField } from "./types"
6+
import { Section } from "./Section"
7+
8+
type GeneralProps = {
9+
showAllWorkspacesTasks: boolean
10+
setCachedStateField: SetCachedStateField<keyof ExtensionStateContextType>
11+
}
12+
13+
export const GeneralSettings = ({ showAllWorkspacesTasks, setCachedStateField }: GeneralProps) => {
14+
const { t } = useAppTranslation()
15+
16+
return (
17+
<Section>
18+
<div>
19+
<VSCodeCheckbox
20+
checked={showAllWorkspacesTasks}
21+
onChange={(e) => {
22+
const checked = (e.target as HTMLInputElement).checked
23+
setCachedStateField("showAllWorkspacesTasks", checked)
24+
}}>
25+
<span className="font-medium">{t("settings:general.showAllWorkspacesTasks.label")}</span>
26+
</VSCodeCheckbox>
27+
<div className="text-vscode-descriptionForeground text-sm mt-1">
28+
{t("settings:general.showAllWorkspacesTasks.description")}
29+
</div>
30+
</div>
31+
</Section>
32+
)
33+
}

0 commit comments

Comments
 (0)