Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(scheduler): 限制分钟间隔为整小时槽位 (#4847)

DavidShenXDe8179c4733c9
diff --git a/apps/desktop/src/main/cindy-make/__tests__/versionStartup.test.ts b/apps/desktop/src/main/cindy-make/__tests__/versionStartup.test.ts
index f0c6e8ab79..89abfd5945 100644
--- a/apps/desktop/src/main/cindy-make/__tests__/versionStartup.test.ts
+++ b/apps/desktop/src/main/cindy-make/__tests__/versionStartup.test.ts
@@ -145,7 +145,16 @@ afterEach(async () => {
else Reflect.deleteProperty(process, 'resourcesPath');
vi.restoreAllMocks();
vi.unstubAllEnvs();
- if (root) await rm(root, { recursive: true, force: true });
+ if (root)
+ await rm(root, {
+ recursive: true,
+ force: true,
+ // Windows may briefly retain a lock/reclaim entry while the async
+ // version-store cleanup has just completed. Match the production
+ // cleanup retry policy so test teardown does not race that release.
+ maxRetries: 3,
+ retryDelay: 100,
+ });
});
function saveOriginal() {
store.writeVersionJson(path.join(store.versionsRoot(h.profile), 'original.json'), original);
diff --git a/apps/desktop/src/renderer/__tests__/cindyMakeInlineEntry.test.ts b/apps/desktop/src/renderer/__tests__/cindyMakeInlineEntry.test.ts
index 03b5af44f3..0e35f31834 100644
--- a/apps/desktop/src/renderer/__tests__/cindyMakeInlineEntry.test.ts
+++ b/apps/desktop/src/renderer/__tests__/cindyMakeInlineEntry.test.ts
@@ -147,4 +147,30 @@ describe('Cindy Make composer presentation', () => {
}
}
});
+
+ it('keeps recovery actions inside the editable composer instead of replacing it', () => {
+ const ast = ts.createSourceFile('session.tsx', sessionView, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
+ let topSlot: ts.JsxAttribute | undefined;
+ let inputLock: ts.Expression | undefined;
+ const visit = (node: ts.Node) => {
+ if ((ts.isJsxSelfClosingElement(node) || ts.isJsxOpeningElement(node))
+ && node.tagName.getText(ast) === 'ChatInput') {
+ topSlot = node.attributes.properties.find((prop): prop is ts.JsxAttribute =>
+ ts.isJsxAttribute(prop) && prop.name.getText(ast) === 'topSlot');
+ }
+ if (ts.isVariableDeclaration(node) && node.name.getText(ast) === 'cindyMakeInputLocked') {
+ inputLock = node.initializer;
+ }
+ ts.forEachChild(node, visit);
+ };
+ visit(ast);
+ expect(topSlot).toBeDefined();
+ expect(topSlot!.getText(ast)).toMatch(/cindyMakeRecoveryId\s*&&\s*session\s*\?/);
+ expect(topSlot!.getText(ast)).toContain('<CindyMakeEditingActions');
+ expect(topSlot!.getText(ast)).toContain('sessionId={session.id}');
+ expect(topSlot!.getText(ast)).toContain('messageId={cindyMakeRecoveryId}');
+ expect(inputLock).toBeDefined();
+ expect(inputLock!.getText(ast)).toContain('cindyMakeComposerPhase || cindyMakePendingTest');
+ expect(inputLock!.getText(ast)).not.toContain('cindyMakeRecoveryId');
+ });
});
diff --git a/apps/desktop/src/renderer/features/scheduler/components/ScheduleChips.tsx b/apps/desktop/src/renderer/features/scheduler/components/ScheduleChips.tsx
index bd98f5aded..174bc2ee4b 100644
--- a/apps/desktop/src/renderer/features/scheduler/components/ScheduleChips.tsx
+++ b/apps/desktop/src/renderer/features/scheduler/components/ScheduleChips.tsx
@@ -5,6 +5,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { ChevronDown, ExternalLink, Folder, MessageCircle, Timer, SlidersHorizontal } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { Popover, PopoverTrigger, PopoverContent } from '@/components/ui/popover';
+import { Select } from '@/components/ui/select';
import { Tip } from '@/components/ui/tooltip';
import {
addRecentFolder,
@@ -37,6 +38,9 @@ import {
switchScheduleTimingMode,
WEEKDAY_LABELS,
DEFAULT_CONFIG,
+ isSupportedIntervalMinutes,
+ resolveIntervalMinutesPresetValue,
+ SUPPORTED_INTERVAL_MINUTES,
type CodexScheduleConfig,
} from '../lib/cronCodexPreset';
import { getScheduleDefaultModel, type EffortValue } from '../hooks/useScheduleForm';
@@ -384,10 +388,15 @@ export function ScheduleChip({
};
const setMode = (mode: EditableScheduleMenuMode) => {
+ // Re-selecting the visible mode is not an instruction to replace a legacy value.
+ // An exact interval has its own activeMode and can still enter a supported preset.
+ if (mode === 'intervalMinutes' && mode === activeMode) return;
+ // Exact intervals have no preset config; their compatibility Cron is not authoritative.
+ const presetConfig = activeMode === 'exactInterval' ? DEFAULT_CONFIG : config;
const patch: Partial<CodexScheduleConfig> = { mode };
- if (mode === 'interval') patch.intervalHours = config.mode === 'interval' ? config.intervalHours : 1;
+ if (mode === 'interval') patch.intervalHours = presetConfig.mode === 'interval' ? presetConfig.intervalHours : 1;
if (mode === 'intervalMinutes') {
- patch.intervalMinutes = config.mode === 'intervalMinutes' ? config.intervalMinutes : 5;
+ patch.intervalMinutes = resolveIntervalMinutesPresetValue(presetConfig);
}
update(patch);
};
@@ -521,11 +530,20 @@ function ScheduleConfigPanel({
<div className="flex min-h-[34px] w-full items-center gap-1.5">
<IntervalMinutesInput
value={panelConfig.intervalMinutes}
+ label={t('scheduler.chips.scheduleField.intervalMinutesAria')}
onFocus={commit}
onChange={(intervalMinutes) => onUpdate({ mode: 'intervalMinutes', intervalMinutes })}
/>
<span className="text-13 text-[var(--cmd-palette-item-meta)] dark:text-[var(--settings-section-desc)]">{t('scheduler.chips.scheduleField.minutesSuffix')}</span>
</div>
+ <p className="text-11 leading-4 text-[var(--cmd-palette-item-meta)] dark:text-[var(--settings-section-desc)]">
+ {t('scheduler.chips.scheduleField.minuteIntervalHint')}
+ </p>
+ {!isSupportedIntervalMinutes(panelConfig.intervalMinutes) && (
+ <p className="text-11 leading-4 text-[var(--cmd-palette-item-meta)] dark:text-[var(--settings-section-desc)]">
+ {t('scheduler.chips.scheduleField.unsupportedMinuteInterval', { count: panelConfig.intervalMinutes })}
+ </p>
+ )}
<PreviewPill
text={
panelConfig.intervalMinutes === 1
@@ -610,35 +628,38 @@ function IntervalHoursInput({
function IntervalMinutesInput({
value,
+ label,
onFocus,
onChange,
}: {
value: number;
+ label: string;
onFocus: () => void;
onChange: (value: number) => void;
}) {
- const [draft, setDraft] = useState(String(value));
-
- useEffect(() => {
- setDraft(String(value));
- }, [value]);
-
+ const valueString = String(value);
+ const isSupported = SUPPORTED_INTERVAL_MINUTES.includes(
+ value as (typeof SUPPORTED_INTERVAL_MINUTES)[number],
+ );
+ const options = [
+ ...(!isSupported
+ ? [{ value: valueString, label: String(value) + '*', disabled: true }]
+ : []),
+ ...SUPPORTED_INTERVAL_MINUTES.map((minutes) => ({
+ value: String(minutes),
+ label: String(minutes),
+ })),
+ ];
return (
- <input
- type="text"
- inputMode="numeric"
- pattern="[0-9]*"
- maxLength={2}
- value={draft}
- onFocus={onFocus}
- onBlur={() => setDraft(String(value))}
- onChange={(e) => {
- const digits = e.target.value.replace(/\D/g, '').slice(0, 2);
- setDraft(digits);
- if (!digits) return;
- onChange(clamp(Number(digits), 1, 59));
+ <Select
+ label={label}
+ value={valueString}
+ options={options}
+ onOpenChange={(open) => {
+ if (open) onFocus();
}}
- className={inputPillClass('w-[68px] text-center')}
+ onValueChange={(next) => onChange(Number(next))}
+ className="w-[88px] px-2 text-center text-13"
/>
);
}
diff --git a/apps/desktop/src/renderer/features/scheduler/components/__tests__/ScheduleChip.test.tsx b/apps/desktop/src/renderer/features/scheduler/components/__tests__/ScheduleChip.test.tsx
new file mode 100644
index 0000000000..ce9550066b
--- /dev/null
+++ b/apps/desktop/src/renderer/features/scheduler/components/__tests__/ScheduleChip.test.tsx
@@ -0,0 +1,88 @@
+// @vitest-environment jsdom
+import { useState } from 'react';
+import { cleanup, fireEvent, render, screen } from '@testing-library/react';
+import { afterEach, expect, it, vi } from 'vitest';
+
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({ t: (key: string) => key, i18n: { language: 'en' } }),
+}));
+
+import { ScheduleChip } from '../ScheduleChips';
+
+afterEach(cleanup);
+
+function renderChip(cronExpr: string, intervalMs?: number) {
+ const onChange = vi.fn();
+ function Harness() {
+ const [schedule, setSchedule] = useState({ cronExpr, intervalMs });
+ return <ScheduleChip {...schedule} onChangeSchedule={(next) => {
+ onChange(next);
+ setSchedule({ cronExpr: next.cronExpr, intervalMs: next.intervalMs });
+ }} />;
+ }
+ render(<Harness />);
+ fireEvent.click(screen.getByRole('button'));
+ return onChange;
+}
+
+it.each([5, 28])('labels the %i-minute interval dropdown as an interval, not a clock minute', (minutes) => {
+ renderChip(`*/${minutes} * * * *`);
+ expect(screen.getByRole('combobox', {
+ name: 'scheduler.chips.scheduleField.intervalMinutesAria',
+ })).toBeTruthy();
+ expect(screen.queryByLabelText('scheduler.chips.scheduleField.scheduleMinuteAria')).toBeNull();
+});
+
+it('keeps the clock-minute label for a daily schedule', () => {
+ renderChip('30 9 * * *');
+ expect(screen.getByRole('textbox', {
+ name: 'scheduler.chips.scheduleField.scheduleMinuteAria',
+ })).toBeTruthy();
+ expect(screen.queryByLabelText('scheduler.chips.scheduleField.intervalMinutesAria')).toBeNull();
+});
+
+it.each([7, 28, 59])('keeps legacy */%i when the selected minute menu is clicked again', (minutes) => {
+ const onChange = renderChip(`*/${minutes} * * * *`);
+ const menu = screen.getByRole('button', { name: 'scheduler.chips.scheduleMenu.intervalMinutes' });
+ fireEvent.click(menu);
+ fireEvent.click(menu);
+ expect(onChange).not.toHaveBeenCalled();
+ expect(screen.getByRole('combobox').textContent).toContain(`${minutes}*`);
+});
+
+it.each([28, 59])('still lets an exact %i-minute interval explicitly enter the supported minute preset', (minutes) => {
+ const onChange = renderChip(`*/${minutes} * * * *`, minutes * 60_000);
+ fireEvent.click(screen.getByRole('button', { name: 'scheduler.chips.scheduleMenu.intervalMinutes' }));
+ expect(onChange).toHaveBeenCalledWith({ cronExpr: '*/5 * * * *', intervalMs: 300_000 });
+ onChange.mockClear();
+ fireEvent.click(screen.getByRole('button', { name: 'scheduler.chips.scheduleMenu.intervalMinutes' }));
+ expect(onChange).not.toHaveBeenCalled();
+});
+
+const staleCronValues = ['*/20 * * * *', '0 */8 * * *', '*/28 * * * *', '30 9 * * *'];
+
+it.each(staleCronValues)('starts the minute preset at its default, ignoring exact-interval metadata %s', (cronExpr) => {
+ const onChange = renderChip(cronExpr, 28 * 60_000);
+ expect(onChange).not.toHaveBeenCalled();
+ fireEvent.click(screen.getByRole('button', { name: 'scheduler.chips.timingMode.currentExact' }));
+ expect(onChange).not.toHaveBeenCalled();
+ fireEvent.click(screen.getByRole('button', { name: 'scheduler.chips.scheduleMenu.intervalMinutes' }));
+ expect(onChange).toHaveBeenCalledWith({ cronExpr: '*/5 * * * *', intervalMs: 300_000 });
+});
+
+it.each(staleCronValues)('starts the hour preset at its default, ignoring exact-interval metadata %s', (cronExpr) => {
+ const onChange = renderChip(cronExpr, 28 * 60_000);
+ expect(onChange).not.toHaveBeenCalled();
+ fireEvent.click(screen.getByRole('button', { name: 'scheduler.chips.scheduleMenu.interval' }));
+ expect(onChange).toHaveBeenCalledWith({ cronExpr: '0 */1 * * *', intervalMs: 3_600_000 });
+});
+
+it.each([7, 28, 59])('switches a stale Cron from the current %i-minute interval and keeps the legacy value on menu re-selection', (minutes) => {
+ const onChange = renderChip('*/5 * * * *', minutes * 60_000);
+ fireEvent.click(screen.getByRole('button', { name: 'scheduler.chips.timingMode.cron' }));
+ expect(onChange).toHaveBeenCalledWith({ cronExpr: `*/${minutes} * * * *`, intervalMs: undefined });
+ expect(screen.getByRole('combobox').textContent).toContain(`${minutes}*`);
+ onChange.mockClear();
+ fireEvent.click(screen.getByRole('button', { name: 'scheduler.chips.scheduleMenu.intervalMinutes' }));
+ expect(onChange).not.toHaveBeenCalled();
+});
diff --git a/apps/desktop/src/renderer/features/scheduler/lib/__tests__/scheduleFormLogic.test.ts b/apps/desktop/src/renderer/features/scheduler/lib/__tests__/scheduleFormLogic.test.ts
index 7f4b708ec0..3b466186d4 100644
--- a/apps/desktop/src/renderer/features/scheduler/lib/__tests__/scheduleFormLogic.test.ts
+++ b/apps/desktop/src/renderer/features/scheduler/lib/__tests__/scheduleFormLogic.test.ts
@@ -46,7 +46,9 @@ import {
cronExprToIntervalMs,
intervalMsToCronExpr,
resolveScheduleTimingPresentation,
+ resolveIntervalMinutesPresetValue,
switchScheduleTimingMode,
+ SUPPORTED_INTERVAL_MINUTES,
} from '../cronCodexPreset';
const tapsvcProvider: ProviderView = {
@@ -363,9 +365,14 @@ describe('schedule timing mode conversion', () => {
});
it('converts only the minute/hour presets supported by the timing-mode switch', () => {
+ expect(SUPPORTED_INTERVAL_MINUTES).toEqual([1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30]);
expect(cronExprToIntervalMs('*/10 * * * *')).toBe(10 * 60_000);
expect(intervalMsToCronExpr(10 * 60_000)).toBe('*/10 * * * *');
expect(intervalMsToCronExpr(2 * 60 * 60_000)).toBe('0 */2 * * *');
+ expect(cronExprToIntervalMs('*/28 * * * *')).toBeUndefined();
+ expect(cronExprToIntervalMs('*/59 * * * *')).toBeUndefined();
+ expect(intervalMsToCronExpr(28 * 60_000)).toBeUndefined();
+ expect(intervalMsToCronExpr(59 * 60_000)).toBeUndefined();
expect(intervalMsToCronExpr(90_000)).toBeUndefined();
});
@@ -389,6 +396,36 @@ describe('schedule timing mode conversion', () => {
intervalMs: 2 * 60_000,
});
});
+
+ it('preserves legacy unsupported minute Crons when switching to interval mode', () => {
+ expect(switchScheduleTimingMode('*/28 * * * *', undefined, 'interval')).toEqual({
+ cronExpr: '*/28 * * * *',
+ intervalMs: 28 * 60_000,
+ });
+ expect(switchScheduleTimingMode('*/59 * * * *', undefined, 'interval')).toEqual({
+ cronExpr: '*/59 * * * *',
+ intervalMs: 59 * 60_000,
+ });
+ });
+
+ it('falls back to a supported minute preset after an exact legacy interval', () => {
+ expect(resolveIntervalMinutesPresetValue({ mode: 'intervalMinutes', intervalMinutes: 28 })).toBe(5);
+ expect(resolveIntervalMinutesPresetValue({ mode: 'intervalMinutes', intervalMinutes: 20 })).toBe(20);
+ expect(resolveIntervalMinutesPresetValue({ mode: 'interval', intervalMinutes: 20 })).toBe(5);
+ });
+
+ it.each([7, 28, 59])('switches legacy %i-minute intervals using the authoritative value', (minutes) => {
+ const result = switchScheduleTimingMode('*/5 * * * *', minutes * 60_000, 'cron');
+ expect(result).toEqual({ cronExpr: `*/${minutes} * * * *`, intervalMs: undefined });
+ expect(switchScheduleTimingMode(result.cronExpr, undefined, 'interval')).toEqual({
+ cronExpr: result.cronExpr, intervalMs: minutes * 60_000,
+ });
+ // Conversion compatibility must not reintroduce these values into new presets.
+ expect(intervalMsToCronExpr(minutes * 60_000)).toBeUndefined();
+ expect(resolveScheduleTimingPresentation('*/5 * * * *', minutes * 60_000)).toEqual({
+ kind: 'intervalExact',
+ });
+ });
});
function makeTemplate(overrides: Partial<ScheduleTemplate> = {}): ScheduleTemplate {
diff --git a/apps/desktop/src/renderer/features/scheduler/lib/cronCodexPreset.ts b/apps/desktop/src/renderer/features/scheduler/lib/cronCodexPreset.ts
index 9ec9a5a561..ff827eb7fa 100644
--- a/apps/desktop/src/renderer/features/scheduler/lib/cronCodexPreset.ts
+++ b/apps/desktop/src/renderer/features/scheduler/lib/cronCodexPreset.ts
@@ -1,4 +1,7 @@
import type { TFunction } from 'i18next';
+import { SUPPORTED_INTERVAL_MINUTES } from '@cindy/maker-shared';
+
+export { SUPPORTED_INTERVAL_MINUTES } from '@cindy/maker-shared';
/**
* cronCodexPreset — codex 8 种 schedule mode ↔ 5-field cron 双向转换
@@ -44,7 +47,7 @@ export interface CodexScheduleConfig {
monthDay: number;
/** 间隔小时数(>=1)。interval 用 */
intervalHours: number;
- /** 间隔分钟数(1-59)。intervalMinutes 用;N=1 等价于 cron `* * * * *` */
+ /** 间隔分钟数(能整除 60 的值)。intervalMinutes 用;N=1 等价于 cron `* * * * *` */
intervalMinutes: number;
/** 任意 cron 字符串。custom 用 */
customCron: string;
@@ -84,6 +87,18 @@ export const DEFAULT_CONFIG: CodexScheduleConfig = {
customCron: '0 9 * * *',
};
+export function isSupportedIntervalMinutes(value: number): boolean {
+ return (SUPPORTED_INTERVAL_MINUTES as readonly number[]).includes(value);
+}
+
+export function resolveIntervalMinutesPresetValue(
+ config: Pick<CodexScheduleConfig, 'mode' | 'intervalMinutes'>,
+): number {
+ return config.mode === 'intervalMinutes' && isSupportedIntervalMinutes(config.intervalMinutes)
+ ? config.intervalMinutes
+ : 5;
+}
+
const NUM = /^\d+$/;
/** 把 mode + 参数序列化为 5-field cron string。 */
@@ -227,9 +242,17 @@ function clampIntervalMinutes(n: number): number {
return Math.max(1, Math.min(59, Math.floor(n)));
}
+/** Parse a legacy minute Cron into an exact interval, including values no longer offered as presets. */
+function cronExprToExactMinuteIntervalMs(expr: string): number | undefined {
+ const match = /^\*\/(\d+) \* \* \* \*$/.exec(expr.trim());
+ if (!match) return undefined;
+ const minutes = Number(match[1]);
+ return minutes >= 1 && minutes <= 59 ? minutes * 60_000 : undefined;
+}
+
// 把 cron 表达式反推成 interval 毫秒——只识别 UI 的 4 个 interval-style preset:
// - `* * * * *` → 60_000(1 分钟)
-// - `*\/N * * * *` (N: 2-59) → N * 60_000
+// - `*\/N * * * *` (N: an interval that divides 60) → N * 60_000
// - `0 * * * *` → 3_600_000(1 小时)
// - `0 *\/N * * *` (N: 1-23) → N * 3_600_000
// 其它任何 cron(daily/weekly/custom)→ undefined,让该任务继续走 cron 槽位语义。
@@ -242,7 +265,7 @@ export function cronExprToIntervalMs(expr: string): number | undefined {
const minMatch = /^\*\/(\d+) \* \* \* \*$/.exec(trimmed);
if (minMatch) {
const n = Number(minMatch[1]);
- if (n >= 2 && n <= 59) return n * 60_000;
+ if (isSupportedIntervalMinutes(n)) return n * 60_000;
return undefined;
}
const hourMatch = /^0 \*\/(\d+) \* \* \*$/.exec(trimmed);
@@ -255,7 +278,7 @@ export function cronExprToIntervalMs(expr: string): number | undefined {
}
/**
- * 把当前 UI 可编辑的相对间隔转换成等价 Cron preset,供 interval 回显和显式切回
+ * 把当前 UI 可编辑的相对间隔转换成对应 Cron preset,供 interval 回显和显式切回
* Cron 使用。返回 undefined 表示该间隔无法由现有“每 N 分钟/小时”控件精确表达。
*/
export function intervalMsToCronExpr(intervalMs: number): string | undefined {
@@ -266,7 +289,7 @@ export function intervalMsToCronExpr(intervalMs: number): string | undefined {
}
if (intervalMs % 60_000 === 0) {
const minutes = intervalMs / 60_000;
- if (minutes >= 1 && minutes <= 59) return minutes === 1 ? '* * * * *' : `*/${minutes} * * * *`;
+ if (isSupportedIntervalMinutes(minutes)) return minutes === 1 ? '* * * * *' : `*/${minutes} * * * *`;
}
return undefined;
}
@@ -300,14 +323,25 @@ export function switchScheduleTimingMode(
nextMode: 'cron' | 'interval',
): { cronExpr: string; intervalMs?: number } {
if (nextMode === 'interval') {
- const nextIntervalMs = cronExprToIntervalMs(cronExpr) ?? DEFAULT_SCHEDULE_INTERVAL_MS;
+ const nextIntervalMs = cronExprToIntervalMs(cronExpr)
+ ?? cronExprToExactMinuteIntervalMs(cronExpr)
+ ?? intervalMs
+ ?? DEFAULT_SCHEDULE_INTERVAL_MS;
return {
- cronExpr: intervalMsToCronExpr(nextIntervalMs) ?? '*/5 * * * *',
+ // Keep an unsupported legacy minute Cron intact so switching modes does not silently reset it.
+ cronExpr: intervalMsToCronExpr(nextIntervalMs) ?? (cronExpr.trim() || '*/5 * * * *'),
intervalMs: nextIntervalMs,
};
}
+ const currentIntervalMs = intervalMs ?? DEFAULT_SCHEDULE_INTERVAL_MS;
+ const minutes = currentIntervalMs / 60_000;
+ // Explicit switching keeps the pre-restriction conversion for legacy whole minutes.
+ // Cron uses hourly slots, not exact elapsed time; this must not enable new presets.
+ const legacyMinuteCron = Number.isInteger(minutes) && minutes >= 1 && minutes <= 59
+ ? (minutes === 1 ? '* * * * *' : `*/${minutes} * * * *`)
+ : undefined;
return {
- cronExpr: intervalMsToCronExpr(intervalMs ?? DEFAULT_SCHEDULE_INTERVAL_MS) ?? cronExpr,
+ cronExpr: intervalMsToCronExpr(currentIntervalMs) ?? legacyMinuteCron ?? cronExpr,
intervalMs: undefined,
};
}
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 500b3f2910..ccfa5c7e91 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -10954,7 +10954,7 @@
"intervalChip": "After completion · {{schedule}}"
},
"scheduleMenu": {
- "intervalMinutes": "Minutes (every N minutes)",
+ "intervalMinutes": "Minutes (Every N Minutes)",
"interval": "Hourly (every N hours)",
"daily": "Daily (every day)",
"weekdays": "Weekdays",
@@ -10975,7 +10975,10 @@
"minuteLabel": "Minute",
"scheduleHourAria": "Schedule hour",
"scheduleMinuteAria": "Schedule minute",
- "openTimePickerAria": "Open time picker"
+ "intervalMinutesAria": "Repeat Interval (Minutes)",
+ "openTimePickerAria": "Open time picker",
+ "minuteIntervalHint": "Only minute intervals that divide an hour are available: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, or 30 minutes. For 60 minutes, choose 1 hour.",
+ "unsupportedMinuteInterval": "This task uses the legacy {{count}}-minute Cron setting. Choose an available interval to correct it."
},
"model": {
"loading": "Loading models…",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index c152fc2624..c37602d204 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -10939,7 +10939,7 @@
"intervalChip": "完了後に計時 · {{schedule}}"
},
"scheduleMenu": {
- "intervalMinutes": "Minutes(N 分ごと)",
+ "intervalMinutes": "分(N 分ごと)",
"interval": "Hourly(N 時間ごと)",
"daily": "Daily(毎日)",
"weekdays": "Weekdays(平日)",
@@ -10960,7 +10960,10 @@
"minuteLabel": "分",
"scheduleHourAria": "スケジュール時",
"scheduleMinuteAria": "スケジュール分",
- "openTimePickerAria": "時刻ピッカーを開く"
+ "intervalMinutesAria": "繰り返し間隔(分)",
+ "openTimePickerAria": "時刻ピッカーを開く",
+ "minuteIntervalHint": "1 時間を割り切れる分間隔のみ使用できます:1、2、3、4、5、6、10、12、15、20、30 分。60 分の場合は「1 時間ごと」を選択してください。",
+ "unsupportedMinuteInterval": "このタスクは {{count}} 分の旧 Cron 設定を使用しています。利用可能な間隔を選んで修正してください。"
},
"model": {
"loading": "モデルを読み込み中…",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 2c5d0cf448..ef52ea38bb 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -10939,7 +10939,7 @@
"intervalChip": "완료 후 대기 · {{schedule}}"
},
"scheduleMenu": {
- "intervalMinutes": "Minutes (N분마다)",
+ "intervalMinutes": "분 (N분마다)",
"interval": "Hourly (N시간마다)",
"daily": "Daily (매일)",
"weekdays": "Weekdays (평일)",
@@ -10960,7 +10960,10 @@
"minuteLabel": "분",
"scheduleHourAria": "스케줄 시간",
"scheduleMinuteAria": "스케줄 분",
- "openTimePickerAria": "시간 선택기 열기"
+ "intervalMinutesAria": "반복 간격(분)",
+ "openTimePickerAria": "시간 선택기 열기",
+ "minuteIntervalHint": "1시간을 나눌 수 있는 분 간격만 사용할 수 있습니다: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30분. 60분은 ‘1시간마다’를 선택하세요.",
+ "unsupportedMinuteInterval": "이 작업은 {{count}}분의 이전 Cron 설정을 사용 중입니다. 사용 가능한 간격을 선택해 수정하세요."
},
"model": {
"loading": "모델 로드 중…",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index ebc96e7212..00443f114b 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -10939,7 +10939,7 @@
"intervalChip": "完成后计时 · {{schedule}}"
},
"scheduleMenu": {
- "intervalMinutes": "Minutes(每 N 分钟)",
+ "intervalMinutes": "分钟(每 N 分钟)",
"interval": "Hourly(每 N 小时)",
"daily": "Daily(每天)",
"weekdays": "Weekdays(工作日)",
@@ -10960,7 +10960,10 @@
"minuteLabel": "分钟",
"scheduleHourAria": "计划小时",
"scheduleMinuteAria": "计划分钟",
- "openTimePickerAria": "打开时间选择器"
+ "intervalMinutesAria": "重复间隔(分钟)",
+ "openTimePickerAria": "打开时间选择器",
+ "minuteIntervalHint": "仅支持能整除 60 的分钟间隔:1、2、3、4、5、6、10、12、15、20、30 分钟;60 分钟请选择“每 1 小时”。",
+ "unsupportedMinuteInterval": "该自动化使用了 {{count}} 分钟的旧 Cron 设置;请选择一个可用间隔来修正它。"
},
"model": {
"loading": "加载模型中…",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index de0d450bfa..41353fe005 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -10939,7 +10939,7 @@
"intervalChip": "完成後計時 · {{schedule}}"
},
"scheduleMenu": {
- "intervalMinutes": "Minutes(每 N 分鐘)",
+ "intervalMinutes": "分鐘(每 N 分鐘)",
"interval": "Hourly(每 N 小時)",
"daily": "Daily(每天)",
"weekdays": "Weekdays(工作日)",
@@ -10960,7 +10960,10 @@
"minuteLabel": "分鐘",
"scheduleHourAria": "計劃小時",
"scheduleMinuteAria": "計劃分鐘",
- "openTimePickerAria": "開啟時間選擇器"
+ "intervalMinutesAria": "重複間隔(分鐘)",
+ "openTimePickerAria": "開啟時間選擇器",
+ "minuteIntervalHint": "僅支援可整除 60 的分鐘間隔:1、2、3、4、5、6、10、12、15、20、30 分鐘;60 分鐘請選擇「每 1 小時」。",
+ "unsupportedMinuteInterval": "目前任務使用了 {{count}} 分鐘的舊 Cron 設定;請選擇可用的間隔來修正。"
},
"model": {
"loading": "載入模型中…",
diff --git a/apps/mobile/app/automations/[deviceId].tsx b/apps/mobile/app/automations/[deviceId].tsx
index ae8ffe0cb1..54866d8029 100644
--- a/apps/mobile/app/automations/[deviceId].tsx
+++ b/apps/mobile/app/automations/[deviceId].tsx
@@ -90,6 +90,7 @@ import {
type TemplateParamValidation,
} from '@/scheduler/scheduleFormModel';
import { useRemoteScheduleEventSnapshot } from '@/scheduler/remoteScheduleEvents';
+import { formatScheduleInterval } from '@/scheduler/scheduleIntervalLabel';
import {
buildMobileTemplateOverrides,
isLocalizedBuiltinTemplate,
@@ -1080,7 +1081,7 @@ function ScheduleFormCard({
}) {
const styles = useThemedStyles(makeStyles);
const { colors } = useTheme();
- const { t } = useTranslation();
+ const { t, i18n } = useTranslation();
const setField = <K extends keyof MobileScheduleDraft>(key: K, value: MobileScheduleDraft[K]) => {
onChange({ ...draft, [key]: value });
};
@@ -1104,6 +1105,13 @@ function ScheduleFormCard({
: sessionMode === 'persistent'
? t('devices.automations.form.sessionMode.persistent')
: t('devices.automations.form.sessionMode.fresh');
+ const preservedIntervalMs = !draft.intervalMinutes
+ && !draft.intervalMinutesTouched
+ && typeof draft.sourceIntervalMs === 'number'
+ && Number.isFinite(draft.sourceIntervalMs)
+ && draft.sourceIntervalMs > 0
+ ? draft.sourceIntervalMs
+ : undefined;
return (
<View style={styles.formCard} testID="automations.form">
@@ -1281,6 +1289,13 @@ function ScheduleFormCard({
testID="automations.form.intervalInput"
value={draft.intervalMinutes}
/>
+ <Text style={styles.fieldHint} testID="automations.form.intervalHint">
+ {preservedIntervalMs !== undefined
+ ? t('devices.automations.form.intervalPreservedHint', {
+ duration: formatScheduleInterval(preservedIntervalMs, i18n.resolvedLanguage || i18n.language),
+ })
+ : t('devices.automations.form.intervalHint')}
+ </Text>
</View>
<View style={styles.fieldGroup}>
<Text style={styles.fieldLabel}>Cron</Text>
diff --git a/apps/mobile/src/__tests__/scheduleFormModel.test.ts b/apps/mobile/src/__tests__/scheduleFormModel.test.ts
index 4fb1bff633..ad194caa4f 100644
--- a/apps/mobile/src/__tests__/scheduleFormModel.test.ts
+++ b/apps/mobile/src/__tests__/scheduleFormModel.test.ts
@@ -96,6 +96,12 @@ describe('mobile schedule form model', () => {
expect(buildMobileScheduleInput({ ...claude, name: 'Claude', prompt: 'run' })).not.toHaveProperty('fastMode');
});
+ it.each(['60', '1380'])('accepts the advertised whole-hour boundary of %s minutes', (intervalMinutes) => {
+ const draft = { ...createMobileScheduleDraft(null), name: 'Boundary', prompt: 'run', intervalMinutes };
+ expect(validateMobileScheduleDraft(draft)).toBeNull();
+ expect(buildMobileScheduleInput(draft).intervalMs).toBe(Number(intervalMinutes) * 60_000);
+ });
+
it('validates required fields and supported interval-style cron presets', () => {
const draft = createMobileScheduleDraft(null);
expect(validateMobileScheduleDraft(draft)).toMatchObject({ field: 'name' });
@@ -107,6 +113,14 @@ describe('mobile schedule form model', () => {
})).toMatchObject({
field: 'intervalMinutes',
});
+ for (const intervalMinutes of ['7', '28', '59', '1440']) {
+ expect(validateMobileScheduleDraft({
+ ...draft,
+ name: 'Bad',
+ prompt: 'run',
+ intervalMinutes,
+ })).toMatchObject({ field: 'intervalMinutes' });
+ }
expect(validateMobileScheduleDraft({
...draft,
name: 'Manual',
diff --git a/apps/mobile/src/__tests__/scheduleIntervalLabel.test.ts b/apps/mobile/src/__tests__/scheduleIntervalLabel.test.ts
new file mode 100644
index 0000000000..01f7c5cb5f
--- /dev/null
+++ b/apps/mobile/src/__tests__/scheduleIntervalLabel.test.ts
@@ -0,0 +1,49 @@
+import { describe, expect, it } from 'vitest';
+import { createInstance } from 'i18next';
+import { formatScheduleInterval } from '@/scheduler/scheduleIntervalLabel';
+import { buildMobileScheduleInput, createMobileScheduleDraft } from '@/scheduler/scheduleFormModel';
+import en from '@/i18n/locales/en/devices.json';
+import zhCN from '@/i18n/locales/zh-CN/devices.json';
+import zhTW from '@/i18n/locales/zh-TW/devices.json';
+import ja from '@/i18n/locales/ja/devices.json';
+import ko from '@/i18n/locales/ko/devices.json';
+
+describe('preserved schedule interval labels', () => {
+ it.each([
+ [61_000, '1 minute 1 second'],
+ [450_000, '7 minutes 30 seconds'],
+ [28 * 60_000, '28 minutes'],
+ [59 * 60_000, '59 minutes'],
+ [59_000, '59 seconds'],
+ [61_001, '1 minute 1 second 1 millisecond'],
+ [1, '1 millisecond'],
+ ])('formats %i ms without a repeating minute fraction', (ms, expected) => {
+ expect(formatScheduleInterval(ms, 'en')).toBe(expected);
+ });
+
+ it.each([
+ ['en', en, '1 minute 1 second'],
+ ['zh-CN', zhCN, '1分钟 1秒钟'],
+ ['zh-TW', zhTW, '1 分鐘 1 秒'],
+ ['ja', ja, '1 分 1 秒'],
+ ['ko', ko, '1분 1초'],
+ ] as const)('interpolates a localized duration in %s', async (locale, resources, expected) => {
+ const i18n = createInstance();
+ await i18n.init({ lng: locale, resources: { [locale]: { translation: resources } } });
+ const duration = formatScheduleInterval(61_000, locale);
+ expect(duration).toBe(expected);
+ const hint = i18n.t('automations.form.intervalPreservedHint', { duration });
+ expect(hint).toContain(expected);
+ expect(hint).not.toContain('{{');
+ expect(hint).not.toContain('1.016666');
+ });
+
+ it('does not change the stored interval when formatting an untouched draft', () => {
+ const draft = {
+ ...createMobileScheduleDraft(null), name: 'Legacy', prompt: 'run',
+ intervalMinutes: '', sourceIntervalMs: 61_001, intervalMinutesTouched: false,
+ };
+ formatScheduleInterval(draft.sourceIntervalMs, 'en');
+ expect(buildMobileScheduleInput(draft).intervalMs).toBe(61_001);
+ });
+});
diff --git a/apps/mobile/src/i18n/locales/en/devices.json b/apps/mobile/src/i18n/locales/en/devices.json
index e8a93336d5..2ec84c34f6 100644
--- a/apps/mobile/src/i18n/locales/en/devices.json
+++ b/apps/mobile/src/i18n/locales/en/devices.json
@@ -596,6 +596,8 @@
},
"boundSessionA11y": "Bind session {{name}}",
"intervalPlaceholder": "Leave empty to use cron",
+ "intervalHint": "For minute intervals, use 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, or 30 minutes. For whole-hour intervals, enter a multiple of 60 from 60 to 1380 minutes (1–23 hours).",
+ "intervalPreservedHint": "This task's exact interval is {{duration}} and will be preserved until you edit or clear it.",
"workspace": {
"project": "Project",
"dialogue": "Chat"
@@ -733,7 +735,7 @@
"workingDir": "Enter a project directory",
"effort": "Reasoning effort must be one of: {{values}}",
"intervalPositiveInteger": "The interval in minutes must be a positive integer",
- "intervalUnsupported": "Minute intervals support 1–59 minutes, or whole-hour intervals from 1–23 hours"
+ "intervalUnsupported": "Minute intervals must divide an hour: use 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, or 30 minutes, or whole-hour intervals from 1–23 hours"
},
"schedule": {
"paused": "Paused",
diff --git a/apps/mobile/src/i18n/locales/ja/devices.json b/apps/mobile/src/i18n/locales/ja/devices.json
index d758efc50b..491103f390 100644
--- a/apps/mobile/src/i18n/locales/ja/devices.json
+++ b/apps/mobile/src/i18n/locales/ja/devices.json
@@ -596,6 +596,8 @@
},
"boundSessionA11y": "セッション {{name}} をひも付け",
"intervalPlaceholder": "空欄の場合は cron を使用",
+ "intervalHint": "分間隔は 1、2、3、4、5、6、10、12、15、20、30 分から選択してください。整数時間の間隔は、60~1380 分(1~23 時間)の範囲で 60 の倍数を入力してください。",
+ "intervalPreservedHint": "このタスクの正確な間隔は {{duration}} です。編集または消去するまで保持されます。",
"workspace": {
"project": "プロジェクト",
"dialogue": "会話"
@@ -733,7 +735,7 @@
"workingDir": "プロジェクトディレクトリを入力してください",
"effort": "推論強度は次のいずれかを指定してください:{{values}}",
"intervalPositiveInteger": "間隔(分)は正の整数で入力してください",
- "intervalUnsupported": "分間隔は 1~59 分、または 1~23 時間の正時の間隔に対応しています"
+ "intervalUnsupported": "分間隔は 1 時間を割り切れる値(1、2、3、4、5、6、10、12、15、20、30 分)、または 1~23 時間の正時で指定してください"
},
"schedule": {
"paused": "一時停止中",
diff --git a/apps/mobile/src/i18n/locales/ko/devices.json b/apps/mobile/src/i18n/locales/ko/devices.json
index 20c0e858b3..f56c7b8607 100644
--- a/apps/mobile/src/i18n/locales/ko/devices.json
+++ b/apps/mobile/src/i18n/locales/ko/devices.json
@@ -596,6 +596,8 @@
},
"boundSessionA11y": "세션 {{name}} 연결",
"intervalPlaceholder": "비워 두면 cron 사용",
+ "intervalHint": "분 간격은 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30분을 사용하세요. 정수 시간 간격은 60~1380분(1~23시간) 범위에서 60의 배수로 입력하세요.",
+ "intervalPreservedHint": "이 작업의 정확한 간격은 {{duration}}이며, 수정하거나 지우기 전까지 유지됩니다.",
"workspace": {
"project": "프로젝트",
"dialogue": "대화"
@@ -733,7 +735,7 @@
"workingDir": "프로젝트 디렉터리를 입력하세요",
"effort": "추론 강도는 다음 중 하나여야 합니다: {{values}}",
"intervalPositiveInteger": "분 간격은 양의 정수여야 합니다",
- "intervalUnsupported": "분 간격은 1~59분 또는 1~23시간의 정시 간격만 지원합니다"
+ "intervalUnsupported": "분 간격은 1시간을 나눌 수 있는 값(1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30분) 또는 1~23시간의 정시 간격만 지원합니다"
},
"schedule": {
"paused": "일시 중지됨",
diff --git a/apps/mobile/src/i18n/locales/zh-CN/devices.json b/apps/mobile/src/i18n/locales/zh-CN/devices.json
index 8c59a03d43..294b33a976 100644
--- a/apps/mobile/src/i18n/locales/zh-CN/devices.json
+++ b/apps/mobile/src/i18n/locales/zh-CN/devices.json
@@ -596,6 +596,8 @@
},
"boundSessionA11y": "绑定任务 {{name}}",
"intervalPlaceholder": "留空则使用 cron",
+ "intervalHint": "分钟间隔请选择 1、2、3、4、5、6、10、12、15、20 或 30 分钟;整小时间隔请输入 60 的倍数,范围为 60–1380 分钟(1–23 小时)。",
+ "intervalPreservedHint": "当前任务的精确间隔为每 {{duration}};未编辑或清空前会保留。",
"workspace": {
"project": "项目",
"dialogue": "对话"
@@ -733,7 +735,7 @@
"workingDir": "请输入项目目录",
"effort": "推理强度只能是 {{values}}",
"intervalPositiveInteger": "间隔分钟必须是正整数",
- "intervalUnsupported": "分钟间隔只支持 1–59 分钟,或 1–23 小时的整点间隔"
+ "intervalUnsupported": "分钟间隔必须能整除 60:请选择 1、2、3、4、5、6、10、12、15、20 或 30 分钟,或 1–23 小时的整点间隔"
},
"schedule": {
"paused": "已暂停",
diff --git a/apps/mobile/src/i18n/locales/zh-TW/devices.json b/apps/mobile/src/i18n/locales/zh-TW/devices.json
index ba03c98e2e..b1ae8ec2a0 100644
--- a/apps/mobile/src/i18n/locales/zh-TW/devices.json
+++ b/apps/mobile/src/i18n/locales/zh-TW/devices.json
@@ -596,6 +596,8 @@
},
"boundSessionA11y": "繫結任務 {{name}}",
"intervalPlaceholder": "留空則使用 cron",
+ "intervalHint": "分鐘間隔請選擇 1、2、3、4、5、6、10、12、15、20 或 30 分鐘;整小時間隔請輸入 60 的倍數,範圍為 60–1380 分鐘(1–23 小時)。",
+ "intervalPreservedHint": "目前任務的精確間隔為每 {{duration}};未編輯或清空前會保留。",
"workspace": {
"project": "專案",
"dialogue": "對話"
@@ -733,7 +735,7 @@
"workingDir": "請輸入專案目錄",
"effort": "推理強度只能是 {{values}}",
"intervalPositiveInteger": "間隔分鐘必須是正整數",
- "intervalUnsupported": "分鐘間隔只支援 1–59 分鐘,或 1–23 小時的整點間隔"
+ "intervalUnsupported": "分鐘間隔必須可整除 60:請選擇 1、2、3、4、5、6、10、12、15、20 或 30 分鐘,或 1–23 小時的整點間隔"
},
"schedule": {
"paused": "已暫停",
diff --git a/apps/mobile/src/scheduler/scheduleIntervalLabel.ts b/apps/mobile/src/scheduler/scheduleIntervalLabel.ts
new file mode 100644
index 0000000000..93772a26c0
--- /dev/null
+++ b/apps/mobile/src/scheduler/scheduleIntervalLabel.ts
@@ -0,0 +1,18 @@
+/** Display the stored interval without rounding it to whole minutes. */
+export function formatScheduleInterval(intervalMs: number, locale: string): string {
+ const parts: string[] = [];
+ let remaining = intervalMs;
+ for (const [unit, size] of [['minute', 60_000], ['second', 1_000], ['millisecond', 1]] as const) {
+ const count = unit === 'millisecond' ? remaining : Math.floor(remaining / size);
+ remaining %= size;
+ if (count > 0) {
+ parts.push(new Intl.NumberFormat(locale, {
+ style: 'unit',
+ unit,
+ unitDisplay: 'long',
+ maximumFractionDigits: 20,
+ }).format(count));
+ }
+ }
+ return parts.join(' ');
+}
diff --git a/packages/maker-shared/src/__tests__/scheduleForm.test.ts b/packages/maker-shared/src/__tests__/scheduleForm.test.ts
index 565acfac60..9cb3f38e5b 100644
--- a/packages/maker-shared/src/__tests__/scheduleForm.test.ts
+++ b/packages/maker-shared/src/__tests__/scheduleForm.test.ts
@@ -134,13 +134,20 @@ describe('mobile schedule form model', () => {
// 90 分钟表单表达不了(非 1-59 分钟/整点小时),intervalMinutes 折叠成 ''
const draft = createMobileScheduleDraft(schedule({ intervalMs: 90 * 60_000 }));
expect(draft.intervalMinutes).toBe('');
+ expect(draft.sourceIntervalMs).toBe(90 * 60_000);
+
+ const nonMinuteDraft = createMobileScheduleDraft(schedule({ intervalMs: 7.5 * 60_000 }));
+ expect(nonMinuteDraft.intervalMinutes).toBe('');
+ expect(nonMinuteDraft.sourceIntervalMs).toBe(7.5 * 60_000);
// 只改 prompt:间隔原值回传,不因「表单显示不了」被顺手清空
const untouched = buildMobileScheduleInput({ ...draft, prompt: 'new prompt' });
expect(untouched.intervalMs).toBe(90 * 60_000);
// 用户经编辑入口清空 → 明确清空
- const cleared = buildMobileScheduleInput(updateDraftIntervalMinutes(draft, ''));
+ const clearedDraft = updateDraftIntervalMinutes(draft, '');
+ expect(clearedDraft.intervalMinutesTouched).toBe(true);
+ const cleared = buildMobileScheduleInput(clearedDraft);
expect(cleared.intervalMs).toBeNull();
// 切 manual 是显式 cadence 操作:切回 recurring 也不复活旧间隔
@@ -300,6 +307,14 @@ describe('mobile schedule form model', () => {
})).toMatchObject({
field: 'intervalMinutes',
});
+ for (const intervalMinutes of ['7', '28', '59']) {
+ expect(validateMobileScheduleDraft({
+ ...draft,
+ name: 'Bad',
+ prompt: 'run',
+ intervalMinutes,
+ })).toMatchObject({ field: 'intervalMinutes' });
+ }
expect(validateMobileScheduleDraft({
...draft,
name: 'Manual',
diff --git a/packages/maker-shared/src/scheduleForm.ts b/packages/maker-shared/src/scheduleForm.ts
index 4a200b35b8..51d351e3ac 100644
--- a/packages/maker-shared/src/scheduleForm.ts
+++ b/packages/maker-shared/src/scheduleForm.ts
@@ -23,6 +23,9 @@ export const MOBILE_SCHEDULE_EFFORT_VALUES = [
'ultra',
] as const;
+/** Minute steps that map to stable fixed slots across hour boundaries. */
+export const SUPPORTED_INTERVAL_MINUTES = [1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30] as const;
+
export type MobileScheduleEffort = (typeof MOBILE_SCHEDULE_EFFORT_VALUES)[number];
export type MobileScheduleRunMode = 'recurring' | 'manual';
export type MobileScheduleSessionMode = 'fresh' | 'persistent' | 'bound';
@@ -41,7 +44,7 @@ export interface MobileScheduleDraft {
timezone: string;
intervalMinutes: string;
/**
- * 原任务的 intervalMs。表单只表达得了 1-59 分钟 / 整点小时,MCP 可以设出
+ * 原任务的 intervalMs。表单只表达得了能整除 60 的分钟间隔 / 整点小时,MCP 可以设出
* 表单区间外的间隔(如 90 分钟),这时 intervalMinutes 折叠成 '' ——保存时
* 必须能区分「表达不了」和「用户清空」,否则只改 prompt 也会静默清掉间隔
* (copilot review 发现)。
@@ -697,7 +700,7 @@ function validateIntervalMinutes(
'intervalMinutes',
localizer,
'devices.automations.presentation.validation.intervalUnsupported',
- '分钟间隔只支持 1-59 分钟,或 1-23 小时的整点间隔',
+ '分钟间隔必须能整除 60:请选择 ' + SUPPORTED_INTERVAL_MINUTES.join('、') + ' 分钟,或 1-23 小时的整点间隔',
);
}
return null;
@@ -712,7 +715,7 @@ function parseSupportedIntervalMinutes(value: string): number | null {
function intervalMinutesToCronExpr(minutes: number): string | null {
if (minutes === 1) return '* * * * *';
- if (minutes >= 2 && minutes <= 59) return `*/${minutes} * * * *`;
+ if ((SUPPORTED_INTERVAL_MINUTES as readonly number[]).includes(minutes)) return `*/${minutes} * * * *`;
if (minutes === 60) return '0 * * * *';
if (minutes % 60 === 0) {
const hours = minutes / 60;