Skip to content

Commit 7351fd6

Browse files
committed
Remove outdated migrations and add instructions state cleanup migration
1 parent 2ea87b2 commit 7351fd6

8 files changed

Lines changed: 60 additions & 302 deletions

‎apps/editor/src/extension.ts‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ import { PanelProvider } from './views/panel/backend/panel-provider'
44
import { WebSocketManager } from './services/websocket-manager'
55
import { ApiManager } from './services/api-manager'
66
import {
7-
migrate_preset_is_default_to_is_selected,
8-
migrate_api_providers_to_model_providers,
9-
migrate_token_count_cache,
10-
migrate_saved_contexts_to_global_storage,
117
migrate_token_cache_cleanup,
12-
migrate_configurations_code_completions_to_code_at_cursor
8+
migrate_configurations_code_completions_to_code_at_cursor,
9+
migrate_instructions_state_cleanup
1310
} from './migrations'
1411
import { SharedFileState } from './context/shared-file-state'
1512
import {
@@ -55,18 +52,12 @@ export async function activate(context: vscode.ExtensionContext) {
5552
websocket_server_instance = new WebSocketManager(context)
5653

5754
const migrations = async () => {
58-
// 1 September 2025
59-
await migrate_preset_is_default_to_is_selected(context)
60-
// 16 September 2025
61-
await migrate_api_providers_to_model_providers(context)
62-
// 4 January 2026
63-
await migrate_token_count_cache(context)
64-
// 5 January 2026
65-
await migrate_saved_contexts_to_global_storage(context)
6655
// 12 January 2026
6756
await migrate_token_cache_cleanup(context)
6857
// 30 January 2026
6958
await migrate_configurations_code_completions_to_code_at_cursor(context)
59+
// 14 February 2026
60+
await migrate_instructions_state_cleanup(context)
7061
}
7162

7263
await migrations()
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
export * from './migrate-preset-is-default-to-is-selected'
2-
export * from './migrate-api-providers-to-model-providers'
3-
export * from './migrate-token-count-cache'
4-
export * from './migrate-saved-contexts-to-global-storage'
51
export * from './migrate-token-cache-cleanup'
62
export * from './migrate-configurations-code-completions-to-code-at-cursor'
3+
4+
export * from './migrate-instructions-state-cleanup'

‎apps/editor/src/migrations/migrate-api-providers-to-model-providers.ts‎

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import * as vscode from 'vscode'
2+
import { Logger } from '@shared/utils/logger'
3+
4+
const MIGRATION_ID = 'instructions-state-cleanup-20260214'
5+
6+
const KEYS_TO_CLEAR = [
7+
'instructions-edit-context',
8+
'instructions-ask',
9+
'instructions-no-context',
10+
'instructions-code-at-cursor',
11+
'instructions-prune-context'
12+
]
13+
14+
/**
15+
* Migration to clear instructions state keys from global and workspace state.
16+
*/
17+
export async function migrate_instructions_state_cleanup(
18+
context: vscode.ExtensionContext
19+
): Promise<void> {
20+
try {
21+
if (context.globalState.get(MIGRATION_ID)) {
22+
return
23+
}
24+
25+
for (const key of KEYS_TO_CLEAR) {
26+
if (context.globalState.get(key) !== undefined) {
27+
await context.globalState.update(key, undefined)
28+
}
29+
if (context.workspaceState.get(key) !== undefined) {
30+
await context.workspaceState.update(key, undefined)
31+
}
32+
}
33+
34+
Logger.info({
35+
function_name: 'migrate_instructions_state_cleanup',
36+
message:
37+
'Successfully cleared instructions state keys from global and workspace state'
38+
})
39+
40+
await context.globalState.update(MIGRATION_ID, true)
41+
} catch (error) {
42+
Logger.error({
43+
function_name: 'migrate_instructions_state_cleanup',
44+
message: 'Error cleaning up instructions state keys',
45+
data: error instanceof Error ? error.message : String(error)
46+
})
47+
}
48+
}

‎apps/editor/src/migrations/migrate-preset-is-default-to-is-selected.ts‎

Lines changed: 0 additions & 78 deletions
This file was deleted.

‎apps/editor/src/migrations/migrate-saved-contexts-to-global-storage.ts‎

Lines changed: 0 additions & 123 deletions
This file was deleted.

‎apps/editor/src/migrations/migrate-token-count-cache.ts‎

Lines changed: 0 additions & 39 deletions
This file was deleted.

‎apps/editor/src/views/panel/backend/panel-provider.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -641,11 +641,12 @@ export class PanelProvider implements vscode.WebviewViewProvider {
641641
}
642642

643643
private _load_instructions(key: string): InstructionsState {
644-
const stored = this.context.workspaceState.get<any>(key)
645-
if (typeof stored == 'string') {
646-
return { instructions: [stored], active_index: 0 }
647-
}
648-
return stored ?? { instructions: [''], active_index: 0 }
644+
return (
645+
this.context.workspaceState.get<any>(key) || {
646+
instructions: [''],
647+
active_index: 0
648+
}
649+
)
649650
}
650651

651652
public send_message(message: BackendMessage) {

0 commit comments

Comments
 (0)