@@ -8,6 +8,7 @@ import { Label } from './ui/label';
8
8
import { ToolConfirmationDialog } from './ToolConfirmationDialog' ;
9
9
import { For , Memo , useObservable , useObserveEffect } from '@legendapp/state/react' ;
10
10
import { getObservableIndex } from '@legendapp/state' ;
11
+ import { useApi } from '@/contexts/ApiContext' ;
11
12
12
13
interface Props {
13
14
conversationId : string ;
@@ -33,6 +34,15 @@ export const ConversationContent: FC<Props> = ({ conversationId, isReadOnly }) =
33
34
// Store the previous conversation ID to detect changes
34
35
const prevConversationIdRef = useRef < string | null > ( null ) ;
35
36
37
+ const { api } = useApi ( ) ;
38
+ const hasSession$ = useObservable < boolean > ( false ) ;
39
+
40
+ useObserveEffect ( api . sessions$ . get ( conversationId ) , ( ) => {
41
+ if ( ! isReadOnly ) {
42
+ hasSession$ . set ( api . sessions$ . get ( conversationId ) . get ( ) !== undefined ) ;
43
+ }
44
+ } ) ;
45
+
36
46
// Detect when the conversation changes and set focus
37
47
useEffect ( ( ) => {
38
48
if ( conversationId !== prevConversationIdRef . current ) {
@@ -216,6 +226,7 @@ export const ConversationContent: FC<Props> = ({ conversationId, isReadOnly }) =
216
226
onSend = { handleSendMessage }
217
227
onInterrupt = { interruptGeneration }
218
228
isReadOnly = { isReadOnly }
229
+ hasSession$ = { hasSession$ }
219
230
defaultModel = { AVAILABLE_MODELS [ 0 ] }
220
231
availableModels = { AVAILABLE_MODELS }
221
232
autoFocus$ = { shouldFocus$ }
0 commit comments