Skip to content

Commit 8c026dc

Browse files
committed
Relocate the find relevant files instructions prefix configuration to the general settings section
- in General section, below "Clear Checks in Workspace Behavior", add text field for [Fragment] - translate [Fragment] - remove handling of relevant_files_instructions_prefix - when clearing 'find relevant files instructions' and blurring out the field, the default instructions are not always restored
1 parent 2e43b3c commit 8c026dc

13 files changed

Lines changed: 177 additions & 97 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import * as vscode from 'vscode'
2+
import { SettingsProvider } from '@/views/settings/backend/settings-provider'
3+
import { find_relevant_files_instructions_prefix } from '@/constants/instructions'
4+
5+
export const handle_get_find_relevant_files_instructions_prefix = async (
6+
provider: SettingsProvider
7+
): Promise<void> => {
8+
const config = vscode.workspace.getConfiguration('codeWebChat')
9+
const instructions =
10+
config.get<string>('findRelevantFilesInstructionsPrefix') ||
11+
find_relevant_files_instructions_prefix
12+
provider.postMessage({
13+
command: 'FIND_RELEVANT_FILES_INSTRUCTIONS_PREFIX',
14+
instructions
15+
})
16+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import * as vscode from 'vscode'
2+
import { UpdateFindRelevantFilesInstructionsPrefixMessage } from '@/views/settings/types/messages'
3+
import { find_relevant_files_instructions_prefix } from '@/constants/instructions'
4+
5+
export const handle_update_find_relevant_files_instructions_prefix = async (
6+
message: UpdateFindRelevantFilesInstructionsPrefixMessage
7+
): Promise<void> => {
8+
await vscode.workspace
9+
.getConfiguration('codeWebChat')
10+
.update(
11+
'findRelevantFilesInstructionsPrefix',
12+
message.instructions == '' ||
13+
message.instructions == find_relevant_files_instructions_prefix
14+
? undefined
15+
: message.instructions,
16+
vscode.ConfigurationTarget.Global
17+
)
18+
}

‎apps/editor/src/views/settings/backend/message-handlers/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,5 @@ export * from './handle-get-extended-cache-duration-for-anthropic'
4141
export * from './handle-update-extended-cache-duration-for-anthropic'
4242
export * from './handle-open-keybindings'
4343
export * from './handle-open-external-url'
44+
export * from './handle-get-find-relevant-files-instructions-prefix'
45+
export * from './handle-update-find-relevant-files-instructions-prefix'

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ import {
4646
handle_get_extended_cache_duration_for_anthropic,
4747
handle_update_extended_cache_duration_for_anthropic,
4848
handle_open_keybindings,
49-
handle_open_external_url
49+
handle_open_external_url,
50+
handle_get_find_relevant_files_instructions_prefix,
51+
handle_update_find_relevant_files_instructions_prefix
5052
} from './message-handlers'
5153

5254
export class SettingsProvider {
@@ -360,6 +362,14 @@ export class SettingsProvider {
360362
await handle_open_keybindings(message)
361363
} else if (message.command == 'OPEN_EXTERNAL_URL') {
362364
await handle_open_external_url(message)
365+
} else if (
366+
message.command == 'GET_FIND_RELEVANT_FILES_INSTRUCTIONS_PREFIX'
367+
) {
368+
await handle_get_find_relevant_files_instructions_prefix(this)
369+
} else if (
370+
message.command == 'UPDATE_FIND_RELEVANT_FILES_INSTRUCTIONS_PREFIX'
371+
) {
372+
await handle_update_find_relevant_files_instructions_prefix(message)
363373
}
364374
},
365375
null,
@@ -404,6 +414,7 @@ export class SettingsProvider {
404414
void handle_get_are_automatic_checkpoints_disabled(this)
405415
void handle_get_checkpoint_lifespan(this)
406416
void handle_get_gemini_user_id(this)
417+
void handle_get_find_relevant_files_instructions_prefix(this)
407418
void handle_get_ai_studio_user_id(this)
408419
void handle_get_send_with_shift_enter(this)
409420
void handle_get_check_new_files(this)

‎apps/editor/src/views/settings/frontend/Home/Home.tsx‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ type Props = {
103103
are_automatic_checkpoints_disabled: boolean
104104
checkpoint_lifespan: number
105105
edit_format_instructions: EditFormatInstructions
106+
find_relevant_files_instructions_prefix: string
106107
clear_checks_in_workspace_behavior: 'ignore-open-editors' | 'uncheck-all'
107108
extended_cache_duration_for_anthropic: boolean
108109
fix_all_automatically: boolean
@@ -121,6 +122,9 @@ type Props = {
121122
on_edit_format_instructions_change: (
122123
instructions: EditFormatInstructions
123124
) => void
125+
on_find_relevant_files_instructions_prefix_change: (
126+
instructions: string
127+
) => void
124128
on_edit_context_system_instructions_change: (instructions: string) => void
125129
on_voice_input_instructions_change: (instructions: string) => void
126130
on_automatic_checkpoints_toggle: (disabled: boolean) => void
@@ -347,6 +351,12 @@ export const Home: React.FC<Props> = (props) => {
347351
on_clear_checks_in_workspace_behavior_change={
348352
props.on_clear_checks_in_workspace_behavior_change
349353
}
354+
find_relevant_files_instructions_prefix={
355+
props.find_relevant_files_instructions_prefix
356+
}
357+
on_find_relevant_files_instructions_prefix_change={
358+
props.on_find_relevant_files_instructions_prefix_change
359+
}
350360
edit_format_instructions={props.edit_format_instructions}
351361
on_edit_format_instructions_change={
352362
props.on_edit_format_instructions_change

‎apps/editor/src/views/settings/frontend/Home/sections/GeneralSection.tsx‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
EDIT_FORMAT_INSTRUCTIONS_TRUNCATED,
1919
EDIT_FORMAT_INSTRUCTIONS_WHOLE
2020
} from '@/constants/edit-format-instructions'
21+
import { find_relevant_files_instructions_prefix as default_find_relevant_files_instructions_prefix } from '@/constants/instructions'
2122
import { use_translation } from '../../i18n/use-translation'
2223

2324
type ClearChecksBehavior = 'ignore-open-editors' | 'uncheck-all'
@@ -28,13 +29,17 @@ type Props = {
2829
send_with_shift_enter: boolean
2930
check_new_files: boolean
3031
checkpoint_lifespan: number
32+
find_relevant_files_instructions_prefix: string
3133
gemini_user_id: number | null
3234
ai_studio_user_id: number | null
3335
on_gemini_user_id_change: (id: number | null) => void
3436
on_ai_studio_user_id_change: (id: number | null) => void
3537
on_automatic_checkpoints_toggle: (disabled: boolean) => void
3638
on_send_with_shift_enter_change: (enabled: boolean) => void
3739
on_check_new_files_change: (enabled: boolean) => void
40+
on_find_relevant_files_instructions_prefix_change: (
41+
instructions: string
42+
) => void
3843
on_checkpoint_lifespan_change: (hours: number | undefined) => void
3944
clear_checks_in_workspace_behavior: ClearChecksBehavior
4045
edit_format_instructions: EditFormatInstructions
@@ -59,6 +64,10 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
5964
const [context_size_warning_threshold, set_context_size_warning_threshold] =
6065
useState<number>()
6166
const [checkpoint_lifespan, set_checkpoint_lifespan] = useState<number>()
67+
const [
68+
find_relevant_files_instructions_prefix,
69+
set_find_relevant_files_instructions_prefix
70+
] = useState('')
6271
const [gemini_user_id_str, set_gemini_user_id_str] = useState('')
6372
const [ai_studio_user_id_str, set_ai_studio_user_id_str] = useState('')
6473
const [instructions, set_instructions] = useState<EditFormatInstructions>({
@@ -82,6 +91,12 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
8291
set_checkpoint_lifespan(props.checkpoint_lifespan)
8392
}, [props.checkpoint_lifespan])
8493

94+
useEffect(() => {
95+
set_find_relevant_files_instructions_prefix(
96+
props.find_relevant_files_instructions_prefix || ''
97+
)
98+
}, [props.find_relevant_files_instructions_prefix])
99+
85100
useEffect(() => {
86101
set_gemini_user_id_str(
87102
props.gemini_user_id === null || props.gemini_user_id === undefined
@@ -121,6 +136,17 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
121136
}
122137
}
123138

139+
const handle_find_relevant_files_instructions_prefix_blur = () => {
140+
props.on_find_relevant_files_instructions_prefix_change(
141+
find_relevant_files_instructions_prefix
142+
)
143+
if (find_relevant_files_instructions_prefix == '') {
144+
set_find_relevant_files_instructions_prefix(
145+
default_find_relevant_files_instructions_prefix
146+
)
147+
}
148+
}
149+
124150
const handle_checkpoint_lifespan_blur = () => {
125151
if (checkpoint_lifespan && checkpoint_lifespan > 0) {
126152
props.on_checkpoint_lifespan_change(checkpoint_lifespan)
@@ -277,6 +303,19 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
277303
/>
278304
}
279305
/>
306+
<UiItem
307+
title={t('general.find-relevant-files-instructions-prefix.title')}
308+
description={t(
309+
'general.find-relevant-files-instructions-prefix.description'
310+
)}
311+
slot_below={
312+
<UiTextarea
313+
value={find_relevant_files_instructions_prefix}
314+
on_change={set_find_relevant_files_instructions_prefix}
315+
on_blur={handle_find_relevant_files_instructions_prefix_blur}
316+
/>
317+
}
318+
/>
280319
</UiGroup>
281320

282321
<UiGroup title={t('general.checkpoints.title')}>

‎apps/editor/src/views/settings/frontend/Settings.tsx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export const Settings = () => {
4343
settings_hook.send_with_shift_enter !== undefined &&
4444
settings_hook.check_new_files !== undefined &&
4545
settings_hook.clear_checks_in_workspace_behavior !== undefined &&
46+
settings_hook.find_relevant_files_instructions_prefix !== undefined &&
4647
settings_hook.fix_all_automatically !== undefined &&
4748
settings_hook.extended_cache_duration_for_anthropic !== undefined
4849
)
@@ -97,6 +98,9 @@ export const Settings = () => {
9798
extended_cache_duration_for_anthropic={
9899
settings_hook.extended_cache_duration_for_anthropic!
99100
}
101+
find_relevant_files_instructions_prefix={
102+
settings_hook.find_relevant_files_instructions_prefix!
103+
}
100104
fix_all_automatically={settings_hook.fix_all_automatically!}
101105
set_providers={settings_hook.set_providers}
102106
set_code_at_cursor_configs={settings_hook.set_code_at_cursor_configs}
@@ -118,6 +122,9 @@ export const Settings = () => {
118122
on_commit_instructions_change={
119123
settings_hook.handle_commit_instructions_change
120124
}
125+
on_find_relevant_files_instructions_prefix_change={
126+
settings_hook.handle_find_relevant_files_instructions_prefix_change
127+
}
121128
on_include_prompts_in_commit_messages_change={
122129
settings_hook.handle_include_prompts_in_commit_messages_change
123130
}

‎apps/editor/src/views/settings/frontend/hooks/use-settings.ts‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ export const use_settings = (vscode: any) => {
7878
extended_cache_duration_for_anthropic,
7979
set_extended_cache_duration_for_anthropic
8080
] = useState<boolean | undefined>(undefined)
81+
const [
82+
find_relevant_files_instructions_prefix,
83+
set_find_relevant_files_instructions_prefix
84+
] = useState<boolean | undefined>(undefined)
8185

8286
useEffect(() => {
8387
post_message(vscode, { command: 'GET_MODEL_PROVIDERS' })
@@ -101,6 +105,9 @@ export const use_settings = (vscode: any) => {
101105
post_message(vscode, { command: 'GET_CHECK_NEW_FILES' })
102106
post_message(vscode, { command: 'GET_CLEAR_CHECKS_IN_WORKSPACE_BEHAVIOR' })
103107
post_message(vscode, { command: 'GET_FIX_ALL_AUTOMATICALLY' })
108+
post_message(vscode, {
109+
command: 'GET_FIND_RELEVANT_FILES_INSTRUCTIONS_PREFIX'
110+
})
104111
post_message(vscode, {
105112
command: 'GET_EXTENDED_CACHE_DURATION_FOR_ANTHROPIC'
106113
})
@@ -153,6 +160,8 @@ export const use_settings = (vscode: any) => {
153160
set_fix_all_automatically(message.enabled)
154161
} else if (message.command == 'EXTENDED_CACHE_DURATION_FOR_ANTHROPIC') {
155162
set_extended_cache_duration_for_anthropic(message.enabled)
163+
} else if (message.command == 'FIND_RELEVANT_FILES_INSTRUCTIONS_PREFIX') {
164+
set_find_relevant_files_instructions_prefix(message.instructions)
156165
}
157166
}
158167

@@ -474,6 +483,14 @@ export const use_settings = (vscode: any) => {
474483
})
475484
}
476485

486+
const handle_find_relevant_files_instructions_prefix_change = (
487+
instructions: string
488+
) =>
489+
post_message(vscode, {
490+
command: 'UPDATE_FIND_RELEVANT_FILES_INSTRUCTIONS_PREFIX',
491+
instructions
492+
})
493+
477494
return {
478495
providers,
479496
set_providers,
@@ -504,6 +521,7 @@ export const use_settings = (vscode: any) => {
504521
clear_checks_in_workspace_behavior,
505522
fix_all_automatically,
506523
extended_cache_duration_for_anthropic,
524+
find_relevant_files_instructions_prefix,
507525
handle_reorder_providers,
508526
handle_add_provider,
509527
handle_delete_provider,
@@ -534,6 +552,7 @@ export const use_settings = (vscode: any) => {
534552
handle_fix_all_automatically_change,
535553
handle_extended_cache_duration_for_anthropic_change,
536554
handle_open_keybindings,
537-
handle_open_external_url
555+
handle_open_external_url,
556+
handle_find_relevant_files_instructions_prefix_change
538557
}
539558
}

‎apps/editor/src/views/settings/frontend/i18n/translations/general.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,42 @@ export const general = {
327327
hu: "A 'Kijelölés Törlése' gomb viselkedése.",
328328
bg: "Поведение на бутона 'Изчистване' в работното пространство."
329329
},
330+
'general.find-relevant-files-instructions-prefix.title': {
331+
en: 'Find Relevant Files Instructions',
332+
pl: 'Instrukcje znajdowania odpowiednich plików',
333+
'zh-cn': '查找相关文件说明',
334+
ja: '関連ファイルの検索手順',
335+
'zh-tw': '尋找相關檔案說明',
336+
de: 'Anweisungen zum Finden relevanter Dateien',
337+
es: 'Instrucciones para buscar archivos relevantes',
338+
fr: 'Instructions pour trouver des fichiers pertinents',
339+
'pt-br': 'Instruções para Encontrar Arquivos Relevantes',
340+
ru: 'Инструкции по поиску релевантных файлов',
341+
ko: '관련 파일 찾기 지침',
342+
it: 'Istruzioni per trovare file pertinenti',
343+
tr: 'İlgili Dosyaları Bulma Talimatları',
344+
cs: 'Instrukce k nalezení relevantních souborů',
345+
hu: 'Releváns Fájlok Keresési Utasításai',
346+
bg: 'Инструкции за намиране на съответните файлове'
347+
},
348+
'general.find-relevant-files-instructions-prefix.description': {
349+
en: 'Instructions used when searching for relevant files with AI.',
350+
pl: 'Instrukcje używane podczas wyszukiwania odpowiednich plików za pomocą AI.',
351+
'zh-cn': '使用 AI 搜索相关文件时使用的说明。',
352+
ja: 'AIを使用して関連ファイルを検索する際に使用される指示。',
353+
'zh-tw': '使用 AI 搜尋相關檔案時使用的說明。',
354+
de: 'Anweisungen, die bei der Suche nach relevanten Dateien mit KI verwendet werden.',
355+
es: 'Instrucciones utilizadas al buscar archivos relevantes con IA.',
356+
fr: "Instructions utilisées lors de la recherche de fichiers pertinents avec l'IA.",
357+
'pt-br': 'Instruções usadas ao buscar arquivos relevantes com IA.',
358+
ru: 'Инструкции, используемые при поиске релевантных файлов с помощью ИИ.',
359+
ko: 'AI로 관련 파일을 검색할 때 사용되는 지침입니다.',
360+
it: "Istruzioni utilizzate durante la ricerca di file pertinenti con l'IA.",
361+
tr: 'Yapay zeka ile ilgili dosyaları ararken kullanılan talimatlar.',
362+
cs: 'Instrukce používané při vyhledávání relevantních souborů pomocí AI.',
363+
hu: 'MI segítségével történő releváns fájlok keresésekor használt utasítások.',
364+
bg: 'Инструкции, използвани при търсене на съответните файлове с ИИ.'
365+
},
330366
'general.clear-checks.ignore-open-editors': {
331367
en: 'Ignore Open Editors',
332368
pl: 'Ignoruj otwarte edytory',

‎apps/editor/src/views/settings/types/messages.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,15 @@ export interface OpenExternalUrlMessage {
320320
url: string
321321
}
322322

323+
export interface GetFindRelevantFilesInstructionsPrefixMessage {
324+
command: 'GET_FIND_RELEVANT_FILES_INSTRUCTIONS_PREFIX'
325+
}
326+
327+
export interface UpdateFindRelevantFilesInstructionsPrefixMessage {
328+
command: 'UPDATE_FIND_RELEVANT_FILES_INSTRUCTIONS_PREFIX'
329+
instructions: string
330+
}
331+
323332
export type FrontendMessage =
324333
| GetModelProvidersMessage
325334
| ReorderModelProvidersMessage
@@ -385,6 +394,8 @@ export type FrontendMessage =
385394
| UpdateExtendedCacheDurationForAnthropicMessage
386395
| OpenKeybindingsMessage
387396
| OpenExternalUrlMessage
397+
| GetFindRelevantFilesInstructionsPrefixMessage
398+
| UpdateFindRelevantFilesInstructionsPrefixMessage
388399

389400
// === FROM BACKEND TO FRONTEND ===
390401
export interface ModelProvidersMessage {
@@ -502,6 +513,11 @@ export interface ExtendedCacheDurationForAnthropicMessage {
502513
enabled: boolean
503514
}
504515

516+
export interface FindRelevantFilesInstructionsPrefixMessage {
517+
command: 'FIND_RELEVANT_FILES_INSTRUCTIONS_PREFIX'
518+
instructions: string
519+
}
520+
505521
export type BackendMessage =
506522
| ModelProvidersMessage
507523
| CodeAtCursorConfigurationsMessage
@@ -526,3 +542,4 @@ export type BackendMessage =
526542
| ShowSectionMessage
527543
| FixAllAutomaticallyMessage
528544
| ExtendedCacheDurationForAnthropicMessage
545+
| FindRelevantFilesInstructionsPrefixMessage

0 commit comments

Comments
 (0)