@@ -12,6 +12,7 @@ import { extract_paths_from_bullet_list } from '@/utils/extract-paths-from-bulle
1212import { get_all_workspace_files } from '@/context/helpers/get-all-workspace-files'
1313import { Logger } from '@shared/utils/logger'
1414import { show_search_results_quick_pick } from './utils/show-search-results-quick-pick'
15+ import { prompt_for_search_term } from './utils/prompt-for-search-term'
1516import { antigravity_agent } from './agents/antigravity'
1617import { claude_agent } from './agents/claude'
1718import { codex_agent } from './agents/codex'
@@ -57,10 +58,29 @@ export const agentic_search = async (params: {
5758 }
5859
5960 const output_channel = get_output_channel ( )
60- const query = params . query
61+ let query = params . query
6162
6263 while ( true ) {
63- const available_agents = AGENTS . filter ( ( a ) => a . is_installed ( ) )
64+ const query_result = await prompt_for_search_term ( query )
65+
66+ if ( query_result . back ) {
67+ return 'back'
68+ }
69+
70+ if ( query_result . value === undefined ) {
71+ return undefined
72+ }
73+
74+ query = query_result . value
75+
76+ if ( query . trim ( ) == '' ) {
77+ continue
78+ }
79+
80+ let go_back_to_query = false
81+
82+ while ( true ) {
83+ const available_agents = AGENTS . filter ( ( a ) => a . is_installed ( ) )
6484
6585 if ( available_agents . length == 0 ) {
6686 vscode . window . showInformationMessage (
@@ -160,7 +180,7 @@ export const agentic_search = async (params: {
160180 agent_quick_pick . placeholder = t (
161181 'views.prompt.handlers.handle-agentic-search.agent.select-agent-placeholder'
162182 )
163- agent_quick_pick . buttons = [ close_button ]
183+ agent_quick_pick . buttons = [ vscode . QuickInputButtons . Back , close_button ]
164184 agent_quick_pick . ignoreFocusOut = true
165185
166186 const config_listener = vscode . workspace . onDidChangeConfiguration (
@@ -183,7 +203,11 @@ export const agentic_search = async (params: {
183203 let is_resolved = false
184204
185205 agent_quick_pick . onDidTriggerButton ( ( button ) => {
186- if ( button === close_button ) {
206+ if ( button === vscode . QuickInputButtons . Back ) {
207+ is_resolved = true
208+ resolve ( 'back' )
209+ agent_quick_pick . hide ( )
210+ } else if ( button === close_button ) {
187211 is_resolved = true
188212 resolve ( undefined )
189213 agent_quick_pick . hide ( )
@@ -272,7 +296,7 @@ export const agentic_search = async (params: {
272296
273297 agent_quick_pick . onDidHide ( ( ) => {
274298 if ( ! is_resolved ) {
275- resolve ( undefined )
299+ resolve ( 'back' )
276300 }
277301 config_listener . dispose ( )
278302 agent_quick_pick . dispose ( )
@@ -282,7 +306,12 @@ export const agentic_search = async (params: {
282306 }
283307 )
284308
285- if ( ! agent_selection_result || agent_selection_result === 'back' ) {
309+ if ( agent_selection_result === 'back' ) {
310+ go_back_to_query = true
311+ break
312+ }
313+
314+ if ( ! agent_selection_result ) {
286315 return undefined
287316 }
288317
@@ -557,11 +586,13 @@ export const agentic_search = async (params: {
557586 vscode . window . showErrorMessage (
558587 t ( 'views.prompt.handlers.handle-agentic-search.error.failed' , { error : String ( err ) } )
559588 )
560- return undefined
589+ go_back_to_query = true
590+ break
561591 }
562592
563593 if ( is_cancelled ) {
564- return undefined
594+ go_back_to_query = true
595+ break
565596 }
566597
567598 const duration = format_duration ( Date . now ( ) - start_time )
@@ -573,7 +604,8 @@ export const agentic_search = async (params: {
573604 vscode . window . showInformationMessage (
574605 t ( 'views.prompt.handlers.handle-agentic-search.info.no-files' )
575606 )
576- return undefined
607+ go_back_to_query = true
608+ break
577609 }
578610
579611 const all_workspace_files = await get_all_workspace_files ( {
@@ -605,7 +637,8 @@ export const agentic_search = async (params: {
605637 vscode . window . showInformationMessage (
606638 t ( 'views.prompt.handlers.handle-agentic-search.info.no-files' )
607639 )
608- return undefined
640+ go_back_to_query = true
641+ break
609642 }
610643
611644 let should_go_back_to_workspace = false
@@ -658,5 +691,12 @@ export const agentic_search = async (params: {
658691 break
659692 }
660693
694+ if ( go_back_to_query ) {
695+ continue
696+ }
697+
698+ break
699+ }
700+
661701 return undefined
662702}
0 commit comments