summaryrefslogtreecommitdiff
path: root/makima/frontend/src/hooks/useDirectives.ts
diff options
context:
space:
mode:
Diffstat (limited to 'makima/frontend/src/hooks/useDirectives.ts')
-rw-r--r--makima/frontend/src/hooks/useDirectives.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/makima/frontend/src/hooks/useDirectives.ts b/makima/frontend/src/hooks/useDirectives.ts
index b69275a..f5f2b36 100644
--- a/makima/frontend/src/hooks/useDirectives.ts
+++ b/makima/frontend/src/hooks/useDirectives.ts
@@ -80,6 +80,17 @@ export function useDirective(id: string | undefined) {
refresh();
}, [refresh]);
+ // Auto-poll while directive is active or has an orchestrator task
+ useEffect(() => {
+ if (!directive) return;
+ const needsPolling =
+ directive.status === "active" || directive.orchestratorTaskId != null;
+ if (!needsPolling) return;
+
+ const interval = setInterval(refresh, 5000);
+ return () => clearInterval(interval);
+ }, [directive?.status, directive?.orchestratorTaskId, refresh]);
+
const update = useCallback(async (req: UpdateDirectiveRequest) => {
if (!id) return;
await updateDirective(id, req);