@@ -22,6 +22,7 @@ const HomeInput: React.FC<HomeInputProps> = ({
2222 onInputSubmit,
2323 onQuickTaskSelect,
2424} ) => {
25+ const [ submitting , setSubmitting ] = useState ( false ) ;
2526 const [ input , setInput ] = useState ( "" ) ;
2627 const textareaRef = useRef < HTMLTextAreaElement > ( null ) ;
2728 const navigate = useNavigate ( ) ;
@@ -42,6 +43,8 @@ const HomeInput: React.FC<HomeInputProps> = ({
4243
4344 const handleSubmit = async ( ) => {
4445 if ( input . trim ( ) ) {
46+ setSubmitting ( true ) ;
47+ showToast ( "Creating a task..." , "info" ) ;
4548 try {
4649 const response = await TaskService . submitInputTask ( input . trim ( ) ) ;
4750
@@ -52,9 +55,20 @@ const HomeInput: React.FC<HomeInputProps> = ({
5255
5356 showToast ( "Task created!" , "success" ) ;
5457 navigate ( `/plan/${ response . plan_id } ` ) ;
58+ console . log ( 'Task response' , response ) ;
59+ if ( response . plan_id != null ) {
60+ // plan_id is valid (not null or undefined)
61+ navigate ( `/plan/${ response . plan_id } ` ) ;
62+ } else {
63+ // plan_id is not valid, handle accordingly
64+ console . log ( 'Invalid plan:' , response . status ) ;
65+ showToast ( "Failed to create task" , "error" ) ;
66+ }
5567 } catch ( error ) {
5668 console . error ( "Failed to create task:" , error ) ;
5769 showToast ( "Something went wrong" , "error" ) ;
70+ } finally {
71+ setSubmitting ( false ) ;
5872 }
5973 }
6074 } ;
@@ -90,12 +104,13 @@ const HomeInput: React.FC<HomeInputProps> = ({
90104 value = { input }
91105 placeholder = "Describe what you'd like to do or use / to reference files, people, and more"
92106 onChange = { setInput }
107+ disabledChat = { submitting }
93108 >
94109 < Button
95110 appearance = "subtle"
96111 className = "home-input-send-button"
97112 onClick = { handleSubmit }
98- disabled = { ! input . trim ( ) }
113+ disabled = { submitting }
99114 icon = { < Send20Regular /> }
100115 />
101116 < Button
0 commit comments