Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
fix weird loading state in actions (#439)
Salih Altun579aa274cda8
diff --git a/skyvern-frontend/src/routes/tasks/detail/ScrollableActionList.tsx b/skyvern-frontend/src/routes/tasks/detail/ScrollableActionList.tsxindex dcb44b7ea..5cc959d0d 100644--- a/skyvern-frontend/src/routes/tasks/detail/ScrollableActionList.tsx+++ b/skyvern-frontend/src/routes/tasks/detail/ScrollableActionList.tsx@@ -70,6 +70,7 @@ function ScrollableActionList({const selected = activeIndex === index;return (<div+ key={index}ref={(element) => {refs.current[index] = element;}}diff --git a/skyvern-frontend/src/routes/tasks/detail/useActions.tsx b/skyvern-frontend/src/routes/tasks/detail/useActions.tsxindex 08b4814cf..5b51358a9 100644--- a/skyvern-frontend/src/routes/tasks/detail/useActions.tsx+++ b/skyvern-frontend/src/routes/tasks/detail/useActions.tsx@@ -22,11 +22,12 @@ function getActionInput(action: ActionApiResponse) {return input;}-function useActions(- taskId: string,-): ReturnType<typeof useQuery<Array<Action | null>>> {+function useActions(taskId: string): {+ data?: Array<Action>;+ isFetching: boolean;+} {const credentialGetter = useCredentialGetter();- const { data: task } = useQuery<TaskApiResponse>({+ const { data: task, isFetching: taskIsFetching } = useQuery<TaskApiResponse>({queryKey: ["task", taskId],queryFn: async () => {const client = await getClient(credentialGetter);@@ -37,40 +38,43 @@ function useActions(const taskIsRunningOrQueued =task?.status === Status.Running || task?.status === Status.Queued;- const useQueryReturn = useQuery<Array<Action | null>>({- queryKey: ["task", taskId, "actions"],+ const stepsQuery = useQuery<Array<StepApiResponse>>({+ queryKey: ["task", taskId, "steps"],queryFn: async () => {const client = await getClient(credentialGetter);- const steps = (await client+ return client.get(`/tasks/${taskId}/steps`)- .then((response) => response.data)) as Array<StepApiResponse>;-- const actions = steps.map((step) => {- const actionsAndResults = step.output.actions_and_results;-- const actions = actionsAndResults.map((actionAndResult, index) => {- const action: Action = {- reasoning: actionAndResult[0].reasoning,- confidence: actionAndResult[0].confidence_float,- input: getActionInput(actionAndResult[0]),- type: actionAndResult[0].action_type,- success: actionAndResult[1][0].success,- stepId: step.step_id,- index,- };- return action;- });- return actions;- });-- return actions.flat();+ .then((response) => response.data);},enabled: !!task,staleTime: taskIsRunningOrQueued ? 30 : Infinity,refetchOnWindowFocus: taskIsRunningOrQueued,});- return useQueryReturn;+ const actions = stepsQuery.data+ ?.map((step) => {+ const actionsAndResults = step.output.actions_and_results;++ const actions = actionsAndResults.map((actionAndResult, index) => {+ const action: Action = {+ reasoning: actionAndResult[0].reasoning,+ confidence: actionAndResult[0].confidence_float,+ input: getActionInput(actionAndResult[0]),+ type: actionAndResult[0].action_type,+ success: actionAndResult[1][0].success,+ stepId: step.step_id,+ index,+ };+ return action;+ });+ return actions;+ })+ .flat();++ return {+ data: actions,+ isFetching: stepsQuery.isFetching || taskIsFetching,+ };}export { useActions };