Skip to content

Commit 86ac144

Browse files
committed
change order of useSWR
1 parent f744d30 commit 86ac144

File tree

1 file changed

+19
-18
lines changed
  • src/renderer/components/Experiment/Tasks

1 file changed

+19
-18
lines changed

src/renderer/components/Experiment/Tasks/Tasks.tsx

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,25 @@ export default function Tasks() {
4747
setTaskBeingEdited(null);
4848
};
4949

50+
// Fetch jobs with automatic polling
51+
const {
52+
data: jobs,
53+
error: jobsError,
54+
isLoading: jobsIsLoading,
55+
mutate: jobsMutate,
56+
} = useSWR(
57+
experimentInfo?.id
58+
? chatAPI.Endpoints.Jobs.GetJobsOfType(experimentInfo.id, 'REMOTE', '')
59+
: null,
60+
fetcher,
61+
{
62+
refreshInterval: 3000, // Poll every 3 seconds for job status updates
63+
revalidateOnFocus: false, // Don't refetch when window regains focus
64+
revalidateOnReconnect: true, // Refetch when network reconnects
65+
},
66+
);
67+
68+
5069
// Fetch tasks with useSWR
5170
const {
5271
data: allTasks,
@@ -65,24 +84,6 @@ export default function Tasks() {
6584
task.remote_task === true && task.experiment_id === experimentInfo?.id,
6685
) || [];
6786

68-
// Fetch jobs with automatic polling
69-
const {
70-
data: jobs,
71-
error: jobsError,
72-
isLoading: jobsIsLoading,
73-
mutate: jobsMutate,
74-
} = useSWR(
75-
experimentInfo?.id
76-
? chatAPI.Endpoints.Jobs.GetJobsOfType(experimentInfo.id, 'REMOTE', '')
77-
: null,
78-
fetcher,
79-
{
80-
refreshInterval: 3000, // Poll every 3 seconds for job status updates
81-
revalidateOnFocus: false, // Don't refetch when window regains focus
82-
revalidateOnReconnect: true, // Refetch when network reconnects
83-
},
84-
);
85-
8687
// Check remote job status periodically to update LAUNCHING jobs
8788
const { data: remoteJobStatus } = useSWR(
8889
'/remote/check-status',

0 commit comments

Comments
 (0)