Skip to content

Commit 693c34f

Browse files
author
Eric Wheeler
committed
cleanup: remove taskHistory from global state
Removed taskHistory field and all its references from the codebase as part of migrating to file-based storage. - Removed taskHistory from GlobalSettings schema - Removed import of historyItemSchema - Removed taskHistory from ExtensionState interface - Cleared PASS_THROUGH_STATE_KEYS array in ContextProxy - Updated ClineProvider to use file-based API instead of global state - Updated UI components to work without taskHistory prop Signed-off-by: Eric Wheeler <[email protected]>
1 parent cf1d4e2 commit 693c34f

File tree

8 files changed

+23
-44
lines changed

8 files changed

+23
-44
lines changed

packages/types/src/global-settings.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
providerSettingsEntrySchema,
88
providerSettingsSchema,
99
} from "./provider-settings.js"
10-
import { historyItemSchema } from "./history.js"
1110
import { codebaseIndexModelsSchema, codebaseIndexConfigSchema } from "./codebase-index.js"
1211
import { experimentsSchema } from "./experiment.js"
1312
import { telemetrySettingsSchema } from "./telemetry.js"
@@ -26,8 +25,6 @@ export const globalSettingsSchema = z.object({
2625

2726
lastShownAnnouncementId: z.string().optional(),
2827
customInstructions: z.string().optional(),
29-
taskHistory: z.array(historyItemSchema).optional(),
30-
3128
condensingApiConfigId: z.string().optional(),
3229
customCondensingPrompt: z.string().optional(),
3330

src/core/config/ContextProxy.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ type GlobalStateKey = keyof GlobalState
2323
type SecretStateKey = keyof SecretState
2424
type RooCodeSettingsKey = keyof RooCodeSettings
2525

26-
const PASS_THROUGH_STATE_KEYS = ["taskHistory"]
26+
const PASS_THROUGH_STATE_KEYS: string[] = []
2727

2828
export const isPassThroughStateKey = (key: string) => PASS_THROUGH_STATE_KEYS.includes(key)
2929

3030
const globalSettingsExportSchema = globalSettingsSchema.omit({
31-
taskHistory: true,
3231
listApiConfigMeta: true,
3332
currentApiConfigName: true,
3433
})

src/core/webview/ClineProvider.ts

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { Terminal } from "../../integrations/terminal/Terminal"
4646
import { downloadTask } from "../../integrations/misc/export-markdown"
4747
import { getTheme } from "../../integrations/theme/getTheme"
4848
import WorkspaceTracker from "../../integrations/workspace/WorkspaceTracker"
49+
import { getHistoryItem, setHistoryItems, deleteHistoryItem } from "../task-persistence/taskHistory"
4950
import { McpHub } from "../../services/mcp/McpHub"
5051
import { McpServerManager } from "../../services/mcp/McpServerManager"
5152
import { MarketplaceManager } from "../../services/marketplace"
@@ -1128,8 +1129,8 @@ export class ClineProvider
11281129
uiMessagesFilePath: string
11291130
apiConversationHistory: Anthropic.MessageParam[]
11301131
}> {
1131-
const history = this.getGlobalState("taskHistory") ?? []
1132-
const historyItem = history.find((item) => item.id === id)
1132+
// Get the history item from the file-based storage
1133+
const historyItem = await getHistoryItem(id)
11331134

11341135
if (historyItem) {
11351136
const { getTaskDirectoryPath } = await import("../../utils/storage")
@@ -1155,10 +1156,9 @@ export class ClineProvider
11551156
}
11561157
}
11571158

1158-
// if we tried to get a task that doesn't exist, remove it from state
1159-
// FIXME: this seems to happen sometimes when the json file doesnt save to disk for some reason
1160-
await this.deleteTaskFromState(id)
1161-
throw new Error("Task not found")
1159+
// If we tried to get a task that doesn't exist, delete it from storage
1160+
await deleteHistoryItem(id)
1161+
throw new Error(`Task not found, removed from index: ${id}`)
11621162
}
11631163

11641164
async showTaskWithId(id: string) {
@@ -1241,9 +1241,7 @@ export class ClineProvider
12411241
}
12421242

12431243
async deleteTaskFromState(id: string) {
1244-
const taskHistory = this.getGlobalState("taskHistory") ?? []
1245-
const updatedTaskHistory = taskHistory.filter((task) => task.id !== id)
1246-
await this.updateGlobalState("taskHistory", updatedTaskHistory)
1244+
await deleteHistoryItem(id)
12471245
await this.postStateToWebview()
12481246
}
12491247

@@ -1387,7 +1385,6 @@ export class ClineProvider
13871385
ttsSpeed,
13881386
diffEnabled,
13891387
enableCheckpoints,
1390-
taskHistory,
13911388
soundVolume,
13921389
browserViewportSize,
13931390
screenshotQuality,
@@ -1472,12 +1469,9 @@ export class ClineProvider
14721469
autoCondenseContextPercent: autoCondenseContextPercent ?? 100,
14731470
uriScheme: vscode.env.uriScheme,
14741471
currentTaskItem: this.getCurrentCline()?.taskId
1475-
? (taskHistory || []).find((item: HistoryItem) => item.id === this.getCurrentCline()?.taskId)
1472+
? await getHistoryItem(this.getCurrentCline()!.taskId)
14761473
: undefined,
14771474
clineMessages: this.getCurrentCline()?.clineMessages || [],
1478-
taskHistory: (taskHistory || [])
1479-
.filter((item: HistoryItem) => item.ts && item.task)
1480-
.sort((a: HistoryItem, b: HistoryItem) => b.ts - a.ts),
14811475
soundEnabled: soundEnabled ?? false,
14821476
ttsEnabled: ttsEnabled ?? false,
14831477
ttsSpeed: ttsSpeed ?? 1.0,
@@ -1645,7 +1639,6 @@ export class ClineProvider
16451639
allowedMaxRequests: stateValues.allowedMaxRequests,
16461640
autoCondenseContext: stateValues.autoCondenseContext ?? true,
16471641
autoCondenseContextPercent: stateValues.autoCondenseContextPercent ?? 100,
1648-
taskHistory: stateValues.taskHistory,
16491642
allowedCommands: stateValues.allowedCommands,
16501643
deniedCommands: stateValues.deniedCommands,
16511644
soundEnabled: stateValues.soundEnabled ?? false,
@@ -1725,17 +1718,11 @@ export class ClineProvider
17251718
}
17261719

