Skip to content

Commit 1805e8e

Browse files
authored
fix(ui): surface auto-disabled automations instead of hiding them as paused (#123769)
An auto-disabled job (10 consecutive run failures / 3 schedule errors) rendered as plain 'Paused' and simultaneously vanished from the failed chip, the failing count, and the error dot — the escalation removed visibility exactly when the problem became permanent. The recorded fact (state.autoDisabled, already public and used by CLI/doctor) now renders as a distinct danger note with the reason and count, and auto-disabled jobs stay in the active-failure predicate.
1 parent 3289e08 commit 1805e8e

6 files changed

Lines changed: 76 additions & 6 deletions

File tree

‎ui/src/i18n/locales/en.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5732,6 +5732,8 @@ export const en: TranslationMap = {
57325732
refresh: "Refresh",
57335733
refreshing: "Refreshing...",
57345734
paused: "Paused",
5735+
autoDisabledRunFailures: "Auto-disabled · {count} run failures",
5736+
autoDisabledScheduleErrors: "Auto-disabled · {count} schedule errors",
57355737
tasksTab: "Automations",
57365738
activityTab: "Run history",
57375739
},

‎ui/src/lib/cron-status.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,15 @@ describe("isCronJobActiveFailure", () => {
1515
expect(isCronJobActiveFailure(failedJob(true))).toBe(true);
1616
expect(isCronJobActiveFailure(failedJob(false))).toBe(false);
1717
});
18+
19+
it("keeps auto-disabled jobs visible as failures", () => {
20+
// Auto-disable is the escalated failure state; without this the job drops
21+
// out of every failure surface at the moment the problem became permanent.
22+
const job = failedJob(false);
23+
job.state = {
24+
...job.state,
25+
autoDisabled: { reason: "consecutive-failures", atMs: 1, consecutiveErrors: 10 },
26+
};
27+
expect(isCronJobActiveFailure(job)).toBe(true);
28+
});
1829
});

‎ui/src/lib/cron-status.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,14 @@ export function isCronJobRunning(job: CronJob): boolean {
1616
}
1717

1818
// "Failed cron" surfaces (cron page, sidebar attention chips) track current
19-
// actionability, so a failure only counts while the job is still enabled.
20-
// Disabled jobs keep their historical `lastRunStatus: "error"` for detail
21-
// views, but a retired job must not be reported as an active problem.
19+
// actionability, so a failure only counts while the job is still enabled —
20+
// with one exception: auto-disabled jobs are the ESCALATED failure state, not
21+
// an operator pause, so hiding them would drop the problem from every failure
22+
// surface exactly when it became permanent. Operator-paused jobs keep their
23+
// historical `lastRunStatus: "error"` for detail views without being flagged.
2224
export function isCronJobActiveFailure(job: CronJob): boolean {
25+
if (job.state?.autoDisabled) {
26+
return true;
27+
}
2328
return job.enabled && resolveCronJobLastRunStatus(job) === "error";
2429
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Auto-disabled state rendering for the Automations (cron) table.
2+
// Lives beside view.test.ts, which sits at the max-lines cap.
3+
import { expect, it } from "vitest";
4+
import {
5+
createCronViewJob as createJob,
6+
renderCronView as renderView,
7+
} from "./view.test-support.ts";
8+
9+
it("labels an auto-disabled job distinctly from an operator pause", () => {
10+
const paused = createJob("job-paused", { enabled: false });
11+
const autoDisabled = createJob("job-auto", {
12+
enabled: false,
13+
state: {
14+
lastRunStatus: "error",
15+
lastError: "provider exploded",
16+
autoDisabled: { reason: "consecutive-failures", atMs: 1, consecutiveErrors: 10 },
17+
},
18+
});
19+
const container = renderView({ jobs: [paused, autoDisabled] });
20+
const rows = Array.from(container.querySelectorAll(".cron-table__row"));
21+
expect(rows[0]?.textContent).toContain("Paused");
22+
const note = rows[1]?.querySelector("[data-test-id='cron-row-auto-disabled-job-auto']");
23+
expect(note?.textContent?.trim()).toBe("Auto-disabled · 10 run failures");
24+
expect(note?.getAttribute("title")).toBe("provider exploded");
25+
// Escalated failure keeps the error dot even though the job is disabled.
26+
expect(rows[1]?.querySelector(".cron-table__dot--error")).not.toBeNull();
27+
});

‎ui/src/pages/cron/view.ts‎

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -753,9 +753,7 @@ function renderJobRow(job: CronJob, props: CronProps) {
753753
>
754754
`
755755
: nothing}
756-
${job.enabled
757-
? nothing
758-
: html`<span class="muted cron-table__paused-note">${t("cron.list.paused")}</span>`}
756+
${job.enabled ? nothing : renderDisabledNote(job)}
759757
</span>
760758
<span class="cron-table__cell">${formatCronSchedule(job)}</span>
761759
<span class="cron-table__cell">
@@ -796,6 +794,29 @@ function renderJobRow(job: CronJob, props: CronProps) {
796794
`;
797795
}
798796

797+
/** Auto-disabled is the escalated failure state, not an operator pause: the
798+
* recorded fact (state.autoDisabled) must stay visible or the job silently
799+
* drops out of every failure surface the moment the problem became permanent. */
800+
function renderDisabledNote(job: CronJob) {
801+
const autoDisabled = job.state?.autoDisabled;
802+
if (!autoDisabled) {
803+
return html`<span class="muted cron-table__paused-note">${t("cron.list.paused")}</span>`;
804+
}
805+
const label = t(
806+
autoDisabled.reason === "schedule-errors"
807+
? "cron.list.autoDisabledScheduleErrors"
808+
: "cron.list.autoDisabledRunFailures",
809+
{ count: String(autoDisabled.consecutiveErrors) },
810+
);
811+
const lastError = job.state?.lastError?.trim();
812+
return html`<span
813+
class="cron-table__paused-note cron-table__auto-disabled"
814+
data-test-id=${`cron-row-auto-disabled-${job.id}`}
815+
title=${lastError ?? label}
816+
>${label}</span
817+
>`;
818+
}
819+
799820
function renderLastRunCell(job: CronJob) {
800821
const status = resolveCronJobLastRunStatus(job);
801822
const lastRunAtMs = job.state?.lastRunAtMs;

‎ui/src/styles/cron.css‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,10 @@
362362
color: var(--accent);
363363
}
364364

365+
.cron-table__auto-disabled {
366+
color: var(--danger);
367+
}
368+
365369
.cron-table__cell {
366370
color: var(--text);
367371
font-size: 12.5px;

0 commit comments

Comments
 (0)