diff --git a/dashboard/e2e/selfhost.spec.ts b/dashboard/e2e/selfhost.spec.ts index 1c13582b..9f5db0fa 100644 --- a/dashboard/e2e/selfhost.spec.ts +++ b/dashboard/e2e/selfhost.spec.ts @@ -531,6 +531,32 @@ test("System: the domain section at 1440 and 390, no sideways scroll", async ({ } }); +test("System: the beta channel installs at any hour, a gap after the last install; stable keeps its window", async ({ page }) => { + const beta = { auto: true, channel: "beta", day: "sun", hour: 3, timezone: "UTC", majors: "ask", gap_hours: 2 }; + const { systemCalls } = await setup(page, SELF, { signedIn: true, version: { settings: beta } }); + await page.goto("/settings/system/"); + const day = page.getByRole("combobox", { name: "Day" }); + await pickOption(day, "any"); + await expect(page.getByRole("combobox", { name: "Hour", exact: true })).toHaveCount(0); + await pickOption(page.getByRole("combobox", { name: "Hours between installs" }), "4"); + await page.getByRole("button", { name: "Save changes" }).click(); + await expect.poll(() => systemCalls.find((c) => c.path === "/api/system/auto-update")?.body).toMatchObject({ day: "any", gap_hours: 4, channel: "beta" }); + + // Stable has no Any hour: moving to it puts the window back on a day. + await page.getByTestId("channel-stable").click(); + await expect(page.getByRole("combobox", { name: "Hour", exact: true })).toBeVisible(); + await day.click(); + await expect(page.getByRole("option", { name: "Any hour (beta)" })).toHaveCount(0); +}); + +test("System: an updater without Any hour never offers it", async ({ page }) => { + await setup(page, SELF, { signedIn: true, version: { settings: { auto: true, channel: "beta", day: "sun", hour: 3, timezone: "UTC", majors: "ask" } } }); + await page.goto("/settings/system/"); + await page.getByRole("combobox", { name: "Day" }).click(); + await expect(page.getByRole("option", { name: "Monday" })).toBeVisible(); + await expect(page.getByRole("option", { name: "Any hour (beta)" })).toHaveCount(0); +}); + test("System: an update still being prepared shows that, before the change set has any details", async ({ page }) => { // While preparing, the install sends only status and version. await setup(page, SELF, { diff --git a/dashboard/src/app/settings/system/page.tsx b/dashboard/src/app/settings/system/page.tsx index 914df5c4..8eea8abc 100644 --- a/dashboard/src/app/settings/system/page.tsx +++ b/dashboard/src/app/settings/system/page.tsx @@ -42,6 +42,10 @@ const DAYS: [string, string][] = [ ["sun", "Sunday"], ]; +/** The beta channel's window: every hour, at least `gap_hours` after the last install. */ +const ANY_HOUR = "any"; +const GAP_HOURS = [1, 2, 3, 4, 6, 8, 12, 24]; + const STATUS: Record = { running: { label: "Running", tone: "waiting" }, preparing: { label: "Preparing", tone: "waiting" }, @@ -230,6 +234,13 @@ function System() { const v = form.values; const set = (k: K, val: AutoUpdateSettings[K]) => form.set(k, val); + // Any hour is the beta channel's only, and only from an updater that has it (it returns gap_hours). + const anyHourOffered = data?.settings?.gap_hours !== undefined && v.channel === "beta"; + const setChannel = (c: AutoUpdateSettings["channel"]) => { + set("channel", c); + // Stable installs in its window: Any hour goes back to the default day, as the updater does. + if (c !== "beta" && v.day === ANY_HOUR) set("day", DEFAULTS.day); + }; const latest = data.latest; const history = data.history ?? []; const canRollBack = history.some((h) => h.status === "succeeded" && h.from_version); @@ -330,21 +341,42 @@ function System() { set("auto", c)} labelledBy={ids.labelId} describedBy={ids.helpId} />} /> (
- set("hour", Number(h))} - options={Array.from({ length: 24 }, (_, h) => ({ value: String(h), label: `${String(h).padStart(2, "0")}:00` }))} + id={ids.inputId} + aria-label="Day" + value={v.day} + onChange={(d) => set("day", d)} + options={[ + ...(anyHourOffered || v.day === ANY_HOUR ? [{ value: ANY_HOUR, label: "Any hour (beta)" }] : []), + ...DAYS.map(([k, label]) => ({ value: k, label })), + ]} /> + {v.day === ANY_HOUR ? ( + set("hour", Number(h))} + options={Array.from({ length: 24 }, (_, h) => ({ value: String(h), label: `${String(h).padStart(2, "0")}:00` }))} + /> + )}
)} /> @@ -384,7 +416,7 @@ function System() { name="update-channel" value={c.value} checked={v.channel === c.value} - onChange={() => set("channel", c.value)} + onChange={() => setChannel(c.value)} className="mt-1 h-4 w-4 shrink-0 accent-sky-500" /> @@ -530,6 +562,7 @@ function Working({ label }: { label: string }) { /** "Sundays at 03:00 UTC": when automatic updates may start, or null when they're off. */ function windowText(s: AutoUpdateSettings | undefined): string | null { if (!s?.auto) return null; + if (s.day === ANY_HOUR) return `any hour, at least ${plural(s.gap_hours ?? 2, "hour")} after the last install`; const day = s.day === "daily" ? "every day" : `${DAYS.find(([k]) => k === s.day)?.[1] ?? s.day}s`; return `${day} at ${String(s.hour).padStart(2, "0")}:00 ${s.timezone.replace(/_/g, " ")}`; } diff --git a/dashboard/src/lib/api.ts b/dashboard/src/lib/api.ts index cf75f431..67b012c1 100644 --- a/dashboard/src/lib/api.ts +++ b/dashboard/src/lib/api.ts @@ -5719,13 +5719,15 @@ export interface AutoUpdateSettings { auto: boolean; /** stable: releases only. beta: the nightly builds too (an updater from before calls it "preview"). */ channel: "stable" | "beta"; - /** mon…sun, or daily */ + /** mon…sun, daily, or any: every hour (the beta channel only), gap_hours after the last install. */ day: string; hour: number; timezone: string; majors: "ask" | "auto"; /** How often the "What's new" email may go. Absent from an updater from before it existed. */ digest?: "weekly" | "biweekly" | "off"; + /** With day "any": the hours at least between two installs. Absent from an updater that has no "any". */ + gap_hours?: number; } export interface UpdateEntry {