@@ -205,7 +205,10 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
205
205
const [ close_and_halt_confirm , set_close_and_halt_confirm ] =
206
206
useState < boolean > ( false ) ;
207
207
208
- const [ showAI , setShowAI ] = useState < boolean > ( false ) ;
208
+ const [ showAIDialogs , setShowAIDialogs ] = useState < {
209
+ main : boolean ;
210
+ popover : boolean ;
211
+ } > ( { main : false , popover : false } ) ;
209
212
const [ showNewAI , setShowNewAI ] = useState < boolean > ( false ) ;
210
213
211
214
const [ helpSearch , setHelpSearch ] = useState < string > ( "" ) ;
@@ -235,7 +238,8 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
235
238
new ManageCommands ( {
236
239
props,
237
240
studentProjectFunctionality : student_project_functionality ,
238
- setShowAI,
241
+ setShowAI : ( val : boolean ) =>
242
+ setShowAIDialogs ( ( prev ) => ( { ...prev , main : val } ) ) ,
239
243
setShowNewAI,
240
244
helpSearch,
241
245
setHelpSearch,
@@ -248,7 +252,7 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
248
252
student_project_functionality ,
249
253
helpSearch ,
250
254
setHelpSearch ,
251
- setShowAI ,
255
+ setShowAIDialogs ,
252
256
setShowNewAI ,
253
257
read_only ,
254
258
editorSettings ,
@@ -579,7 +583,7 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
579
583
) ;
580
584
}
581
585
582
- function renderAssistant ( noLabel ) : Rendered {
586
+ function renderAssistant ( noLabel , where : "main" | "popover" ) : Rendered {
583
587
if (
584
588
! manageCommands . isVisible ( "chatgpt" ) ||
585
589
! redux . getStore ( "projects" ) . hasLanguageModelEnabled ( props . project_id )
@@ -590,11 +594,13 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
590
594
< LanguageModelTitleBarButton
591
595
path = { props . path }
592
596
type = { props . type }
593
- showDialog = { showAI }
594
- setShowDialog = { setShowAI }
597
+ showDialog = { showAIDialogs [ where ] }
598
+ setShowDialog = { ( value : boolean ) => {
599
+ setShowAIDialogs ( ( prev ) => ( { ...prev , [ where ] : value } ) ) ;
600
+ } }
595
601
project_id = { props . project_id }
596
602
buttonRef = { getTourRef ( "chatgpt" ) }
597
- key = { " ai-button" }
603
+ key = { ` ai-button- ${ where } ` }
598
604
id = { props . id }
599
605
actions = { props . actions }
600
606
buttonSize = { button_size ( ) }
@@ -641,7 +647,7 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
641
647
) ;
642
648
}
643
649
644
- function renderSaveTimetravelGroup ( ) : Rendered {
650
+ function renderSaveTimetravelGroup ( where : "main" | "popover" ) : Rendered {
645
651
if ( props . type == "chat" ) {
646
652
// these buttons don't make much sense for side chat.
647
653
return ;
@@ -651,7 +657,7 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
651
657
let x ;
652
658
if ( ( x = renderSaveButton ( noLabel ) ) ) v . push ( x ) ;
653
659
if ( ( x = renderTimeTravel ( noLabel ) ) ) v . push ( x ) ;
654
- if ( ( x = renderAssistant ( noLabel ) ) ) v . push ( x ) ;
660
+ if ( ( x = renderAssistant ( noLabel , where ) ) ) v . push ( x ) ;
655
661
if ( ( x = renderComputeServer ( noLabel ) ) ) v . push ( x ) ;
656
662
if ( v . length == 1 ) return v [ 0 ] ;
657
663
if ( v . length > 0 ) {
@@ -754,7 +760,11 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
754
760
// seems too horrible right now since it is a selector.
755
761
}
756
762
757
- function renderButtons ( style ?: CSS , noRefs ?) : Rendered {
763
+ function renderButtons (
764
+ style ?: CSS ,
765
+ noRefs ?,
766
+ where : "main" | "popover" = "main" ,
767
+ ) : Rendered {
758
768
if ( ! is_active ) {
759
769
return (
760
770
< div style = { { display : "flex" , width : "100%" } } >
@@ -784,7 +794,7 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
784
794
}
785
795
786
796
const v : ( React . JSX . Element | undefined | null ) [ ] = [ ] ;
787
- v . push ( renderSaveTimetravelGroup ( ) ) ;
797
+ v . push ( renderSaveTimetravelGroup ( where ) ) ;
788
798
if ( props . title != null ) {
789
799
v . push ( renderTitle ( ) ) ;
790
800
}
@@ -841,7 +851,7 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
841
851
}
842
852
return (
843
853
< Popover
844
- overlayStyle = { { zIndex : 990 } }
854
+ styles = { { root : { zIndex : 990 } } }
845
855
open = {
846
856
props . tab_is_visible && props . is_visible && showMainButtonsPopover
847
857
}
@@ -860,7 +870,11 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
860
870
marginRight : "3px" ,
861
871
} }
862
872
>
863
- { renderButtons ( { maxHeight : "50vh" , display : "block" } , true ) }
873
+ { renderButtons (
874
+ { maxHeight : "50vh" , display : "block" } ,
875
+ true ,
876
+ "popover" ,
877
+ ) }
864
878
</ div >
865
879
< div >
866
880
{ renderFrameControls ( ) }
0 commit comments