File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77 migrate_preset_is_default_to_is_selected ,
88 migrate_api_providers_to_model_providers ,
99 migrate_token_count_cache ,
10- migrate_saved_contexts_to_global_storage
10+ migrate_saved_contexts_to_global_storage ,
11+ migrate_token_cache_cleanup
1112} from './migrations'
1213import {
1314 apply_chat_response_command ,
@@ -56,6 +57,8 @@ export async function activate(context: vscode.ExtensionContext) {
5657 await migrate_token_count_cache ( context )
5758 // 5 January 2026
5859 await migrate_saved_contexts_to_global_storage ( context )
60+ // 12 January 2026
61+ await migrate_token_cache_cleanup ( context )
5962 }
6063
6164 await migrations ( )
Original file line number Diff line number Diff line change @@ -2,3 +2,4 @@ export * from './migrate-preset-is-default-to-is-selected'
22export * from './migrate-api-providers-to-model-providers'
33export * from './migrate-token-count-cache'
44export * from './migrate-saved-contexts-to-global-storage'
5+ export * from './migrate-token-cache-cleanup'
Original file line number Diff line number Diff line change 1+ import * as vscode from 'vscode'
2+ import { Logger } from '@shared/utils/logger'
3+
4+ const MIGRATION_ID = 'token-cache-cleanup-20260112'
5+ const OLD_KEY = 'token-cache'
6+
7+ /**
8+ * Migration to clear the old 'token-cache' from global state.
9+ */
10+ export async function migrate_token_cache_cleanup (
11+ context : vscode . ExtensionContext
12+ ) : Promise < void > {
13+ try {
14+ if ( context . globalState . get ( MIGRATION_ID ) ) {
15+ return
16+ }
17+
18+ const old_cache = context . globalState . get ( OLD_KEY )
19+
20+ if ( old_cache ) {
21+ // Passing undefined removes the key from storage
22+ await context . globalState . update ( OLD_KEY , undefined )
23+
24+ Logger . info ( {
25+ function_name : 'migrate_token_cache_cleanup' ,
26+ message : "Successfully cleared old 'token-cache' from global state"
27+ } )
28+ }
29+
30+ await context . globalState . update ( MIGRATION_ID , true )
31+ } catch ( error ) {
32+ Logger . error ( {
33+ function_name : 'migrate_token_cache_cleanup' ,
34+ message : "Error cleaning up old 'token-cache'" ,
35+ data : error instanceof Error ? error . message : String ( error )
36+ } )
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments