@@ -3,14 +3,11 @@ import { Layout as UiLayout } from '@ui/components/editor/settings/Layout'
33import { NavigationItem as UiNavigationItem } from '@ui/components/editor/settings/NavigationItem'
44import { ModelProvidersSection } from './sections/ModelProvidersSection'
55import { ConfigurationsSection } from './sections/ConfigurationsSection'
6- import { NavigationDivider as UiNavigationDivider } from '@ui/components/editor/settings/NavigationDivider'
76import { Item as UiItem } from '@ui/components/editor/settings/Item'
87import { Group as UiGroup } from '@ui/components/editor/settings/Group/Group'
98import { Section as UiSection } from '@ui/components/editor/settings/Section'
10- import { Textarea as UiTextarea } from '@ui/components/editor/common/Textarea'
119import { Toggler as UiToggler } from '@ui/components/editor/common/Toggler'
1210import { Button as UiButton } from '@ui/components/editor/common/Button'
13- import { TextButton as UiTextButton } from '@ui/components/editor/settings/TextButton'
1411import { Notice as UiNotice } from '@ui/components/editor/settings/Notice'
1512import {
1613 ApiConfigurationForClient ,
@@ -34,48 +31,22 @@ type NavItem =
3431 | 'general'
3532 | 'model-providers'
3633 | 'configurations'
37- | 'edit-context'
38- | 'code-at-cursor'
39- | 'commit-messages'
40- | 'voice-input'
4134
42- type NavConfigItem =
43- | { type : 'item' ; id : NavItem ; label : TranslationKey }
44- | { type : 'divider' ; text ?: TranslationKey }
35+ type NavConfigItem = { id : NavItem ; label : TranslationKey }
4536
4637const NAV_ITEMS_CONFIG : NavConfigItem [ ] = [
4738 {
48- type : 'item' ,
4939 id : 'general' ,
5040 label : 'sidebar.general'
5141 } ,
5242 {
53- type : 'item' ,
5443 id : 'model-providers' ,
5544 label : 'sidebar.model-providers'
5645 } ,
5746 {
58- type : 'item' ,
5947 id : 'configurations' ,
6048 label : 'sidebar.configurations'
6149 } ,
62- { type : 'divider' , text : 'sidebar.api-tools' } ,
63- { type : 'item' , id : 'edit-context' , label : 'sidebar.edit-context' } ,
64- {
65- type : 'item' ,
66- id : 'code-at-cursor' ,
67- label : 'sidebar.code-at-cursor'
68- } ,
69- {
70- type : 'item' ,
71- id : 'commit-messages' ,
72- label : 'sidebar.commit-messages'
73- } ,
74- {
75- type : 'item' ,
76- id : 'voice-input' ,
77- label : 'sidebar.voice-input'
78- }
7950]
8051
8152type Props = {
@@ -159,11 +130,7 @@ export const Home: React.FC<Props> = (props) => {
159130 const section_refs = useRef < Record < NavItem , HTMLDivElement | null > > ( {
160131 general : null ,
161132 'model-providers' : null ,
162- configurations : null ,
163- 'edit-context' : null ,
164- 'code-at-cursor' : null ,
165- 'commit-messages' : null ,
166- 'voice-input' : null
133+ configurations : null
167134 } )
168135 const [ commit_instructions , set_commit_instructions ] = useState ( '' )
169136 const [ voice_input_instructions , set_voice_input_instructions ] = useState ( '' )
@@ -199,22 +166,6 @@ export const Home: React.FC<Props> = (props) => {
199166 ( is_stuck : boolean ) => handle_stuck_change ( 'configurations' , is_stuck ) ,
200167 [ handle_stuck_change ]
201168 )
202- const edit_context_on_stuck_change = useCallback (
203- ( is_stuck : boolean ) => handle_stuck_change ( 'edit-context' , is_stuck ) ,
204- [ handle_stuck_change ]
205- )
206- const code_at_cursor_on_stuck_change = useCallback (
207- ( is_stuck : boolean ) => handle_stuck_change ( 'code-at-cursor' , is_stuck ) ,
208- [ handle_stuck_change ]
209- )
210- const voice_input_on_stuck_change = useCallback (
211- ( is_stuck : boolean ) => handle_stuck_change ( 'voice-input' , is_stuck ) ,
212- [ handle_stuck_change ]
213- )
214- const commit_messages_on_stuck_change = useCallback (
215- ( is_stuck : boolean ) => handle_stuck_change ( 'commit-messages' , is_stuck ) ,
216- [ handle_stuck_change ]
217- )
218169
219170 const get_has_warning = ( id : NavItem ) : boolean => {
220171 if ( id == 'model-providers' ) {
@@ -226,10 +177,7 @@ export const Home: React.FC<Props> = (props) => {
226177 }
227178 }
228179
229- const nav_item_ids = NAV_ITEMS_CONFIG . filter (
230- ( item ) : item is Extract < NavConfigItem , { type : 'item' } > =>
231- item . type == 'item'
232- ) . map ( ( item ) => item . id )
180+ const nav_item_ids = NAV_ITEMS_CONFIG . map ( ( item ) => item . id )
233181 const active_nav_item_id =
234182 nav_item_ids . filter ( ( id ) => stuck_sections . has ( id ) ) . pop ( ) || nav_item_ids [ 0 ]
235183
@@ -283,14 +231,6 @@ export const Home: React.FC<Props> = (props) => {
283231 ref = { scroll_container_ref }
284232 title = { t ( 'sidebar.settings' ) }
285233 sidebar = { NAV_ITEMS_CONFIG . map ( ( item , i ) => {
286- if ( item . type == 'divider' ) {
287- return (
288- < UiNavigationDivider
289- key = { i }
290- text = { item . text ? t ( item . text ) : undefined }
291- />
292- )
293- }
294234
295235 return (
296236 < UiNavigationItem
@@ -343,13 +283,18 @@ export const Home: React.FC<Props> = (props) => {
343283 on_open_allow_patterns_settings = {
344284 props . on_open_allow_patterns_settings
345285 }
286+ on_open_keybindings = { props . on_open_keybindings }
346287 gemini_user_id = { props . gemini_user_id }
347288 ai_studio_user_id = { props . ai_studio_user_id }
348289 on_gemini_user_id_change = { props . on_gemini_user_id_change }
349290 on_ai_studio_user_id_change = { props . on_ai_studio_user_id_change }
350291 on_stuck_change = { general_on_stuck_change }
351292 auto_run_intelligent_update = { props . auto_run_intelligent_update }
352293 on_auto_run_intelligent_update_change = { props . on_auto_run_intelligent_update_change }
294+ include_prompts_in_commit_messages = { props . include_prompts_in_commit_messages }
295+ on_include_prompts_in_commit_messages_change = { props . on_include_prompts_in_commit_messages_change }
296+ voice_input_push_to_talk = { props . voice_input_push_to_talk }
297+ on_voice_input_push_to_talk_change = { props . on_voice_input_push_to_talk_change }
353298 />
354299
355300 < UiSection
@@ -448,168 +393,51 @@ export const Home: React.FC<Props> = (props) => {
448393 on_set_default_api_configuration = { props . on_set_default_api_configuration }
449394 on_select_default_api_configuration = { props . on_select_default_api_configuration }
450395 on_stuck_change = { configurations_on_stuck_change }
396+ edit_context_instructions = { edit_context_instructions }
397+ commit_instructions = { commit_instructions }
398+ voice_input_instructions = { voice_input_instructions }
399+ set_edit_context_instructions = { set_edit_context_instructions }
400+ set_commit_instructions = { set_commit_instructions }
401+ set_voice_input_instructions = { set_voice_input_instructions }
402+ on_edit_context_instructions_blur = { ( ) => {
403+ props . on_edit_context_system_instructions_change (
404+ edit_context_instructions
405+ )
406+ if (
407+ edit_context_instructions == '' &&
408+ props . edit_context_system_instructions ==
409+ default_system_instructions
410+ ) {
411+ set_edit_context_instructions ( default_system_instructions )
412+ }
413+ } }
414+ on_commit_instructions_blur = { ( ) => {
415+ props . on_commit_instructions_change ( commit_instructions )
416+ if (
417+ commit_instructions == '' &&
418+ props . commit_message_instructions ==
419+ default_commit_message_instructions
420+ ) {
421+ set_commit_instructions (
422+ default_commit_message_instructions
423+ )
424+ }
425+ } }
426+ on_voice_input_instructions_blur = { ( ) => {
427+ props . on_voice_input_instructions_change (
428+ voice_input_instructions
429+ )
430+ if (
431+ voice_input_instructions == '' &&
432+ props . voice_input_instructions ==
433+ default_voice_input_instructions
434+ ) {
435+ set_voice_input_instructions (
436+ default_voice_input_instructions
437+ )
438+ }
439+ } }
451440 />
452-
453- < UiSection
454- ref = { ( el ) => ( section_refs . current [ 'edit-context' ] = el ) }
455- title = { t ( 'sidebar.edit-context' ) }
456- subtitle = { t ( 'edit-context.subtitle' ) }
457- on_stuck_change = { edit_context_on_stuck_change }
458- >
459- < UiNotice type = "info" > { t ( 'edit-context.notice' ) } </ UiNotice >
460- < UiGroup >
461- < UiItem
462- title = { t ( 'edit-context.system-instructions.title' ) }
463- description = { t ( 'edit-context.system-instructions.description' ) }
464- >
465- < UiTextarea
466- value = { edit_context_instructions }
467- on_change = { set_edit_context_instructions }
468- on_blur = { ( ) => {
469- props . on_edit_context_system_instructions_change (
470- edit_context_instructions
471- )
472- if (
473- edit_context_instructions == '' &&
474- props . edit_context_system_instructions ==
475- default_system_instructions
476- ) {
477- set_edit_context_instructions ( default_system_instructions )
478- }
479- } }
480- />
481- </ UiItem >
482- </ UiGroup >
483- </ UiSection >
484-
485- < UiSection
486- ref = { ( el ) => ( section_refs . current [ 'code-at-cursor' ] = el ) }
487- title = { t ( 'sidebar.code-at-cursor' ) }
488- subtitle = { t ( 'code-at-cursor.subtitle' ) }
489- on_stuck_change = { code_at_cursor_on_stuck_change }
490- >
491- < UiNotice type = "info" > { t ( 'code-at-cursor.notice' ) } </ UiNotice >
492- < UiGroup >
493- < UiItem
494- title = { t ( 'code-at-cursor.keyboard-shortcut.title' ) }
495- description = { t ( 'code-at-cursor.keyboard-shortcut.description' ) }
496- slot_right = {
497- < UiTextButton
498- on_click = { ( ) =>
499- props . on_open_keybindings ( 'codeWebChat.codeAtCursor' )
500- }
501- >
502- { t ( 'code-at-cursor.keyboard-shortcut.action' ) }
503- </ UiTextButton >
504- }
505- />
506- </ UiGroup >
507- </ UiSection >
508-
509- < UiSection
510- ref = { ( el ) => ( section_refs . current [ 'commit-messages' ] = el ) }
511- title = { t ( 'sidebar.commit-messages' ) }
512- subtitle = { t ( 'commit-messages.subtitle' ) }
513- on_stuck_change = { commit_messages_on_stuck_change }
514- >
515- < UiNotice type = "info" > { t ( 'commit-messages.notice' ) } </ UiNotice >
516- < UiGroup >
517- < UiItem
518- title = { t ( 'commit-messages.instructions.title' ) }
519- description = { t ( 'commit-messages.instructions.description' ) }
520- >
521- < UiTextarea
522- value = { commit_instructions }
523- on_change = { set_commit_instructions }
524- on_blur = { ( ) => {
525- props . on_commit_instructions_change ( commit_instructions )
526- if (
527- commit_instructions == '' &&
528- props . commit_message_instructions ==
529- default_commit_message_instructions
530- ) {
531- set_commit_instructions (
532- default_commit_message_instructions
533- )
534- }
535- } }
536- />
537- </ UiItem >
538- < UiItem
539- title = { t ( 'commit-messages.include-prompts.title' ) }
540- description = { t ( 'commit-messages.include-prompts.description' ) }
541- slot_right = {
542- < UiToggler
543- is_on = { props . include_prompts_in_commit_messages }
544- on_toggle = { props . on_include_prompts_in_commit_messages_change }
545- />
546- }
547- />
548- </ UiGroup >
549- </ UiSection >
550-
551- < UiSection
552- ref = { ( el ) => ( section_refs . current [ 'voice-input' ] = el ) }
553- title = { t ( 'sidebar.voice-input' ) }
554- subtitle = { t ( 'voice-input.subtitle' ) }
555- on_stuck_change = { voice_input_on_stuck_change }
556- >
557- < UiNotice type = "info" >
558- < Translation
559- id = "voice-input.notice"
560- components = { {
561- link : (
562- < a
563- href = "#"
564- onClick = { ( e ) => {
565- e . preventDefault ( )
566- props . on_open_external_url (
567- 'https://ai.google.dev/gemini-api/docs/audio'
568- )
569- } }
570- >
571- { t ( 'voice-input.notice.link' ) }
572- </ a >
573- )
574- } }
575- />
576- </ UiNotice >
577- < UiGroup >
578- < UiItem
579- title = { t ( 'voice-input.instructions.title' ) }
580- description = { t ( 'voice-input.instructions.description' ) }
581- >
582- < UiTextarea
583- value = { voice_input_instructions }
584- on_change = { set_voice_input_instructions }
585- on_blur = { ( ) => {
586- props . on_voice_input_instructions_change (
587- voice_input_instructions
588- )
589- if (
590- voice_input_instructions == '' &&
591- props . voice_input_instructions ==
592- default_voice_input_instructions
593- ) {
594- set_voice_input_instructions (
595- default_voice_input_instructions
596- )
597- }
598- } }
599- />
600- </ UiItem >
601- < UiItem
602- title = { t ( 'voice-input.push-to-talk.title' ) }
603- description = { t ( 'voice-input.push-to-talk.description' ) }
604- slot_right = {
605- < UiToggler
606- is_on = { props . voice_input_push_to_talk }
607- on_toggle = { props . on_voice_input_push_to_talk_change }
608- />
609- }
610- />
611- </ UiGroup >
612- </ UiSection >
613441 </ UiLayout >
614442 </ div >
615443 )
0 commit comments