@@ -41,11 +41,11 @@ export const EditWebConfigurationForm: React.FC<Props> = (props) => {
4141 props . web_configuration . options || [ ]
4242 )
4343
44- const chatbot_config = chatbot ? CHATBOTS [ chatbot ] : undefined
45- const models = useMemo ( ( ) => chatbot_config ? .models || { } , [ chatbot_config ] )
44+ const chatbot_config = CHATBOTS [ chatbot ]
45+ const models = useMemo ( ( ) => chatbot_config . models || { } , [ chatbot_config ] )
4646 const model_info = useMemo (
4747 ( ) =>
48- model && chatbot_config ? .models
48+ model && chatbot_config . models
4949 ? chatbot_config . models [ model ]
5050 : undefined ,
5151 [ model , chatbot_config ]
@@ -59,7 +59,6 @@ export const EditWebConfigurationForm: React.FC<Props> = (props) => {
5959 } , [ model_info ] )
6060
6161 useEffect ( ( ) => {
62- if ( ! chatbot ) return
6362 const chatbot_config = CHATBOTS [ chatbot ]
6463
6564 if ( new_url && chatbot_config . url_override_disabled_options ) {
@@ -72,33 +71,27 @@ export const EditWebConfigurationForm: React.FC<Props> = (props) => {
7271 } , [ chatbot , new_url ] )
7372
7473 const supports_reasoning_effort =
75- chatbot_config ? .supports_reasoning_effort ||
74+ chatbot_config . supports_reasoning_effort ||
7675 ! ! model_info ?. supported_reasoning_efforts
7776 const supports_system_instructions =
78- chatbot_config ? .supports_system_instructions
79- const supports_port = chatbot_config ? .supports_user_provided_port
80- const supports_url_override = chatbot_config ? .supports_url_override
77+ chatbot_config . supports_system_instructions
78+ const supports_port = chatbot_config . supports_user_provided_port
79+ const supports_url_override = chatbot_config . supports_url_override
8180 const supports_user_provided_model =
82- chatbot_config ? .supports_user_provided_model
81+ chatbot_config . supports_user_provided_model
8382
8483 useEffect ( ( ) => {
85- if ( chatbot ) {
86- props . on_update ( {
87- name,
88- chatbot,
89- ...( reasoning_effort ? { reasoning_effort } : { } ) ,
90- ...( model ? { model } : { } ) ,
91- ...( system_instructions ? { system_instructions } : { } ) ,
92- ...( port !== undefined ? { port } : { } ) ,
93- ...( new_url ? { new_url } : { } ) ,
94- ...( options . length ? { options } : { } ) ,
95- is_pinned : props . web_configuration . is_pinned
96- } )
97- } else {
98- props . on_update ( {
99- name
100- } )
101- }
84+ props . on_update ( {
85+ name,
86+ chatbot,
87+ ...( reasoning_effort ? { reasoning_effort } : { } ) ,
88+ ...( model ? { model } : { } ) ,
89+ ...( system_instructions ? { system_instructions } : { } ) ,
90+ ...( port !== undefined ? { port } : { } ) ,
91+ ...( new_url ? { new_url } : { } ) ,
92+ ...( options . length ? { options } : { } ) ,
93+ is_pinned : props . web_configuration . is_pinned
94+ } )
10295 } , [
10396 name ,
10497 reasoning_effort ,
@@ -149,7 +142,7 @@ export const EditWebConfigurationForm: React.FC<Props> = (props) => {
149142
150143 const supported_reasoning_efforts = useMemo ( ( ) => {
151144 return (
152- chatbot_config ? .supported_reasoning_efforts ||
145+ chatbot_config . supported_reasoning_efforts ||
153146 model_info ?. supported_reasoning_efforts ||
154147 [ ]
155148 )
@@ -167,20 +160,18 @@ export const EditWebConfigurationForm: React.FC<Props> = (props) => {
167160 < UiScrollable top_shadow >
168161 < div className = { styles . form } >
169162 < UiFieldset >
170- { chatbot && (
171- < UiField
172- label = { t ( 'edit-web-configuration-form.chatbot' ) }
173- html_for = "chatbot"
174- >
175- < UiQuickPickButton
176- label = { chatbot }
177- onClick = { ( e ) => {
178- e . stopPropagation ( )
179- props . pick_chatbot ( chatbot )
180- } }
181- />
182- </ UiField >
183- ) }
163+ < UiField
164+ label = { t ( 'edit-web-configuration-form.chatbot' ) }
165+ html_for = "chatbot"
166+ >
167+ < UiQuickPickButton
168+ label = { chatbot }
169+ onClick = { ( e ) => {
170+ e . stopPropagation ( )
171+ props . pick_chatbot ( chatbot )
172+ } }
173+ />
174+ </ UiField >
184175
185176 { ( Object . keys ( models ) . length > 0 || chatbot == 'OpenRouter' ) && (
186177 < UiField
@@ -272,7 +263,7 @@ export const EditWebConfigurationForm: React.FC<Props> = (props) => {
272263 < UiInput
273264 id = "name"
274265 type = "text"
275- value = { name && / ^ \( \d + \) $ / . test ( name ) ? '' : name ! }
266+ value = { name && / ^ \( \d + \) $ / . test ( name ) ? '' : name }
276267 on_change = { set_name }
277268 placeholder = {
278269 chatbot ||
@@ -312,7 +303,7 @@ export const EditWebConfigurationForm: React.FC<Props> = (props) => {
312303 { supports_url_override && (
313304 < UiField
314305 label = {
315- chatbot_config ? .url_override_label ||
306+ chatbot_config . url_override_label ||
316307 t ( 'edit-web-configuration-form.url-override' )
317308 }
318309 html_for = "new-url"
@@ -346,49 +337,48 @@ export const EditWebConfigurationForm: React.FC<Props> = (props) => {
346337 ) }
347338 </ UiFieldset >
348339
349- { chatbot &&
350- Object . keys ( chatbot_config ?. supported_options || { } ) . length > 0 && (
351- < UiFieldset label = { t ( 'edit-web-configuration-form.options' ) } >
352- < div className = { styles . options } >
353- { Object . entries ( chatbot_config ! . supported_options ! ) . map (
354- ( [ key , label ] ) => {
355- const is_disabled_by_url_override =
356- ! ! new_url &&
357- chatbot_config ! . url_override_disabled_options ?. includes (
358- key
359- )
360-
361- if ( model_info ?. disabled_options ?. includes ( key ) ) {
362- return null
363- }
364-
365- return (
366- < UiPresetOption
367- key = { key }
368- label = { label as string }
369- checked = { options . includes ( key ) }
370- on_change = { ( ) => handle_option_toggle ( key ) }
371- disabled = { is_disabled_by_url_override }
372- disabled_reason = {
373- is_disabled_by_url_override
374- ? t (
375- 'edit-web-configuration-form.options.disabled-reason'
376- ) . replace (
377- '{label}' ,
378- chatbot_config ! . url_override_label ||
379- t (
380- 'edit-web-configuration-form.options.custom-url'
381- )
382- )
383- : undefined
384- }
385- />
340+ { Object . keys ( chatbot_config . supported_options || { } ) . length > 0 && (
341+ < UiFieldset label = { t ( 'edit-web-configuration-form.options' ) } >
342+ < div className = { styles . options } >
343+ { Object . entries ( chatbot_config . supported_options ! ) . map (
344+ ( [ key , label ] ) => {
345+ const is_disabled_by_url_override =
346+ ! ! new_url &&
347+ chatbot_config . url_override_disabled_options ?. includes (
348+ key
386349 )
350+
351+ if ( model_info ?. disabled_options ?. includes ( key ) ) {
352+ return null
387353 }
388- ) }
389- </ div >
390- </ UiFieldset >
391- ) }
354+
355+ return (
356+ < UiPresetOption
357+ key = { key }
358+ label = { label as string }
359+ checked = { options . includes ( key ) }
360+ on_change = { ( ) => handle_option_toggle ( key ) }
361+ disabled = { is_disabled_by_url_override }
362+ disabled_reason = {
363+ is_disabled_by_url_override
364+ ? t (
365+ 'edit-web-configuration-form.options.disabled-reason'
366+ ) . replace (
367+ '{label}' ,
368+ chatbot_config . url_override_label ||
369+ t (
370+ 'edit-web-configuration-form.options.custom-url'
371+ )
372+ )
373+ : undefined
374+ }
375+ />
376+ )
377+ }
378+ ) }
379+ </ div >
380+ </ UiFieldset >
381+ ) }
392382 </ div >
393383 </ UiScrollable >
394384 )
0 commit comments