Skip to content

The agent that grows with you

fix(desktop): label an overdue next run on the Bot Mode routine card

teknium100b7997f4705
diff --git a/apps/desktop/src/app/cron/job-state.ts b/apps/desktop/src/app/cron/job-state.ts
index bf7348f67da..f8b08c32cd2 100644
--- a/apps/desktop/src/app/cron/job-state.ts
+++ b/apps/desktop/src/app/cron/job-state.ts
@@ -35,7 +35,10 @@ export const NEXT_RUN_OVERDUE_GRACE_MS = 15 * 60 * 1000
// the slot is upcoming, within grace, unparseable, or the job is not expected to fire. A slot
// parked in the past is the only user-visible trace of a dead scheduler (#114309), so no
// surface may present it as an upcoming "Next".
-export function nextRunOverdueMs(job: Pick<CronJob, 'enabled' | 'next_run_at' | 'state'>, nowMs = Date.now()): null | number {
+export function nextRunOverdueMs(
+ job: { enabled?: boolean; next_run_at?: null | string; state?: null | string },
+ nowMs = Date.now()
+): null | number {
const state = jobState(job as CronJob)
if (state === 'paused' || state === 'completed' || state === 'disabled' || !job.next_run_at) {
diff --git a/apps/desktop/src/plugins/hermes-bots/cron-detail.test.tsx b/apps/desktop/src/plugins/hermes-bots/cron-detail.test.tsx
index 57ebdf91a5f..43af45964ab 100644
--- a/apps/desktop/src/plugins/hermes-bots/cron-detail.test.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/cron-detail.test.tsx
@@ -38,7 +38,9 @@ const activeJob: RoutineJob = {
last_run_at: '2026-08-23T09:00:00Z',
last_status: 'success',
name: '[bot:notetaker] Morning digest',
- next_run_at: '2026-08-23T10:00:00Z',
+ // Relative to the clock: a fixed stamp ages into the past and the "next run"
+ // it promises would start rendering as overdue (see the overdue case below).
+ next_run_at: new Date(Date.now() + 60 * 60 * 1000).toISOString(),
prompt_preview: 'Summarize yesterday and post it.',
repeat: 'forever',
schedule: 'every 1440m'
@@ -161,6 +163,29 @@ describe('the row is reachable', () => {
expect(screen.getByRole('switch')).toHaveProperty('disabled', true)
expect(screen.getByText(/Paused for security/)).toBeTruthy()
})
+
+ it('labels a next run parked past the scheduler grace as overdue, never as "Next" (#114309)', () => {
+ const hour = 60 * 60 * 1000
+ const overdue: RoutineJob = { ...activeJob, next_run_at: new Date(Date.now() - 7 * hour).toISOString() }
+ const upcoming: RoutineJob = { ...activeJob, next_run_at: new Date(Date.now() + 7 * hour).toISOString() }
+
+ render(<RoutineRow job={overdue} onOpen={() => undefined} owner={{ name: 'notetaker' }} />)
+
+ // The card and the inspector make the same call: the stored slot sitting
+ // hours in the past is the only visible trace of a scheduler that stopped
+ // ticking, so it must not be promised as an upcoming run.
+ expect(screen.getByText(/^Overdue since:.*ago$/)).toBeTruthy()
+ expect(screen.queryByText(/^Next:/)).toBeNull()
+ expect(valueOf(routineDetailRows(overdue), 'Overdue since')).toBeTruthy()
+ expect(valueOf(routineDetailRows(overdue), 'Next run')).toBeUndefined()
+
+ cleanup()
+ render(<RoutineRow job={upcoming} onOpen={() => undefined} owner={{ name: 'notetaker' }} />)
+
+ expect(screen.getByText(/^Next: in /)).toBeTruthy()
+ expect(valueOf(routineDetailRows(upcoming), 'Next run')).toBeTruthy()
+ expect(valueOf(routineDetailRows({ ...overdue, enabled: false, state: 'paused' }), 'Overdue since')).toBeUndefined()
+ })
})
describe('the inspector', () => {
diff --git a/apps/desktop/src/plugins/hermes-bots/cron.tsx b/apps/desktop/src/plugins/hermes-bots/cron.tsx
index 99f9ebee78d..9f946213877 100644
--- a/apps/desktop/src/plugins/hermes-bots/cron.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/cron.tsx
@@ -19,6 +19,7 @@ import {
GlyphSpinner,
host,
Input,
+ nextRunOverdueMs,
PanelEmpty,
queryClient,
relativeTime,
@@ -381,7 +382,9 @@ export function routineDetailRows(job: RoutineJob | null | undefined): Array<{ l
// raw string when it says something the label dropped.
['Schedule (raw)', raw && raw !== label ? raw : null],
['Repeat', job?.repeat],
- ['Next run', paused ? null : routineTimestamp(job?.next_run_at)],
+ // A slot parked past the scheduler grace is labelled overdue, never
+ // promised as a next run (#114309); the card below makes the same call.
+ [job && nextRunOverdueMs(job) !== null ? 'Overdue since' : 'Next run', paused ? null : routineTimestamp(job?.next_run_at)],
['Last run', routineTimestamp(job?.last_run_at)],
['Last result', routineLastResult(job?.last_status)],
['Delivers to', job?.deliver],
@@ -584,7 +587,7 @@ export function RoutineRow({ job, onOpen, owner }: RoutineRowProps) {
</span>
<span className="ml-auto shrink-0 whitespace-nowrap text-[0.65rem] text-(--ui-text-quaternary)">
{active && job.next_run_at
- ? `${c.next} ${relativeTime(new Date(job.next_run_at).getTime())}`
+ ? `${nextRunOverdueMs(job) === null ? c.next : c.overdueSince} ${relativeTime(new Date(job.next_run_at).getTime())}`
: c.states.paused}
</span>
</div>
diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.ts
index 35b6694390c..229a219ea80 100644
--- a/apps/desktop/src/sdk/index.ts
+++ b/apps/desktop/src/sdk/index.ts
@@ -1570,6 +1570,11 @@ export { SidebarRowLead } from '@/app/chat/sidebar/chrome'
export { ConnectionGlyph } from '@/app/chat/sidebar/connection-glyph'
export { SIDEBAR_ROW_LEAD, SIDEBAR_TRUNCATED_LEADING } from '@/app/chat/sidebar/row-geometry'
export { PALETTE_AREA, type PaletteContribution } from '@/app/command-palette/contrib'
+/** THE overdue test for a cron job's `next_run_at`: non-null once the stored slot
+ * sits past the scheduler grace and the job is expected to fire. Every surface
+ * that prints a next run switches its label on this (`t.cron.next` →
+ * `t.cron.overdueSince`) so a dead scheduler never reads as "Next: 7 hr ago". */
+export { nextRunOverdueMs } from '@/app/cron/job-state'
/** THE master-detail toolkit core uses for list+inspector surfaces (Scheduled
* jobs, Kanban, …): a dense left `PanelList` of `PanelListRow`s beside a
* scrolling `PanelDetail` of `PanelSectionLabel` / `PanelMeta` / `PanelBlock`.
diff --git a/website/docs/user-guide/features/cron.md b/website/docs/user-guide/features/cron.md
index b260492397a..7256397c687 100644
--- a/website/docs/user-guide/features/cron.md
+++ b/website/docs/user-guide/features/cron.md
@@ -347,7 +347,7 @@ hermes cron list
hermes cron status
```
-`hermes cron status` reports whether the scheduler is alive (gateway process, ticker heartbeat, last successful tick) and the soonest scheduled run across your active jobs, ordered by actual instant even when jobs store different UTC offsets. A `next_run_at` that is already more than 15 minutes in the past is never shown as an upcoming "Next run": `cron status` prints `⚠ Next run <time> is OVERDUE — passed 7h ago but the job has not fired`, `cron list` labels the row `Overdue:`, the dashboard shows `Overdue since`, and when the gateway is down `status` also says when the scheduler last ticked. That is the signature of a scheduler that stopped ticking — restart the gateway (`hermes gateway restart`) so the next tick picks the overdue job up, or run it right away with `hermes cron run <id>`.
+`hermes cron status` reports whether the scheduler is alive (gateway process, ticker heartbeat, last successful tick) and the soonest scheduled run across your active jobs, ordered by actual instant even when jobs store different UTC offsets. A `next_run_at` that is already more than 15 minutes in the past is never shown as an upcoming "Next run": `cron status` prints `⚠ Next run <time> is OVERDUE — passed 7h ago but the job has not fired`, `cron list` labels the row `Overdue:`, the dashboard and the Desktop cron panel (including a Bot's Routines card) show `Overdue since`, and when the gateway is down `status` also says when the scheduler last ticked. That is the signature of a scheduler that stopped ticking — restart the gateway (`hermes gateway restart`) so the next tick picks the overdue job up, or run it right away with `hermes cron run <id>`.
For a named profile served by the default-profile multiplexer, `hermes cron status` names that scheduler host and reports the named profile's own heartbeat health. Missing or stale heartbeats point to `hermes --profile default gateway restart`. `cron list` and `cron create` also warn when that heartbeat is missing or stale; `cron status` additionally checks the last successful tick and reports tick errors.