Skip to content

Commit 1d168cf

Browse files
committed
Add setting to automatically run agentic search when context is empty
- in settings > CLI > Agentic Search, add option: 'Run automatically' ('Look for relevant files when context is empty'). Disabled state by default. Use the value in `apps/editor/src/views/prompt/backend/message-handlers/utils/show-context-cannot-be-empty-warning.ts` - keep showing warning notification but without the button
1 parent 1cc034a commit 1d168cf

12 files changed

Lines changed: 154 additions & 0 deletions

File tree

‎apps/editor/package.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,11 @@
10721072
],
10731073
"default": 1
10741074
},
1075+
"codeWebChat.agenticSearchRunAutomatically": {
1076+
"type": "boolean",
1077+
"scope": "resource",
1078+
"default": false
1079+
},
10751080
"codeWebChat.editFilesSystemInstructions": {
10761081
"type": "string",
10771082
"scope": "resource",

‎apps/editor/src/views/prompt/backend/message-handlers/utils/show-context-cannot-be-empty-warning.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@ import { handle_agentic_search } from '../handle-agentic-search'
66
export const show_context_cannot_be_empty_warning = async (
77
prompt_view_provider: PromptViewProvider
88
): Promise<void> => {
9+
const config = vscode.workspace.getConfiguration('codeWebChat')
10+
const run_automatically = config.get<boolean>(
11+
'agenticSearchRunAutomatically',
12+
false
13+
)
14+
15+
if (run_automatically) {
16+
void vscode.window.showWarningMessage(
17+
t(
18+
'views.common.handlers.utils.show-context-cannot-be-empty-warning.context-cannot-be-empty'
19+
)
20+
)
21+
await handle_agentic_search(prompt_view_provider)
22+
return
23+
}
24+
925
const agentic_search_action = t('feature.agentic-search.title.agentic-search')
1026
const selection = await vscode.window.showWarningMessage(
1127
t(
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as vscode from 'vscode'
2+
import { SettingsViewProvider } from '@/views/settings/backend/settings-view-provider'
3+
4+
export const handle_get_agentic_search_run_automatically = async (
5+
provider: SettingsViewProvider
6+
): Promise<void> => {
7+
const config = vscode.workspace.getConfiguration('codeWebChat')
8+
const enabled = config.get<boolean>('agenticSearchRunAutomatically', false)
9+
provider.postMessage({
10+
command: 'AGENTIC_SEARCH_RUN_AUTOMATICALLY',
11+
enabled
12+
})
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as vscode from 'vscode'
2+
import { UpdateAgenticSearchRunAutomaticallyMessage } from '@/views/settings/types/messages'
3+
4+
export const handle_update_agentic_search_run_automatically = async (
5+
message: UpdateAgenticSearchRunAutomaticallyMessage
6+
): Promise<void> => {
7+
const config = vscode.workspace.getConfiguration('codeWebChat')
8+
await config.update(
9+
'agenticSearchRunAutomatically',
10+
message.enabled,
11+
vscode.ConfigurationTarget.Global
12+
)
13+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export * from './handle-get-agentic-search-instructions'
3333
export * from './handle-update-agentic-search-instructions'
3434
export * from './handle-get-agentic-search-invocation-count'
3535
export * from './handle-update-agentic-search-invocation-count'
36+
export * from './handle-get-agentic-search-run-automatically'
37+
export * from './handle-update-agentic-search-run-automatically'
3638
export * from './handle-get-gemini-user-id'
3739
export * from './handle-update-gemini-user-id'
3840
export * from './handle-get-ai-studio-user-id'

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ export class SettingsViewProvider {
167167
message.command === 'UPDATE_AGENTIC_SEARCH_INVOCATION_COUNT'
168168
) {
169169
await handlers.handle_update_agentic_search_invocation_count(message)
170+
} else if (message.command === 'GET_AGENTIC_SEARCH_RUN_AUTOMATICALLY') {
171+
await handlers.handle_get_agentic_search_run_automatically(this)
172+
} else if (
173+
message.command === 'UPDATE_AGENTIC_SEARCH_RUN_AUTOMATICALLY'
174+
) {
175+
await handlers.handle_update_agentic_search_run_automatically(message)
170176
} else if (message.command === 'GET_GEMINI_USER_ID') {
171177
await handlers.handle_get_gemini_user_id(this)
172178
} else if (message.command === 'UPDATE_GEMINI_USER_ID') {
@@ -273,6 +279,7 @@ export class SettingsViewProvider {
273279
void handlers.handle_get_voice_input_instructions(this)
274280
void handlers.handle_get_agentic_search_instructions(this)
275281
void handlers.handle_get_agentic_search_invocation_count(this)
282+
void handlers.handle_get_agentic_search_run_automatically(this)
276283
void handlers.handle_get_gemini_user_id(this)
277284
void handlers.handle_get_ai_studio_user_id(this)
278285
void handlers.handle_get_send_with_shift_enter(this)

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ type Props = {
158158
on_agentic_search_instructions_change: (instructions: string) => void
159159
agentic_search_invocation_count: 1 | 2 | 3
160160
on_agentic_search_invocation_count_change: (count: 1 | 2 | 3) => void
161+
agentic_search_run_automatically: boolean
162+
on_agentic_search_run_automatically_change: (enabled: boolean) => void
161163
gemini_user_id: number | null
162164
ai_studio_user_id: number | null
163165
send_with_shift_enter: boolean
@@ -585,6 +587,12 @@ export const Home: React.FC<Props> = (props) => {
585587
on_agentic_search_invocation_count_change={
586588
props.on_agentic_search_invocation_count_change
587589
}
590+
agentic_search_run_automatically={
591+
props.agentic_search_run_automatically
592+
}
593+
on_agentic_search_run_automatically_change={
594+
props.on_agentic_search_run_automatically_change
595+
}
588596
/>
589597
</UiLayout>
590598
</div>

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { SortableList } from '@ui/components/editor/settings-view/SortableList'
77
import { IconButton } from '@ui/components/editor/common/IconButton'
88
import { Dropdown as UiDropdown } from '@ui/components/editor/common/Dropdown'
99
import { Textarea as UiTextarea } from '@ui/components/editor/common/Textarea'
10+
import { Toggler as UiToggler } from '@ui/components/editor/common/Toggler'
1011
import { DefaultConfigurationSelector } from '@ui/components/editor/settings-view/DefaultConfigurationSelector'
1112
import { CliConfiguration } from '@/types/cli-configuration'
1213
import { use_translation } from '../../i18n/use-translation'
@@ -36,6 +37,8 @@ type Props = {
3637
on_restore_agentic_search_instructions: () => void
3738
agentic_search_invocation_count: 1 | 2 | 3
3839
on_agentic_search_invocation_count_change: (count: 1 | 2 | 3) => void
40+
agentic_search_run_automatically: boolean
41+
on_agentic_search_run_automatically_change: (enabled: boolean) => void
3942
set_section_ref: (id: NavItem, el: HTMLDivElement | null) => void
4043
}
4144

@@ -228,6 +231,16 @@ export const CliSection = forwardRef<HTMLDivElement, Props>((props, ref) => {
228231
/>
229232
}
230233
/>
234+
<UiItem
235+
title={t('cli.agentic-search.run-automatically.title')}
236+
description={t('cli.agentic-search.run-automatically.description')}
237+
slot_right={
238+
<UiToggler
239+
is_on={props.agentic_search_run_automatically}
240+
on_toggle={props.on_agentic_search_run_automatically_change}
241+
/>
242+
}
243+
/>
231244
</UiGroup>
232245
</div>
233246
<div

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export const Settings = () => {
9696
settings_hook.agentic_search_instructions !== undefined &&
9797
settings_hook.default_agentic_search_instructions !== undefined &&
9898
settings_hook.agentic_search_invocation_count !== undefined &&
99+
settings_hook.agentic_search_run_automatically !== undefined &&
99100
settings_hook.commit_message_instructions !== undefined &&
100101
settings_hook.default_commit_message_instructions !== undefined &&
101102
settings_hook.attach_ascii_tree_of_context !== undefined &&
@@ -193,6 +194,12 @@ export const Settings = () => {
193194
on_agentic_search_invocation_count_change={
194195
settings_hook.handle_agentic_search_invocation_count_change
195196
}
197+
agentic_search_run_automatically={
198+
settings_hook.agentic_search_run_automatically!
199+
}
200+
on_agentic_search_run_automatically_change={
201+
settings_hook.handle_agentic_search_run_automatically_change
202+
}
196203
commit_message_instructions={settings_hook.commit_message_instructions!}
197204
default_commit_message_instructions={
198205
settings_hook.default_commit_message_instructions!

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ export const use_settings = (vscode: any) => {
6464
] = useState<string | undefined>(undefined)
6565
const [agentic_search_invocation_count, set_agentic_search_invocation_count] =
6666
useState<1 | 2 | 3 | undefined>(undefined)
67+
const [
68+
agentic_search_run_automatically,
69+
set_agentic_search_run_automatically
70+
] = useState<boolean | undefined>(undefined)
6771
const [attach_ascii_tree_of_context, set_attach_ascii_tree_of_context] =
6872
useState<'ask' | 'always' | 'never' | undefined>(undefined)
6973
const [
@@ -110,6 +114,7 @@ export const use_settings = (vscode: any) => {
110114
post_message(vscode, { command: 'GET_VOICE_INPUT_INSTRUCTIONS' })
111115
post_message(vscode, { command: 'GET_AGENTIC_SEARCH_INSTRUCTIONS' })
112116
post_message(vscode, { command: 'GET_AGENTIC_SEARCH_INVOCATION_COUNT' })
117+
post_message(vscode, { command: 'GET_AGENTIC_SEARCH_RUN_AUTOMATICALLY' })
113118
post_message(vscode, {
114119
command: 'GET_ATTACH_ASCII_TREE_OF_CONTEXT'
115120
})
@@ -162,6 +167,8 @@ export const use_settings = (vscode: any) => {
162167
set_default_agentic_search_instructions(message.default_instructions)
163168
} else if (message.command === 'AGENTIC_SEARCH_INVOCATION_COUNT') {
164169
set_agentic_search_invocation_count(message.count)
170+
} else if (message.command === 'AGENTIC_SEARCH_RUN_AUTOMATICALLY') {
171+
set_agentic_search_run_automatically(message.enabled)
165172
} else if (message.command === 'ATTACH_ASCII_TREE_OF_CONTEXT') {
166173
set_attach_ascii_tree_of_context(message.value)
167174
} else if (
@@ -381,6 +388,14 @@ export const use_settings = (vscode: any) => {
381388
})
382389
}
383390

391+
const handle_agentic_search_run_automatically_change = (enabled: boolean) => {
392+
set_agentic_search_run_automatically(enabled)
393+
post_message(vscode, {
394+
command: 'UPDATE_AGENTIC_SEARCH_RUN_AUTOMATICALLY',
395+
enabled
396+
})
397+
}
398+
384399
const handle_attach_ascii_tree_of_context_change = (
385400
value: 'ask' | 'always' | 'never'
386401
) => {
@@ -549,6 +564,7 @@ export const use_settings = (vscode: any) => {
549564
agentic_search_instructions,
550565
default_agentic_search_instructions,
551566
agentic_search_invocation_count,
567+
agentic_search_run_automatically,
552568
attach_ascii_tree_of_context,
553569
use_context_files_in_commit_message_prompt,
554570
select_all_prompts_in_commit_messages_by_default,
@@ -581,6 +597,7 @@ export const use_settings = (vscode: any) => {
581597
handle_voice_input_instructions_change,
582598
handle_agentic_search_instructions_change,
583599
handle_agentic_search_invocation_count_change,
600+
handle_agentic_search_run_automatically_change,
584601
handle_attach_ascii_tree_of_context_change,
585602
handle_use_context_files_in_commit_message_prompt_change,
586603
handle_select_all_prompts_in_commit_messages_by_default_change,

0 commit comments

Comments
 (0)