@@ -15,7 +15,7 @@ import { logger } from "@renderer/lib/logger";
1515import type { Task , WorkspaceMode } from "@shared/types" ;
1616import { useNavigationStore } from "@stores/navigationStore" ;
1717import type { Editor } from "@tiptap/react" ;
18- import { useCallback } from "react" ;
18+ import { useCallback , useState } from "react" ;
1919
2020const log = logger . scope ( "task-creation" ) ;
2121
@@ -52,11 +52,8 @@ export function useTaskCreation({
5252 githubIntegrationId,
5353 workspaceMode,
5454} : UseTaskCreationOptions ) : UseTaskCreationReturn {
55- const {
56- mutate : createTask ,
57- isPending : isCreatingTask ,
58- invalidateTasks,
59- } = useCreateTask ( ) ;
55+ const { mutate : createTask , invalidateTasks } = useCreateTask ( ) ;
56+ const [ isSubmitting , setIsSubmitting ] = useState ( false ) ;
6057 const { navigateToTask } = useNavigationStore ( ) ;
6158 const { client, isAuthenticated } = useAuthStore ( ) ;
6259 const { setRepoPath : saveRepoPath , setWorkspaceMode : saveWorkspaceMode } =
@@ -70,7 +67,7 @@ export function useTaskCreation({
7067 isAuthenticated &&
7168 ! ! client &&
7269 ( isCloudMode ? ! ! selectedRepository : ! ! selectedDirectory ) &&
73- ! isCreatingTask &&
70+ ! isSubmitting &&
7471 ! editor . isEmpty ;
7572
7673 const handleSubmit = useCallback ( async ( ) => {
@@ -80,13 +77,15 @@ export function useTaskCreation({
8077 isAuthenticated &&
8178 ! ! client &&
8279 ( isCloud ? ! ! selectedRepository : ! ! selectedDirectory ) &&
83- ! isCreatingTask &&
80+ ! isSubmitting &&
8481 ! editor . isEmpty ;
8582
8683 if ( ! canSubmit ) {
8784 return ;
8885 }
8986
87+ setIsSubmitting ( true ) ;
88+
9089 const editorJson = editor . getJSON ( ) ;
9190 const content = tiptapToMarkdown ( editorJson ) . trim ( ) ;
9291 if ( ! content ) {
@@ -195,6 +194,7 @@ export function useTaskCreation({
195194 } ,
196195 onError : ( error ) => {
197196 log . error ( "Failed to create task:" , error ) ;
197+ setIsSubmitting ( false ) ;
198198 } ,
199199 } ,
200200 ) ;
@@ -209,15 +209,15 @@ export function useTaskCreation({
209209 navigateToTask ,
210210 autoRunTasks ,
211211 clearDraft ,
212- isCreatingTask ,
212+ isSubmitting ,
213213 client ,
214214 isAuthenticated ,
215215 invalidateTasks ,
216216 saveWorkspaceMode ,
217217 ] ) ;
218218
219219 return {
220- isCreatingTask,
220+ isCreatingTask : isSubmitting ,
221221 canSubmit,
222222 handleSubmit,
223223 } ;
0 commit comments