17271720
async updateTaskHistory(item: HistoryItem): Promise<HistoryItem[]> {
1728-
const history = (this.getGlobalState("taskHistory") as HistoryItem[] | undefined) || []
1729-
const existingItemIndex = history.findIndex((h) => h.id === item.id)
1721+
await setHistoryItems([item])
17301722

1731-
if (existingItemIndex !== -1) {
1732-
history[existingItemIndex] = item
1733-
} else {
1734-
history.push(item)
1735-
}
1736-
1737-
await this.updateGlobalState("taskHistory", history)
1738-
return history
1723+
// Return all history items for the current workspace
1724+
const { getHistoryItemsForSearch } = await import("../task-persistence/taskHistory")
1725+
return await getHistoryItemsForSearch({ workspacePath: this.cwd })
17391726
}
17401727

17411728
// ContextProxy

src/shared/ExtensionMessage.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,6 @@ export type ExtensionState = Pick<
242242
uriScheme?: string
243243
shouldShowAnnouncement: boolean
244244

245-
taskHistory: HistoryItem[]
246-
247245
writeDelayMs: number
248246
requestDelaySeconds: number
249247

webview-ui/src/components/chat/ChatTextArea.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
8484
cwd,
8585
pinnedApiConfigs,
8686
togglePinnedApiConfig,
87-
taskHistory,
8887
clineMessages,
8988
} = useExtensionState()
9089

@@ -184,7 +183,6 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
184183
// Use custom hook for prompt history navigation
185184
const { handleHistoryNavigation, resetHistoryNavigation, resetOnInputChange } = usePromptHistory({
186185
clineMessages,
187-
taskHistory,
188186
cwd,
189187
inputValue,
190188
setInputValue,

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
8686
const {
8787
clineMessages: messages,
8888
currentTaskItem,
89-
taskHistory,
9089
apiConfiguration,
9190
organizationAllowList,
9291
mcpServers,
@@ -1712,7 +1711,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
17121711
<RooTips cycle={false} />
17131712
</div>
17141713
{/* Show the task history preview if expanded and tasks exist */}
1715-
{taskHistory.length > 0 && isExpanded && <HistoryPreview />}
1714+
{ isExpanded && <HistoryPreview />}
17161715
</div>
17171716
</div>
17181717
)}

webview-ui/src/components/chat/hooks/usePromptHistory.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { ClineMessage, HistoryItem } from "@roo-code/types"
1+
import { ClineMessage } from "@roo-code/types"
22
import { useCallback, useEffect, useMemo, useState } from "react"
3+
import { useTaskSearch } from "../../../components/history/useTaskSearch"
34

45
interface UsePromptHistoryProps {
56
clineMessages: ClineMessage[] | undefined
6-
taskHistory: HistoryItem[] | undefined
77
cwd: string | undefined
88
inputValue: string
99
setInputValue: (value: string) => void
@@ -26,7 +26,6 @@ export interface UsePromptHistoryReturn {
2626

2727
export const usePromptHistory = ({
2828
clineMessages,
29-
taskHistory,
3029
cwd,
3130
inputValue,
3231
setInputValue,
@@ -39,6 +38,9 @@ export const usePromptHistory = ({
3938
const [tempInput, setTempInput] = useState("")
4039
const [promptHistory, setPromptHistory] = useState<string[]>([])
4140

41+
// Use the useTaskSearch hook to get the task history
42+
const { tasks } = useTaskSearch({ workspacePath: cwd, limit: MAX_PROMPT_HISTORY_SIZE })
43+
4244
// Initialize prompt history with hybrid approach: conversation messages if in task, otherwise task history
4345
const filteredPromptHistory = useMemo(() => {
4446
// First try to get conversation messages (user_feedback from clineMessages)
@@ -58,16 +60,16 @@ export const usePromptHistory = ({
5860
}
5961

6062
// Fall back to task history only when starting fresh (no active conversation)
61-
if (!taskHistory?.length || !cwd) {
63+
if (!tasks.length || !cwd) {
6264
return []
6365
}
6466

6567
// Extract user prompts from task history for the current workspace only
66-
return taskHistory
67-
.filter((item) => item.task?.trim() && (!item.workspace || item.workspace === cwd))
68+
return tasks
69+
.filter((item) => item.task?.trim())
6870
.map((item) => item.task)
6971
.slice(0, MAX_PROMPT_HISTORY_SIZE)
70-
}, [clineMessages, taskHistory, cwd])
72+
}, [clineMessages, tasks, cwd])
7173

7274
// Update prompt history when filtered history changes and reset navigation
7375
useEffect(() => {

webview-ui/src/context/ExtensionStateContext.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
160160
const [state, setState] = useState<ExtensionState & { organizationAllowList?: OrganizationAllowList }>({
161161
version: "",
162162
clineMessages: [],
163-
taskHistory: [],
164163
shouldShowAnnouncement: false,
165164
allowedCommands: [],
166165
deniedCommands: [],

0 commit comments

Comments
 (0)