fix: refresh jobs list immediately after replay
Add /api/jobs/list endpoint and fetch the updated list right after a successful replay so the new job appears instantly instead of waiting for the next SSE poll (up to 15s when idle). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -95,9 +95,21 @@ export function JobsList({ initialJobs, libraries, highlightJobId }: JobsListPro
|
||||
}
|
||||
};
|
||||
|
||||
const refreshJobs = async () => {
|
||||
try {
|
||||
const res = await fetch("/api/jobs/list");
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
if (Array.isArray(data)) setJobs(data);
|
||||
}
|
||||
} catch { /* SSE will catch up */ }
|
||||
};
|
||||
|
||||
const handleReplay = async (id: string) => {
|
||||
const response = await fetch(`/api/jobs/${id}/replay`, { method: "POST" });
|
||||
if (!response.ok) {
|
||||
if (response.ok) {
|
||||
await refreshJobs();
|
||||
} else {
|
||||
const data = await response.json().catch(() => ({}));
|
||||
console.error("Failed to replay job:", data?.error ?? response.status);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user