Open source CapCut alternative.
TypeScript
feat(site): show when a held job resumes in the su jobs list
David Lefbddc8beb82b
diff --git a/site/src/app/api/jobs/route.ts b/site/src/app/api/jobs/route.tsindex 63aa7c23..37a1f35a 100644--- a/site/src/app/api/jobs/route.ts+++ b/site/src/app/api/jobs/route.ts@@ -29,6 +29,7 @@ export const GET = withSuperUser(async () => {result: job.result ?? undefined,error: job.error ?? undefined,createdAt: job.createdAt.toISOString(),+ notBefore: job.notBefore?.toISOString(),})),});});diff --git a/site/src/app/su/jobs/list/page.tsx b/site/src/app/su/jobs/list/page.tsxindex 669b43e2..d010f3e9 100644--- a/site/src/app/su/jobs/list/page.tsx+++ b/site/src/app/su/jobs/list/page.tsx@@ -37,6 +37,20 @@ function formatWhen(iso: string): string {return then.toLocaleDateString(undefined, { month: "short", day: "numeric" });}+function formatIn(iso: string): string {+ const mins = Math.ceil((new Date(iso).getTime() - Date.now()) / 60000);+ if (mins < 1) return "now";+ if (mins < 60) return `in ${mins}m`;+ return `in ${Math.floor(mins / 60)}h ${mins % 60}m`;+}++// A queued job held back until later: deferred by its own run, or queued+// for a later time.+function heldUntil(item: AsyncJobListItem): string | null {+ if (item.state !== "queued" || !item.notBefore) return null;+ return new Date(item.notBefore).getTime() > Date.now() ? item.notBefore : null;+}+const stateDot: Record<AsyncJobListItem["state"], string> = {queued: "bg-muted-foreground/40",running: "bg-blue-500 animate-pulse",@@ -77,6 +91,11 @@ export default function SuJobsPage() {<span className="text-muted-foreground">{formatWhen(item.createdAt)}</span>+ {heldUntil(item) ? (+ <span className="text-muted-foreground">+ held · resumes {formatIn(heldUntil(item)!)}+ </span>+ ) : null}</div>{doneSummary(item) ? (<p className="text-muted-foreground">{doneSummary(item)}</p>diff --git a/site/src/queries/jobs.ts b/site/src/queries/jobs.tsindex 5b346831..1317f994 100644--- a/site/src/queries/jobs.ts+++ b/site/src/queries/jobs.ts@@ -19,6 +19,9 @@ export type AsyncJobListItem = {result?: Record<string, unknown>;error?: string;createdAt: string;+ // When a held-back job is due: one deferred by its own run (a drainer+ // waiting on the email quota) or queued for later.+ notBefore?: string;};export const recentJobsQueryKey = ["jobs", "recent"] as const;