@@ -55,7 +55,7 @@ const SPECIAL_ID_WIPE_ALL: DConversationId = 'wipe-chats';
55
55
export function AppChat ( ) {
56
56
57
57
// state
58
- const [ isComposerBroadcast , setIsComposerBroadcast ] = React . useState ( false ) ;
58
+ const [ isComposerMulticast , setIsComposerMulticast ] = React . useState ( false ) ;
59
59
const [ isMessageSelectionMode , setIsMessageSelectionMode ] = React . useState ( false ) ;
60
60
const [ diagramConfig , setDiagramConfig ] = React . useState < DiagramConfig | null > ( null ) ;
61
61
const [ tradeConfig , setTradeConfig ] = React . useState < TradeConfig | null > ( null ) ;
@@ -116,10 +116,9 @@ export function AppChat() {
116
116
117
117
// Window actions
118
118
119
- const isSplitPane = chatPanes . length > 1 ;
120
- const panesConversationIDs = chatPanes . length > 0 ? chatPanes . map ( ( pane ) => pane . conversationId ) : [ null ] ;
121
- const showBroadcastControl = isSplitPane && new Set ( panesConversationIDs ) . size >= 2 ;
122
- const isRealBroadcast = showBroadcastControl && isComposerBroadcast ;
119
+ const isMultiPane = chatPanes . length >= 2 ;
120
+ const isMultiConversationId = isMultiPane && new Set ( chatPanes . map ( ( pane ) => pane . conversationId ) ) . size >= 2 ;
121
+ const willMulticast = isComposerMulticast && isMultiConversationId ;
123
122
124
123
const setFocusedConversationId = React . useCallback ( ( conversationId : DConversationId | null ) => {
125
124
conversationId && openConversationInFocusedPane ( conversationId ) ;
@@ -129,12 +128,12 @@ export function AppChat() {
129
128
conversationId && openConversationInSplitPane ( conversationId ) ;
130
129
} , [ openConversationInSplitPane ] ) ;
131
130
132
- const toggleSplitPane = React . useCallback ( ( ) => {
133
- if ( isSplitPane )
131
+ const handleToggleMultiPane = React . useCallback ( ( ) => {
132
+ if ( isMultiPane )
134
133
removeOtherPanes ( ) ;
135
134
else
136
135
duplicateFocusedPane ( ) ;
137
- } , [ duplicateFocusedPane , isSplitPane , removeOtherPanes ] ) ;
136
+ } , [ duplicateFocusedPane , isMultiPane , removeOtherPanes ] ) ;
138
137
139
138
const handleNavigateHistory = React . useCallback ( ( direction : 'back' | 'forward' ) => {
140
139
if ( navigateHistoryInFocusedPane ( direction ) )
@@ -240,19 +239,19 @@ export function AppChat() {
240
239
}
241
240
const userText = multiPartMessage [ 0 ] . text ;
242
241
243
- // broadcast mode scatterer
244
- const uniqueConversationIds = new Set ( [ conversationId ] ) ;
245
- if ( isRealBroadcast )
246
- chatPanes . forEach ( pane => pane . conversationId && uniqueConversationIds . add ( pane . conversationId ) ) ;
242
+ // multicast: send the message to all the panes
243
+ const uniqueIds = new Set ( [ conversationId ] ) ;
244
+ if ( willMulticast )
245
+ chatPanes . forEach ( pane => pane . conversationId && uniqueIds . add ( pane . conversationId ) ) ;
247
246
248
- // we loop to handle both the normal and broadcast modes
247
+ // we loop to handle both the normal and multicast modes
249
248
let enqueued = false ;
250
- for ( const targetConversationId of uniqueConversationIds ) {
251
- const targetConversation = getConversation ( targetConversationId ) ;
252
- if ( targetConversation ) {
249
+ for ( const _cId of uniqueIds ) {
250
+ const _conversation = getConversation ( _cId ) ;
251
+ if ( _conversation ) {
253
252
// start execution fire/forget
254
- void _handleExecute ( chatModeId , targetConversationId , [
255
- ...targetConversation . messages ,
253
+ void _handleExecute ( chatModeId , _cId , [
254
+ ..._conversation . messages ,
256
255
createDMessage ( 'user' , userText ) ,
257
256
] ) ;
258
257
enqueued = true ;
@@ -321,7 +320,7 @@ export function AppChat() {
321
320
const handleConversationBranch = React . useCallback ( ( conversationId : DConversationId , messageId : string | null ) : DConversationId | null => {
322
321
showNextTitleChange . current = true ;
323
322
const branchedConversationId = branchConversation ( conversationId , messageId ) ;
324
- if ( isSplitPane )
323
+ if ( isMultiPane )
325
324
openSplitConversationId ( branchedConversationId ) ;
326
325
else
327
326
setFocusedConversationId ( branchedConversationId ) ;
@@ -335,7 +334,7 @@ export function AppChat() {
335
334
} ,
336
335
} ) ;
337
336
return branchedConversationId ;
338
- } , [ branchConversation , isSplitPane , openSplitConversationId , setFocusedConversationId ] ) ;
337
+ } , [ branchConversation , isMultiPane , openSplitConversationId , setFocusedConversationId ] ) ;
339
338
340
339
const handleConversationFlatten = React . useCallback ( ( conversationId : DConversationId ) => setFlattenConversationId ( conversationId ) , [ ] ) ;
341
340
@@ -422,14 +421,14 @@ export function AppChat() {
422
421
hasConversations = { ! areChatsEmpty }
423
422
isConversationEmpty = { isFocusedChatEmpty }
424
423
isMessageSelectionMode = { isMessageSelectionMode }
425
- isSplitPane = { isSplitPane }
426
- setIsMessageSelectionMode = { setIsMessageSelectionMode }
424
+ isMultiPane = { isMultiPane }
427
425
onConversationBranch = { handleConversationBranch }
428
426
onConversationClear = { handleConversationClear }
429
427
onConversationFlatten = { handleConversationFlatten }
430
- onToggleSplitPanes = { toggleSplitPane }
428
+ onToggleMultiPane = { handleToggleMultiPane }
429
+ setIsMessageSelectionMode = { setIsMessageSelectionMode }
431
430
/> ,
432
- [ areChatsEmpty , focusedConversationId , handleConversationBranch , handleConversationClear , handleConversationFlatten , isFocusedChatEmpty , isMessageSelectionMode , isMobile , isSplitPane , toggleSplitPane ] ,
431
+ [ areChatsEmpty , focusedConversationId , handleConversationBranch , handleConversationClear , handleConversationFlatten , handleToggleMultiPane , isFocusedChatEmpty , isMessageSelectionMode , isMobile , isMultiPane ] ,
433
432
) ;
434
433
435
434
usePluggableOptimaLayout ( drawerContent , centerItems , menuItems , 'AppChat' ) ;
@@ -456,18 +455,23 @@ export function AppChat() {
456
455
const setFocus = chatPanes . length < 2 || ! event . altKey ;
457
456
setFocusedPane ( setFocus ? idx : - 1 ) ;
458
457
} }
459
- onCollapse = { ( ) => removePane ( idx ) }
458
+ onCollapse = { ( ) => {
459
+ // the small delay does not look good but lets the Panel state settle
460
+ // setTimeout(() => removePane(idx), 50);
461
+ // NOTE: seems there's an issue anyway with the Pane locking the screen, so we'll just call it directly
462
+ removePane ( idx ) ;
463
+ } }
460
464
style = { {
461
465
// for anchoring the scroll button in place
462
466
position : 'relative' ,
463
- ...( panesConversationIDs . length >= 2 ? {
467
+ ...( isMultiPane ? {
464
468
borderRadius : '0.375rem' ,
465
469
border : `2px solid ${ idx === focusedPaneIndex
466
- ? ( isRealBroadcast ? theme . palette . warning . solidBg : theme . palette . primary . solidBg )
467
- : ( isRealBroadcast ? theme . palette . warning . softActiveBg : theme . palette . background . level1 ) } `,
468
- filter : ( isRealBroadcast || idx = == focusedPaneIndex )
469
- ? undefined :
470
- 'grayscale(60%)' ,
470
+ ? ( ( willMulticast || ! isMultiConversationId ) ? theme . palette . warning . solidBg : theme . palette . primary . solidBg )
471
+ : ( ( willMulticast || ! isMultiConversationId ) ? theme . palette . warning . softActiveBg : theme . palette . background . level1 ) } `,
472
+ filter : ( ! willMulticast && idx ! == focusedPaneIndex )
473
+ ? ( ! isMultiConversationId ? 'grayscale(66.67%)' /* clone of the same */ : 'grayscale(66.67%)' )
474
+ : undefined ,
471
475
} : { } ) ,
472
476
} }
473
477
>
@@ -529,12 +533,11 @@ export function AppChat() {
529
533
composerTextAreaRef = { composerTextAreaRef }
530
534
conversationId = { focusedConversationId }
531
535
capabilityHasT2I = { capabilityHasT2I }
536
+ isMulticast = { ! isMultiConversationId ? null : isComposerMulticast }
532
537
isDeveloperMode = { focusedSystemPurposeId === 'Developer' }
533
538
onAction = { handleComposerAction }
534
539
onTextImagine = { handleTextImagine }
535
- isBroadcast = { isComposerBroadcast }
536
- onSetBroadcast = { setIsComposerBroadcast }
537
- showBroadcastControl = { showBroadcastControl }
540
+ setIsMulticast = { setIsComposerMulticast }
538
541
sx = { {
539
542
zIndex : 21 , // position: 'sticky', bottom: 0,
540
543
backgroundColor : themeBgAppChatComposer ,
0 commit comments