Skip to content

Commit 78073a5

Browse files
committed
Implement system instructions override for tool configurations and update associated settings UI
1 parent 3391c7d commit 78073a5

6 files changed

Lines changed: 91 additions & 49 deletions

File tree

‎apps/editor/package.json‎

Lines changed: 9 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,13 +1778,7 @@
17781778
"type": "number"
17791779
},
17801780
"reasoningEffort": {
1781-
"type": "string",
1782-
"enum": [
1783-
"none",
1784-
"low",
1785-
"medium",
1786-
"high"
1787-
]
1781+
"type": "string"
17881782
},
17891783
"isDefault": {
17901784
"type": "boolean"
@@ -1816,13 +1810,7 @@
18161810
"type": "number"
18171811
},
18181812
"reasoningEffort": {
1819-
"type": "string",
1820-
"enum": [
1821-
"none",
1822-
"low",
1823-
"medium",
1824-
"high"
1825-
]
1813+
"type": "string"
18261814
},
18271815
"isDefault": {
18281816
"type": "boolean"
@@ -1854,13 +1842,10 @@
18541842
"type": "number"
18551843
},
18561844
"reasoningEffort": {
1857-
"type": "string",
1858-
"enum": [
1859-
"none",
1860-
"low",
1861-
"medium",
1862-
"high"
1863-
]
1845+
"type": "string"
1846+
},
1847+
"systemInstructionsOverride": {
1848+
"type": "string"
18641849
},
18651850
"isPinned": {
18661851
"type": "boolean"
@@ -1889,13 +1874,7 @@
18891874
"type": "number"
18901875
},
18911876
"reasoningEffort": {
1892-
"type": "string",
1893-
"enum": [
1894-
"none",
1895-
"low",
1896-
"medium",
1897-
"high"
1898-
]
1877+
"type": "string"
18991878
},
19001879
"isDefault": {
19011880
"type": "boolean"
@@ -1927,13 +1906,7 @@
19271906
"type": "number"
19281907
},
19291908
"reasoningEffort": {
1930-
"type": "string",
1931-
"enum": [
1932-
"none",
1933-
"low",
1934-
"medium",
1935-
"high"
1936-
]
1909+
"type": "string"
19371910
},
19381911
"isDefault": {
19391912
"type": "boolean"
@@ -1965,13 +1938,7 @@
19651938
"type": "number"
19661939
},
19671940
"reasoningEffort": {
1968-
"type": "string",
1969-
"enum": [
1970-
"none",
1971-
"low",
1972-
"medium",
1973-
"high"
1974-
]
1941+
"type": "string"
19751942
},
19761943
"isDefault": {
19771944
"type": "boolean"

‎apps/editor/src/services/model-providers-manager.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export type ToolConfig = {
2525
model: string
2626
temperature?: number
2727
reasoning_effort?: ReasoningEffort
28+
system_instructions_override?: string
2829
is_pinned?: boolean
2930
}
3031

@@ -162,19 +163,21 @@ export class ModelProvidersManager {
162163
model: string
163164
temperature?: number
164165
reasoningEffort?: ReasoningEffort
166+
systemInstructionsOverride?: string
165167
isPinned?: boolean
166168
}[]
167169
>(settings_key, [])
168170

169171
const tool_configs: ToolConfig[] = settings_configs
170172
.map((sc) => {
171-
const provider = this._providers.find((p) => p.name === sc.providerName)
173+
const provider = this._providers.find((p) => p.name == sc.providerName)
172174
return {
173175
provider_name: sc.providerName,
174176
provider_type: provider?.type || '',
175177
model: sc.model,
176178
temperature: sc.temperature,
177179
reasoning_effort: sc.reasoningEffort,
180+
system_instructions_override: sc.systemInstructionsOverride,
178181
is_pinned: sc.isPinned
179182
}
180183
})
@@ -204,6 +207,8 @@ export class ModelProvidersManager {
204207
}
205208
if (c.reasoning_effort !== undefined)
206209
new_config.reasoningEffort = c.reasoning_effort
210+
if (c.system_instructions_override !== undefined)
211+
new_config.systemInstructionsOverride = c.system_instructions_override
207212
if (c.is_pinned) new_config.isPinned = c.is_pinned
208213
return new_config
209214
})
@@ -224,7 +229,9 @@ export class ModelProvidersManager {
224229
settings_config.model === tool_config.model &&
225230
settings_config.temperature === tool_config.temperature &&
226231
(settings_config.reasoningEffort ?? undefined) ===
227-
(tool_config.reasoning_effort ?? undefined)
232+
(tool_config.reasoning_effort ?? undefined) &&
233+
(settings_config.systemInstructionsOverride ?? undefined) ===
234+
(tool_config.system_instructions_override ?? undefined)
228235
)
229236
}
230237

@@ -238,6 +245,7 @@ export class ModelProvidersManager {
238245
model: string
239246
temperature?: number
240247
reasoningEffort?: ReasoningEffort
248+
systemInstructionsOverride?: string
241249
isDefault?: boolean
242250
isPinned?: boolean
243251
}[]
@@ -256,6 +264,8 @@ export class ModelProvidersManager {
256264
model: default_config_from_settings.model,
257265
temperature: default_config_from_settings.temperature,
258266
reasoning_effort: default_config_from_settings.reasoningEffort,
267+
system_instructions_override:
268+
default_config_from_settings.systemInstructionsOverride,
259269
is_pinned: default_config_from_settings.isPinned
260270
}
261271
const validated_config = this._validate_tool_config(tool_config)

