@@ -375,6 +375,7 @@ export default function PlannerCanvas() {
375375 const [ hasHydrated , setHasHydrated ] = useState ( ( ) => useStore . persist ?. hasHydrated ?. ( ) ?? true ) ;
376376 const [ isEditingTitle , setIsEditingTitle ] = useState ( false ) ;
377377 const [ isGeneratingTitle , setIsGeneratingTitle ] = useState ( false ) ;
378+ const [ titleError , setTitleError ] = useState ( null ) ;
378379 const [ configModalNode , setConfigModalNode ] = useState ( null ) ;
379380 const [ isConfigModalOpen , setIsConfigModalOpen ] = useState ( false ) ;
380381 const setActiveApp = useStore . use . actions ( ) . setActiveApp ;
@@ -810,6 +811,7 @@ export default function PlannerCanvas() {
810811
811812 const handleTitleChange = useCallback ( ( e ) => {
812813 setWorkflowTitle ( e . target . value ) ;
814+ setTitleError ( null ) ;
813815 } , [ ] ) ;
814816
815817 const handleTitleBlur = useCallback ( ( ) => {
@@ -826,9 +828,12 @@ export default function PlannerCanvas() {
826828 const generateAITitle = useCallback ( async ( ) => {
827829 if ( isGeneratingTitle ) return ; // Prevent double-clicks
828830
831+ const previousTitle = workflowTitle ;
832+
829833 try {
830834 console . log ( 'Generating AI title...' ) ;
831835 setIsGeneratingTitle ( true ) ;
836+ setTitleError ( null ) ;
832837
833838 const flowData = { nodes, edges } ;
834839
@@ -861,23 +866,27 @@ export default function PlannerCanvas() {
861866 suggestedTitle = suggestedTitle . replace ( / [ ' " ] / g, '' ) . trim ( ) ;
862867 console . log ( 'Suggested title:' , suggestedTitle ) ;
863868 setWorkflowTitle ( suggestedTitle ) ;
869+ setTitleError ( null ) ;
864870 } else {
865871 console . warn ( 'No title in response:' , data ) ;
866872 setWorkflowTitle ( 'AI Generated Flow' ) ;
873+ setTitleError ( null ) ;
867874 }
868875 } else {
869876 console . error ( 'API error:' , response . status , response . statusText ) ;
870877 const errorData = await response . json ( ) . catch ( ( ) => ( { } ) ) ;
871878 console . error ( 'Error details:' , errorData ) ;
872- setWorkflowTitle ( '' ) ; // Reset to empty
879+ setWorkflowTitle ( previousTitle ) ;
880+ setTitleError ( 'Unable to generate a new title. Please try again.' ) ;
873881 }
874882 } catch ( error ) {
875883 console . error ( 'Failed to generate AI title:' , error ) ;
876- setWorkflowTitle ( '' ) ; // Reset to empty
884+ setWorkflowTitle ( previousTitle ) ;
885+ setTitleError ( 'Unable to generate a new title. Please try again.' ) ;
877886 } finally {
878887 setIsGeneratingTitle ( false ) ;
879888 }
880- } , [ nodes , edges , isGeneratingTitle , workflowAutoTitleModel ] ) ;
889+ } , [ nodes , edges , isGeneratingTitle , workflowAutoTitleModel , workflowTitle ] ) ;
881890
882891 // Persist planner graph on each change
883892 useEffect ( ( ) => {
@@ -891,33 +900,38 @@ export default function PlannerCanvas() {
891900 < div className = "planner-canvas-container" >
892901 { /* Workflow Title in upper left corner */ }
893902 < div className = "workflow-title-container" >
894- { isEditingTitle ? (
895- < input
896- type = "text"
897- value = { workflowTitle }
898- onChange = { handleTitleChange }
899- onBlur = { handleTitleBlur }
900- onKeyPress = { handleTitleKeyPress }
901- placeholder = "Title your Flow"
902- className = "workflow-title-input"
903- autoFocus
904- />
905- ) : (
906- < div
907- className = "workflow-title-display"
908- onDoubleClick = { handleTitleDoubleClick }
903+ < div className = "workflow-title-row" >
904+ { isEditingTitle ? (
905+ < input
906+ type = "text"
907+ value = { workflowTitle }
908+ onChange = { handleTitleChange }
909+ onBlur = { handleTitleBlur }
910+ onKeyPress = { handleTitleKeyPress }
911+ placeholder = "Title your Flow"
912+ className = "workflow-title-input"
913+ autoFocus
914+ />
915+ ) : (
916+ < div
917+ className = "workflow-title-display"
918+ onDoubleClick = { handleTitleDoubleClick }
919+ >
920+ { workflowTitle || 'Title your Flow' }
921+ </ div >
922+ ) }
923+ < button
924+ className = "btn btn-ai-title"
925+ onClick = { generateAITitle }
926+ disabled = { isGeneratingTitle }
927+ title = { isGeneratingTitle ? "Generating title..." : "Generate title with AI" }
909928 >
910- { workflowTitle || 'Title your Flow' }
911- </ div >
929+ < span className = "icon" > { isGeneratingTitle ? 'hourglass_empty' : 'auto_awesome' } </ span >
930+ </ button >
931+ </ div >
932+ { titleError && (
933+ < div className = "workflow-title-error" > { titleError } </ div >
912934 ) }
913- < button
914- className = "btn btn-ai-title"
915- onClick = { generateAITitle }
916- disabled = { isGeneratingTitle }
917- title = { isGeneratingTitle ? "Generating title..." : "Generate title with AI" }
918- >
919- < span className = "icon" > { isGeneratingTitle ? 'hourglass_empty' : 'auto_awesome' } </ span >
920- </ button >
921935 </ div >
922936
923937 < div className = "planner-toolbar" >
0 commit comments