Report renderer progress and detect stalled jobs

This commit is contained in:
2026-10-04 20:25:06 +05:00
parent 3b3cf6997c
commit 3bdf987916
11 changed files with 277 additions and 25 deletions

View File

@@ -3,6 +3,8 @@ import { useEffect, useState } from "react";
import Image from "next/image";
import { api } from "./StartGame";
import type { DatasetManifest } from "@/shared/protocol";
import type { ProcessingJob } from "@/shared/processing-progress";
import { ProcessingProgress } from "./ProcessingProgress";
type Draft = {
id: string;
name: string;
@@ -13,6 +15,7 @@ type Draft = {
map: string | null;
manifest: DatasetManifest;
previews: { id: string; image: string | null }[];
upload_jobs: ProcessingJob | null;
};
export function DraftEditor({ id }: { id: string }) {
const [draft, setDraft] = useState<Draft | null>(null),
@@ -29,6 +32,7 @@ export function DraftEditor({ id }: { id: string }) {
api<Draft>("datasets/" + id)
.then((d) => {
if (disposed) return;
setError("");
setDraft(d);
setName(d.name);
setDescription(d.description);
@@ -37,7 +41,10 @@ export function DraftEditor({ id }: { id: string }) {
timer = setTimeout(load, 5000);
})
.catch((e) => {
if (!disposed) setError(e.message);
if (!disposed) {
setError(e.message);
timer = setTimeout(load, 5000);
}
});
load();
return () => {
@@ -89,6 +96,7 @@ export function DraftEditor({ id }: { id: string }) {
return (
<>
<span className="badge">{draft.state}</span>
<ProcessingProgress job={draft.upload_jobs} />
{["uploading", "processing"].includes(draft.state) && (
<p role="status" className="success-message">
{draft.state === "uploading"