Skip to content

Commit 2dca3fc

Browse files
committed
Consolidate tool configurations into a single unified settings key and implement a migration for existing user data
1 parent 4325fe0 commit 2dca3fc

21 files changed

Lines changed: 626 additions & 1382 deletions

apps/editor/package.json

Lines changed: 6 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,69 +1343,7 @@
13431343
]
13441344
}
13451345
},
1346-
"codeWebChat.configurationsForCodeAtCursor": {
1347-
"type": "array",
1348-
"scope": "resource",
1349-
"items": {
1350-
"type": "object",
1351-
"properties": {
1352-
"providerName": {
1353-
"type": "string"
1354-
},
1355-
"model": {
1356-
"type": "string"
1357-
},
1358-
"temperature": {
1359-
"type": "number"
1360-
},
1361-
"reasoningEffort": {
1362-
"type": "string"
1363-
},
1364-
"isDefault": {
1365-
"type": "boolean"
1366-
},
1367-
"isPinned": {
1368-
"type": "boolean"
1369-
}
1370-
},
1371-
"required": [
1372-
"providerName",
1373-
"model"
1374-
]
1375-
}
1376-
},
1377-
"codeWebChat.configurationsForFindRelevantFiles": {
1378-
"type": "array",
1379-
"scope": "resource",
1380-
"items": {
1381-
"type": "object",
1382-
"properties": {
1383-
"providerName": {
1384-
"type": "string"
1385-
},
1386-
"model": {
1387-
"type": "string"
1388-
},
1389-
"temperature": {
1390-
"type": "number"
1391-
},
1392-
"reasoningEffort": {
1393-
"type": "string"
1394-
},
1395-
"isDefault": {
1396-
"type": "boolean"
1397-
},
1398-
"isPinned": {
1399-
"type": "boolean"
1400-
}
1401-
},
1402-
"required": [
1403-
"providerName",
1404-
"model"
1405-
]
1406-
}
1407-
},
1408-
"codeWebChat.configurationsForEditContext": {
1346+
"codeWebChat.configurations": {
14091347
"type": "array",
14101348
"scope": "resource",
14111349
"items": {
@@ -1428,98 +1366,20 @@
14281366
},
14291367
"isPinned": {
14301368
"type": "boolean"
1431-
}
1432-
},
1433-
"required": [
1434-
"providerName",
1435-
"model"
1436-
]
1437-
}
1438-
},
1439-
"codeWebChat.configurationsForIntelligentUpdate": {
1440-
"type": "array",
1441-
"scope": "resource",
1442-
"items": {
1443-
"type": "object",
1444-
"properties": {
1445-
"providerName": {
1446-
"type": "string"
14471369
},
1448-
"model": {
1449-
"type": "string"
1450-
},
1451-
"temperature": {
1452-
"type": "number"
1453-
},
1454-
"reasoningEffort": {
1455-
"type": "string"
1456-
},
1457-
"isDefault": {
1370+
"isDefaultForCodeAtCursor": {
14581371
"type": "boolean"
14591372
},
1460-
"isPinned": {
1373+
"isDefaultForFindRelevantFiles": {
14611374
"type": "boolean"
1462-
}
1463-
},
1464-
"required": [
1465-
"providerName",
1466-
"model"
1467-
]
1468-
}
1469-
},
1470-
"codeWebChat.configurationsForCommitMessages": {
1471-
"type": "array",
1472-
"scope": "resource",
1473-
"items": {
1474-
"type": "object",
1475-
"properties": {
1476-
"providerName": {
1477-
"type": "string"
14781375
},
1479-
"model": {
1480-
"type": "string"
1481-
},
1482-
"temperature": {
1483-
"type": "number"
1484-
},
1485-
"reasoningEffort": {
1486-
"type": "string"
1487-
},
1488-
"isDefault": {
1376+
"isDefaultForIntelligentUpdate": {
14891377
"type": "boolean"
14901378
},
1491-
"isPinned": {
1492-
"type": "boolean"
1493-
}
1494-
},
1495-
"required": [
1496-
"providerName",
1497-
"model"
1498-
]
1499-
}
1500-
},
1501-
"codeWebChat.configurationsForVoiceInput": {
1502-
"type": "array",
1503-
"scope": "resource",
1504-
"items": {
1505-
"type": "object",
1506-
"properties": {
1507-
"providerName": {
1508-
"type": "string"
1509-
},
1510-
"model": {
1511-
"type": "string"
1512-
},
1513-
"temperature": {
1514-
"type": "number"
1515-
},
1516-
"reasoningEffort": {
1517-
"type": "string"
1518-
},
1519-
"isDefault": {
1379+
"isDefaultForCommitMessages": {
15201380
"type": "boolean"
15211381
},
1522-
"isPinned": {
1382+
"isDefaultForVoiceInput": {
15231383
"type": "boolean"
15241384
}
15251385
},

apps/editor/src/extension.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import {
99
migrate_instructions_state_cleanup,
1010
migrate_checkpoints_title_to_trigger,
1111
migrate_model_providers_type,
12-
migrate_prune_context_to_find_relevant_files
12+
migrate_prune_context_to_find_relevant_files,
13+
migrate_merge_configurations
1314
} from './migrations'
1415
import {
1516
apply_chat_response_command,
@@ -63,6 +64,8 @@ export const activate = async (context: vscode.ExtensionContext) => {
6364
await migrate_model_providers_type(context)
6465
// 10 March 2026
6566
await migrate_prune_context_to_find_relevant_files(context)
67+
// 25 March 2026
68+
await migrate_merge_configurations(context)
6669
}
6770

6871
await migrations()

apps/editor/src/migrations/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ export * from './migrate-instructions-state-cleanup'
44
export * from './migrate-checkpoints-title-to-trigger'
55
export * from './migrate-model-providers-type'
66
export * from './migrate-prune-context-to-find-relevant-files'
7+
export * from './migrate-merge-configurations'
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
import * as vscode from 'vscode'
2+
import { Logger } from '@shared/utils/logger'
3+
4+
const MIGRATION_ID = 'merge-configurations-migration-20260311'
5+
6+
export async function migrate_merge_configurations(
7+
context: vscode.ExtensionContext
8+
): Promise<void> {
9+
try {
10+
if (context.globalState.get(MIGRATION_ID)) {
11+
return
12+
}
13+
14+
const config = vscode.workspace.getConfiguration('codeWebChat')
15+
16+
const editContextInspect = config.inspect<any[]>(
17+
'configurationsForEditContext'
18+
)
19+
const codeAtCursorInspect = config.inspect<any[]>(
20+
'configurationsForCodeAtCursor'
21+
)
22+
const findRelevantFilesInspect = config.inspect<any[]>(
23+
'configurationsForFindRelevantFiles'
24+
)
25+
const intelligentUpdateInspect = config.inspect<any[]>(
26+
'configurationsForIntelligentUpdate'
27+
)
28+
const commitMessagesInspect = config.inspect<any[]>(
29+
'configurationsForCommitMessages'
30+
)
31+
const voiceInputInspect = config.inspect<any[]>(
32+
'configurationsForVoiceInput'
33+
)
34+
35+
const mergedConfigs: any[] = []
36+
37+
const addConfig = (sourceConfig: any, sourceKey: string) => {
38+
let existing = mergedConfigs.find(
39+
(c) =>
40+
c.providerName === sourceConfig.providerName &&
41+
c.model === sourceConfig.model &&
42+
c.temperature === sourceConfig.temperature &&
43+
c.reasoningEffort === sourceConfig.reasoningEffort &&
44+
c.systemInstructionsOverride ===
45+
sourceConfig.systemInstructionsOverride
46+
)
47+
48+
if (!existing) {
49+
existing = {
50+
providerName: sourceConfig.providerName,
51+
model: sourceConfig.model
52+
}
53+
if (sourceConfig.temperature !== undefined)
54+
existing.temperature = sourceConfig.temperature
55+
if (sourceConfig.reasoningEffort !== undefined)
56+
existing.reasoningEffort = sourceConfig.reasoningEffort
57+
if (sourceConfig.systemInstructionsOverride !== undefined)
58+
existing.systemInstructionsOverride =
59+
sourceConfig.systemInstructionsOverride
60+
if (sourceConfig.isPinned !== undefined)
61+
existing.isPinned = sourceConfig.isPinned
62+
63+
mergedConfigs.push(existing)
64+
} else {
65+
if (sourceConfig.isPinned) existing.isPinned = true
66+
}
67+
68+
if (sourceConfig.isDefault) {
69+
if (sourceKey === 'configurationsForCodeAtCursor')
70+
existing.isDefaultForCodeAtCursor = true
71+
if (sourceKey === 'configurationsForFindRelevantFiles')
72+
existing.isDefaultForFindRelevantFiles = true
73+
if (sourceKey === 'configurationsForIntelligentUpdate')
74+
existing.isDefaultForIntelligentUpdate = true
75+
if (sourceKey === 'configurationsForCommitMessages')
76+
existing.isDefaultForCommitMessages = true
77+
if (sourceKey === 'configurationsForVoiceInput')
78+
existing.isDefaultForVoiceInput = true
79+
}
80+
}
81+
82+
const processSource = (inspect: any, key: string) => {
83+
if (inspect?.globalValue && Array.isArray(inspect.globalValue)) {
84+
for (const c of inspect.globalValue) {
85+
addConfig(c, key)
86+
}
87+
}
88+
}
89+
90+
processSource(editContextInspect, 'configurationsForEditContext')
91+
processSource(codeAtCursorInspect, 'configurationsForCodeAtCursor')
92+
processSource(
93+
findRelevantFilesInspect,
94+
'configurationsForFindRelevantFiles'
95+
)
96+
processSource(
97+
intelligentUpdateInspect,
98+
'configurationsForIntelligentUpdate'
99+
)
100+
processSource(commitMessagesInspect, 'configurationsForCommitMessages')
101+
processSource(voiceInputInspect, 'configurationsForVoiceInput')
102+
103+
if (mergedConfigs.length > 0) {
104+
// Check if there are existing unified configs
105+
const existingConfigsInspect = config.inspect<any[]>('configurations')
106+
if (
107+
existingConfigsInspect?.globalValue &&
108+
Array.isArray(existingConfigsInspect.globalValue)
109+
) {
110+
for (const c of existingConfigsInspect.globalValue) {
111+
addConfig(c, 'configurations')
112+
}
113+
}
114+
115+
await config.update(
116+
'configurations',
117+
mergedConfigs,
118+
vscode.ConfigurationTarget.Global
119+
)
120+
}
121+
122+
// Clear old configs
123+
if (editContextInspect?.globalValue !== undefined)
124+
await config.update(
125+
'configurationsForEditContext',
126+
undefined,
127+
vscode.ConfigurationTarget.Global
128+
)
129+
if (codeAtCursorInspect?.globalValue !== undefined)
130+
await config.update(
131+
'configurationsForCodeAtCursor',
132+
undefined,
133+
vscode.ConfigurationTarget.Global
134+
)
135+
if (findRelevantFilesInspect?.globalValue !== undefined)
136+
await config.update(
137+
'configurationsForFindRelevantFiles',
138+
undefined,
139+
vscode.ConfigurationTarget.Global
140+
)
141+
if (intelligentUpdateInspect?.globalValue !== undefined)
142+
await config.update(
143+
'configurationsForIntelligentUpdate',
144+
undefined,
145+
vscode.ConfigurationTarget.Global
146+
)
147+
if (commitMessagesInspect?.globalValue !== undefined)
148+
await config.update(
149+
'configurationsForCommitMessages',
150+
undefined,
151+
vscode.ConfigurationTarget.Global
152+
)
153+
if (voiceInputInspect?.globalValue !== undefined)
154+
await config.update(
155+
'configurationsForVoiceInput',
156+
undefined,
157+
vscode.ConfigurationTarget.Global
158+
)
159+
160+
await context.globalState.update(MIGRATION_ID, true)
161+
162+
Logger.info({
163+
function_name: 'migrate_merge_configurations',
164+
message: 'Successfully merged configurations'
165+
})
166+
} catch (error) {
167+
Logger.error({
168+
function_name: 'migrate_merge_configurations',
169+
message: 'Error merging configurations',
170+
data: error instanceof Error ? error.message : String(error)
171+
})
172+
}
173+
}

0 commit comments

Comments
 (0)