@@ -66,7 +66,9 @@ type Props = {
6666 api_edit_format : EditFormat
6767 on_chat_edit_format_change : ( edit_format : EditFormat ) => void
6868 on_api_edit_format_change : ( edit_format : EditFormat ) => void
69- on_web_configurations_reorder : ( reordered_web_configurations : WebConfiguration [ ] ) => void
69+ on_web_configurations_reorder : (
70+ reordered_web_configurations : WebConfiguration [ ]
71+ ) => void
7072 on_web_configuration_edit : ( web_configuration_name : string ) => void
7173 on_duplicate_web_configuration : ( index : number ) => void
7274 on_delete_web_configuration : ( index : number ) => void
@@ -152,6 +154,13 @@ const chatbot_to_icon: Record<keyof typeof CHATBOTS, Icon.Variant> = {
152154export const MainView : React . FC < Props > = ( props ) => {
153155 const { t } = use_translation ( )
154156
157+ const is_in_edit_context_prompt_type =
158+ ( props . mode == MODE . WEB && props . web_prompt_type == 'edit-context' ) ||
159+ ( props . mode == MODE . API && props . api_prompt_type == 'edit-context' )
160+
161+ const is_in_ask_about_context_prompt_type =
162+ props . mode == MODE . WEB && props . web_prompt_type == 'ask-about-context'
163+
155164 const is_in_code_completions_prompt_type =
156165 ( props . mode == MODE . WEB && props . web_prompt_type == 'code-at-cursor' ) ||
157166 ( props . mode == MODE . API && props . api_prompt_type == 'code-at-cursor' )
@@ -168,6 +177,28 @@ export const MainView: React.FC<Props> = (props) => {
168177 const is_in_no_context_prompt_type =
169178 props . mode == MODE . WEB && props . web_prompt_type == 'no-context'
170179
180+ let warning : string | undefined
181+ if (
182+ ( props . mode == MODE . API && props . api_configurations . length == 0 ) ||
183+ ( props . mode == MODE . WEB && props . web_configurations . length == 0 )
184+ ) {
185+ warning = 'Add a configuration'
186+ } else if ( ! ! props . current_selection && is_in_code_completions_prompt_type ) {
187+ warning = 'Remove the text selection'
188+ } else if (
189+ is_in_code_completions_prompt_type &&
190+ ! props . currently_open_file_path
191+ ) {
192+ warning = 'Open a file'
193+ } else if (
194+ ( is_in_edit_context_prompt_type ||
195+ is_in_find_relevant_files_prompt_type ||
196+ is_in_ask_about_context_prompt_type ) &&
197+ props . token_count == 0
198+ ) {
199+ warning = 'Select context files'
200+ }
201+
171202 const { current_invocation_count, handle_invocation_count_change } =
172203 use_invocation_counts ( {
173204 mode : props . mode ,
@@ -214,23 +245,28 @@ export const MainView: React.FC<Props> = (props) => {
214245
215246 const last_choice_button_title = use_last_choice_button_title ( {
216247 mode : props . mode ,
217- selected_web_configuration_or_group_name : props . selected_web_configuration_name ,
248+ selected_web_configuration_or_group_name :
249+ props . selected_web_configuration_name ,
218250 web_configurations : props . web_configurations ,
219251 selected_api_configuration_id : props . selected_api_configuration_id ,
220252 api_configurations : props . api_configurations
221253 } )
222254
223- const web_configurations : UiConfigurations . Configuration [ ] = props . web_configurations . map (
224- ( web_configuration , index ) => {
225- const is_unnamed = ! web_configuration . name || / ^ \( \d + \) $ / . test ( web_configuration . name . trim ( ) )
255+ const web_configurations : UiConfigurations . Configuration [ ] =
256+ props . web_configurations . map ( ( web_configuration , index ) => {
257+ const is_unnamed =
258+ ! web_configuration . name ||
259+ / ^ \( \d + \) $ / . test ( web_configuration . name . trim ( ) )
226260 const display_name = is_unnamed
227261 ? web_configuration . chatbot !
228262 : web_configuration . name ! . replace ( / \( \d + \) $ / , '' )
229263
230264 const get_details = ( ) : string [ ] => {
231265 const { chatbot, model, reasoning_effort } = web_configuration
232266 const model_display_name =
233- model && chatbot ? CHATBOTS [ chatbot ] . models ?. [ model ] ?. label || model : null
267+ model && chatbot
268+ ? CHATBOTS [ chatbot ] . models ?. [ model ] ?. label || model
269+ : null
234270
235271 const details : string [ ] = [ ]
236272 if ( is_unnamed ) {
@@ -253,13 +289,14 @@ export const MainView: React.FC<Props> = (props) => {
253289 title : display_name ,
254290 details : get_details ( ) ,
255291 is_pinned : web_configuration . is_pinned ,
256- icon : web_configuration . chatbot ? chatbot_to_icon [ web_configuration . chatbot ] : undefined ,
292+ icon : web_configuration . chatbot
293+ ? chatbot_to_icon [ web_configuration . chatbot ]
294+ : undefined
257295 }
258- }
259- )
296+ } )
260297
261- const api_configurations_ui : UiConfigurations . Configuration [ ] = props . api_configurations . map (
262- ( c ) => {
298+ const api_configurations_ui : UiConfigurations . Configuration [ ] =
299+ props . api_configurations . map ( ( c ) => {
263300 const details = [ c . model_provider_name ]
264301 if ( c . reasoning_effort ) {
265302 details . push ( `${ c . reasoning_effort } ` )
@@ -273,8 +310,7 @@ export const MainView: React.FC<Props> = (props) => {
273310 details,
274311 is_pinned : c . is_pinned
275312 }
276- }
277- )
313+ } )
278314
279315 return (
280316 < >
@@ -393,11 +429,9 @@ export const MainView: React.FC<Props> = (props) => {
393429 on_tab_change = { props . on_tab_change }
394430 on_new_tab = { props . on_new_tab }
395431 on_tab_delete = { props . on_tab_delete }
396- missing_configuration = {
397- ( props . mode == MODE . API && props . api_configurations . length == 0 ) ||
398- ( props . mode == MODE . WEB && props . web_configurations . length == 0 )
399- }
432+ warning = { warning }
400433 voice_input_push_to_talk = { props . voice_input_push_to_talk }
434+ token_count = { props . token_count }
401435 />
402436 < UiContextUtilisation
403437 current_context_size = { props . token_count }
@@ -436,14 +470,20 @@ export const MainView: React.FC<Props> = (props) => {
436470 props . on_web_configurations_reorder ( new_web_configurations )
437471 } }
438472 on_duplicate = { ( id ) => {
439- const idx = props . web_configurations . findIndex ( ( p , i ) => ( p . name ?? `unnamed-${ i } ` ) === id )
473+ const idx = props . web_configurations . findIndex (
474+ ( p , i ) => ( p . name ?? `unnamed-${ i } ` ) === id
475+ )
440476 props . on_duplicate_web_configuration ( idx )
441477 } }
442478 on_delete = { ( id ) => {
443- const idx = props . web_configurations . findIndex ( ( p , i ) => ( p . name ?? `unnamed-${ i } ` ) === id )
479+ const idx = props . web_configurations . findIndex (
480+ ( p , i ) => ( p . name ?? `unnamed-${ i } ` ) === id
481+ )
444482 props . on_delete_web_configuration ( idx )
445483 } }
446- on_toggle_pinned = { ( id ) => props . on_toggle_web_configuration_pinned ( id ) }
484+ on_toggle_pinned = { ( id ) =>
485+ props . on_toggle_web_configuration_pinned ( id )
486+ }
447487 selected_configuration_id = { props . selected_web_configuration_name }
448488 is_collapsed = { props . web_configurations_collapsed }
449489 on_toggle_collapsed = { props . on_web_configurations_collapsed_change }
@@ -468,7 +508,9 @@ export const MainView: React.FC<Props> = (props) => {
468508 < UiConfigurations
469509 configurations = { api_configurations_ui }
470510 on_configuration_click = { props . on_api_configuration_click }
471- on_reorder = { ( reordered ) => props . on_api_configurations_reorder ( reordered ) }
511+ on_reorder = { ( reordered ) =>
512+ props . on_api_configurations_reorder ( reordered )
513+ }
472514 on_toggle_pinned = { props . on_toggle_pinned_api_configuration }
473515 on_edit = { props . on_edit_api_configuration }
474516 on_delete = { props . on_delete_api_configuration }
0 commit comments