Skip to content

Commit 13ccd7a

Browse files
abhizipstackclaude
andcommitted
fix: address reviewer feedback — next_run_time, null guards, stale closure
P1: _compute_next_run_time added remaining to reference (last_run_at) instead of now, giving wrong results for interval jobs. Fixed to use timezone.now() + remaining. Added logger.debug on failure. P1: getTooltipText crashed when a job had no linked periodic task. Guarded with optional chaining on periodic_task_details. P2: Auto-expand useEffect used JobHistoryData as dep, resetting user-expanded rows on every filter change. Switched to backUpData so it only fires on fresh data loads. P2: handleJobChange useCallback was missing getRunHistoryList in its dependency array, risking stale closure. Added to deps. Nit: Added RUNNING key to STATUS_META so backends that send RUNNING instead of STARTED render correctly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ad1faaa commit 13ccd7a

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

backend/backend/core/scheduler/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ def _compute_next_run_time(periodic, last_run_at):
2929
schedule = periodic.schedule
3030
reference = last_run_at or periodic.last_run_at or timezone.now()
3131
remaining = schedule.remaining_estimate(reference)
32-
return reference + remaining
32+
return timezone.now() + remaining
3333
except Exception:
34+
logger.debug("Failed to compute next_run_time for %s", periodic, exc_info=True)
3435
return None
3536

3637

frontend/src/ide/run-history/Runhistory.jsx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,13 @@ const Runhistory = () => {
140140
const { page_items } = res.data.data;
141141
const scheduledObj = {};
142142
const jobIds = page_items.map((el) => {
143-
scheduledObj[el.user_task_id] = getTooltipText(
144-
el.periodic_task_details[el.task_type],
145-
el.task_type
146-
);
143+
const taskDetails = el.periodic_task_details?.[el.task_type];
144+
if (taskDetails) {
145+
scheduledObj[el.user_task_id] = getTooltipText(
146+
taskDetails,
147+
el.task_type
148+
);
149+
}
147150
return { label: el.task_name, value: el.user_task_id };
148151
});
149152
setJobSchedule(scheduledObj);
@@ -180,13 +183,13 @@ const Runhistory = () => {
180183
}
181184
}, [filterQueries.status, backUpData]);
182185

183-
/* ─── auto-expand failed rows ─── */
186+
/* ─── auto-expand failed rows on fresh data load (not on filter changes) ─── */
184187
useEffect(() => {
185-
const failedIds = (JobHistoryData || [])
188+
const failedIds = (backUpData || [])
186189
.filter((r) => r.status === "FAILURE" && r.error_message)
187190
.map((r) => r.id);
188191
setExpandedRowKeys(failedIds);
189-
}, [JobHistoryData]);
192+
}, [backUpData]);
190193

191194
/* ─── handlers ─── */
192195
const handleJobChange = useCallback(
@@ -203,7 +206,7 @@ const Runhistory = () => {
203206
{ replace: true }
204207
);
205208
},
206-
[setSearchParams]
209+
[setSearchParams, getRunHistoryList]
207210
);
208211

209212
const handleStatusChange = useCallback((value) => {
@@ -332,6 +335,12 @@ const Runhistory = () => {
332335
color: token.colorInfo,
333336
bg: token.colorInfoBg,
334337
},
338+
RUNNING: {
339+
icon: <SyncOutlined spin />,
340+
label: "Running",
341+
color: token.colorInfo,
342+
bg: token.colorInfoBg,
343+
},
335344
RETRY: {
336345
icon: <SyncOutlined spin />,
337346
label: "Retrying",

0 commit comments

Comments
 (0)