Skip to content

Commit 7bcd8ac

Browse files
Alix-007steipete
andauthored
fix(doctor): expose disabled in-flight automations (#128664)
Co-authored-by: Peter Steinberger <[email protected]>
1 parent 0a79ae5 commit 7bcd8ac

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

‎src/commands/doctor/cron/index.test.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -927,10 +927,14 @@ describe("maybeRepairLegacyCronStore", () => {
927927
describe("in-flight cron job advisory", () => {
928928
const RUNNING_AT_MS = Date.parse("2026-05-01T00:00:00.000Z");
929929

930-
it("warns about jobs still marked in-flight without touching the store", async () => {
930+
it("warns about disabled jobs still marked in-flight without hiding the inventory", async () => {
931931
const storePath = await makeTempStorePath();
932932
await writeCurrentCronStore(storePath, [
933-
createCurrentCronJob({ id: "running-job", state: { runningAtMs: RUNNING_AT_MS } }),
933+
createCurrentCronJob({
934+
id: "running-job",
935+
enabled: false,
936+
state: { runningAtMs: RUNNING_AT_MS },
937+
}),
934938
]);
935939
const prompter = makePrompter(true);
936940

@@ -941,8 +945,9 @@ describe("maybeRepairLegacyCronStore", () => {
941945
});
942946

943947
expectNoteContaining("1 automation is still marked in-flight", "Cron");
944-
expectNoteContaining("shows it as `running`", "Cron");
948+
expectNoNoteContaining("shows it as `running`", "Cron");
945949
expectNoteContaining("marks such runs interrupted the next time it starts", "Cron");
950+
expectNoteContaining("openclaw automations list --all", "Cron");
946951
expectNoteContaining("openclaw automations show <id>", "Cron");
947952

948953
// Observer-only: no repair prompt and the running marker is left untouched.
@@ -967,7 +972,7 @@ describe("maybeRepairLegacyCronStore", () => {
967972
});
968973

969974
expectNoteContaining("2 automations are still marked in-flight", "Cron");
970-
expectNoteContaining("shows them as `running`", "Cron");
975+
expectNoteContaining("openclaw automations list --all", "Cron");
971976
});
972977

973978
it("stays silent when no job is marked in-flight", async () => {

‎src/commands/doctor/cron/index.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ function readLegacyCronStorePath(cfg: OpenClawConfig): string | undefined {
4949

5050
// Count jobs the store still marks in-flight (`state.runningAtMs` is a number).
5151
// The scheduler sets this while a run is active and clears it on completion, so a
52-
// leftover marker (gateway killed mid-run) makes `cron list` show the job as
53-
// `running` while nothing executes it. Startup marks exactly these runs interrupted
52+
// leftover marker (gateway killed mid-run) can survive while nothing executes it.
53+
// Startup marks exactly these runs interrupted
5454
// (`src/cron/service/ops-lifecycle.ts` `start`), so doctor only reports the count here.
5555
function countInFlightCronJobs(jobs: Array<Record<string, unknown>>): number {
5656
return jobs.filter((job) => {
@@ -459,9 +459,9 @@ export async function maybeRepairLegacyCronStore(params: {
459459
const subject = inFlightCount === 1 ? "it" : "them";
460460
note(
461461
[
462-
`${pluralize(inFlightCount, "automation")} ${inFlightCount === 1 ? "is" : "are"} still marked in-flight (\`state.runningAtMs\` is set), so ${formatCliCommand("openclaw automations list")} shows ${subject} as \`running\`.`,
462+
`${pluralize(inFlightCount, "automation")} ${inFlightCount === 1 ? "is" : "are"} still marked in-flight (\`state.runningAtMs\` is set).`,
463463
`- If no gateway is currently executing ${subject}, the marker is left over from an interrupted run; the gateway marks such runs interrupted the next time it starts.`,
464-
`- Review with ${formatCliCommand("openclaw automations list")} or ${formatCliCommand("openclaw automations show <id>")}.`,
464+
`- Review with ${formatCliCommand("openclaw automations list --all")} or ${formatCliCommand("openclaw automations show <id>")}.`,
465465
].join("\n"),
466466
"Cron",
467467
);

0 commit comments

Comments
 (0)