From 1b635d6a799be330d7a36db9f98a85f94ade672a Mon Sep 17 00:00:00 2001 From: Shuchang Zheng Date: Thu, 24 Oct 2024 07:12:53 -0700 Subject: [PATCH] add some refetching and invalidating logic for workflow runs (#1048) --- .../src/routes/tasks/detail/TaskDetails.tsx | 12 ++++++++++++ .../src/routes/workflows/WorkflowRun.tsx | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/skyvern-frontend/src/routes/tasks/detail/TaskDetails.tsx b/skyvern-frontend/src/routes/tasks/detail/TaskDetails.tsx index d4ece11b..48986f4e 100644 --- a/skyvern-frontend/src/routes/tasks/detail/TaskDetails.tsx +++ b/skyvern-frontend/src/routes/tasks/detail/TaskDetails.tsx @@ -97,6 +97,18 @@ function TaskDetails() { queryClient.invalidateQueries({ queryKey: ["tasks"], }); + if (task?.workflow_run_id) { + queryClient.invalidateQueries({ + queryKey: ["workflowRun", task.workflow_run_id], + }); + queryClient.invalidateQueries({ + queryKey: [ + "workflowRun", + workflow?.workflow_permanent_id, + task.workflow_run_id, + ], + }); + } toast({ variant: "success", title: "Task Canceled", diff --git a/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx b/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx index ae97457c..9e3e3cd4 100644 --- a/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx +++ b/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx @@ -97,6 +97,18 @@ function WorkflowRun() { return false; }, placeholderData: keepPreviousData, + refetchOnMount: (query) => { + if (!query.state.data) { + return false; + } + return statusIsRunningOrQueued(query.state.data); + }, + refetchOnWindowFocus: (query) => { + if (!query.state.data) { + return false; + } + return statusIsRunningOrQueued(query.state.data); + }, }); const { data: workflowTasks, isLoading: workflowTasksIsLoading } = useQuery<