Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

feat(scheduled): add an interval cadence and a form that owns its page

Hanawad84afc7f9501
diff --git a/apps/desktop/src/features/scheduled/ScheduledEditor.tsx b/apps/desktop/src/features/scheduled/ScheduledEditor.tsx
index 4c02f288e..0598e48af 100644
--- a/apps/desktop/src/features/scheduled/ScheduledEditor.tsx
+++ b/apps/desktop/src/features/scheduled/ScheduledEditor.tsx
@@ -1,9 +1,16 @@
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
-import type { GlobalPermissionMode, ProjectRecord, ScheduledTask, ScheduledSessionMode } from "@pi-desktop/shared";
+import type {
+ GlobalPermissionMode,
+ ProjectRecord,
+ ScheduledSessionMode,
+ ScheduledTask,
+ ScheduledTaskSchedule,
+} from "@pi-desktop/shared";
import { Button, Field, Input, Textarea } from "../../components/ui";
import { SettingsMenuSelect } from "../../components/settings/SettingsMenuSelect";
import { ScheduledWeekdaySelect } from "./ScheduledWeekdaySelect";
+import { convertInterval, intervalAmount, SCHEDULED_INTERVAL_MINUTES } from "./scheduled-format";
import {
ScheduledExecutionSettings,
type ScheduledModelSelection,
@@ -57,6 +64,34 @@ export function ScheduledEditor({
const [sessionMode, setSessionMode] = useState<ScheduledSessionMode>(
task?.sessionMode ?? "perRun",
);
+
+ // An interval is one number plus the unit it reads in. The stored value is
+ // always minutes, which is what the host arms and what the rail reports.
+ const storedInterval = intervalAmount(task?.schedule?.intervalMinutes) ?? {
+ unit: "minutes" as const,
+ value: 30,
+ };
+ const [intervalValue, setIntervalValue] = useState(String(storedInterval.value));
+ const [intervalUnit, setIntervalUnit] = useState<"minutes" | "hours">(storedInterval.unit);
+ const intervalMinutes =
+ intervalUnit === "hours" ? Number(intervalValue) * 60 : Number(intervalValue);
+ const validInterval =
+ Number.isInteger(Number(intervalValue)) &&
+ intervalMinutes >= SCHEDULED_INTERVAL_MINUTES.min &&
+ intervalMinutes <= SCHEDULED_INTERVAL_MINUTES.max;
+ const intervalFloor = intervalUnit === "hours" ? 1 : SCHEDULED_INTERVAL_MINUTES.min;
+ const intervalCeiling =
+ intervalUnit === "hours"
+ ? SCHEDULED_INTERVAL_MINUTES.max / 60
+ : SCHEDULED_INTERVAL_MINUTES.max;
+ /** The same span in the other unit, clamped into the stored range. */
+ const switchIntervalUnit = (unit: "minutes" | "hours") => {
+ const current = Number(intervalValue);
+ setIntervalValue(
+ String(convertInterval(Number.isFinite(current) ? current : 30, intervalUnit, unit)),
+ );
+ setIntervalUnit(unit);
+ };
const defaultModel = !task && settings?.defaultProviderId && settings.defaultModelId
? { providerId: settings.defaultProviderId, modelId: settings.defaultModelId }
: {};
@@ -76,7 +111,8 @@ export function ScheduledEditor({
Number(minute) >= 0 && Number(minute) < 60;
const valid = !!prompt.trim() && !!title.trim() &&
((cadence !== "daily" && cadence !== "weekly") || validTime) &&
- (cadence !== "weekly" || weekdays.length > 0);
+ (cadence !== "weekly" || weekdays.length > 0) &&
+ (cadence !== "interval" || validInterval);
const periods = [
{ id: "morning", label: t("scheduled.morning"), hour: "09" },
{ id: "afternoon", label: t("scheduled.afternoon"), hour: "14" },
@@ -87,9 +123,32 @@ export function ScheduledEditor({
const cadences = [
["manual", "scheduled.cadenceManual"],
["hourly", "scheduled.cadenceHourly"],
+ ["interval", "scheduled.interval"],
["daily", "scheduled.cadenceDaily"],
["weekly", "scheduled.cadenceWeekly"],
] as const;
+
+ // The interval value rides along with every armed cadence, so a task that
+ // switches between a calendar and an interval keeps the value for the way
+ // back. A number the field refuses is left out rather than saved.
+ const scheduleFor = (): ScheduledTaskSchedule | null => {
+ if (cadence === "manual") return null;
+ const base = {
+ hour: 0,
+ minute: 0,
+ weekday: 0,
+ ...(validInterval ? { intervalMinutes } : {}),
+ };
+ if (cadence === "hourly" || cadence === "interval") return base;
+ return {
+ ...base,
+ hour: Number(hour),
+ minute: Number(minute),
+ weekday: weekdays[0] ?? 0,
+ ...(cadence === "weekly" ? { weekdays } : {}),
+ };
+ };
+
return (
<form
className="dest-create space-y-3"
@@ -119,15 +178,7 @@ export function ScheduledEditor({
title: title.trim(),
prompt: prompt.trim(),
cadence,
- schedule:
- cadence === "manual"
- ? null
- : cadence === "hourly"
- ? { hour: 0, minute: 0, weekday: 0 }
- : {
- hour: Number(hour), minute: Number(minute), weekday: weekdays[0] ?? 0,
- ...(cadence === "weekly" ? { weekdays } : {}),
- },
+ schedule: scheduleFor(),
...executionSettings,
});
}}
@@ -198,6 +249,33 @@ export function ScheduledEditor({
onChange={(value) => setCadence(value as ScheduledTask["cadence"])}
/>
</Field>
+ {cadence === "interval" && (
+ <Field label={t("scheduled.interval")}>
+ <div className="scheduled-interval">
+ <Input
+ type="number"
+ inputMode="numeric"
+ min={intervalFloor}
+ max={intervalCeiling}
+ step={1}
+ disabled={busy}
+ value={intervalValue}
+ aria-label={t("scheduled.interval")}
+ onChange={(event) => setIntervalValue(event.target.value)}
+ />
+ <SettingsMenuSelect
+ label={t("scheduled.interval")}
+ value={intervalUnit}
+ disabled={busy}
+ options={[
+ { id: "minutes", label: t("scheduled.intervalUnitMinutes") },
+ { id: "hours", label: t("scheduled.intervalUnitHours") },
+ ]}
+ onChange={(unit) => switchIntervalUnit(unit === "hours" ? "hours" : "minutes")}
+ />
+ </div>
+ </Field>
+ )}
{(cadence === "daily" || cadence === "weekly") && (
<Field label={t("scheduled.time")}>
<SettingsMenuSelect label={t("scheduled.time")} disabled={busy}
@@ -224,6 +302,7 @@ export function ScheduledEditor({
</p>
)}
{cadence === "hourly" && <p className="dest-row-meta">{t("scheduled.hourlyHint")}</p>}
+ {cadence === "interval" && <p className="dest-row-meta">{t("scheduled.intervalHint")}</p>}
<p className="dest-row-meta">{t("scheduled.localTimeHint")}</p>
<div className="flex gap-2">
<Button type="submit" variant="primary" disabled={busy || !valid}>
diff --git a/apps/desktop/src/features/scheduled/ScheduledTaskDetail.tsx b/apps/desktop/src/features/scheduled/ScheduledTaskDetail.tsx
index f8af60905..702674749 100644
--- a/apps/desktop/src/features/scheduled/ScheduledTaskDetail.tsx
+++ b/apps/desktop/src/features/scheduled/ScheduledTaskDetail.tsx
@@ -12,7 +12,7 @@ import {
formatScheduleClock,
} from "./scheduled-format";
import { resolveSelectedRun, runDurationMs } from "./scheduled-runs";
-import { CADENCE_I18N_KEYS, RUN_STATUS_I18N_KEYS } from "./scheduled-labels";
+import { cadenceHasClock, cadenceLabel, CADENCE_I18N_KEYS, RUN_STATUS_I18N_KEYS } from "./scheduled-labels";
import { ScheduledRunHistory } from "./ScheduledRunHistory";
import { ScheduledRunTranscript } from "./ScheduledRunTranscript";
@@ -66,8 +66,8 @@ export function ScheduledTaskDetail({
const [instructionOpen, setInstructionOpen] = useState(false);
const latest = runs[0] ?? null;
const latestDuration = runDurationMs(latest);
- const clock = formatScheduleClock(task.schedule);
- const cadence = t(CADENCE_I18N_KEYS[task.cadence]);
+ const clock = cadenceHasClock(task.cadence) ? formatScheduleClock(task.schedule) : null;
+ const cadence = cadenceLabel(t, task);
const selectedRun = resolveSelectedRun(runs, selectedRunId);
const selectedDuration = runDurationMs(selectedRun);
const selectedSessionId = selectedRun?.sessionId ?? null;
diff --git a/apps/desktop/src/features/scheduled/ScheduledTaskRail.tsx b/apps/desktop/src/features/scheduled/ScheduledTaskRail.tsx
index 93bd90f3d..1add29368 100644
--- a/apps/desktop/src/features/scheduled/ScheduledTaskRail.tsx
+++ b/apps/desktop/src/features/scheduled/ScheduledTaskRail.tsx
@@ -10,7 +10,7 @@ import {
} from "../../components/icons";
import { formatDuration, formatRelativeMoment, formatScheduleClock } from "./scheduled-format";
import { runDurationMs } from "./scheduled-runs";
-import { CADENCE_I18N_KEYS, RUN_STATUS_I18N_KEYS } from "./scheduled-labels";
+import { cadenceHasClock, cadenceLabel, RUN_STATUS_I18N_KEYS } from "./scheduled-labels";
function RunGlyph({ run }: { run: ScheduledTaskRun }) {
switch (run.status) {
@@ -58,8 +58,8 @@ export function ScheduledTaskRail({
const selected = task.id === selectedTaskId;
const latest = latestRuns.get(task.id) ?? null;
const duration = runDurationMs(latest);
- const clock = formatScheduleClock(task.schedule);
- const cadence = t(CADENCE_I18N_KEYS[task.cadence]);
+ const clock = cadenceHasClock(task.cadence) ? formatScheduleClock(task.schedule) : null;
+ const cadence = cadenceLabel(t, task);
const running = latest?.status === "running";
return (
<li key={task.id}>
diff --git a/apps/desktop/src/features/scheduled/scheduled-editor.css b/apps/desktop/src/features/scheduled/scheduled-editor.css
index 9487cbb8f..cab4387d6 100644
--- a/apps/desktop/src/features/scheduled/scheduled-editor.css
+++ b/apps/desktop/src/features/scheduled/scheduled-editor.css
@@ -121,3 +121,15 @@
border-color: var(--ds-text-primary);
color: var(--ds-bg-primary);
}
+
+/* A count and its unit are one control: the number field keeps the shared
+ field metric but takes only the width a two-digit count needs. */
+.scheduled-interval {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+}
+
+.scheduled-interval .field-input {
+ width: 92px;
+}
diff --git a/apps/desktop/src/features/scheduled/scheduled-format.ts b/apps/desktop/src/features/scheduled/scheduled-format.ts
index 78a1ac23c..f157efde8 100644
--- a/apps/desktop/src/features/scheduled/scheduled-format.ts
+++ b/apps/desktop/src/features/scheduled/scheduled-format.ts
@@ -81,3 +81,49 @@ export function formatScheduleClock(
export function lastAttemptAt(task: ScheduledTask): string | null {
return task.lastRunAt ?? null;
}
+
+/**
+ * Elapsed minutes an `interval` task waits between runs, as stored. Mirrors
+ * `INTERVAL_MIN_MINUTES` / `INTERVAL_MAX_MINUTES` in
+ * `crates/host-core/src/scheduled/timing.rs`, which stays authoritative: the
+ * host refuses to arm anything outside this range.
+ */
+export const SCHEDULED_INTERVAL_MINUTES = { min: 5, max: 1440 } as const;
+
+/**
+ * A stored interval in the largest whole unit that still states it exactly, so
+ * `60` reports as one hour rather than sixty minutes. `null` when the value
+ * cannot describe an interval — the same values the host refuses to arm.
+ */
+export function intervalAmount(
+ minutes: number | null | undefined,
+): { unit: "minutes" | "hours"; value: number } | null {
+ if (minutes === null || minutes === undefined) return null;
+ const value = Math.trunc(minutes);
+ if (
+ !Number.isFinite(value) ||
+ value < SCHEDULED_INTERVAL_MINUTES.min ||
+ value > SCHEDULED_INTERVAL_MINUTES.max
+ ) {
+ return null;
+ }
+ return value % 60 === 0
+ ? { unit: "hours", value: value / 60 }
+ : { unit: "minutes", value };
+}
+
+/** The same span in another unit, clamped into the range the host arms. */
+export function convertInterval(
+ value: number,
+ from: "minutes" | "hours",
+ to: "minutes" | "hours",
+): number {
+ if (from === to || !Number.isFinite(value)) return value;
+ if (to === "hours") {
+ return Math.min(SCHEDULED_INTERVAL_MINUTES.max / 60, Math.max(1, Math.round(value / 60)));
+ }
+ return Math.min(
+ SCHEDULED_INTERVAL_MINUTES.max,
+ Math.max(SCHEDULED_INTERVAL_MINUTES.min, Math.round(value * 60)),
+ );
+}
diff --git a/apps/desktop/src/features/scheduled/scheduled-labels.ts b/apps/desktop/src/features/scheduled/scheduled-labels.ts
index 10d700181..d1cd878cc 100644
--- a/apps/desktop/src/features/scheduled/scheduled-labels.ts
+++ b/apps/desktop/src/features/scheduled/scheduled-labels.ts
@@ -1,4 +1,6 @@
-import type { ScheduledTaskRun } from "@pi-desktop/shared";
+import type { TFunction } from "i18next";
+import type { ScheduledTask, ScheduledTaskCadence, ScheduledTaskRun } from "@pi-desktop/shared";
+import { intervalAmount } from "./scheduled-format";
/** One vocabulary for run status and cadence labels, shared by the rail, the
* history rows, the detail facts, and the run-content header. */
@@ -12,6 +14,28 @@ export const RUN_STATUS_I18N_KEYS: Record<ScheduledTaskRun["status"], string> =
export const CADENCE_I18N_KEYS = {
manual: "scheduled.cadenceManual",
hourly: "scheduled.cadenceHourly",
+ interval: "scheduled.interval",
daily: "scheduled.cadenceDaily",
weekly: "scheduled.cadenceWeekly",
} as const;
+
+/** Only a calendar cadence has a clock to report beside its name: an interval
+ * states elapsed minutes, and hourly counts from the moment it was armed. */
+export function cadenceHasClock(cadence: ScheduledTaskCadence): boolean {
+ return cadence === "daily" || cadence === "weekly";
+}
+
+/**
+ * A task's cadence in one phrase. An interval carries its own value — that
+ * value *is* the schedule — while a calendar cadence is named by its kind and
+ * reports its clock separately.
+ */
+export function cadenceLabel(t: TFunction, task: ScheduledTask): string {
+ const amount = intervalAmount(task.schedule?.intervalMinutes);
+ if (task.cadence !== "interval" || !amount) return t(CADENCE_I18N_KEYS[task.cadence]);
+ const value =
+ amount.unit === "hours"
+ ? t("scheduled.intervalHours", { count: amount.value })
+ : t("scheduled.intervalMinutes", { count: amount.value });
+ return t("scheduled.intervalEvery", { value });
+}
diff --git a/apps/desktop/src/features/scheduled/scheduled-workspace.css b/apps/desktop/src/features/scheduled/scheduled-workspace.css
index 3b55adaf8..acf706ec5 100644
--- a/apps/desktop/src/features/scheduled/scheduled-workspace.css
+++ b/apps/desktop/src/features/scheduled/scheduled-workspace.css
@@ -111,9 +111,11 @@
background: var(--ds-bg-hover);
}
+/* Selection has to read on both themes: the raised fill is white on white in
+ the light theme, so the row also carries an accent tint and a leading bar. */
.scheduled-task.is-selected {
- background: var(--ds-raised);
- box-shadow: var(--ds-raised-shadow);
+ background: color-mix(in oklab, var(--ds-accent) 12%, var(--ds-raised));
+ box-shadow: var(--ds-raised-shadow), inset 2px 0 0 var(--ds-accent);
}
.scheduled-task-title {
@@ -341,8 +343,11 @@
background: var(--ds-bg-hover);
}
+/* The selected run follows the task column's language: accent tint plus the
+ same leading bar, one step lighter because it sits inside a card. */
.scheduled-run.is-selected {
- background: var(--ds-bg-active);
+ background: color-mix(in oklab, var(--ds-accent) 10%, var(--ds-tile-deep));
+ box-shadow: inset 2px 0 0 var(--ds-accent);
}
.scheduled-run-main {
diff --git a/apps/desktop/src/pages/ScheduledPage.tsx b/apps/desktop/src/pages/ScheduledPage.tsx
index a6cd62298..40ba09cfb 100644
--- a/apps/desktop/src/pages/ScheduledPage.tsx
+++ b/apps/desktop/src/pages/ScheduledPage.tsx
@@ -102,7 +102,9 @@ export function ScheduledPage() {
</Panel>
) : null}
- {loaded && tasks.length > 0 ? (
+ {/* The form owns the page while it is open: the task column and the
+ selected task's page would only compete with the draft. */}
+ {loaded && tasks.length > 0 && !editor ? (
<div className="scheduled-workspace">
<ScheduledTaskRail
tasks={tasks}
diff --git a/apps/desktop/test/scheduled-workspace.test.mjs b/apps/desktop/test/scheduled-workspace.test.mjs
index dd022ad8b..e66eeebc4 100644
--- a/apps/desktop/test/scheduled-workspace.test.mjs
+++ b/apps/desktop/test/scheduled-workspace.test.mjs
@@ -7,6 +7,7 @@ import { I18nextProvider } from "react-i18next";
import { catalogs } from "@pi-desktop/i18n";
import { createServer } from "vite";
import { fileURLToPath } from "node:url";
+import { readFile } from "node:fs/promises";
const NOW = Date.parse("2026-01-02T12:00:00Z");
@@ -331,3 +332,110 @@ test("a run's transcript follows the run, not just its session", async () => {
assert.match(source, /run\.status !== "running"/, "an in-flight run keeps following it");
assert.match(source, /revision\.current\+\+/, "and a late response cannot overwrite a newer read");
});
+
+const TASK_INTERVAL = {
+ ...TASK_A,
+ id: "task-interval",
+ title: "Interval sweep",
+ cadence: "interval",
+ schedule: { hour: 0, minute: 0, weekday: 0, intervalMinutes: 90 },
+};
+
+/** A catalog lookup with the shape i18next gives `cadenceLabel`, so the shared
+ * phrasing can be asserted without a component around it. */
+function englishLookup() {
+ const scheduled = catalogs.en.scheduled;
+ return (key, options) => {
+ const name = key.replace("scheduled.", "");
+ const value = scheduled[name] ?? scheduled[`${name}_other`];
+ return String(value).replace(/\{\{(\w+)\}\}/g, (_, token) =>
+ String(options?.[token] ?? ""),
+ );
+ };
+}
+
+test("an interval task states its own span, never a clock", async () => {
+ await withVite(async (server) => {
+ const format = await server.ssrLoadModule("/src/features/scheduled/scheduled-format.ts");
+ assert.deepEqual(format.intervalAmount(30), { unit: "minutes", value: 30 });
+ assert.deepEqual(format.intervalAmount(90), { unit: "minutes", value: 90 });
+ assert.deepEqual(format.intervalAmount(120), { unit: "hours", value: 2 });
+ assert.deepEqual(format.intervalAmount(1440), { unit: "hours", value: 24 });
+ for (const value of [null, undefined, 0, 4, 1441, Number.NaN]) {
+ assert.equal(format.intervalAmount(value), null, `${value} is not an interval`);
+ }
+ assert.equal(format.SCHEDULED_INTERVAL_MINUTES.min, 5);
+ assert.equal(format.SCHEDULED_INTERVAL_MINUTES.max, 1440);
+
+ assert.equal(format.convertInterval(90, "minutes", "hours"), 2);
+ assert.equal(format.convertInterval(2, "hours", "minutes"), 120);
+ assert.equal(format.convertInterval(1, "hours", "hours"), 1);
+ assert.equal(format.convertInterval(0, "minutes", "hours"), 1);
+ assert.equal(format.convertInterval(99, "hours", "minutes"), 1440);
+
+ const labels = await server.ssrLoadModule("/src/features/scheduled/scheduled-labels.ts");
+ const t = englishLookup();
+ assert.equal(labels.cadenceLabel(t, TASK_INTERVAL), "Every 90 minutes");
+ assert.equal(
+ labels.cadenceLabel(t, {
+ ...TASK_INTERVAL,
+ schedule: { hour: 0, minute: 0, weekday: 0, intervalMinutes: 120 },
+ }),
+ "Every 2 hours",
+ );
+ assert.equal(labels.cadenceLabel(t, TASK_A), "Daily");
+ assert.equal(labels.cadenceLabel(t, { ...TASK_INTERVAL, schedule: null }), "Interval");
+ assert.equal(labels.cadenceHasClock("daily"), true);
+ assert.equal(labels.cadenceHasClock("weekly"), true);
+ assert.equal(labels.cadenceHasClock("interval"), false);
+
+ const rail = await render(server, "/src/features/scheduled/ScheduledTaskRail.tsx", "ScheduledTaskRail", {
+ tasks: [TASK_INTERVAL, TASK_B],
+ latestRuns: new Map([["task-interval", RUN_COMPLETED]]),
+ selectedTaskId: "task-interval",
+ now: NOW,
+ locale: "en",
+ onSelect() {},
+ });
+ assert.match(rail, /Every 90 minutes/);
+ assert.doesNotMatch(rail, /00:00/);
+ assert.match(rail, /Manual/);
+ });
+});
+
+test("the editor states an interval as a count plus its unit", async () => {
+ await withVite(async (server) => {
+ const editor = (task) =>
+ render(server, "/src/features/scheduled/ScheduledEditor.tsx", "ScheduledEditor", {
+ task,
+ projects: [],
+ currentWorkspacePath: "/Users/dev/project",
+ busy: false,
+ save: async () => {},
+ cancel() {},
+ });
+
+ const minutes = await editor(TASK_INTERVAL);
+ assert.match(minutes, /class="scheduled-interval"/);
+ assert.match(minutes, /value="90"/);
+ assert.match(minutes, /Minutes/);
+ assert.match(minutes, /Runs once per interval/);
+
+ const hours = await editor({
+ ...TASK_INTERVAL,
+ schedule: { hour: 0, minute: 0, weekday: 0, intervalMinutes: 120 },
+ });
+ assert.match(hours, /value="2"/);
+ assert.match(hours, /Hours/);
+
+ const calendar = await editor(TASK_A);
+ assert.doesNotMatch(calendar, /class="scheduled-interval"/);
+ assert.match(calendar, /09:05/);
+ });
+});
+
+test("the task form owns the Scheduled page while it is open", async () => {
+ const source = await readFile(new URL("../src/pages/ScheduledPage.tsx", import.meta.url), "utf8");
+ assert.match(source, /loaded && tasks\.length > 0 && !editor \?/);
+ assert.match(source, /className="scheduled-editor-slot"/);
+});
diff --git a/crates/host-core/src/rpc/scheduled_tools.rs b/crates/host-core/src/rpc/scheduled_tools.rs
index 3fb868516..887f0d993 100644
--- a/crates/host-core/src/rpc/scheduled_tools.rs
+++ b/crates/host-core/src/rpc/scheduled_tools.rs
@@ -20,13 +20,14 @@ pub fn definitions() -> Vec<Value> {
let fields = json!({
"title":{"type":"string","minLength":1,"maxLength":80},
"prompt":{"type":"string","minLength":1,"maxLength":64000},
- "cadence":{"type":"string","enum":["manual","hourly","daily","weekly"]},
+ "cadence":{"type":"string","enum":["manual","hourly","interval","daily","weekly"]},
"enabled":{"type":"boolean"},
"schedule":{"type":"object","additionalProperties":false,"required":["hour","minute","weekday"],"properties":{
"hour":{"type":"integer","minimum":0,"maximum":23},
"minute":{"type":"integer","minimum":0,"maximum":59},
"weekday":{"type":"integer","minimum":0,"maximum":6},
- "weekdays":{"type":"array","minItems":1,"maxItems":7,"uniqueItems":true,"items":{"type":"integer","minimum":0,"maximum":6}}
+ "weekdays":{"type":"array","minItems":1,"maxItems":7,"uniqueItems":true,"items":{"type":"integer","minimum":0,"maximum":6}},
+ "intervalMinutes":{"type":"integer","minimum":5,"maximum":1440}
}}
});
["ScheduledTaskList", "ScheduledTaskCreate", "ScheduledTaskUpdate", "ScheduledTaskDelete"].into_iter().map(|name| {
@@ -110,7 +111,7 @@ fn execute_inner(st: &AppState, p: &ToolsExecuteParams) -> Result<Value, JsonRpc
let cadence = match args.get("cadence") {
Some(value) => value
.as_str()
- .filter(|v| matches!(*v, "manual" | "hourly" | "daily" | "weekly"))
+ .filter(|v| matches!(*v, "manual" | "hourly" | "interval" | "daily" | "weekly"))
.ok_or_else(|| invalid("invalid cadence"))?,
None => existing
.as_ref()
@@ -208,6 +209,23 @@ mod tests {
use std::sync::Arc;
use tokio::sync::{mpsc, Mutex};
+ #[test]
+ fn tool_schema_offers_the_interval_cadence_and_its_value() {
+ let definitions = definitions();
+ let create = definitions
+ .iter()
+ .find(|item| item["name"] == "ScheduledTaskCreate")
+ .expect("the create tool is defined");
+ assert_eq!(
+ create["parameters"]["properties"]["cadence"]["enum"],
+ json!(["manual", "hourly", "interval", "daily", "weekly"])
+ );
+ assert_eq!(
+ create["parameters"]["properties"]["schedule"]["properties"]["intervalMinutes"],
+ json!({"type":"integer","minimum":5,"maximum":1440})
+ );
+ }
+
#[cfg(windows)]
#[tokio::test]
async fn review_ui_task_is_visible_to_same_project_conversation() {
diff --git a/crates/host-core/src/scheduled.rs b/crates/host-core/src/scheduled.rs
index 1159568aa..338efb12d 100644
--- a/crates/host-core/src/scheduled.rs
+++ b/crates/host-core/src/scheduled.rs
@@ -67,7 +67,7 @@ pub struct TaskRun {
pub ended_at: Option<String>,
}
-const CADENCES: [&str; 4] = ["manual", "hourly", "daily", "weekly"];
+const CADENCES: [&str; 5] = ["manual", "hourly", "interval", "daily", "weekly"];
fn normalize_cadence(value: Option<&str>) -> String {
match value {
diff --git a/crates/host-core/src/scheduled/automation.rs b/crates/host-core/src/scheduled/automation.rs
index ba0285937..3767b0da9 100644
--- a/crates/host-core/src/scheduled/automation.rs
+++ b/crates/host-core/src/scheduled/automation.rs
@@ -123,11 +123,21 @@ pub fn configure(config: &mut Value, input: &Value, cadence: &str, now: i64) ->
|| input.get("cadence").is_some()
|| input.get("enabled").is_some()
{
- let next = config
+ let armed = config
.get("schedule")
- .and_then(|value| serde_json::from_value::<Schedule>(value.clone()).ok())
- .and_then(|schedule| schedule.next(cadence, now));
- config["nextRunAt"] = json!(next);
+ .and_then(|value| serde_json::from_value::<Schedule>(value.clone()).ok());
+ // An interval task is armed by its own value: a schedule without
+ // intervalMinutes would leave the next occurrence empty, so the input
+ // is refused instead of saved as a task that never fires.
+ if cadence == "interval"
+ && armed
+ .as_ref()
+ .and_then(|schedule| schedule.interval_minutes)
+ .is_none()
+ {
+ bail!("an interval schedule requires intervalMinutes");
+ }
+ config["nextRunAt"] = json!(armed.and_then(|schedule| schedule.next(cadence, now)));
}
Ok(())
}
@@ -243,4 +253,49 @@ mod tests {
"aborted"
);
}
+
+ #[test]
+ fn interval_tasks_wait_their_own_minutes_and_need_their_value() {
+ let dir = tempfile::tempdir().unwrap();
+ let db = Database::open_in_dir(dir.path()).unwrap();
+ let rejected = create_task(
+ &db,
+ &json!({"prompt":"check", "cadence":"interval", "schedule":{"hour":0,"minute":0,"weekday":0}}),
+ );
+ assert!(
+ rejected.is_err(),
+ "an interval schedule without its value would never fire"
+ );
+
+ let task = create_task(
+ &db,
+ &json!({"prompt":"check", "cadence":"interval",
+ "schedule":{"hour":0,"minute":0,"weekday":0,"intervalMinutes":15}}),
+ )
+ .unwrap();
+ let next = crate::db::ts_to_ms(task.next_run_at.as_ref().unwrap());
+ let now = now_ms();
+ assert!(next > now && next <= now + 15 * 60_000 + 5_000);
+ assert!(due(&db, next - 60_000).unwrap().is_empty(), "not due yet");
+ assert_eq!(due(&db, next).unwrap(), vec![task.id.clone()]);
+
+ // A cadence switch keeps the value for the way back and arms the new
+ // rule from it instead.
+ let daily = update_task(
+ &db,
+ &json!({"id":task.id,"cadence":"daily",
+ "schedule":{"hour":9,"minute":30,"weekday":0,"intervalMinutes":15}}),
+ )
+ .unwrap()
+ .unwrap();
+ assert_eq!(daily.cadence, "daily");
+ assert_eq!(
+ daily
+ .schedule
+ .as_ref()
+ .and_then(|item| item.interval_minutes),
+ Some(15)
+ );
+ assert!(daily.next_run_at.is_some(), "a daily task keeps its clock");
+ }
}
diff --git a/crates/host-core/src/scheduled/timing.rs b/crates/host-core/src/scheduled/timing.rs
index 23f5c8dc7..cb0478c13 100644
--- a/crates/host-core/src/scheduled/timing.rs
+++ b/crates/host-core/src/scheduled/timing.rs
@@ -2,7 +2,15 @@ use anyhow::{bail, Result};
use chrono::{Datelike, Local, TimeZone, Timelike};
use serde::{Deserialize, Serialize};
-/// Daily/weekly schedules use local time; hourly schedules use elapsed time.
+/// Elapsed minutes between runs of an `interval` task: five minutes to 24
+/// hours. The floor keeps an occurrence from being skipped the moment it is
+/// admitted, because the host polls every 30 s and drops one more than 90 s
+/// late. Mirrored by `SCHEDULED_INTERVAL_MINUTES` in the renderer.
+pub const INTERVAL_MIN_MINUTES: u32 = 5;
+pub const INTERVAL_MAX_MINUTES: u32 = 1440;
+
+/// Daily/weekly schedules use local time; hourly and interval schedules count
+/// elapsed time.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct Schedule {
@@ -13,6 +21,10 @@ pub struct Schedule {
/// When present, replaces the legacy single weekday. Monday = 0.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub weekdays: Option<Vec<u32>>,
+ /// Elapsed minutes between runs of an `interval` task. Only that cadence
+ /// reads it, so switching cadence keeps the value for the way back.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub interval_minutes: Option<u32>,
}
impl Schedule {
@@ -32,6 +44,11 @@ impl Schedule {
bail!("weekdays must contain unique days from 0 to 6");
}
}
+ if let Some(minutes) = self.interval_minutes {
+ if !(INTERVAL_MIN_MINUTES..=INTERVAL_MAX_MINUTES).contains(&minutes) {
+ bail!("intervalMinutes must be between {INTERVAL_MIN_MINUTES} and {INTERVAL_MAX_MINUTES}");
+ }
+ }
Ok(())
}
@@ -40,12 +57,18 @@ impl Schedule {
}
fn next_in<T: TimeZone>(&self, cadence: &str, after: i64, zone: &T) -> Option<i64> {
- if self.validate().is_err() || !matches!(cadence, "hourly" | "daily" | "weekly") {
+ if self.validate().is_err()
+ || !matches!(cadence, "hourly" | "daily" | "weekly" | "interval")
+ {
return None;
}
if cadence == "hourly" {
return after.checked_add(3_600_000);
}
+ if cadence == "interval" {
+ let minutes = i64::from(self.interval_minutes?);
+ return after.checked_add(minutes.checked_mul(60_000)?);
+ }
let first = after
.div_euclid(60_000)
.checked_add(1)?
@@ -84,6 +107,7 @@ mod tests {
minute: 15,
weekday: 0,
weekdays: Some(vec![0, 2, 4]),
+ interval_minutes: None,
};
let monday = Utc
.with_ymd_and_hms(2026, 9, 21, 9, 15, 0)
@@ -146,6 +170,7 @@ mod tests {
minute: 15,
weekday: 0,
weekdays: None,
+ interval_minutes: None,
};
let start = Utc
.with_ymd_and_hms(2026, 9, 21, 10, 42, 37)
@@ -191,6 +216,7 @@ mod tests {
minute: 30,
weekday: 0,
weekdays: None,
+ interval_minutes: None,
};
assert_eq!(
spring.next("daily", timestamp("2026-03-08T06:00:00Z")),
@@ -201,6 +227,7 @@ mod tests {
minute: 30,
weekday: 0,
weekdays: None,
+ interval_minutes: None,
};
assert_eq!(
fall.next("daily", timestamp("2026-11-01T05:30:00Z")),
@@ -219,6 +246,7 @@ mod tests {
minute: 15,
weekday: 0,
weekdays: None,
+ interval_minutes: None,
};
let monday = Utc
.with_ymd_and_hms(2026, 9, 21, 9, 15, 0)
@@ -246,6 +274,7 @@ mod tests {
minute: 0,
weekday: 0,
weekdays: None,
+ interval_minutes: None,
}
.validate()
.is_err());
@@ -254,6 +283,7 @@ mod tests {
minute: 60,
weekday: 0,
weekdays: None,
+ interval_minutes: None,
}
.validate()
.is_err());
@@ -262,8 +292,62 @@ mod tests {
minute: 0,
weekday: 7,
weekdays: None,
+ interval_minutes: None,
}
.validate()
.is_err());
}
+
+ #[test]
+ fn interval_cadence_waits_its_own_minutes_and_requires_them() {
+ let start = Utc
+ .with_ymd_and_hms(2026, 9, 21, 10, 42, 37)
+ .unwrap()
+ .timestamp_millis();
+ let mut schedule = Schedule {
+ hour: 0,
+ minute: 0,
+ weekday: 0,
+ weekdays: None,
+ interval_minutes: Some(30),
+ };
+ assert_eq!(
+ schedule.next_in("interval", start, &Utc),
+ Some(start + 30 * 60_000),
+ "an interval task counts elapsed time, not a calendar"
+ );
+ schedule.interval_minutes = Some(INTERVAL_MIN_MINUTES);
+ assert_eq!(
+ schedule.next_in("interval", start, &Utc),
+ Some(start + 300_000)
+ );
+ schedule.interval_minutes = Some(INTERVAL_MAX_MINUTES);
+ assert_eq!(
+ schedule.next_in("interval", start, &Utc),
+ Some(start + 86_400_000)
+ );
+ assert_eq!(
+ schedule.next_in("hourly", start, &Utc),
+ Some(start + 3_600_000),
+ "another cadence spends its own rule, not the interval"
+ );
+ for minutes in [
+ Some(0),
+ Some(INTERVAL_MIN_MINUTES - 1),
+ Some(INTERVAL_MAX_MINUTES + 1),
+ ] {
+ schedule.interval_minutes = minutes;
+ assert!(schedule.validate().is_err());
+ assert_eq!(schedule.next_in("interval", start, &Utc), None);
+ }
+ schedule.interval_minutes = None;
+ assert!(schedule.validate().is_ok(), "the value is optional");
+ assert_eq!(
+ schedule.next_in("interval", start, &Utc),
+ None,
+ "an interval task without its value never fires"
+ );
+ schedule.interval_minutes = Some(30);
+ assert_eq!(schedule.next_in("interval", i64::MAX, &Utc), None);
+ }
}
diff --git a/docs/spec/03-runtime/04-data-storage.md b/docs/spec/03-runtime/04-data-storage.md
index 85bba6989..02dfba58e 100644
--- a/docs/spec/03-runtime/04-data-storage.md
+++ b/docs/spec/03-runtime/04-data-storage.md
@@ -1105,7 +1105,7 @@ CREATE TABLE scheduled_tasks (
id TEXT PRIMARY KEY,
title TEXT NOT NULL,
prompt TEXT NOT NULL,
- cadence TEXT NOT NULL DEFAULT 'manual', -- manual | hourly | daily | weekly
+ cadence TEXT NOT NULL DEFAULT 'manual', -- manual | hourly | interval | daily | weekly
enabled INTEGER NOT NULL DEFAULT 1,
project_id INTEGER REFERENCES projects(id) ON DELETE SET NULL,
config_json TEXT NOT NULL DEFAULT '{}', -- mode, cron expr, model override, notify policy
@@ -1134,14 +1134,20 @@ SessionList and session search hide the transcript while it has a run, and
deleting the task returns it to the ordinary lists instead of leaving it
unreachable (issue #1291).
The existing JSON extension stores `schedule: {hour, minute, weekday}`,
-`nextRunAt` (epoch milliseconds), `workspacePath`, and `sessionMode` (`perRun` or
-`reuse`, absent means `perRun`) for desktop automations.
+`intervalMinutes` (5–1440; required by an `interval` cadence and read by no other
+one, so a schedule that keeps the field keeps its value), `nextRunAt` (epoch
+milliseconds), `workspacePath`, and `sessionMode` (`perRun` or `reuse`, absent
+means `perRun`) for desktop automations.
Optional `weekdays` stores 1–7 unique integers in 0–6, overriding legacy
`weekday` for weekly schedules. Missing `weekdays` preserves the single-day
behavior. Invalid or empty selections are rejected before mutation. No table
migration is needed. Daily/weekly schedules use the host local timezone; hourly
-schedules compute `nextRunAt = now + 3_600_000`, ignoring calendar fields. Absence
-of `schedule` leaves legacy tasks unarmed. No physical schema change is made.
+and interval schedules count elapsed time from the moment they were armed:
+hourly computes `nextRunAt = now + 3_600_000` and interval computes
+`nextRunAt = now + intervalMinutes × 60_000`, both ignoring calendar fields.
+An `interval` task whose schedule carries no `intervalMinutes` is refused rather
+than saved unarmed. Absence of `schedule` leaves legacy tasks unarmed. No
+physical schema change is made.
Task wire fields project `schedule`, RFC3339 `nextRunAt`, `workspacePath` and the
optional task-owned `permissionMode` plus paired `providerId`/`modelId` values.
These additive values stay in `config_json`; no physical migration is required.
diff --git a/docs/spec/04-ux/01-ui-ia.md b/docs/spec/04-ux/01-ui-ia.md
index 413348faa..dc4388616 100644
--- a/docs/spec/04-ux/01-ui-ia.md
+++ b/docs/spec/04-ux/01-ui-ia.md
@@ -246,7 +246,9 @@ destination, chat as the home surface, tools and permissions inline.
### 3.3 Scheduled
A task column beside the selected task's page, with an explicit create/edit form, a cadence dropdown, time,
next occurrence, saved project, per-task permission/model selection, a per-task conversation mode (a new conversation per run, or one conversation every run continues), pause/resume and delete confirmation. Hourly
-schedules repeat at one-hour intervals without a time selector. Daily schedules
+schedules repeat at one-hour intervals without a time selector. An interval
+schedule states its own span as a count with a minute or hour unit (5 minutes to
+24 hours) and counts elapsed time from the moment it was armed. Daily schedules
use a themed time-period dropdown: Morning 09:00, Afternoon 14:00, Evening
19:00, Night 22:00. The form does not expose hour/minute editing. AI tools may
set an exact time; a non-preset time displays as Custom with its HH:mm value
@@ -255,6 +257,11 @@ separate dropdown listing Monday through Sunday with selection markers.
Each day toggles independently; there are no preset combinations. An empty
selection disables saving. The menu supports arrows, Home/End, Enter/Space,
Escape/outside dismissal, and exposes selected states. The column reports each
+Escape/outside dismissal, exposes selected states, and owns the page while it is
+open: the task column and the task page step aside rather than compete with the
+draft. The form also states an interval as a count with a minute or hour unit
+(5 minutes to 24 hours) and keeps that value while another cadence is selected,
+so switching a task between a calendar and an interval loses neither.
task's cadence and clock, the outcome of its newest run with its duration, and
whether it is paused or running. The task page shows that task's last run, next
occurrence, project, permission and model, its instruction behind a disclosure,
diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.md
index 87c05be16..d44f696b3 100644
--- a/docs/spec/04-ux/08-component-spec.md
+++ b/docs/spec/04-ux/08-component-spec.md
@@ -4114,7 +4114,8 @@ TASKS (2) │ Nightly dependency check [Enabled] [Run now]
| State | Appearance |
|---|---|
-| Selected task | Raised tile with the shared raised shadow, and one `aria-current="true"` |
+| Selected task | Accent-tinted raised tile with the shared raised shadow and a 2px accent bar on the leading edge, and one `aria-current="true"`. The tint matters in both themes: a plain raised fill is white on white in the light theme |
+| Selected run | The same accent tint with the leading bar, one step lighter because the row sits inside a card |
| Running task | Warning-coloured dot in the row plus a `Running / awaiting input` badge |
| Paused task | `Disabled` chip; the row still reports its last outcome |
| Never run | `Not run yet` in the row's outcome line |
@@ -4137,6 +4138,12 @@ TASKS (2) │ Nightly dependency check [Enabled] [Run now]
- The conversation mode decides who owns a run's transcript: `perRun` opens a
conversation for each run, and `reuse` continues the task's previous one while
it still exists and still belongs to the same project.
+- The task form owns the page while it is open: the task column and the task
+ page are not rendered, so the draft never competes with the page it came from.
+- An interval task states a count with a minute or hour unit (5 minutes to 24
+ hours, stored as minutes, refused outside that range). The value rides along
+ with every armed cadence, so switching between a calendar and an interval
+ loses neither, and the row reports the span instead of a clock.
- Open conversation is the only action that leaves for the chat route. A
scheduled run's conversation then shows a back row in the chat top bar,
labelled with the route and, when the row's own origin is known, the task it
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 0d3c9b3a7..c6d44913f 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -415,6 +415,10 @@
select custom days, save and reopen; reject empty days; verify the four defaults,
arrows, Home/End, Enter, Escape/Tab and outside dismissal; select hourly without time
fields and verify its first occurrence is one hour away; pause/resume; Run now
+ select an interval cadence, enter 30 minutes and verify the row states that
+ span instead of a clock, then switch to a weekly cadence and back to confirm
+ the value survived; open the edit form and verify the task column and the task
+ page step aside;
and read the admitted run's transcript inside the task page; open the result
conversation from that page and verify its top bar offers the way back to the
scheduled task; return and confirm the same task and run are still selected;
@@ -431,7 +435,9 @@
not dispatch, both execution paths reach the real Agent sidecar, the task's own
history lists each run with its status and duration and Open conversation
reaches the persisted transcript while the SessionList and session search never
- list it, that conversation's top bar returns to the same task and run, and
+ list it, that conversation's top bar returns to the same task and run, an
+ interval task arms from the span the form states and reports it in its row,
+ the task form owns the page while it is open, and
automatic execution does not require a
renderer prompt. Host tests additionally prove duplicate admission rejection,
stale/missed occurrence handling, invalid input rejection and recovery.
diff --git a/docs/zh-CN/spec/03-runtime/04-data-storage.md b/docs/zh-CN/spec/03-runtime/04-data-storage.md
index 6b568b7bb..79c64a15d 100644
--- a/docs/zh-CN/spec/03-runtime/04-data-storage.md
+++ b/docs/zh-CN/spec/03-runtime/04-data-storage.md
@@ -891,7 +891,7 @@ CREATE TABLE scheduled_tasks (
id TEXT PRIMARY KEY,
title TEXT NOT NULL,
prompt TEXT NOT NULL,
- cadence TEXT NOT NULL DEFAULT 'manual', -- manual | hourly | daily | weekly
+ cadence TEXT NOT NULL DEFAULT 'manual', -- manual | hourly | interval | daily | weekly
enabled INTEGER NOT NULL DEFAULT 1,
project_id INTEGER REFERENCES projects(id) ON DELETE SET NULL,
config_json TEXT NOT NULL DEFAULT '{}', -- mode, cron expr, model override, notify policy
@@ -914,11 +914,11 @@ CREATE INDEX idx_task_runs ON task_runs(task_id, started_at DESC);
生成会话的运行通过 `session_id` 免费获取其转录本。
该转录本通过针对 `task_runs` 的 `EXISTS` 判断被识别为自动化产出,每个会话摘要与搜索命中都以 `scheduledRun` 返回这一归属。归属在读取时派生、不写入会话行:因此在该会话仍属于某次运行时,会话列表与会话搜索会隐藏它;删除任务后它会回到普通列表,而不会变得无法访问(issue #1291)。
-`config_json` 保存 `schedule: {hour, minute, weekday}`、毫秒时间戳 `nextRunAt`、
+`config_json` 保存 `schedule: {hour, minute, weekday}`、`intervalMinutes`(5–1440,只有 `interval` 周期读取,因此保留该字段的排程会保留它的值)、毫秒时间戳 `nextRunAt`、
`workspacePath`、会话模式 `sessionMode`(`perRun` 或 `reuse`,缺失按 `perRun`),以及可选的任务级 `permissionMode` 与成对的 `providerId`/`modelId`。
这些新增字段无需物理表迁移。缺少模型字段时仍在运行时读取应用默认值;缺少权限字段时,
-自动运行继续使用 Ask,立即运行继续继承全局权限。每天、每周按宿主本地时区计算。每小时采用 `nextRunAt = now + 3_600_000`,
-忽略日历时间字段。可选 `weekdays` 保存 1–7 个不重复的 0–6 整数,覆盖每周的旧 `weekday`;
+自动运行继续使用 Ask,立即运行继续继承全局权限。每天、每周按宿主本地时区计算;每小时与间隔按准入时刻起算的经过时间计算:每小时采用 `nextRunAt = now + 3_600_000`,间隔采用 `nextRunAt = now + intervalMinutes × 60_000`,两者都忽略日历时间字段。
+`interval` 任务的排程若缺少 `intervalMinutes`,写入会被拒绝,而不是保存成永不触发的任务。可选 `weekdays` 保存 1–7 个不重复的 0–6 整数,覆盖每周的旧 `weekday`;
缺失时保留单日语义,空数组、重复或越界值在写入前拒绝。无需表结构迁移。
无 `schedule` 的旧任务不会自动运行;无需修改表或迁移数据库。见 ADR 0305。
diff --git a/docs/zh-CN/spec/04-ux/01-ui-ia.md b/docs/zh-CN/spec/04-ux/01-ui-ia.md
index 09a8609fc..12b43f755 100644
--- a/docs/zh-CN/spec/04-ux/01-ui-ia.md
+++ b/docs/zh-CN/spec/04-ux/01-ui-ia.md
@@ -203,10 +203,12 @@
### 3. 3 定时任务
任务列与所选任务的页面并排展示,支持创建、编辑、暂停、启用和确认删除。表单可为每个任务单独选择项目、权限、模型与会话模式(每次新开会话或复用同一会话)。周期保留下拉选择,并与时分统一为自定义主题菜单。每小时按一小时间隔执行,不显示时间选择;保存、启用、启动或上次自动准入后重新计时。
+间隔直接给出跨度:数量加分钟或小时单位(5 分钟至 24 小时),从准入时刻起算。
每天通过下拉框选择上午 09:00、下午 14:00、晚上 19:00、夜间 22:00;
界面不提供时分编辑,AI 可设置具体时间,非预设值显示为自定义时间,其他字段的编辑不得覆盖它。每周通过独立下拉面板多选周一至周日,
右侧显示选中标记,不提供快捷组合。至少选择一天才能保存。支持方向键、Home/End、Enter/Space
选择及 Escape/外部点击关闭,选项具有选中状态语义。
+表单打开时独占本页:任务列与任务页面让位,不与草稿争夺空间;间隔值在切换到其他周期时保留,日历与间隔之间来回切换都不会丢失。
每天、每周按电脑本地时区计算并显示下次执行时间。
任务列显示每个任务的周期与时间、最近一次运行的结果与耗时,以及暂停或运行中状态;任务页面显示该任务的上次运行、下次执行、项目、权限与模型,指令默认折叠,运行记录只列本任务的运行(状态、开始时间、耗时与稳定错误码,最新在前),并在页内按有界读取展示所选运行的转写。运行的转写属于本页面:会话列表与全局搜索不再列出它,只有“打开会话”这个显式动作才会把它带入对话页,对话顶部栏随后为这段会话提供返回入口(入口标注它所属的任务;返回后仍选中同一个任务与同一次运行,若本页紧邻其后则直接复用导航历史)。侧边栏时钟与全局搜索均可进入。立即运行在后台执行并选中刚准入的那次运行,读者仍停留在本页。
diff --git a/docs/zh-CN/spec/04-ux/08-component-spec.md b/docs/zh-CN/spec/04-ux/08-component-spec.md
index 3007d8066..f8806901e 100644
--- a/docs/zh-CN/spec/04-ux/08-component-spec.md
+++ b/docs/zh-CN/spec/04-ux/08-component-spec.md
@@ -2883,7 +2883,8 @@ Sidebar footer Popover (360px max)
| 状态 | 外观 |
|---|---|
-| 选中任务 | 抬升底板与共享抬升阴影,且只有一处 `aria-current="true"` |
+| 选中任务 | 带强调色底纹的抬升底板、共享抬升阴影,以及前缘 2px 强调色竖条,且只有一处 `aria-current="true"`。底纹在两种主题下都必需:亮色主题里纯抬升底板是白底白 |
+| 选中运行 | 与任务行相同的强调色底纹与前缘竖条,因为位于卡片内而略浅一档 |
| 运行中任务 | 行内警告色圆点,并显示「运行中/等待输入」徽章 |
| 已暂停任务 | `已禁用` 标签;该行仍显示上次运行结果 |
| 尚未运行 | 结果行显示「尚未运行」 |
@@ -2902,6 +2903,8 @@ Sidebar footer Popover (360px max)
- 指令按需展开,默认折叠。
- 立即运行在后台执行,选中刚准入的那次运行,读者仍停留在本页面。
- 会话模式决定运行转写的归属:`perRun` 为每次运行新开一段会话;`reuse` 在该任务上一次会话仍存在、且仍属于同一项目时继续使用它。
+- 表单打开时独占本页:任务列与任务页面不再渲染,草稿不会与它来源的页面争夺空间。
+- 间隔任务给出数量加分钟或小时单位(5 分钟至 24 小时,以分钟存储,超出范围会被拒绝)。该值随每个已排程周期一并保存,日历与间隔之间来回切换都不会丢失;任务行显示跨度而不是时钟。
- 「打开会话」是唯一离开本页面进入对话页的动作。定时任务的会话随后在对话顶部栏显示返回行,行上标注目标页面(已知来源时还标注所属任务);返回后恢复同一个任务与同一次运行,若本页紧邻该会话之后则沿导航历史后退。
- 宽度大于 900px 时任务列吸附在标题栏下方;更窄时任务列堆叠在页面上方。
- 动画仅使用颜色与箭头过渡,并在 `prefers-reduced-motion` 下关闭,包括运行中圆点的脉冲。
diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
index 81256e94d..b034a6942 100644
--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
@@ -8717,10 +8717,11 @@ the latest destination. These assertions measure work counts, not device FPS.
- **步骤:** 点击页脚时钟;创建每天上午 09:00 的任务;选择另一个已保存项目、Auto 权限和非默认模型;编辑名称;暂停/启用;立即运行并在任务页面内读取刚准入运行的转写;从该页面打开结果会话,确认顶部栏提供返回定时任务的入口,返回后仍选中同一个任务与同一次运行;验证周期/四个时段主题下拉菜单、星期多选及选中标记、保存回显、空选择与固定时间;
验证方向键、Home/End、Enter、Escape/Tab 和外部点击关闭;
验证每小时无时间输入且首次等待一小时;设置每天任务在下一个真实分钟执行;
+ 选择间隔周期并填入 30 分钟,确认任务行显示该跨度而不是时钟,再切到每周周期后切回,确认该值仍然保留;打开编辑表单,确认任务列与任务页面让位;
观察自动完成;删除已结束的任务。普通 Agent 对话经模型工具调用发现、创建、查询、
修改任务到 15:30,再删除;验证页面显示具体时间,改名保存不覆盖。模型为本地确定性夹具。
- **预期:** 项目、权限和精确 provider/model 只保存在该任务,重新打开仍显示相同值并实际传到 sidecar,其他任务不受影响;项目、权限和模型控件保持嵌在“指令”框的 Composer 风格底栏中,窄窗口也不产生横向溢出;缺少新增字段的旧记录保持原默认行为。配置持久化并显示下次时间;暂停后不触发;手动与自动入口均调用真实
- Agent sidecar;本任务的运行记录列出每次运行的状态与耗时,「打开会话」到达持久化会话,而会话列表与会话搜索不会列出它,该会话顶部栏可返回同一个任务与同一次运行;自动执行不依赖渲染器发送提示词。
+ Agent sidecar;本任务的运行记录列出每次运行的状态与耗时,「打开会话」到达持久化会话,而会话列表与会话搜索不会列出它,该会话顶部栏可返回同一个任务与同一次运行;间隔任务按表单给出的跨度排程并在任务行中显示,表单打开时独占本页;自动执行不依赖渲染器发送提示词。
宿主测试补充验证重复准入、错过时段、无效输入和重启恢复。
- **规格:** 04-ux/01-ui-ia §3.3;04-ux/08-component-spec §6、§20A;03-runtime/04-data-storage §4.11;
ADR scheduled-desktop-automations;ADR 0305。
diff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.ts
index 1046527ba..4ac094496 100644
--- a/packages/i18n/src/locales/de/index.ts
+++ b/packages/i18n/src/locales/de/index.ts
@@ -1785,6 +1785,15 @@ sklm: {
"cadenceHourly": "Stündlich",
"cadenceDaily": "Täglich",
"cadenceWeekly": "Wöchentlich",
+ "interval": "Intervall",
+ "intervalEvery": "Alle {{value}}",
+ "intervalMinutes_one": "{{count}} Minute",
+ "intervalMinutes_other": "{{count}} Minuten",
+ "intervalHours_one": "{{count}} Stunde",
+ "intervalHours_other": "{{count}} Stunden",
+ "intervalUnitMinutes": "Minuten",
+ "intervalUnitHours": "Stunden",
+ "intervalHint": "Läuft einmal pro Intervall, erstmals ein Intervall nach dem Speichern oder Aktivieren. Ein App-Neustart startet das Intervall neu.",
"enabled": "Aktiviert",
"disabled": "Deaktiviert",
"runNow": "Jetzt ausführen",
diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.ts
index 67dd5610c..3fbb662d0 100644
--- a/packages/i18n/src/locales/en/index.ts
+++ b/packages/i18n/src/locales/en/index.ts
@@ -1808,6 +1808,15 @@ sklm: {
cadenceHourly: "Hourly",
cadenceDaily: "Daily",
cadenceWeekly: "Weekly",
+ interval: "Interval",
+ intervalEvery: "Every {{value}}",
+ intervalMinutes_one: "{{count}} minute",
+ intervalMinutes_other: "{{count}} minutes",
+ intervalHours_one: "{{count}} hour",
+ intervalHours_other: "{{count}} hours",
+ intervalUnitMinutes: "Minutes",
+ intervalUnitHours: "Hours",
+ intervalHint: "Runs once per interval, starting one interval after saving or enabling. Restarting the app starts a new interval.",
enabled: "Enabled",
disabled: "Disabled",
runNow: "Run now",
diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.ts
index 57e17e322..ca0c3a2fa 100644
--- a/packages/i18n/src/locales/es/index.ts
+++ b/packages/i18n/src/locales/es/index.ts
@@ -1785,6 +1785,15 @@ sklm: {
"cadenceHourly": "Cada hora",
"cadenceDaily": "Diario",
"cadenceWeekly": "Semanal",
+ "interval": "Intervalo",
+ "intervalEvery": "Cada {{value}}",
+ "intervalMinutes_one": "{{count}} minuto",
+ "intervalMinutes_other": "{{count}} minutos",
+ "intervalHours_one": "{{count}} hora",
+ "intervalHours_other": "{{count}} horas",
+ "intervalUnitMinutes": "Minutos",
+ "intervalUnitHours": "Horas",
+ "intervalHint": "Se ejecuta una vez por intervalo, desde un intervalo después de guardar o activar. Reiniciar la app inicia un intervalo nuevo.",
"enabled": "Habilitado",
"disabled": "Deshabilitado",
"runNow": "Ejecutar ahora",
diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.ts
index 417cc1c87..1c6a32753 100644
--- a/packages/i18n/src/locales/fr/index.ts
+++ b/packages/i18n/src/locales/fr/index.ts
@@ -1785,6 +1785,15 @@ sklm: {
"cadenceHourly": "Toutes les heures",
"cadenceDaily": "Quotidien",
"cadenceWeekly": "Hebdomadaire",
+ "interval": "Intervalle",
+ "intervalEvery": "Toutes les {{value}}",
+ "intervalMinutes_one": "{{count}} minute",
+ "intervalMinutes_other": "{{count}} minutes",
+ "intervalHours_one": "{{count}} heure",
+ "intervalHours_other": "{{count}} heures",
+ "intervalUnitMinutes": "Minutes",
+ "intervalUnitHours": "Heures",
+ "intervalHint": "Une exécution par intervalle, la première un intervalle après enregistrement ou activation. Redémarrer l’application relance l’intervalle.",
"enabled": "Activé",
"disabled": "Désactivé",
"runNow": "Exécuter maintenant",
diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.ts
index 67fb7236c..f2a38bcee 100644
--- a/packages/i18n/src/locales/ko/index.ts
+++ b/packages/i18n/src/locales/ko/index.ts
@@ -1800,6 +1800,15 @@ sklm: {
cadenceHourly: "매시간",
cadenceDaily: "매일",
cadenceWeekly: "매주",
+ interval: "간격",
+ intervalEvery: "{{value}}마다",
+ intervalMinutes_one: "{{count}}분",
+ intervalMinutes_other: "{{count}}분",
+ intervalHours_one: "{{count}}시간",
+ intervalHours_other: "{{count}}시간",
+ intervalUnitMinutes: "분",
+ intervalUnitHours: "시간",
+ intervalHint: "저장하거나 사용 설정한 뒤 한 간격이 지나면 처음 실행됩니다. 앱을 다시 시작하면 간격이 새로 시작됩니다.",
enabled: "활성화됨",
disabled: "비활성화됨",
runNow: "지금 실행",
diff --git a/packages/i18n/src/locales/pt-BR/index.ts b/packages/i18n/src/locales/pt-BR/index.ts
index 38092f128..1a3e60627 100644
--- a/packages/i18n/src/locales/pt-BR/index.ts
+++ b/packages/i18n/src/locales/pt-BR/index.ts
@@ -1740,6 +1740,15 @@ export const ptBR = {
cadenceHourly: "A cada hora",
cadenceDaily: "Diário",
cadenceWeekly: "Semanal",
+ interval: "Intervalo",
+ intervalEvery: "A cada {{value}}",
+ intervalMinutes_one: "{{count}} minuto",
+ intervalMinutes_other: "{{count}} minutos",
+ intervalHours_one: "{{count}} hora",
+ intervalHours_other: "{{count}} horas",
+ intervalUnitMinutes: "Minutos",
+ intervalUnitHours: "Horas",
+ intervalHint: "Executa uma vez por intervalo, começando um intervalo após salvar ou ativar. Reiniciar o app inicia um novo intervalo.",
enabled: "Ativada",
disabled: "Desativada",
runNow: "Executar agora",
diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.ts
index 4222761a0..bbca80d00 100644
--- a/packages/i18n/src/locales/tr/index.ts
+++ b/packages/i18n/src/locales/tr/index.ts
@@ -1790,6 +1790,15 @@ sklm: {
cadenceHourly: "Saatlik",
cadenceDaily: "Günlük",
cadenceWeekly: "Haftalık",
+ interval: "Aralık",
+ intervalEvery: "Her {{value}}",
+ intervalMinutes_one: "{{count}} dakika",
+ intervalMinutes_other: "{{count}} dakika",
+ intervalHours_one: "{{count}} saat",
+ intervalHours_other: "{{count}} saat",
+ intervalUnitMinutes: "Dakika",
+ intervalUnitHours: "Saat",
+ intervalHint: "Kaydettikten veya etkinleştirdikten sonra bir aralık geçince ilk kez çalışır. Uygulamayı yeniden başlatmak aralığı sıfırlar.",
enabled: "Açık",
disabled: "Kapalı",
runNow: "Şimdi çalıştır",
diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.ts
index aee084c71..8bdff779b 100644
--- a/packages/i18n/src/locales/zh-CN/index.ts
+++ b/packages/i18n/src/locales/zh-CN/index.ts
@@ -1771,6 +1771,15 @@ sklm: {
cadenceHourly: "每小时",
cadenceDaily: "每天",
cadenceWeekly: "每周",
+ interval: "间隔",
+ intervalEvery: "每 {{value}}",
+ intervalMinutes_one: "{{count}} 分钟",
+ intervalMinutes_other: "{{count}} 分钟",
+ intervalHours_one: "{{count}} 小时",
+ intervalHours_other: "{{count}} 小时",
+ intervalUnitMinutes: "分钟",
+ intervalUnitHours: "小时",
+ intervalHint: "保存、启用或重启应用后等待一个间隔执行第一次。",
enabled: "已启用",
disabled: "已禁用",
runNow: "立即运行",
diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.ts
index f72b6521d..7d4fa5fa4 100644
--- a/packages/i18n/src/locales/zh-TW/index.ts
+++ b/packages/i18n/src/locales/zh-TW/index.ts
@@ -1771,6 +1771,15 @@ sklm: {
cadenceHourly: "每小時",
cadenceDaily: "每天",
cadenceWeekly: "每週",
+ interval: "間隔",
+ intervalEvery: "每 {{value}}",
+ intervalMinutes_one: "{{count}} 分鐘",
+ intervalMinutes_other: "{{count}} 分鐘",
+ intervalHours_one: "{{count}} 小時",
+ intervalHours_other: "{{count}} 小時",
+ intervalUnitMinutes: "分鐘",
+ intervalUnitHours: "小時",
+ intervalHint: "儲存、啟用或重新啟動應用程式後,等待一個間隔執行第一次。",
enabled: "已啟用",
disabled: "已停用",
runNow: "立即執行",
diff --git a/packages/shared/src/types/platform.ts b/packages/shared/src/types/platform.ts
index 650676010..6db64cf0c 100644
--- a/packages/shared/src/types/platform.ts
+++ b/packages/shared/src/types/platform.ts
@@ -92,7 +92,7 @@ export type OnboardingState = {
};
-export type ScheduledTaskCadence = "manual" | "hourly" | "daily" | "weekly";
+export type ScheduledTaskCadence = "manual" | "hourly" | "interval" | "daily" | "weekly";
export type ScheduledTaskSchedule = {
hour: number;
minute: number;
@@ -100,6 +100,13 @@ export type ScheduledTaskSchedule = {
weekday: number;
/** Selected days, Monday = 0. When present, must be nonempty and unique. */
weekdays?: number[];
+ /**
+ * Elapsed minutes between runs of an `interval` task. That cadence requires
+ * it and no other cadence reads it, so switching back to a calendar keeps
+ * the value for the way back. 5–1440, mirroring `INTERVAL_MIN_MINUTES` and
+ * `INTERVAL_MAX_MINUTES` in `crates/host-core/src/scheduled/timing.rs`.
+ */
+ intervalMinutes?: number;
};
export type ScheduledTaskRun = {
id: string; taskId: string; sessionId: string | null;