Skip to content

Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.

fix(desktop): distinguish schedule history from active work

Seth Wilson97659895d14f
diff --git a/apps/desktop/src/app/pulse.ts b/apps/desktop/src/app/pulse.ts
index 29b58cbb..bf9f455b 100644
--- a/apps/desktop/src/app/pulse.ts
+++ b/apps/desktop/src/app/pulse.ts
@@ -25,7 +25,12 @@ export interface ScheduleInfo {
prompt?: string;
botId?: string;
nextRun?: string;
- lastRun?: string;
+ executeAt?: string;
+ timezone?: string;
+ missedRunPolicy?: 'skip' | 'run_once';
+ paused?: boolean;
+ /** Older runtimes returned only a timestamp. */
+ lastRun?: string | { id: string; status: 'running' | 'completed' | 'failed' | 'interrupted' | 'skipped' | 'dispatched'; startedAt: string; finishedAt?: string; error?: string };
}
export interface BackgroundInfo {
diff --git a/apps/desktop/src/app/schedule-status.test.ts b/apps/desktop/src/app/schedule-status.test.ts
new file mode 100644
index 00000000..5a85607f
--- /dev/null
+++ b/apps/desktop/src/app/schedule-status.test.ts
@@ -0,0 +1,31 @@
+import { describe, expect, it } from 'vitest';
+import type { ScheduleInfo } from './pulse';
+import { scheduleDetail, scheduleIsActive } from './schedule-status';
+
+const once: ScheduleInfo = { id: 'one', description: 'A reminder', delaySeconds: 60, executeAt: '2026-11-06T12:00:00Z' };
+const run = (status: 'running' | 'completed' | 'failed' | 'interrupted' | 'skipped' | 'dispatched') => ({ id: status, status, startedAt: '2026-11-06T12:00:00Z' });
+
+describe('durable schedules in the status bar', () => {
+ it('counts pending and running work, excluding retained terminal one-shots and paused work', () => {
+ expect(scheduleIsActive(once)).toBe(true);
+ expect(scheduleIsActive({ ...once, lastRun: run('running') })).toBe(true);
+ for (const status of ['completed', 'failed', 'interrupted', 'skipped', 'dispatched'] as const) {
+ expect(scheduleIsActive({ ...once, lastRun: run(status) })).toBe(false);
+ }
+ expect(scheduleIsActive({ ...once, cron: '* * * * *', lastRun: run('completed') })).toBe(true);
+ expect(scheduleIsActive({ ...once, cron: '* * * * *', paused: true })).toBe(false);
+ });
+
+ it('uses the absolute due time instead of claiming the original delay remains', () => {
+ expect(scheduleDetail(once)).toContain('pending · due ');
+ expect(scheduleDetail(once)).not.toContain('in 60s');
+ expect(scheduleDetail({ ...once, paused: true, lastRun: run('failed') })).toContain('failed · paused · was due ');
+ expect(scheduleDetail({ ...once, lastRun: run('dispatched') })).toContain('dispatched to bot queue');
+ });
+
+ it('shows the recurring timezone and preserves older-runtime timestamps', () => {
+ expect(scheduleDetail({ ...once, cron: '*/5 * * * *', timezone: 'Europe/London', lastRun: run('completed') })).toContain('scheduled · last run completed · every 5 min · Europe/London');
+ expect(scheduleIsActive({ ...once, lastRun: '2026-11-06T12:00:00Z' })).toBe(true);
+ expect(scheduleDetail({ ...once, executeAt: undefined, lastRun: '2026-11-06T12:00:00Z' })).toBe('pending · delay 60s');
+ });
+});
diff --git a/apps/desktop/src/app/schedule-status.ts b/apps/desktop/src/app/schedule-status.ts
new file mode 100644
index 00000000..3a2b4bca
--- /dev/null
+++ b/apps/desktop/src/app/schedule-status.ts
@@ -0,0 +1,28 @@
+import type { ScheduleInfo } from './pulse';
+
+export function scheduleIsActive(schedule: ScheduleInfo): boolean {
+ const run = typeof schedule.lastRun === 'object' ? schedule.lastRun : undefined;
+ if (schedule.paused || run?.status === 'failed' || run?.status === 'interrupted') return false;
+ return !!schedule.cron || !run || run.status === 'running';
+}
+
+export function scheduleDetail(schedule: ScheduleInfo): string {
+ const run = typeof schedule.lastRun === 'object' ? schedule.lastRun : undefined;
+ const status = run?.status === 'dispatched' ? 'dispatched to bot queue' : run?.status;
+ const state = schedule.paused ? `${status ?? 'pending'} · paused`
+ : status === 'running' ? status
+ : schedule.cron ? `scheduled${status ? ` · last run ${status}` : ''}` : status ?? 'pending';
+ const when = (date: string) => new Date(date).toLocaleString([], { hour: 'numeric', minute: '2-digit', month: 'short', day: 'numeric' });
+ const timing = schedule.cron ? `${cronLabel(schedule.cron)} · ${schedule.timezone ?? 'host timezone'}`
+ : schedule.executeAt ? `${scheduleIsActive(schedule) ? 'due' : 'was due'} ${when(schedule.executeAt)}`
+ : schedule.delaySeconds ? `delay ${schedule.delaySeconds}s` : '';
+ return [state, timing, schedule.botId ? `bot ${schedule.botId}` : '', schedule.nextRun && scheduleIsActive(schedule) ? `next ${when(schedule.nextRun)}` : ''].filter(Boolean).join(' · ');
+}
+
+function cronLabel(cron: string): string {
+ const m = /^\*\/(\d+) \* \* \* \*$/.exec(cron.trim());
+ if (m) return `every ${m[1]} min`;
+ const h = /^0 \*\/(\d+) \* \* \*$/.exec(cron.trim());
+ if (h) return `every ${h[1]} h`;
+ return cron;
+}
diff --git a/apps/desktop/src/extensions/builtin-status.tsx b/apps/desktop/src/extensions/builtin-status.tsx
index f46e5c55..3b7208c0 100644
--- a/apps/desktop/src/extensions/builtin-status.tsx
+++ b/apps/desktop/src/extensions/builtin-status.tsx
@@ -6,6 +6,7 @@ import type { CodeStatus } from "~/api/types";
import { usePermissionMode } from "~/app/permission";
import { useBots, useRuntimeState, useUi } from "~/app/store";
import { refreshPulse, usePulse, type ScheduleInfo } from "~/app/pulse";
+import { scheduleDetail, scheduleIsActive } from "~/app/schedule-status";
import { http } from "~/api/client";
import { useConnections } from "~/shell/connections";
import { StateOrb, LABELS } from "~/components/indicators/StateOrb";
@@ -114,14 +115,15 @@ function OptimusVoice() {
function Schedules() {
const schedules = usePulse((s) => s.schedules);
+ const active = schedules.filter(scheduleIsActive).length;
return (
<StatusPopover width={380} trigger={
<Trigger title="Schedules">
<CalendarClock size={13} />
- <span>{schedules.length} scheduled</span>
+ <span>{active} scheduled</span>
</Trigger>
}>
- <PanelTitle>Schedules · {schedules.length}</PanelTitle>
+ <PanelTitle>Schedules · {active} active{active < schedules.length ? ` · ${schedules.length - active} paused or finished` : ''}</PanelTitle>
{schedules.length === 0 && <p className="text-sm text-ink3">Nothing scheduled.</p>}
{schedules.map((s) => <ScheduleRow key={s.id} s={s} />)}
</StatusPopover>
@@ -150,13 +152,15 @@ function ScheduleRow({ s }: { s: ScheduleInfo }) {
setArmed(false);
}
}
- const detail = [s.cron ? cronLabel(s.cron) : s.delaySeconds ? `in ${s.delaySeconds}s` : "", s.botId ? `bot ${s.botId}` : "", s.nextRun ? `next ${new Date(s.nextRun).toLocaleString([], { hour: "numeric", minute: "2-digit", month: "short", day: "numeric" })}` : ""].filter(Boolean).join(" · ");
+ const detail = scheduleDetail(s);
+ const runError = typeof s.lastRun === 'object' ? s.lastRun.error : undefined;
return (
<div className={cx("group flex items-start gap-2 rounded-md px-1 py-1.5", busy && "opacity-50")}>
<span className="mt-0.5 text-ink3"><CalendarClock size={13} /></span>
<span className="min-w-0 flex-1">
<span className="line-clamp-2 text-sm text-ink">{s.description || s.id}</span>
{detail && <span className="block truncate text-xs text-ink4">{detail}</span>}
+ {runError && <span className="block text-xs text-red">{runError}</span>}
{error && <span className="block text-xs text-red">{error}</span>}
</span>
{armed ? (
@@ -281,14 +285,6 @@ function Breakdown({ title, rows, total }: { title: string; rows: Array<[string,
);
}
-function cronLabel(cron: string): string {
- const m = /^\*\/(\d+) \* \* \* \*$/.exec(cron.trim());
- if (m) return `every ${m[1]} min`;
- const h = /^0 \*\/(\d+) \* \* \*$/.exec(cron.trim());
- if (h) return `every ${h[1]} h`;
- return cron;
-}
-
let registered = false;
/** Register the built-ins once; plugins call mercuryUi.registerStatusItem the same way. */