@@ -6,16 +6,17 @@ import { NavigationDivider } from '@ui/components/editor/settings/NavigationDivi
66import { Item } from '@ui/components/editor/settings/Item'
77import { ApiToolConfigurationSection } from './sections/ApiToolConfigurationSection'
88import { Section } from '@ui/components/editor/settings/Section'
9- import { TextButton } from '@ui/components/editor/settings/TextButton'
10- import { Input } from '@ui/components/editor/common/Input'
119import { Textarea } from '@ui/components/editor/settings/Textarea'
1210import {
1311 ConfigurationForClient ,
1412 ProviderForClient
1513} from '@/views/settings/types/messages'
14+ import { GeneralSection } from './sections/GeneralSection'
15+ import { PresetsSection } from './sections/PresetsSection'
1616
1717type NavItem =
1818 | 'general'
19+ | 'presets'
1920 | 'model-providers'
2021 | 'edit-context'
2122 | 'code-completions'
@@ -32,6 +33,11 @@ const NAV_ITEMS_CONFIG: NavConfigItem[] = [
3233 id : 'general' ,
3334 label : 'General'
3435 } ,
36+ {
37+ type : 'item' ,
38+ id : 'presets' ,
39+ label : 'Presets'
40+ } ,
3541 {
3642 type : 'item' ,
3743 id : 'model-providers' ,
@@ -53,6 +59,7 @@ type Props = {
5359 intelligent_update_configs : ConfigurationForClient [ ]
5460 commit_message_instructions : string
5561 context_size_warning_threshold : number
62+ gemini_user_id : number | null
5663
5764 // handlers
5865 set_providers : ( providers : ProviderForClient [ ] ) => void
@@ -62,6 +69,7 @@ type Props = {
6269 set_commit_messages_configs : ( configs : ConfigurationForClient [ ] ) => void
6370 on_context_size_warning_threshold_change : ( threshold : number ) => void
6471 on_commit_instructions_change : ( instructions : string ) => void
72+ on_gemini_user_id_change : ( id : number | null ) => void
6573 on_open_editor_settings : ( ) => void
6674 on_add_provider : ( ) => void
6775 on_delete_provider : ( provider_name : string ) => void
@@ -84,15 +92,14 @@ export const Home: React.FC<Props> = (props) => {
8492 const scroll_container_ref = useRef < HTMLDivElement > ( null )
8593 const section_refs = useRef < Record < NavItem , HTMLDivElement | null > > ( {
8694 general : null ,
95+ presets : null ,
8796 'model-providers' : null ,
8897 'edit-context' : null ,
8998 'code-completions' : null ,
9099 'intelligent-update' : null ,
91100 'commit-messages' : null
92101 } )
93102 const [ commit_instructions , set_commit_instructions ] = useState ( '' )
94- const [ context_size_warning_threshold , set_context_size_warning_threshold ] =
95- useState ( '' )
96103 const [ stuck_sections , set_stuck_sections ] = useState ( new Set < NavItem > ( ) )
97104
98105 const handle_stuck_change = useCallback ( ( id : NavItem , is_stuck : boolean ) => {
@@ -115,6 +122,10 @@ export const Home: React.FC<Props> = (props) => {
115122 ( is_stuck : boolean ) => handle_stuck_change ( 'general' , is_stuck ) ,
116123 [ handle_stuck_change ]
117124 )
125+ const presets_on_stuck_change = useCallback (
126+ ( is_stuck : boolean ) => handle_stuck_change ( 'presets' , is_stuck ) ,
127+ [ handle_stuck_change ]
128+ )
118129 const model_providers_on_stuck_change = useCallback (
119130 ( is_stuck : boolean ) => handle_stuck_change ( 'model-providers' , is_stuck ) ,
120131 [ handle_stuck_change ]
@@ -147,12 +158,6 @@ export const Home: React.FC<Props> = (props) => {
147158 set_commit_instructions ( props . commit_message_instructions || '' )
148159 } , [ props . commit_message_instructions ] )
149160
150- useEffect ( ( ) => {
151- set_context_size_warning_threshold (
152- String ( props . context_size_warning_threshold )
153- )
154- } , [ props . context_size_warning_threshold ] )
155-
156161 useEffect ( ( ) => {
157162 const handler = setTimeout ( ( ) => {
158163 if (
@@ -169,25 +174,6 @@ export const Home: React.FC<Props> = (props) => {
169174 props . commit_message_instructions
170175 ] )
171176
172- useEffect ( ( ) => {
173- const handler = setTimeout ( ( ) => {
174- const num_threshold = parseInt ( context_size_warning_threshold , 10 )
175- if (
176- ! isNaN ( num_threshold ) &&
177- num_threshold >= 0 &&
178- props . context_size_warning_threshold !== undefined &&
179- num_threshold !== props . context_size_warning_threshold
180- ) {
181- props . on_context_size_warning_threshold_change ( num_threshold )
182- }
183- } , 500 )
184- return ( ) => clearTimeout ( handler )
185- } , [
186- context_size_warning_threshold ,
187- props . on_context_size_warning_threshold_change ,
188- props . context_size_warning_threshold
189- ] )
190-
191177 const handle_scroll_to_section = ( item_id : NavItem ) => {
192178 const section = section_refs . current [ item_id ]
193179 const scroll_container = scroll_container_ref . current
@@ -241,35 +227,21 @@ export const Home: React.FC<Props> = (props) => {
241227 )
242228 } ) }
243229 >
244- < Section
230+ < GeneralSection
245231 ref = { ( el ) => ( section_refs . current [ 'general' ] = el ) }
246- title = "General"
247- subtitle = "General settings for the extension."
232+ context_size_warning_threshold = { props . context_size_warning_threshold }
233+ on_context_size_warning_threshold_change = {
234+ props . on_context_size_warning_threshold_change
235+ }
236+ on_open_editor_settings = { props . on_open_editor_settings }
248237 on_stuck_change = { general_on_stuck_change }
249- >
250- < Item
251- title = "Open Editor Settings"
252- description = "For general editor settings, visit the Editor Settings Page."
253- slot = {
254- < TextButton on_click = { props . on_open_editor_settings } >
255- Open Editor Settings
256- </ TextButton >
257- }
258- />
259- < Item
260- title = "Context Size Warning Threshold"
261- description = "Set the token count threshold for showing a warning about large context sizes."
262- slot_placement = "below"
263- slot = {
264- < Input
265- type = "number"
266- value = { context_size_warning_threshold }
267- onChange = { set_context_size_warning_threshold }
268- max_width = { 100 }
269- />
270- }
271- />
272- </ Section >
238+ />
239+ < PresetsSection
240+ ref = { ( el ) => ( section_refs . current [ 'presets' ] = el ) }
241+ gemini_user_id = { props . gemini_user_id }
242+ on_gemini_user_id_change = { props . on_gemini_user_id_change }
243+ on_stuck_change = { presets_on_stuck_change }
244+ />
273245 < Section
274246 ref = { ( el ) => ( section_refs . current [ 'model-providers' ] = el ) }
275247 title = "Model Providers"
0 commit comments