Skip to content

The agent that grows with you

fix(cli): label an overdue next run in the in-chat /cron and /cron list

teknium1610fc83f500a
diff --git a/hermes_cli/cli_commands_mixin.py b/hermes_cli/cli_commands_mixin.py
index 2f88a542cda..4f4806243c3 100644
--- a/hermes_cli/cli_commands_mixin.py
+++ b/hermes_cli/cli_commands_mixin.py
@@ -1675,6 +1675,7 @@ class CLICommandsMixin:
result = _cron_api(action="list")
jobs = result.get("jobs", []) if result.get("success") else []
if jobs:
+ from hermes_cli.cron import _next_run_row
_pr(" Current Jobs:", " " + "-" * 63)
for job in jobs:
print(f" {job['job_id'][:12]:<12} | {job['schedule']:<15} | {job.get('repeat', '?'):<8}")
@@ -1682,7 +1683,9 @@ class CLICommandsMixin:
print(f" Skills: {', '.join(job['skills'])}")
print(f" {job.get('prompt_preview', '')}")
if job.get("next_run_at"):
- print(f" Next: {job['next_run_at']}")
+ # A stamp parked past the scheduler grace must not read as upcoming (#114309).
+ label, value = _next_run_row(job)
+ print(f" {'Next' if label == 'Next run' else label}: {value}")
print()
else:
print(" No scheduled jobs. Use '/cron add' to create one.")
@@ -1693,13 +1696,14 @@ class CLICommandsMixin:
jobs = result.get("jobs", []) if result.get("success") else []
if not jobs:
return print("(._.) No scheduled jobs.")
+ from hermes_cli.cron import _next_run_row
print()
_pr("Scheduled Jobs:", "-" * 80)
for job in jobs:
_pr(f" ID: {job['job_id']}", f" Name: {job['name']}",
f" State: {job.get('state', '?')}",
f" Schedule: {job['schedule']} ({job.get('repeat', '?')})",
- f" Next run: {job.get('next_run_at', 'N/A')}")
+ " %s: %s" % _next_run_row(job) if job.get("next_run_at") else " Next run: N/A")
if job.get("skills"):
print(f" Skills: {', '.join(job['skills'])}")
print(f" Prompt: {job.get('prompt_preview', '')}")
diff --git a/tests/hermes_cli/test_cron.py b/tests/hermes_cli/test_cron.py
index 15c1104df9e..4300cfbf5fd 100644
--- a/tests/hermes_cli/test_cron.py
+++ b/tests/hermes_cli/test_cron.py
@@ -646,6 +646,35 @@ class TestStatusSurfacesDeadScheduler:
assert "Scheduler last ticked" not in status_out # no heartbeat file → nothing to date
assert "Next run:" in list_out and "Overdue:" not in list_out
+ def test_slash_cron_and_list_flag_overdue_but_not_paused(self, tmp_cron_dir, capsys):
+ # The in-chat `/cron` overview and `/cron list` (classic CLI + Ink TUI forward to the
+ # same handler) read the same rows; a 7h-past stamp must not read as an upcoming run,
+ # while a paused job keeps its plain label — pausing is why it did not fire.
+ from hermes_cli.cli_commands_mixin import CLICommandsMixin
+
+ class _Host(CLICommandsMixin):
+ pass
+
+ stale = create_job(prompt="Hourly", schedule="every 60m")
+ paused = create_job(prompt="Parked", schedule="every 60m")
+ when = datetime.now(timezone.utc) - timedelta(hours=7)
+ self._park_next_run(stale["id"], when)
+ self._park_next_run(paused["id"], when)
+ jobs = load_jobs()
+ jobs[[j["id"] for j in jobs].index(paused["id"])]["enabled"] = False
+ save_jobs(jobs)
+
+ _Host()._handle_cron_command("/cron")
+ overview_out = capsys.readouterr().out
+ _Host()._handle_cron_command("/cron list --all")
+ list_out = capsys.readouterr().out
+
+ for out in (overview_out, list_out):
+ assert out.count("Overdue:") == 1 and "7h ago" in out
+ assert "Next" not in overview_out # the overview lists enabled jobs only
+ assert list_out.count("Next run:") == 1 # only the paused job's stamp stays plain
+ assert list_out.index("Overdue:") < list_out.index("Next run:")
+
class TestSlashCronRunSkipped:
"""``/cron run`` on a job whose claim is refused (paused here; a live claim held by another
diff --git a/tests/hermes_cli/test_web_server_cron_profiles.py b/tests/hermes_cli/test_web_server_cron_profiles.py
index 9e345c5faf8..5bbb4eb0899 100644
--- a/tests/hermes_cli/test_web_server_cron_profiles.py
+++ b/tests/hermes_cli/test_web_server_cron_profiles.py
@@ -1193,3 +1193,21 @@ async def test_create_cron_job_without_profile_defaults_when_unscoped(
assert job["profile"] == "default"
assert (isolated_profiles["default"] / "cron" / "jobs.json").exists()
+
+
+def test_list_cron_jobs_carries_each_profiles_ticker_heartbeat_age(isolated_profiles):
+ """#114309 — the dashboard must be able to say "scheduler last ticked X hours ago":
+ every listed job carries its own profile's ticker heartbeat age (None = never/unknown)."""
+ import time
+
+ for name, home in isolated_profiles.items():
+ with _web_server_cron._cron_store_scope(home) as cron_jobs:
+ cron_jobs.create_job(prompt=f"{name} hourly", schedule="every 1h")
+ (isolated_profiles["worker_alpha"] / "cron" / "ticker_heartbeat").write_text(
+ str(time.time() - 25 * 3600)
+ )
+
+ ages = {job["profile"]: job["scheduler_heartbeat_age_s"] for job in _rt_cron._list_cron_jobs_sync("all")}
+
+ assert ages["default"] is None # no heartbeat file: cannot date the last tick
+ assert 25 * 3600 <= ages["worker_alpha"] < 25 * 3600 + 60