‎apps/editor/src/views/panel/backend/message-handlers/handle-edit-context.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ export const handle_edit_context = async (
479479
}${processed_instructions}`
480480

481481
const system_instructions =
482+
edit_context_config.system_instructions_override ||
482483
vscode.workspace
483484
.getConfiguration('codeWebChat')
484485
.get<string>('editContextSystemInstructions') ||

‎apps/editor/src/views/utils/config-editing.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,42 @@ export const edit_temperature_for_config = async (
511511
})
512512
}
513513

514+
export const edit_system_instructions_override_for_config = async (
515+
config: ToolConfig
516+
): Promise<string | null | undefined> => {
517+
return await new Promise<string | null | undefined>((resolve) => {
518+
const input = vscode.window.createInputBox()
519+
input.title = 'Edit Configuration'
520+
input.value = config.system_instructions_override ?? ''
521+
input.prompt = 'Enter system instructions override.'
522+
input.placeholder = 'System Instructions Override'
523+
524+
let accepted = false
525+
const disposables: vscode.Disposable[] = []
526+
527+
disposables.push(
528+
input.onDidAccept(() => {
529+
const value = input.value
530+
if (value.trim() == '') {
531+
accepted = true
532+
resolve(null)
533+
input.hide()
534+
return
535+
}
536+
accepted = true
537+
resolve(value)
538+
input.hide()
539+
}),
540+
input.onDidHide(() => {
541+
if (!accepted) resolve(undefined)
542+
disposables.forEach((d) => d.dispose())
543+
input.dispose()
544+
})
545+
)
546+
input.show()
547+
})
548+
}
549+
514550
export const edit_reasoning_effort_for_config = async (
515551
current_effort?: string
516552
) => {

‎apps/editor/src/views/utils/upsert-configuration.ts‎

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
edit_provider_for_config,
1313
edit_reasoning_effort_for_config,
1414
edit_temperature_for_config,
15+
edit_system_instructions_override_for_config,
1516
initial_select_model,
1617
initial_select_provider
1718
} from './config-editing'
@@ -392,6 +393,21 @@ export const upsert_configuration = async (params: {
392393

393394
const advanced_items: vscode.QuickPickItem[] = [temperature_item]
394395

396+
if (params.tool_type == 'edit-context') {
397+
const system_instr_item: vscode.QuickPickItem = {
398+
label: 'System Instructions',
399+
description: 'Overrides global system instructions',
400+
detail: updated_config.system_instructions_override
401+
}
402+
if (updated_config.system_instructions_override) {
403+
system_instr_item.buttons = [
404+
{ iconPath: new vscode.ThemeIcon('eraser'), tooltip: 'Unset' }
405+
]
406+
}
407+
408+
advanced_items.push(system_instr_item)
409+
}
410+
395411
const selected_advanced = await new Promise<
396412
vscode.QuickPickItem | undefined
397413
>((resolve) => {
@@ -402,7 +418,7 @@ export const upsert_configuration = async (params: {
402418
quick_pick.buttons = [vscode.QuickInputButtons.Back]
403419
if (last_advanced_label) {
404420
const active = advanced_items.find(
405-
(i) => i.label === last_advanced_label
421+
(i) => i.label == last_advanced_label
406422
)
407423
if (active) quick_pick.activeItems = [active]
408424
}
@@ -411,11 +427,16 @@ export const upsert_configuration = async (params: {
411427

412428
disposables.push(
413429
quick_pick.onDidTriggerItemButton((e) => {
414-
if (e.item.label === 'Temperature') {
430+
if (e.item.label == 'Temperature') {
415431
delete updated_config.temperature
416432
accepted = true
417433
resolve({ label: 'REFRESH' })
418434
quick_pick.hide()
435+
} else if (e.item.label === 'System Instructions') {
436+
delete updated_config.system_instructions_override
437+
accepted = true
438+
resolve({ label: 'REFRESH' })
439+
quick_pick.hide()
419440
}
420441
}),
421442
quick_pick.onDidAccept(() => {
@@ -438,7 +459,7 @@ export const upsert_configuration = async (params: {
438459
})
439460

440461
if (!selected_advanced) break
441-
if (selected_advanced.label === 'REFRESH') continue
462+
if (selected_advanced.label == 'REFRESH') continue
442463

443464
last_advanced_label = selected_advanced.label
444465

@@ -448,6 +469,13 @@ export const upsert_configuration = async (params: {
448469
updated_config.temperature =
449470
new_temp === null ? undefined : new_temp
450471
}
472+
} else if (selected_advanced.label == 'System Instructions') {
473+
const new_instr =
474+
await edit_system_instructions_override_for_config(updated_config)
475+
if (new_instr !== undefined) {
476+
updated_config.system_instructions_override =
477+
new_instr === null ? undefined : new_instr
478+
}
451479
}
452480
}
453481
}

‎packages/ui/src/components/editor/panel/ResponsePreview/ResponsePreview.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ export const ResponsePreview: FC<Props> = (props) => {
292292
>
293293
<span className="codicon codicon-warning" />
294294
{files_in_preview.length > 1
295-
? `${aggressive_fallback_count} of ${files_in_preview.length} files applied with fallback method`
296-
: 'The file applied with fallback method'}
295+
? `${aggressive_fallback_count} of ${files_in_preview.length} edits applied with fallback method`
296+
: 'The edit applied with fallback method'}
297297
</div>
298298
</div>
299299
)}

0 commit comments

Comments
 (0)