diff --git a/dashboard/e2e/token-limit-pauses.spec.ts b/dashboard/e2e/token-limit-pauses.spec.ts index 40d84721..2b80d34f 100644 --- a/dashboard/e2e/token-limit-pauses.spec.ts +++ b/dashboard/e2e/token-limit-pauses.spec.ts @@ -52,13 +52,14 @@ function run(over: Partial = {}): Run { const LIMIT_LINE = "Paused: this month's token limit is used up (40.3M of 40M). Resumes by itself on Tue, Dec 1, 00:00 UTC when the month turns, or as soon as an admin raises the limit."; const ROOM_LINE = "Waiting for token room: this month's limit has 1.5M left and a run like this takes about 4M. Starts by itself on Tue, Dec 1, 00:00 UTC when the month turns, or as soon as an admin raises the limit."; +const LIMIT_PAUSE = { kind: "token_limit", limit: "new tokens", used: 40_300_000, max: 40_000_000, resumes_at: RESUMES, line: LIMIT_LINE, settings_path: "/settings/budget" }; +const ROOM_PAUSE = { kind: "token_room", limit: "new tokens", used: 38_500_000, max: 40_000_000, room: 1_500_000, need: 4_000_000, resumes_at: RESUMES, line: ROOM_LINE, settings_path: "/settings/budget" }; + const RUNS: Record = { "01RUNPAUSE": run({ - waiting_on: { - action: LIMIT_LINE, - detail: "", - pause: { kind: "token_limit", limit: "new tokens", used: 40_300_000, max: 40_000_000, resumes_at: RESUMES, line: LIMIT_LINE, settings_path: "/settings/budget" }, - }, + waiting_on: { action: LIMIT_LINE, detail: "", pause: LIMIT_PAUSE }, + // The runs list and the search carry the pause itself. + pause: LIMIT_PAUSE, }), "01RUNROOM": run({ run_id: "01RUNROOM", @@ -66,11 +67,8 @@ const RUNS: Record = { ticket_id: "acme/bookstore-web#14", current_pass: "triage", pass_history: [{ pass: "triage", started_at: "2026-11-27T15:00:00Z" }], - waiting_on: { - action: ROOM_LINE, - detail: "", - pause: { kind: "token_room", limit: "new tokens", used: 38_500_000, max: 40_000_000, room: 1_500_000, need: 4_000_000, resumes_at: RESUMES, line: ROOM_LINE, settings_path: "/settings/budget" }, - }, + waiting_on: { action: ROOM_LINE, detail: "", pause: ROOM_PAUSE }, + pause: ROOM_PAUSE, }), "01RUNPERSON": run({ run_id: "01RUNPERSON", @@ -112,7 +110,13 @@ async function mockApi(page: Page, init: Partial = {}): Promise String(r.title).toLowerCase().includes(q)) + .map((r) => ({ run_id: r.run_id, title: r.title, ticket_id: r.ticket_id, repo: r.repo, status: r.status, created_at: r.created_at, pause: r.pause ?? null })); + return json(route, { q, runs, reviews: [], releases: [], plans: [] }); + } if (p === "/api/runs" && req.method() === "GET") return json(route, { runs: Object.values(RUNS), next: null }); const m = p.match(/^\/api\/runs\/([^/]+)(?:\/(.+))?$/); if (m) { @@ -160,6 +164,12 @@ test.describe("a run held by the token limit", () => { const link = page.getByTestId("run-pause-settings"); await expect(link).toHaveText("Token limit settings"); await expect(link).toHaveAttribute("href", /\/settings\/budget\/?$/); + // The full sentence is said once, in the box; the last step says only what holds it. + await expect(page.getByText(/Resumes by itself on/)).toHaveCount(1); + const last = page.locator('[data-testid="run-step"][data-pass="end"]'); + await expect(last).toContainText("Paused by the token limit"); + await expect(last).toContainText("Waiting"); + await expect(last).not.toContainText("this month's token limit"); }); test("a run waiting for token room says how much is left and what it needs", async ({ page }) => { @@ -184,6 +194,31 @@ test.describe("a run held by the token limit", () => { }); }); +test.describe("a paused run in the runs list and the palette", () => { + test("the runs list says when a paused run resumes, never that it needs an answer", async ({ page }) => { + await mockApi(page, { usage: usage([REACHED]) }); + await page.goto("/"); + const row = (title: string) => page.getByTestId("run-row").filter({ hasText: title }); + await expect(row("Show the gift card balance at checkout")).toContainText(`Paused, resumes ${RESUMES_LOCAL}`); + await expect(row("Show the gift card balance at checkout")).not.toContainText("Needs your answer"); + await expect(row("Add a reading list export")).toContainText(`Waiting for token room, starts ${RESUMES_LOCAL}`); + // A run waiting on a person keeps its own words. + await expect(row("Fix the shelf sort order")).not.toContainText("Paused"); + }); + + test("the command palette says the same", async ({ page }) => { + await mockApi(page, { usage: usage([REACHED]) }); + await page.goto("/"); + await expect(page.getByTestId("run-row").first()).toBeVisible(); + await page.keyboard.press("Control+k"); + const palette = page.getByRole("dialog", { name: "Search and commands" }); + await palette.getByRole("combobox").fill("gift card"); + const hit = palette.getByRole("group", { name: "Runs" }).getByRole("option", { name: /Show the gift card balance/ }); + await expect(hit).toContainText(`Paused, resumes ${RESUMES_LOCAL}`); + await expect(hit).not.toContainText("Needs your answer"); + }); +}); + test.describe("warning admins before the limit runs out", () => { test("80%, then 95%: each shows the projected date, dismisses, and stays dismissed that month", async ({ page }) => { const db = await mockApi(page, { usage: usage([AT_80]) }); diff --git a/dashboard/src/app/page.tsx b/dashboard/src/app/page.tsx index 8762384d..f2f53be6 100644 --- a/dashboard/src/app/page.tsx +++ b/dashboard/src/app/page.tsx @@ -3,8 +3,8 @@ import { useCan } from "@/hooks/use-can"; import { Suspense, useEffect, useRef, useState } from "react"; import Link from "next/link"; -import { api, type CloseResult, type CloseRunRequest, type Run } from "@/lib/api"; -import { RUN_GROUP_STATUSES, runCanClose, runStatusLook } from "@/components/run-status"; +import { api, type CloseResult, type CloseRunRequest, type Run, type RunListItem } from "@/lib/api"; +import { RUN_GROUP_STATUSES, runCanClose, runListLook } from "@/components/run-status"; import { runHref } from "@/lib/plugins"; import { CloseRunDialog } from "@/components/close-run-dialog"; import { useToast } from "@/components/toast"; @@ -46,7 +46,7 @@ const TAB_TONE = { active: "live", waiting: "waiting", done: "success", failed: interface RunGroup { ticket_id: string; - attempts: Run[]; // newest first + attempts: RunListItem[]; // newest first } function runTitle(run: Run): string { @@ -54,7 +54,7 @@ function runTitle(run: Run): string { } /** One row per ticket: its newest attempt, with older ones inside. */ -function groupRunsByTicket(runs: Run[]): RunGroup[] { +function groupRunsByTicket(runs: RunListItem[]): RunGroup[] { const map = new Map(); for (const run of runs) { // Each plugin run is its own row (they share a ticket id per plugin). @@ -91,7 +91,7 @@ function RunsPage() { const filtered = !!(q || status || repo || startedBy); const clear = () => setParams({ q: "", status: "all", repo: "", started_by: "" }); - const { items: runs, next, loading, loadingMore, error, moreFailed, loadMore, reload } = usePagedList( + const { items: runs, next, loading, loadingMore, error, moreFailed, loadMore, reload } = usePagedList( (cursor) => api.listRuns(cursor, { q, status, repo, started_by: startedBy || undefined }).then((d) => ({ items: d.runs, next: d.next })), [q, status, repo, startedBy], ); @@ -359,7 +359,7 @@ function ticketWords(run: Run, showRepo: boolean): string | null { function RunItem({ group, showRepo, select, spacer }: { group: RunGroup; showRepo: boolean; select?: RowSelect; spacer?: boolean }) { const [latest, ...earlier] = group.attempts; - const look = runStatusLook(latest.status); + const look = runListLook(latest.status, latest.pause); const title = runTitle(latest); const ticket = ticketWords(latest, showRepo); const isPlugin = latest.ticket_source === "plugin"; @@ -412,7 +412,7 @@ function RunItem({ group, showRepo, select, spacer }: { group: RunGroup; showRep > {runTitle(run)} - +