Compare commits

...
Author SHA1 Message Date
abeatrix e262d4fb57 update 2025-09-04 14:35:32 -07:00
abeatrix acc0750970 Merge branch 'fix/taskHistory-migration-across-dev-and-prod' of https://github.com/cline/cline into fix/taskHistory-migration-across-dev-and-prod 2025-09-04 14:21:47 -07:00
abeatrix 3098c040c6 Simplify the migration function
Simplify the migration function by consolidating conditional logic,
removing redundant logging, and using concurrent operations for
better performance. The logic now handles both empty and populated
destination scenarios more clearly.
2025-09-04 14:21:02 -07:00
Arafatkatze 9ebb1c2b38 Adding Multi root algo 2025-09-04 14:19:58 -07:00
Arafatkatze f73fe56474 Adding Multi root algo 2025-09-04 14:18:10 -07:00
AraandBee a81cfdb56e Update src/core/storage/state-migrations.ts
Co-authored-by: Bee <68532117+abeatrix@users.noreply.github.com>
2025-09-04 14:15:00 -07:00
AraandBee 917e66f18c Update src/core/storage/state-migrations.ts
Co-authored-by: Bee <68532117+abeatrix@users.noreply.github.com>
2025-09-04 14:14:53 -07:00
AraandBee 97382e9749 Update src/core/storage/state-migrations.ts
Co-authored-by: Bee <68532117+abeatrix@users.noreply.github.com>
2025-09-04 14:14:46 -07:00
AraandBee 164bd4e393 Update src/core/storage/state-migrations.ts
Co-authored-by: Bee <68532117+abeatrix@users.noreply.github.com>
2025-09-04 14:14:24 -07:00
AraandBee 7ce4943fdc Update src/core/storage/state-migrations.ts
Co-authored-by: Bee <68532117+abeatrix@users.noreply.github.com>
2025-09-04 14:14:17 -07:00
celestial-vault a198adb9e8 fix taskHistory migration when run across main and the prod version which use the old and the new location 2025-09-04 12:14:35 -07:00
+30 -12
View File
@@ -1,6 +1,7 @@
import fs from "fs/promises"
import path from "path"
import * as vscode from "vscode"
import { HistoryItem } from "@/shared/HistoryItem"
import { ensureRulesDirectoryExists, readTaskHistoryFromState, writeTaskHistoryToState } from "./disk"
import { StateManager } from "./StateManager"
@@ -68,20 +69,37 @@ export async function migrateWorkspaceToGlobalStorage(context: vscode.ExtensionC
export async function migrateTaskHistoryToFile(context: vscode.ExtensionContext) {
try {
// If the old taskHistory vs code global state is undefined, do nothing
const vscodeGlobalStateTaskHistory = await context.globalState.get("taskHistory")
if (vscodeGlobalStateTaskHistory === undefined) {
// Get data from old location
const vscodeGlobalStateTaskHistory = context.globalState.get<HistoryItem[] | undefined>("taskHistory")
// Normalize old location data to array (empty array if undefined/null/not-array)
const oldLocationData = Array.isArray(vscodeGlobalStateTaskHistory) ? vscodeGlobalStateTaskHistory : []
// Early return if no migration needed
if (oldLocationData.length === 0) {
console.log("[Storage Migration] No task history to migrate")
return
}
// Read legacy from VS Code globalState, default to []
console.log("[Storage Migration] taskHistory from vscode global state: ", vscodeGlobalStateTaskHistory)
// Always create the file, even when empty
await writeTaskHistoryToState(context, Array.isArray(vscodeGlobalStateTaskHistory) ? vscodeGlobalStateTaskHistory : [])
// Don't remove the old taskHistory yet, while this version is not in production, for better dev experience.
// This is because the old version of the code (still in prod) is still reading taskHistory from the vs code global state, so it will appear as if all the user's tasks have been deleted.
// await context.globalState.update("taskHistory", undefined)
console.log("[Storage Migration] taskHistory file in new location: ", await readTaskHistoryFromState(context))
console.log("[Storage Migration] old vscode global state: ", await context.globalState.get("taskHistory"))
let finalData: HistoryItem[]
let migrationAction: string
const newLocationData = await readTaskHistoryFromState(context)
if (newLocationData.length === 0) {
// Move old data to new location
finalData = oldLocationData
migrationAction = "Migrated task history from old location to new location"
} else {
// Merge old data (more recent) with new data
finalData = [...newLocationData, ...oldLocationData]
migrationAction = "Merged task history from old and new locations"
}
// Perform migration operations sequentially - only clear old data if write succeeds
await writeTaskHistoryToState(context, finalData)
void context.globalState.update("taskHistory", undefined)
console.log(`[Storage Migration] ${migrationAction}`)
} catch (error) {
console.error("[Storage Migration] Failed to migrate task history to file:", error)
}