@@ -22,6 +22,10 @@ type Props = {
2222 send_with_shift_enter : boolean
2323 check_new_files : boolean
2424 checkpoint_lifespan : number
25+ gemini_user_id : number | null
26+ ai_studio_user_id : number | null
27+ on_gemini_user_id_change : ( id : number | null ) => void
28+ on_ai_studio_user_id_change : ( id : number | null ) => void
2529 on_automatic_checkpoints_toggle : ( disabled : boolean ) => void
2630 on_send_with_shift_enter_change : ( enabled : boolean ) => void
2731 on_check_new_files_change : ( enabled : boolean ) => void
@@ -46,6 +50,8 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
4650 const [ context_size_warning_threshold , set_context_size_warning_threshold ] =
4751 useState ( '' )
4852 const [ checkpoint_lifespan_str , set_checkpoint_lifespan_str ] = useState ( '' )
53+ const [ gemini_user_id_str , set_gemini_user_id_str ] = useState ( '' )
54+ const [ ai_studio_user_id_str , set_ai_studio_user_id_str ] = useState ( '' )
4955 const [ instructions , set_instructions ] = useState < EditFormatInstructions > ( {
5056 whole : '' ,
5157 truncated : '' ,
@@ -69,6 +75,23 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
6975 set_checkpoint_lifespan_str ( String ( props . checkpoint_lifespan ) )
7076 } , [ props . checkpoint_lifespan ] )
7177
78+ useEffect ( ( ) => {
79+ set_gemini_user_id_str (
80+ props . gemini_user_id === null || props . gemini_user_id === undefined
81+ ? ''
82+ : String ( props . gemini_user_id )
83+ )
84+ } , [ props . gemini_user_id ] )
85+
86+ useEffect ( ( ) => {
87+ set_ai_studio_user_id_str (
88+ props . ai_studio_user_id === null ||
89+ props . ai_studio_user_id === undefined
90+ ? ''
91+ : String ( props . ai_studio_user_id )
92+ )
93+ } , [ props . ai_studio_user_id ] )
94+
7295 useEffect ( ( ) => {
7396 if ( props . edit_format_instructions ) {
7497 set_instructions ( props . edit_format_instructions )
@@ -89,6 +112,28 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
89112 }
90113 }
91114
115+ const handle_gemini_user_id_blur = ( ) => {
116+ if ( gemini_user_id_str == '' ) {
117+ props . on_gemini_user_id_change ( null )
118+ return
119+ }
120+ const num_id = parseInt ( gemini_user_id_str , 10 )
121+ if ( ! isNaN ( num_id ) && num_id >= 0 ) {
122+ props . on_gemini_user_id_change ( num_id )
123+ }
124+ }
125+
126+ const handle_ai_studio_user_id_blur = ( ) => {
127+ if ( ai_studio_user_id_str == '' ) {
128+ props . on_ai_studio_user_id_change ( null )
129+ return
130+ }
131+ const num_id = parseInt ( ai_studio_user_id_str , 10 )
132+ if ( ! isNaN ( num_id ) && num_id >= 0 ) {
133+ props . on_ai_studio_user_id_change ( num_id )
134+ }
135+ }
136+
92137 const handle_instructions_blur = ( ) => {
93138 props . on_edit_format_instructions_change ( instructions )
94139 }
@@ -318,6 +363,34 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
318363 }
319364 />
320365 </ Group >
366+ < Group title = "Presets" >
367+ < Item
368+ title = "Gemini User ID"
369+ description = "Run Gemini chatbot as non-default user. Check URL for the numeric ID."
370+ slot_right = {
371+ < Input
372+ type = "number"
373+ value = { gemini_user_id_str }
374+ on_change = { set_gemini_user_id_str }
375+ on_blur = { handle_gemini_user_id_blur }
376+ max_width = { 60 }
377+ />
378+ }
379+ />
380+ < Item
381+ title = "AI Studio User ID"
382+ description = "Run AI Studio chatbot as non-default user. Check URL for the numeric ID."
383+ slot_right = {
384+ < Input
385+ type = "number"
386+ value = { ai_studio_user_id_str }
387+ on_change = { set_ai_studio_user_id_str }
388+ on_blur = { handle_ai_studio_user_id_blur }
389+ max_width = { 60 }
390+ />
391+ }
392+ />
393+ </ Group >
321394 </ Section >
322395 )
323396 }
0 commit comments