fix(cli): cron list Agent column shows agentId not model — add Model column (openclaw#26259) thanks @openperf

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: openperf <80630709+openperf@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
wangchunyue
2026-03-01 21:47:32 +08:00
committed by GitHub
parent 98e30dc2a3
commit cb6f993b4c
3 changed files with 92 additions and 2 deletions

View File

@@ -75,6 +75,83 @@ describe("printCronList", () => {
expect(logs.some((line) => line.includes("(stagger 5m)"))).toBe(true);
});
it("shows dash for unset agentId instead of default", () => {
const { logs, runtime } = createRuntimeLogCapture();
const job = createBaseJob({
id: "no-agent-job",
name: "No Agent",
agentId: undefined,
sessionTarget: "isolated",
payload: { kind: "agentTurn", message: "hello", model: "sonnet" },
});
printCronList([job], runtime);
// Header should say "Agent ID" not "Agent"
expect(logs[0]).toContain("Agent ID");
// Data row should show "-" for missing agentId, not "default"
const dataLine = logs[1] ?? "";
expect(dataLine).not.toContain("default");
});
it("shows Model column with payload.model for agentTurn jobs", () => {
const { logs, runtime } = createRuntimeLogCapture();
const job = createBaseJob({
id: "model-job",
name: "With Model",
agentId: "ops",
sessionTarget: "isolated",
payload: { kind: "agentTurn", message: "hello", model: "sonnet" },
});
printCronList([job], runtime);
expect(logs[0]).toContain("Model");
const dataLine = logs[1] ?? "";
expect(dataLine).toContain("sonnet");
});
it("shows dash in Model column for systemEvent jobs", () => {
const { logs, runtime } = createRuntimeLogCapture();
const job = createBaseJob({
id: "sys-event-job",
name: "System Event",
sessionTarget: "main",
payload: { kind: "systemEvent", text: "tick" },
});
printCronList([job], runtime);
expect(logs[0]).toContain("Model");
});
it("shows dash in Model column for agentTurn jobs without model override", () => {
const { logs, runtime } = createRuntimeLogCapture();
const job = createBaseJob({
id: "no-model-job",
name: "No Model",
sessionTarget: "isolated",
payload: { kind: "agentTurn", message: "hello" },
});
printCronList([job], runtime);
const dataLine = logs[1] ?? "";
expect(dataLine).not.toContain("undefined");
});
it("shows explicit agentId when set", () => {
const { logs, runtime } = createRuntimeLogCapture();
const job = createBaseJob({
id: "agent-set-job",
name: "Agent Set",
agentId: "ops",
sessionTarget: "isolated",
payload: { kind: "agentTurn", message: "hello", model: "opus" },
});
printCronList([job], runtime);
const dataLine = logs[1] ?? "";
expect(dataLine).toContain("ops");
expect(dataLine).toContain("opus");
});
it("shows exact label for cron schedules with stagger disabled", () => {
const { logs, runtime } = createRuntimeLogCapture();
const job = createBaseJob({

View File

@@ -86,6 +86,7 @@ const CRON_LAST_PAD = 10;
const CRON_STATUS_PAD = 9;
const CRON_TARGET_PAD = 9;
const CRON_AGENT_PAD = 10;
const CRON_MODEL_PAD = 20;
const pad = (value: string, width: number) => value.padEnd(width);
@@ -171,7 +172,8 @@ export function printCronList(jobs: CronJob[], runtime = defaultRuntime) {
pad("Last", CRON_LAST_PAD),
pad("Status", CRON_STATUS_PAD),
pad("Target", CRON_TARGET_PAD),
pad("Agent", CRON_AGENT_PAD),
pad("Agent ID", CRON_AGENT_PAD),
pad("Model", CRON_MODEL_PAD),
].join(" ");
runtime.log(rich ? theme.heading(header) : header);
@@ -192,7 +194,14 @@ export function printCronList(jobs: CronJob[], runtime = defaultRuntime) {
const statusRaw = formatStatus(job);
const statusLabel = pad(statusRaw, CRON_STATUS_PAD);
const targetLabel = pad(job.sessionTarget ?? "-", CRON_TARGET_PAD);
const agentLabel = pad(truncate(job.agentId ?? "default", CRON_AGENT_PAD), CRON_AGENT_PAD);
const agentLabel = pad(truncate(job.agentId ?? "-", CRON_AGENT_PAD), CRON_AGENT_PAD);
const modelLabel = pad(
truncate(
(job.payload.kind === "agentTurn" ? job.payload.model : undefined) ?? "-",
CRON_MODEL_PAD,
),
CRON_MODEL_PAD,
);
const coloredStatus = (() => {
if (statusRaw === "ok") {
@@ -227,6 +236,9 @@ export function printCronList(jobs: CronJob[], runtime = defaultRuntime) {
coloredStatus,
coloredTarget,
coloredAgent,
job.payload.kind === "agentTurn" && job.payload.model
? colorize(rich, theme.info, modelLabel)
: colorize(rich, theme.muted, modelLabel),
].join(" ");
runtime.log(line.trimEnd());