Skip to content

Commit 7d38e19

Browse files
committed
Add subtasks settings migration
1 parent 762ec17 commit 7d38e19

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

src/extension.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { telemetryService } from "./services/telemetry/TelemetryService"
2323
import { TerminalRegistry } from "./integrations/terminal/TerminalRegistry"
2424
import { API } from "./exports/api"
2525
import { migrateSettings } from "./utils/migrateSettings"
26+
import { migrateSubtasksSettings } from "./utils/migrateSubtasksSettings"
2627

2728
import { handleUri, registerCommands, registerCodeActions, registerTerminalActions } from "./activate"
2829
import { formatLanguage } from "./shared/language"
@@ -48,6 +49,7 @@ export async function activate(context: vscode.ExtensionContext) {
4849

4950
// Migrate old settings to new
5051
await migrateSettings(context, outputChannel)
52+
await migrateSubtasksSettings(context, outputChannel)
5153

5254
// Initialize telemetry service after environment variables are loaded.
5355
telemetryService.initialize()
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import * as vscode from "vscode"
2+
3+
/**
4+
* Migrates old subtasks setting to new subtaskCreation and subtaskCompletion settings.
5+
*
6+
* TODO: Remove this migration code in September 2025 (6 months after implementation)
7+
*/
8+
export async function migrateSubtasksSettings(
9+
context: vscode.ExtensionContext,
10+
outputChannel: vscode.OutputChannel,
11+
): Promise<void> {
12+
// Old and new setting keys
13+
const subtasksKey = "alwaysAllowSubtasks"
14+
const subtaskCreationKey = "alwaysAllowSubtaskCreation"
15+
const subtaskCompletionKey = "alwaysAllowSubtaskCompletion"
16+
17+
try {
18+
// Get old value
19+
const oldValue = await context.globalState.get(subtasksKey)
20+
console.log(`old subtasks value: ${oldValue}`)
21+
22+
if (oldValue !== undefined && typeof oldValue === "boolean") {
23+
// Update new settings
24+
await Promise.all([
25+
context.globalState.update(subtaskCreationKey, oldValue),
26+
context.globalState.update(subtaskCompletionKey, oldValue),
27+
])
28+
29+
const creationValue = await context.globalState.get(subtaskCreationKey)
30+
const completionValue = await context.globalState.get(subtaskCompletionKey)
31+
console.log(`new subtask creation value value: ${creationValue}`)
32+
console.log(`new subtask completion value value: ${completionValue}`)
33+
34+
// Schedule cleanup
35+
setTimeout(async () => {
36+
try {
37+
await context.globalState.update(subtasksKey, undefined)
38+
outputChannel.appendLine("Migrated subtasks settings")
39+
} catch (error) {
40+
outputChannel.appendLine(`Failed to delete old subtasks setting: ${error}`)
41+
}
42+
}, 0)
43+
}
44+
} catch (error) {
45+
outputChannel.appendLine(`Migrating subtasks settings failed: ${error}`)
46+
}
47+
}

0 commit comments

Comments
 (0)