diff options
| author | soryu <soryu@soryu.co> | 2026-02-12 03:04:26 +0000 |
|---|---|---|
| committer | soryu <soryu@soryu.co> | 2026-02-12 03:22:43 +0000 |
| commit | ffbd8fed748ff4b60c53ee6ac54d7cf0548a7048 (patch) | |
| tree | eb95056f7baeca66bf05737875704ec583f2d9bb /makima/frontend/src/hooks | |
| parent | e03ac942b97255f01cb98f3a6c927da18e001b18 (diff) | |
| download | soryu-ffbd8fed748ff4b60c53ee6ac54d7cf0548a7048.tar.gz soryu-ffbd8fed748ff4b60c53ee6ac54d7cf0548a7048.zip | |
Add task cleanup and directive PR updating
Diffstat (limited to 'makima/frontend/src/hooks')
| -rw-r--r-- | makima/frontend/src/hooks/useDirectives.ts | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/makima/frontend/src/hooks/useDirectives.ts b/makima/frontend/src/hooks/useDirectives.ts index f5f2b36..e67733c 100644 --- a/makima/frontend/src/hooks/useDirectives.ts +++ b/makima/frontend/src/hooks/useDirectives.ts @@ -19,6 +19,7 @@ import { failDirectiveStep, skipDirectiveStep, updateDirectiveGoal, + cleanupDirectiveTasks, } from "../lib/api"; export function useDirectives() { @@ -80,16 +81,18 @@ export function useDirective(id: string | undefined) { refresh(); }, [refresh]); - // Auto-poll while directive is active or has an orchestrator task + // Auto-poll while directive is active, has an orchestrator task, or has a completion task useEffect(() => { if (!directive) return; const needsPolling = - directive.status === "active" || directive.orchestratorTaskId != null; + directive.status === "active" || + directive.orchestratorTaskId != null || + directive.completionTaskId != null; if (!needsPolling) return; const interval = setInterval(refresh, 5000); return () => clearInterval(interval); - }, [directive?.status, directive?.orchestratorTaskId, refresh]); + }, [directive?.status, directive?.orchestratorTaskId, directive?.completionTaskId, refresh]); const update = useCallback(async (req: UpdateDirectiveRequest) => { if (!id) return; @@ -151,11 +154,17 @@ export function useDirective(id: string | undefined) { await refresh(); }, [id, refresh]); + const cleanupTasks = useCallback(async () => { + if (!id) return; + await cleanupDirectiveTasks(id); + await refresh(); + }, [id, refresh]); + return { directive, loading, error, refresh, update, addStep, removeStep, start, pause, advance, completeStep, failStep, skipStep, - updateGoal, + updateGoal, cleanupTasks, }; } |
