55 * 2.0.
66 */
77
8- import React , { useState , useEffect } from 'react' ;
8+ import React , { useState } from 'react' ;
99import {
1010 EuiButtonEmpty ,
1111 EuiContextMenuItem ,
@@ -16,11 +16,7 @@ import {
1616} from '@elastic/eui' ;
1717import { css } from '@emotion/react' ;
1818import { i18n } from '@kbn/i18n' ;
19- import {
20- useConversationTitle ,
21- useHasActiveConversation ,
22- useHasPersistedConversation ,
23- } from '../../../hooks/use_conversation' ;
19+ import { useConversationTitle , useHasPersistedConversation } from '../../../hooks/use_conversation' ;
2420import { DeleteConversationModal } from '../delete_conversation_modal' ;
2521import { RenameConversationModal } from '../rename_conversation_modal' ;
2622
@@ -44,47 +40,15 @@ interface ConversationTitleProps {
4440}
4541
4642export const ConversationTitle : React . FC < ConversationTitleProps > = ( { ariaLabelledBy } ) => {
47- const { title, isLoading } = useConversationTitle ( ) ;
48- const hasActiveConversation = useHasActiveConversation ( ) ;
43+ const { title, isLoading : isLoadingTitle } = useConversationTitle ( ) ;
4944 const hasPersistedConversation = useHasPersistedConversation ( ) ;
5045 const { euiTheme } = useEuiTheme ( ) ;
5146
5247 const [ isPopoverOpen , setIsPopoverOpen ] = useState ( false ) ;
5348 const [ isRenameModalOpen , setIsRenameModalOpen ] = useState ( false ) ;
5449 const [ isDeleteModalOpen , setIsDeleteModalOpen ] = useState ( false ) ;
55- const [ previousTitle , setPreviousTitle ] = useState ( '' ) ;
56- const [ currentText , setCurrentText ] = useState ( '' ) ;
57-
58- useEffect ( ( ) => {
59- if ( isLoading || ! hasActiveConversation ) return ;
60-
61- const fullText = title || labels . newConversation ;
62-
63- // Typewriter: ONLY when transitioning from "New conversation" to actual title
64- if ( previousTitle === labels . newConversation && title ) {
65- if ( currentText . length < fullText . length ) {
66- const timeout = setTimeout ( ( ) => {
67- setCurrentText ( fullText . substring ( 0 , currentText . length + 1 ) ) ;
68- } , 50 ) ;
69- return ( ) => clearTimeout ( timeout ) ;
70- }
71- } else if ( title && title !== previousTitle ) {
72- // Normal title change: immediate
73- setCurrentText ( fullText ) ;
74- } else if ( ! title ) {
75- // Reset when switching to new conversation (no title)
76- setCurrentText ( '' ) ;
77- }
78-
79- // Always track the previous title
80- setPreviousTitle ( fullText ) ;
81- } , [ title , currentText , isLoading , previousTitle , hasActiveConversation ] ) ;
8250
83- const displayedTitle = currentText || previousTitle ;
84-
85- if ( ! hasActiveConversation ) {
86- return null ;
87- }
51+ const displayedTitle = isLoadingTitle ? '' : title || labels . newConversation ;
8852
8953 // No popover for unsaved conversations — just show the title
9054 if ( ! hasPersistedConversation ) {
0 commit comments