🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(task): scheduled status + cron schedule editor (#14246)
Arvin Xub814cf2611d0
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex cdfb3a6abe1..7b1c1bd5530 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -570,12 +570,18 @@"taskList.view.list": "List","taskList.viewAll": "View all","taskSchedule.clear": "Clear",+ "taskSchedule.continuous": "Continuous","taskSchedule.enable": "Enable automation","taskSchedule.every": "Every",+ "taskSchedule.frequency": "Frequency","taskSchedule.hours": "Hours","taskSchedule.interval": "Recurring","taskSchedule.intervalTab": "Recurring",+ "taskSchedule.maxExecutions": "Max runs","taskSchedule.minutes": "Minutes",+ "taskSchedule.scheduleType.daily": "Daily",+ "taskSchedule.scheduleType.hourly": "Hourly",+ "taskSchedule.scheduleType.weekly": "Weekly","taskSchedule.scheduler": "Scheduler","taskSchedule.schedulerNotReady": "Scheduler is coming soon. Use Recurring for now.","taskSchedule.schedulerTab": "Scheduler",@@ -584,6 +590,8 @@"taskSchedule.tag.every": "Every {{interval}}","taskSchedule.tag.heartbeat": "Heartbeat · {{every}}","taskSchedule.tag.schedule": "Schedule · {{schedule}}{{timezone}}",+ "taskSchedule.time": "Time",+ "taskSchedule.timezone": "Timezone","taskSchedule.title": "Schedule","taskSchedule.unit.hour_one": "{{count}} hr","taskSchedule.unit.hour_other": "{{count}} hrs",@@ -591,6 +599,14 @@"taskSchedule.unit.minute_other": "{{count}} mins","taskSchedule.unit.second_one": "{{count}} sec","taskSchedule.unit.second_other": "{{count}} secs",+ "taskSchedule.weekday": "Weekday",+ "taskSchedule.weekdays.fri": "Fri",+ "taskSchedule.weekdays.mon": "Mon",+ "taskSchedule.weekdays.sat": "Sat",+ "taskSchedule.weekdays.sun": "Sun",+ "taskSchedule.weekdays.thu": "Thu",+ "taskSchedule.weekdays.tue": "Tue",+ "taskSchedule.weekdays.wed": "Wed","thread.closeSubagentThread": "Collapse subagent conversation","thread.divider": "Subtopic","thread.openSubagentThread": "View full subagent conversation",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex 739a364b11c..0e86381596e 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -570,12 +570,18 @@"taskList.view.list": "列表","taskList.viewAll": "查看全部","taskSchedule.clear": "清除",+ "taskSchedule.continuous": "持续执行","taskSchedule.enable": "启用自动化","taskSchedule.every": "每",+ "taskSchedule.frequency": "执行频率","taskSchedule.hours": "小时","taskSchedule.interval": "循环任务","taskSchedule.intervalTab": "循环任务",+ "taskSchedule.maxExecutions": "最大次数","taskSchedule.minutes": "分钟",+ "taskSchedule.scheduleType.daily": "每日",+ "taskSchedule.scheduleType.hourly": "每小时",+ "taskSchedule.scheduleType.weekly": "每周","taskSchedule.scheduler": "定时任务","taskSchedule.schedulerNotReady": "定时任务即将上线。暂时请使用“循环任务”。","taskSchedule.schedulerTab": "定时任务",@@ -584,6 +590,8 @@"taskSchedule.tag.every": "每 {{interval}}","taskSchedule.tag.heartbeat": "心跳 · {{every}}","taskSchedule.tag.schedule": "计划 · {{schedule}}{{timezone}}",+ "taskSchedule.time": "时间",+ "taskSchedule.timezone": "时区","taskSchedule.title": "计划","taskSchedule.unit.hour_one": "{{count}} 小时","taskSchedule.unit.hour_other": "{{count}} 小时",@@ -591,6 +599,14 @@"taskSchedule.unit.minute_other": "{{count}} 分钟","taskSchedule.unit.second_one": "{{count}} 秒","taskSchedule.unit.second_other": "{{count}} 秒",+ "taskSchedule.weekday": "星期",+ "taskSchedule.weekdays.fri": "五",+ "taskSchedule.weekdays.mon": "一",+ "taskSchedule.weekdays.sat": "六",+ "taskSchedule.weekdays.sun": "日",+ "taskSchedule.weekdays.thu": "四",+ "taskSchedule.weekdays.tue": "二",+ "taskSchedule.weekdays.wed": "三","thread.closeSubagentThread": "收起子智能体对话","thread.divider": "子话题","thread.openSubagentThread": "查看完整子智能体对话",diff --git a/packages/builtin-tool-task/src/constants.ts b/packages/builtin-tool-task/src/constants.tsindex 4badbd01063..a2754e7d5cc 100644--- a/packages/builtin-tool-task/src/constants.ts+++ b/packages/builtin-tool-task/src/constants.ts@@ -1,10 +1,11 @@export const TASK_STATUSES = ['backlog','running',+ 'scheduled','paused','completed','failed','canceled',] as const;-export const UNFINISHED_TASK_STATUSES = ['backlog', 'running', 'paused'] as const;+export const UNFINISHED_TASK_STATUSES = ['backlog', 'running', 'scheduled', 'paused'] as const;diff --git a/packages/database/src/models/taskTopic.ts b/packages/database/src/models/taskTopic.tsindex 97e0442e0f1..2cedd83c1f2 100644--- a/packages/database/src/models/taskTopic.ts+++ b/packages/database/src/models/taskTopic.ts@@ -175,7 +175,7 @@ export class TaskTopicModel {.orderBy(desc(taskTopics.seq));}- async findWithHandoff(taskId: string, limit = 4) {+ async findWithHandoff(taskId: string, limit: number) {const { topics } = await import('../schemas/topic');return this.db.select({diff --git a/packages/types/src/task/index.ts b/packages/types/src/task/index.tsindex 8c8ba4de04f..477ccb96f5b 100644--- a/packages/types/src/task/index.ts+++ b/packages/types/src/task/index.ts@@ -1,6 +1,13 @@// ── Task type aliases ──-export type TaskStatus = 'backlog' | 'canceled' | 'completed' | 'failed' | 'paused' | 'running';+export type TaskStatus =+ | 'backlog'+ | 'canceled'+ | 'completed'+ | 'failed'+ | 'paused'+ | 'running'+ | 'scheduled';export type TaskPriority = 0 | 1 | 2 | 3 | 4;@@ -258,6 +265,11 @@ export interface TaskDetailData {parent?: { identifier: string; name: string | null } | null;priority?: number | null;review?: Record<string, any> | null;+ schedule?: {+ maxExecutions?: number | null;+ pattern?: string | null;+ timezone?: string | null;+ };status: string;subtasks?: TaskDetailSubtask[];topicCount?: number;diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskProperties.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskProperties.tsxindex a1ad00a70c7..a605dd62599 100644--- a/src/features/AgentTasks/AgentTaskDetail/TaskProperties.tsx+++ b/src/features/AgentTasks/AgentTaskDetail/TaskProperties.tsx@@ -22,6 +22,7 @@ const STATUS_META: Record<TaskStatus, StatusMeta> = {failed: { labelKey: 'status.failed' },paused: { labelKey: 'status.paused' },running: { labelKey: 'status.running' },+ scheduled: { labelKey: 'status.scheduled' },};interface PriorityMeta {@@ -43,6 +44,9 @@ const TaskProperties = memo(() => {const status = useTaskStore(taskDetailSelectors.activeTaskStatus) as TaskStatus | undefined;const priority = useTaskStore(taskDetailSelectors.activeTaskPriority);const heartbeatInterval = useTaskStore(taskDetailSelectors.activeTaskPeriodicInterval);+ const automationMode = useTaskStore(taskDetailSelectors.activeTaskAutomationMode);+ const schedulePattern = useTaskStore(taskDetailSelectors.activeTaskSchedulePattern);+ const scheduleTimezone = useTaskStore(taskDetailSelectors.activeTaskScheduleTimezone);if (!taskId) return null;@@ -91,7 +95,12 @@ const TaskProperties = memo(() => {paddingInline={8}variant={'borderless'}>- <TaskTriggerTag heartbeatInterval={heartbeatInterval} mode="inline" />+ <TaskTriggerTag+ heartbeatInterval={automationMode === 'heartbeat' ? heartbeatInterval : undefined}+ mode="inline"+ schedulePattern={automationMode === 'schedule' ? schedulePattern : undefined}+ scheduleTimezone={automationMode === 'schedule' ? scheduleTimezone : undefined}+ /></Block></TaskScheduleConfig></Block>diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskScheduleConfig.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskScheduleConfig.tsxindex 28181a24373..58d36df864b 100644--- a/src/features/AgentTasks/AgentTaskDetail/TaskScheduleConfig.tsx+++ b/src/features/AgentTasks/AgentTaskDetail/TaskScheduleConfig.tsx@@ -18,6 +18,8 @@ import { useTranslation } from 'react-i18next';import { useTaskStore } from '@/store/task';import { taskDetailSelectors } from '@/store/task/selectors';+import SchedulerForm, { type SchedulerFormChange } from './scheduler/SchedulerForm';+type IntervalUnit = 'hours' | 'minutes' | 'seconds';interface IntervalTabProps {@@ -104,14 +106,12 @@ const IntervalTab = memo<IntervalTabProps>(({ currentInterval, taskId }) => {<InputNumbermin={1}placeholder="10"- size={'small'}- style={{ width: 80 }}+ style={{ width: 100 }}value={localValue}onChange={handleValueChange}/><Select- size={'small'}- style={{ width: 90 }}+ style={{ width: 110 }}value={localUnit}variant="outlined"options={[@@ -123,22 +123,36 @@ const IntervalTab = memo<IntervalTabProps>(({ currentInterval, taskId }) => {/></Flexbox></Flexbox>- {currentInterval > 0 && (- <Button size={'small'} onClick={handleClear}>- {t('taskSchedule.clear')}- </Button>- )}+ {currentInterval > 0 && <Button onClick={handleClear}>{t('taskSchedule.clear')}</Button>}</>);});-const SchedulerTab = memo(() => {- const { t } = useTranslation('chat');+interface SchedulerTabProps {+ taskId?: string;+}++const SchedulerTab = memo<SchedulerTabProps>(({ taskId }) => {+ const updateSchedule = useTaskStore((s) => s.updateSchedule);+ const pattern = useTaskStore(taskDetailSelectors.activeTaskSchedulePattern);+ const timezone = useTaskStore(taskDetailSelectors.activeTaskScheduleTimezone);+ const maxExecutions = useTaskStore(taskDetailSelectors.activeTaskScheduleMaxExecutions);++ const handleChange = useCallback(+ (change: SchedulerFormChange) => {+ if (!taskId) return;+ updateSchedule(taskId, change);+ },+ [taskId, updateSchedule],+ );return (- <Flexbox align="center" justify="center" style={{ minHeight: 80, padding: 16 }}>- <Text type="secondary">{t('taskSchedule.schedulerNotReady')}</Text>- </Flexbox>+ <SchedulerForm+ maxExecutions={maxExecutions}+ pattern={pattern}+ timezone={timezone}+ onChange={handleChange}+ />);});@@ -181,27 +195,26 @@ const TaskScheduleConfig = memo(function TaskScheduleConfig({);const content = (- <Flexbox gap={12} style={{ minWidth: 240, padding: 4 }} onClick={(e) => e.stopPropagation()}>+ <Flexbox gap={16} style={{ padding: 8, width: 420 }} onClick={(e) => e.stopPropagation()}><Flexbox horizontal align="center" gap={8}><Text weight={500}>{t('taskSchedule.enable')}</Text>- <Switch checked={enabled} size="small" onChange={handleEnableChange} />+ <Switch checked={enabled} onChange={handleEnableChange} /></Flexbox>{enabled && (<><Segmentedblock- size="small"value={automationMode ?? 'heartbeat'}options={[- { label: t('taskSchedule.intervalTab'), value: 'heartbeat' },{ label: t('taskSchedule.schedulerTab'), value: 'schedule' },+ { label: t('taskSchedule.intervalTab'), value: 'heartbeat' },]}onChange={handleModeChange}/>{automationMode === 'heartbeat' && (<IntervalTab currentInterval={finalCurrentInterval} taskId={finalTaskId} />)}- {automationMode === 'schedule' && <SchedulerTab />}+ {automationMode === 'schedule' && <SchedulerTab taskId={finalTaskId} />}</>)}</Flexbox>diff --git a/src/features/AgentTasks/AgentTaskDetail/scheduler/CronConfig.ts b/src/features/AgentTasks/AgentTaskDetail/scheduler/CronConfig.tsnew file mode 100644index 00000000000..0ed02c92f8e--- /dev/null+++ b/src/features/AgentTasks/AgentTaskDetail/scheduler/CronConfig.ts@@ -0,0 +1,136 @@+import { type Dayjs } from 'dayjs';++export type ScheduleType = 'daily' | 'hourly' | 'weekly';++export const SCHEDULE_TYPE_OPTIONS = [+ { label: 'taskSchedule.scheduleType.daily', value: 'daily' },+ { label: 'taskSchedule.scheduleType.hourly', value: 'hourly' },+ { label: 'taskSchedule.scheduleType.weekly', value: 'weekly' },+] as const;++export const TIMEZONE_OPTIONS = [+ { label: 'UTC', value: 'UTC' },++ // Americas+ { label: 'America/New_York (EST/EDT, UTC-5/-4)', value: 'America/New_York' },+ { label: 'America/Chicago (CST/CDT, UTC-6/-5)', value: 'America/Chicago' },+ { label: 'America/Denver (MST/MDT, UTC-7/-6)', value: 'America/Denver' },+ { label: 'America/Los_Angeles (PST/PDT, UTC-8/-7)', value: 'America/Los_Angeles' },+ { label: 'America/Toronto (EST/EDT, UTC-5/-4)', value: 'America/Toronto' },+ { label: 'America/Vancouver (PST/PDT, UTC-8/-7)', value: 'America/Vancouver' },+ { label: 'America/Mexico_City (CST, UTC-6)', value: 'America/Mexico_City' },+ { label: 'America/Sao_Paulo (BRT, UTC-3)', value: 'America/Sao_Paulo' },+ { label: 'America/Buenos_Aires (ART, UTC-3)', value: 'America/Buenos_Aires' },++ // Europe+ { label: 'Europe/London (GMT/BST, UTC+0/+1)', value: 'Europe/London' },+ { label: 'Europe/Paris (CET/CEST, UTC+1/+2)', value: 'Europe/Paris' },+ { label: 'Europe/Berlin (CET/CEST, UTC+1/+2)', value: 'Europe/Berlin' },+ { label: 'Europe/Madrid (CET/CEST, UTC+1/+2)', value: 'Europe/Madrid' },+ { label: 'Europe/Rome (CET/CEST, UTC+1/+2)', value: 'Europe/Rome' },+ { label: 'Europe/Amsterdam (CET/CEST, UTC+1/+2)', value: 'Europe/Amsterdam' },+ { label: 'Europe/Brussels (CET/CEST, UTC+1/+2)', value: 'Europe/Brussels' },+ { label: 'Europe/Moscow (MSK, UTC+3)', value: 'Europe/Moscow' },+ { label: 'Europe/Istanbul (TRT, UTC+3)', value: 'Europe/Istanbul' },++ // Asia+ { label: 'Asia/Dubai (GST, UTC+4)', value: 'Asia/Dubai' },+ { label: 'Asia/Kolkata (IST, UTC+5:30)', value: 'Asia/Kolkata' },+ { label: 'Asia/Shanghai (CST, UTC+8)', value: 'Asia/Shanghai' },+ { label: 'Asia/Hong_Kong (HKT, UTC+8)', value: 'Asia/Hong_Kong' },+ { label: 'Asia/Taipei (CST, UTC+8)', value: 'Asia/Taipei' },+ { label: 'Asia/Singapore (SGT, UTC+8)', value: 'Asia/Singapore' },+ { label: 'Asia/Tokyo (JST, UTC+9)', value: 'Asia/Tokyo' },+ { label: 'Asia/Seoul (KST, UTC+9)', value: 'Asia/Seoul' },+ { label: 'Asia/Bangkok (ICT, UTC+7)', value: 'Asia/Bangkok' },+ { label: 'Asia/Jakarta (WIB, UTC+7)', value: 'Asia/Jakarta' },++ // Oceania+ { label: 'Australia/Sydney (AEDT/AEST, UTC+11/+10)', value: 'Australia/Sydney' },+ { label: 'Australia/Melbourne (AEDT/AEST, UTC+11/+10)', value: 'Australia/Melbourne' },+ { label: 'Australia/Brisbane (AEST, UTC+10)', value: 'Australia/Brisbane' },+ { label: 'Australia/Perth (AWST, UTC+8)', value: 'Australia/Perth' },+ { label: 'Pacific/Auckland (NZDT/NZST, UTC+13/+12)', value: 'Pacific/Auckland' },++ // Africa & Middle East+ { label: 'Africa/Cairo (EET, UTC+2)', value: 'Africa/Cairo' },+ { label: 'Africa/Johannesburg (SAST, UTC+2)', value: 'Africa/Johannesburg' },+];++export const WEEKDAYS = [+ { key: 1, label: 'taskSchedule.weekdays.mon' },+ { key: 2, label: 'taskSchedule.weekdays.tue' },+ { key: 3, label: 'taskSchedule.weekdays.wed' },+ { key: 4, label: 'taskSchedule.weekdays.thu' },+ { key: 5, label: 'taskSchedule.weekdays.fri' },+ { key: 6, label: 'taskSchedule.weekdays.sat' },+ { key: 0, label: 'taskSchedule.weekdays.sun' },+] as const;++/**+ * Parse cron pattern (minute hour day month weekday) into editable schedule info.+ */+export const parseCronPattern = (+ cronPattern: string,+): {+ hourlyInterval?: number;+ scheduleType: ScheduleType;+ triggerHour: number;+ triggerMinute: number;+ weekdays?: number[];+} => {+ const parts = cronPattern.split(' ');+ if (parts.length !== 5) {+ return { scheduleType: 'daily', triggerHour: 0, triggerMinute: 0 };+ }++ const [minute, hour, , , weekday] = parts;+ const rawMinute = minute === '*' ? 0 : Number.parseInt(minute);+ const triggerMinute = rawMinute >= 15 && rawMinute < 45 ? 30 : 0;++ if (hour.startsWith('*/')) {+ const interval = Number.parseInt(hour.slice(2));+ return { hourlyInterval: interval, scheduleType: 'hourly', triggerHour: 0, triggerMinute };+ }+ if (hour === '*') {+ return { hourlyInterval: 1, scheduleType: 'hourly', triggerHour: 0, triggerMinute };+ }++ const triggerHour = Number.parseInt(hour);++ if (weekday !== '*') {+ const weekdays = weekday.split(',').map((d) => Number.parseInt(d));+ return { scheduleType: 'weekly', triggerHour, triggerMinute, weekdays };+ }++ return { scheduleType: 'daily', triggerHour, triggerMinute };+};++/**+ * Build cron pattern (minute hour day month weekday) from editable schedule info.+ */+export const buildCronPattern = (+ scheduleType: ScheduleType,+ triggerTime: Dayjs,+ hourlyInterval?: number,+ weekdays?: number[],+): string => {+ const rawMinute = triggerTime.minute();+ const minute = rawMinute >= 15 && rawMinute < 45 ? 30 : 0;+ const hour = triggerTime.hour();++ switch (scheduleType) {+ case 'hourly': {+ const interval = hourlyInterval || 1;+ if (interval === 1) return `${minute} * * * *`;+ return `${minute} */${interval} * * *`;+ }+ case 'daily': {+ return `${minute} ${hour} * * *`;+ }+ case 'weekly': {+ const days = weekdays && weekdays.length > 0 ? weekdays.sort().join(',') : '0,1,2,3,4,5,6';+ return `${minute} ${hour} * * ${days}`;+ }+ }+};diff --git a/src/features/AgentTasks/AgentTaskDetail/scheduler/SchedulerForm.tsx b/src/features/AgentTasks/AgentTaskDetail/scheduler/SchedulerForm.tsxnew file mode 100644index 00000000000..0157f3b9dd4--- /dev/null+++ b/src/features/AgentTasks/AgentTaskDetail/scheduler/SchedulerForm.tsx@@ -0,0 +1,302 @@+import { Checkbox, Flexbox, InputNumber, Select, Text } from '@lobehub/ui';+import { TimePicker } from 'antd';+import { createStaticStyles, cx } from 'antd-style';+import dayjs, { type Dayjs } from 'dayjs';+import { memo, useCallback, useEffect, useMemo, useState } from 'react';+import { useTranslation } from 'react-i18next';++import {+ buildCronPattern,+ parseCronPattern,+ SCHEDULE_TYPE_OPTIONS,+ type ScheduleType,+ TIMEZONE_OPTIONS,+ WEEKDAYS,+} from './CronConfig';++const styles = createStaticStyles(({ css, cssVar }) => ({+ label: css`+ flex-shrink: 0;+ width: 80px;+ color: ${cssVar.colorTextSecondary};+ `,+ weekdayButton: css`+ cursor: pointer;++ display: flex;+ align-items: center;+ justify-content: center;++ width: 36px;+ height: 32px;+ border: 1px solid ${cssVar.colorBorder};+ border-radius: 6px;++ font-size: 12px;+ font-weight: 500;+ color: ${cssVar.colorTextSecondary};++ background: transparent;++ transition: all 0.15s ease;++ &:hover {+ border-color: ${cssVar.colorPrimary};+ color: ${cssVar.colorPrimary};+ }+ `,+ weekdayButtonActive: css`+ border-color: ${cssVar.colorPrimary};+ color: ${cssVar.colorTextLightSolid};+ background: ${cssVar.colorPrimary};++ &:hover {+ border-color: ${cssVar.colorPrimaryHover};+ color: ${cssVar.colorTextLightSolid};+ background: ${cssVar.colorPrimaryHover};+ }+ `,+}));++const DEFAULT_PATTERN = '0 9 * * *';+const DEFAULT_TIMEZONE = 'UTC';++export interface SchedulerFormChange {+ maxExecutions: number | null;+ pattern: string;+ timezone: string;+}++interface SchedulerFormProps {+ maxExecutions?: number | null;+ onChange: (change: SchedulerFormChange) => void;+ pattern?: string | null;+ timezone?: string | null;+}++const SchedulerForm = memo<SchedulerFormProps>(({ maxExecutions, onChange, pattern, timezone }) => {+ const { t } = useTranslation('chat');++ const initial = useMemo(() => {+ const parsed = parseCronPattern(pattern || DEFAULT_PATTERN);+ return {+ ...parsed,+ triggerTime: dayjs().hour(parsed.triggerHour).minute(parsed.triggerMinute),+ };+ }, [pattern]);++ const [scheduleType, setScheduleType] = useState<ScheduleType>(initial.scheduleType);+ const [triggerTime, setTriggerTime] = useState<Dayjs>(initial.triggerTime);+ const [hourlyInterval, setHourlyInterval] = useState<number>(initial.hourlyInterval ?? 1);+ const [weekdays, setWeekdays] = useState<number[]>(+ initial.weekdays ?? (initial.scheduleType === 'weekly' ? [1, 2, 3, 4, 5] : []),+ );+ const [tz, setTz] = useState<string>(timezone || DEFAULT_TIMEZONE);+ const [maxExec, setMaxExec] = useState<number | null>(maxExecutions ?? null);++ useEffect(() => {+ setScheduleType(initial.scheduleType);+ setTriggerTime(initial.triggerTime);+ setHourlyInterval(initial.hourlyInterval ?? 1);+ setWeekdays(initial.weekdays ?? (initial.scheduleType === 'weekly' ? [1, 2, 3, 4, 5] : []));+ }, [initial]);++ useEffect(() => {+ setTz(timezone || DEFAULT_TIMEZONE);+ }, [timezone]);++ useEffect(() => {+ setMaxExec(maxExecutions ?? null);+ }, [maxExecutions]);++ const emit = useCallback(+ (+ overrides: Partial<{+ hourlyInterval: number;+ maxExec: number | null;+ scheduleType: ScheduleType;+ triggerTime: Dayjs;+ tz: string;+ weekdays: number[];+ }>,+ ) => {+ const next = {+ hourlyInterval: overrides.hourlyInterval ?? hourlyInterval,+ maxExec: overrides.maxExec === undefined ? maxExec : overrides.maxExec,+ scheduleType: overrides.scheduleType ?? scheduleType,+ triggerTime: overrides.triggerTime ?? triggerTime,+ tz: overrides.tz ?? tz,+ weekdays: overrides.weekdays ?? weekdays,+ };+ const nextPattern = buildCronPattern(+ next.scheduleType,+ next.triggerTime,+ next.hourlyInterval,+ next.weekdays,+ );+ onChange({ maxExecutions: next.maxExec, pattern: nextPattern, timezone: next.tz });+ },+ [hourlyInterval, maxExec, onChange, scheduleType, triggerTime, tz, weekdays],+ );++ const handleScheduleTypeChange = (value: ScheduleType) => {+ const nextWeekdays = value === 'weekly' ? (weekdays.length ? weekdays : [1, 2, 3, 4, 5]) : [];+ setScheduleType(value);+ setWeekdays(nextWeekdays);+ emit({ scheduleType: value, weekdays: nextWeekdays });+ };++ const handleTimeChange = (value: Dayjs | null) => {+ if (!value) return;+ setTriggerTime(value);+ emit({ triggerTime: value });+ };++ const handleHourlyMinuteChange = (minute: number) => {+ const next = dayjs().hour(0).minute(minute);+ setTriggerTime(next);+ emit({ triggerTime: next });+ };++ const handleHourlyIntervalChange = (value: number | string | null) => {+ const next = typeof value === 'number' && value > 0 ? value : 1;+ setHourlyInterval(next);+ emit({ hourlyInterval: next });+ };++ const toggleWeekday = (day: number) => {+ const next = weekdays.includes(day) ? weekdays.filter((d) => d !== day) : [...weekdays, day];+ setWeekdays(next);+ emit({ weekdays: next });+ };++ const handleTimezoneChange = (value: string) => {+ setTz(value);+ emit({ tz: value });+ };++ const handleMaxExecChange = (value: number | string | null) => {+ const next = typeof value === 'number' && value > 0 ? value : null;+ setMaxExec(next);+ emit({ maxExec: next });+ };++ const handleContinuousChange = (checked: boolean) => {+ const next = checked ? null : 100;+ setMaxExec(next);+ emit({ maxExec: next });+ };++ const isUnlimited = maxExec === null || maxExec === undefined;++ return (+ <Flexbox gap={14} paddingBlock={4}>+ <Flexbox horizontal align="center" gap={12} justify="space-between">+ <Text className={styles.label}>{t('taskSchedule.frequency')}</Text>+ <Select+ style={{ width: 200 }}+ value={scheduleType}+ variant="outlined"+ options={SCHEDULE_TYPE_OPTIONS.map((opt) => ({+ label: t(opt.label as any),+ value: opt.value,+ }))}+ onChange={handleScheduleTypeChange}+ />+ </Flexbox>++ {scheduleType !== 'hourly' && (+ <Flexbox horizontal align="center" gap={12} justify="space-between">+ <Text className={styles.label}>{t('taskSchedule.time')}</Text>+ <TimePicker+ format="HH:mm"+ minuteStep={15}+ style={{ width: 200 }}+ value={triggerTime}+ onChange={handleTimeChange}+ />+ </Flexbox>+ )}++ {scheduleType === 'hourly' && (+ <Flexbox horizontal align="center" gap={12} justify="space-between">+ <Text className={styles.label}>{t('taskSchedule.every')}</Text>+ <Flexbox horizontal align="center" gap={8}>+ <InputNumber+ max={24}+ min={1}+ style={{ width: 70 }}+ value={hourlyInterval}+ onChange={handleHourlyIntervalChange}+ />+ <Text type="secondary">{t('taskSchedule.hours')}</Text>+ <Select+ style={{ width: 80 }}+ value={triggerTime.minute()}+ variant="outlined"+ options={[+ { label: ':00', value: 0 },+ { label: ':15', value: 15 },+ { label: ':30', value: 30 },+ { label: ':45', value: 45 },+ ]}+ onChange={handleHourlyMinuteChange}+ />+ </Flexbox>+ </Flexbox>+ )}++ {scheduleType === 'weekly' && (+ <Flexbox horizontal align="center" gap={12} justify="space-between">+ <Text className={styles.label}>{t('taskSchedule.weekday')}</Text>+ <Flexbox horizontal gap={6}>+ {WEEKDAYS.map(({ key, label }) => (+ <div+ key={key}+ className={cx(+ styles.weekdayButton,+ weekdays.includes(key) && styles.weekdayButtonActive,+ )}+ onClick={() => toggleWeekday(key)}+ >+ {t(label as any)}+ </div>+ ))}+ </Flexbox>+ </Flexbox>+ )}++ <Flexbox horizontal align="center" gap={12} justify="space-between">+ <Text className={styles.label}>{t('taskSchedule.timezone')}</Text>+ <Select+ showSearch+ options={TIMEZONE_OPTIONS}+ popupMatchSelectWidth={false}+ style={{ width: 280 }}+ value={tz}+ variant="outlined"+ onChange={handleTimezoneChange}+ />+ </Flexbox>++ <Flexbox horizontal align="center" gap={12} justify="space-between">+ <Text className={styles.label}>{t('taskSchedule.maxExecutions')}</Text>+ <Flexbox horizontal align="center" gap={10}>+ <InputNumber+ disabled={isUnlimited}+ min={1}+ placeholder="100"+ style={{ width: 90 }}+ value={maxExec ?? undefined}+ onChange={handleMaxExecChange}+ />+ <Checkbox checked={isUnlimited} onChange={handleContinuousChange}>+ {t('taskSchedule.continuous')}+ </Checkbox>+ </Flexbox>+ </Flexbox>+ </Flexbox>+ );+});++export default SchedulerForm;diff --git a/src/features/AgentTasks/features/TaskStatusIcon.tsx b/src/features/AgentTasks/features/TaskStatusIcon.tsxindex 60824fb32b9..8e9db4565d2 100644--- a/src/features/AgentTasks/features/TaskStatusIcon.tsx+++ b/src/features/AgentTasks/features/TaskStatusIcon.tsx@@ -1,13 +1,20 @@+import type { TaskStatus } from '@lobechat/types';import { ActionIcon } from '@lobehub/ui';import { cssVar } from 'antd-style';import type { LucideIcon } from 'lucide-react';-import { CircleCheck, CircleDashed, CircleDot, CircleSlash, CircleX, HandIcon } from 'lucide-react';+import {+ CircleCheck,+ CircleDashed,+ CircleDot,+ CircleSlash,+ CircleX,+ Clock,+ HandIcon,+} from 'lucide-react';import { memo } from 'react';import { taskListSelectors } from '@/store/task/selectors';-type TaskStatus = 'backlog' | 'canceled' | 'completed' | 'failed' | 'paused' | 'running';-interface StatusMeta {color: string;icon: LucideIcon;@@ -20,11 +27,12 @@ const STATUS_META: Record<TaskStatus, StatusMeta> = {failed: { color: cssVar.colorError, icon: CircleX },paused: { color: cssVar.colorInfo, icon: HandIcon },running: { color: cssVar.colorWarning, icon: CircleDot },+ scheduled: { color: cssVar.colorTextDescription, icon: Clock },};interface TaskStatusIconProps {size?: number;- status: 'backlog' | 'canceled' | 'completed' | 'failed' | 'paused' | 'running';+ status: TaskStatus;}const TaskStatusIcon = memo<TaskStatusIconProps>(({ size = 16, status }) => {diff --git a/src/features/AgentTasks/features/TaskStatusTag.tsx b/src/features/AgentTasks/features/TaskStatusTag.tsxindex cf84f21bb82..ddf95d47876 100644--- a/src/features/AgentTasks/features/TaskStatusTag.tsx+++ b/src/features/AgentTasks/features/TaskStatusTag.tsx@@ -9,6 +9,7 @@ import {CircleDot,CircleSlash,CircleX,+ Clock,HandIcon,Loader2Icon,} from 'lucide-react';@@ -64,6 +65,12 @@ export const STATUS_META: Record<TaskStatus, StatusMeta> = {label: 'Running',labelKey: 'status.running',},+ scheduled: {+ color: cssVar.colorTextDescription,+ icon: Clock,+ label: 'Scheduled',+ labelKey: 'status.scheduled',+ },};export const USER_SELECTABLE_STATUSES: TaskStatus[] = [diff --git a/src/features/Conversation/ChatInput/QueueTray.tsx b/src/features/Conversation/ChatInput/QueueTray.tsxindex b5652c504d0..d5e678693bc 100644--- a/src/features/Conversation/ChatInput/QueueTray.tsx+++ b/src/features/Conversation/ChatInput/QueueTray.tsx@@ -18,10 +18,10 @@ import { useConversationStore } from '../store';const styles = createStaticStyles(({ css, cssVar }) => ({container: css`- border: 1px solid ${cssVar.colorBorderSecondary};+ border: 1px solid ${cssVar.colorFillSecondary};border-block-end: none;border-radius: 12px 12px 0 0;- background: ${cssVar.colorBgContainer};+ background: ${cssVar.colorBgElevated};`,icon: css`flex-shrink: 0;diff --git a/src/locales/default/chat.ts b/src/locales/default/chat.tsindex cffdee8de48..85cabd60bed 100644--- a/src/locales/default/chat.ts+++ b/src/locales/default/chat.ts@@ -508,27 +508,43 @@ export default {'task.status.initializing': 'Initializing task...','task.subtask': 'Subtask','taskSchedule.clear': 'Clear',+ 'taskSchedule.continuous': 'Continuous','taskSchedule.enable': 'Enable automation','taskSchedule.every': 'Every',+ 'taskSchedule.frequency': 'Frequency','taskSchedule.hours': 'Hours','taskSchedule.interval': 'Recurring','taskSchedule.intervalTab': 'Recurring',+ 'taskSchedule.maxExecutions': 'Max runs','taskSchedule.minutes': 'Minutes',+ 'taskSchedule.scheduleType.daily': 'Daily',+ 'taskSchedule.scheduleType.hourly': 'Hourly',+ 'taskSchedule.scheduleType.weekly': 'Weekly','taskSchedule.scheduler': 'Scheduler','taskSchedule.schedulerNotReady': 'Scheduler is coming soon. Use Recurring for now.','taskSchedule.schedulerTab': 'Scheduler','taskSchedule.seconds': 'Seconds',+ 'taskSchedule.tag.add': 'Set schedule',+ 'taskSchedule.tag.every': 'Every {{interval}}',+ 'taskSchedule.tag.heartbeat': 'Heartbeat · {{every}}',+ 'taskSchedule.tag.schedule': 'Schedule · {{schedule}}{{timezone}}',+ 'taskSchedule.time': 'Time',+ 'taskSchedule.timezone': 'Timezone',+ 'taskSchedule.title': 'Schedule','taskSchedule.unit.hour_one': '{{count}} hr','taskSchedule.unit.hour_other': '{{count}} hrs','taskSchedule.unit.minute_one': '{{count}} min','taskSchedule.unit.minute_other': '{{count}} mins','taskSchedule.unit.second_one': '{{count}} sec','taskSchedule.unit.second_other': '{{count}} secs',- 'taskSchedule.tag.add': 'Set schedule',- 'taskSchedule.tag.every': 'Every {{interval}}',- 'taskSchedule.tag.heartbeat': 'Heartbeat · {{every}}',- 'taskSchedule.tag.schedule': 'Schedule · {{schedule}}{{timezone}}',- 'taskSchedule.title': 'Schedule',+ 'taskSchedule.weekday': 'Weekday',+ 'taskSchedule.weekdays.fri': 'Fri',+ 'taskSchedule.weekdays.mon': 'Mon',+ 'taskSchedule.weekdays.sat': 'Sat',+ 'taskSchedule.weekdays.sun': 'Sun',+ 'taskSchedule.weekdays.thu': 'Thu',+ 'taskSchedule.weekdays.tue': 'Tue',+ 'taskSchedule.weekdays.wed': 'Wed','taskDetail.activities': 'Activities','taskDetail.activitiesEmpty': 'No activity yet','taskDetail.artifacts': 'Artifacts',@@ -580,6 +596,7 @@ export default {'taskDetail.status.failed': 'Failed','taskDetail.status.paused': 'Pending review','taskDetail.status.running': 'In progress',+ 'taskDetail.status.scheduled': 'Scheduled','taskDetail.subtasks': 'Subtasks','taskDetail.addSubtask': 'Add sub-task','taskDetail.subtaskInstructionPlaceholder': 'Describe the sub-task...',diff --git a/src/server/routers/lambda/task.ts b/src/server/routers/lambda/task.tsindex 4a422e859a3..28f696e4292 100644--- a/src/server/routers/lambda/task.ts+++ b/src/server/routers/lambda/task.ts@@ -60,6 +60,8 @@ const updateSchema = z.object({instruction: z.string().optional(),name: z.string().optional(),priority: z.number().min(0).max(4).optional(),+ schedulePattern: z.string().nullable().optional(),+ scheduleTimezone: z.string().nullable().optional(),});const listSchema = z.object({diff --git a/src/server/services/task/index.ts b/src/server/services/task/index.tsindex e4b1bfface9..29d9cbd8c43 100644--- a/src/server/services/task/index.ts+++ b/src/server/services/task/index.ts@@ -61,7 +61,7 @@ export class TaskService {const [allDescendants, dependencies, topics, briefs, comments, workspace] = await Promise.all([this.taskModel.findAllDescendants(task.id),this.taskModel.getDependencies(task.id),- this.taskTopicModel.findWithHandoff(task.id).catch(() => []),+ this.taskTopicModel.findWithHandoff(task.id, 100).catch(() => []),this.briefModel.findByTaskId(task.id).catch(() => []),this.taskModel.getComments(task.id).catch(() => []),this.taskModel.getTreePinnedDocuments(task.id).catch(() => emptyWorkspace),@@ -265,11 +265,14 @@ export class TaskService {return a.time.localeCompare(b.time);});+ const taskConfig = task.config ? (task.config as Record<string, unknown>) : undefined;+ const scheduleConfig = (taskConfig?.schedule ?? {}) as { maxExecutions?: number | null };+return {agentId: task.assigneeAgentId,automationMode: task.automationMode ?? null,checkpoint: this.taskModel.getCheckpointConfig(task),- config: task.config ? (task.config as Record<string, unknown>) : undefined,+ config: taskConfig,createdAt: task.createdAt ? new Date(task.createdAt).toISOString() : undefined,dependencies: dependencies.map((d) => {const info = depIdToInfo.get(d.dependsOnId);@@ -295,6 +298,14 @@ export class TaskService {parent,priority: task.priority,review: this.taskModel.getReviewConfig(task),+ schedule:+ task.schedulePattern || task.scheduleTimezone || scheduleConfig.maxExecutions != null+ ? {+ maxExecutions: scheduleConfig.maxExecutions ?? null,+ pattern: task.schedulePattern,+ timezone: task.scheduleTimezone,+ }+ : undefined,status: task.status,userId: task.assigneeUserId,subtasks,diff --git a/src/server/services/taskLifecycle/index.ts b/src/server/services/taskLifecycle/index.tsindex 3cefcff14fc..dcfc7735bce 100644--- a/src/server/services/taskLifecycle/index.ts+++ b/src/server/services/taskLifecycle/index.ts@@ -101,12 +101,22 @@ export class TaskLifecycleService {if (reviewTerminated) return;- // 4. Default: pause for user review.- // A 'result' brief from the agent is a *proposal* of completion — the user- // must explicitly approve via the brief action to transition to 'completed'.- // Auto-complete only happens via the Judge path above.- if (currentTask && this.taskModel.shouldPauseOnTopicComplete(currentTask)) {- await this.taskModel.updateStatus(taskId, 'paused', { error: null });+ // 4. Default post-tick transition.+ // - Automation tasks (heartbeat / schedule) loop running ↔ scheduled, so+ // a successful tick parks the task at 'scheduled' to wait for the next+ // tick. They never auto-pause on success — only `reason === 'error'`+ // below puts them in 'paused' for human attention.+ // - Non-automation tasks fall back to the legacy "pause for user review"+ // behavior: a 'result' brief from the agent is a *proposal* of+ // completion, and the user must explicitly approve via the brief action+ // to transition to 'completed'. Auto-complete only happens via the+ // Judge path above.+ if (currentTask) {+ if (currentTask.automationMode) {+ await this.taskModel.updateStatus(taskId, 'scheduled', { error: null });+ } else if (this.taskModel.shouldPauseOnTopicComplete(currentTask)) {+ await this.taskModel.updateStatus(taskId, 'paused', { error: null });+ }}} else if (reason === 'error') {if (topicId) await this.taskTopicModel.updateStatus(taskId, topicId, 'failed');diff --git a/src/server/services/taskLifecycle/onTopicComplete.test.ts b/src/server/services/taskLifecycle/onTopicComplete.test.tsnew file mode 100644index 00000000000..582cf8cdc65--- /dev/null+++ b/src/server/services/taskLifecycle/onTopicComplete.test.ts@@ -0,0 +1,169 @@+// @vitest-environment node+import type { TaskItem } from '@lobechat/types';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import { TaskLifecycleService } from './index';++const fakeScheduler = {+ cancelScheduled: vi.fn().mockResolvedValue(undefined),+ scheduleNextTopic: vi.fn().mockResolvedValue('msg-new'),+};++vi.mock('@/server/services/taskScheduler', () => ({+ createTaskSchedulerModule: () => fakeScheduler,+}));++const baseTask = (overrides: Partial<TaskItem> = {}): TaskItem =>+ ({+ automationMode: 'heartbeat',+ config: {},+ context: {},+ error: null,+ heartbeatInterval: 30,+ heartbeatTimeout: 600,+ id: 'task-1',+ identifier: 'TASK-1',+ instruction: 'do the thing',+ name: 'demo',+ status: 'running',+ ...overrides,+ }) as unknown as TaskItem;++describe('TaskLifecycleService.onTopicComplete', () => {+ let service: TaskLifecycleService;+ let updateStatus: ReturnType<typeof vi.fn>;+ let findById: ReturnType<typeof vi.fn>;+ let updateHeartbeat: ReturnType<typeof vi.fn>;+ let updateTopicStatus: ReturnType<typeof vi.fn>;+ let createBrief: ReturnType<typeof vi.fn>;+ let getReviewConfig: ReturnType<typeof vi.fn>;++ beforeEach(() => {+ fakeScheduler.scheduleNextTopic.mockClear().mockResolvedValue('msg-new');++ service = new TaskLifecycleService({} as any, 'user-1');++ updateStatus = vi.fn().mockResolvedValue(null);+ findById = vi.fn();+ updateHeartbeat = vi.fn().mockResolvedValue(undefined);+ updateTopicStatus = vi.fn().mockResolvedValue(undefined);+ createBrief = vi.fn().mockResolvedValue(undefined);+ getReviewConfig = vi.fn().mockReturnValue(undefined);++ const taskModel = (service as any).taskModel;+ taskModel.updateStatus = updateStatus;+ taskModel.findById = findById;+ taskModel.updateHeartbeat = updateHeartbeat;+ taskModel.getReviewConfig = getReviewConfig;+ // Default checkpoint behavior: pause after topic complete+ taskModel.shouldPauseOnTopicComplete = vi.fn().mockReturnValue(true);+ // Avoid generateHandoff side effects by skipping when lastAssistantContent is undefined+ (service as any).taskTopicModel.updateStatus = updateTopicStatus;+ (service as any).briefModel.create = createBrief;+ (service as any).briefModel.hasUnresolvedUrgentByTask = vi.fn().mockResolvedValue(false);+ });++ afterEach(() => {+ vi.restoreAllMocks();+ });++ describe('reason=done', () => {+ it('automation task → status="scheduled" (not paused)', async () => {+ const task = baseTask({ automationMode: 'heartbeat' });+ findById.mockResolvedValue(task);++ await service.onTopicComplete({+ operationId: 'op-1',+ reason: 'done',+ taskId: 'task-1',+ taskIdentifier: 'TASK-1',+ topicId: 'topic-1',+ });++ expect(updateStatus).toHaveBeenCalledWith('task-1', 'scheduled', { error: null });+ expect(updateStatus).not.toHaveBeenCalledWith('task-1', 'paused', expect.anything());+ });++ it('schedule-mode task → status="scheduled"', async () => {+ const task = baseTask({ automationMode: 'schedule' });+ findById.mockResolvedValue(task);++ await service.onTopicComplete({+ operationId: 'op-1',+ reason: 'done',+ taskId: 'task-1',+ taskIdentifier: 'TASK-1',+ topicId: 'topic-1',+ });++ expect(updateStatus).toHaveBeenCalledWith('task-1', 'scheduled', { error: null });+ });++ it('non-automation task with default checkpoint → status="paused" (legacy behavior)', async () => {+ const task = baseTask({ automationMode: null });+ findById.mockResolvedValue(task);++ await service.onTopicComplete({+ operationId: 'op-1',+ reason: 'done',+ taskId: 'task-1',+ taskIdentifier: 'TASK-1',+ topicId: 'topic-1',+ });++ expect(updateStatus).toHaveBeenCalledWith('task-1', 'paused', { error: null });+ expect(updateStatus).not.toHaveBeenCalledWith('task-1', 'scheduled', expect.anything());+ });++ it('non-automation task with shouldPauseOnTopicComplete=false → no status update', async () => {+ const task = baseTask({ automationMode: null });+ findById.mockResolvedValue(task);+ (service as any).taskModel.shouldPauseOnTopicComplete = vi.fn().mockReturnValue(false);++ await service.onTopicComplete({+ operationId: 'op-1',+ reason: 'done',+ taskId: 'task-1',+ taskIdentifier: 'TASK-1',+ topicId: 'topic-1',+ });++ expect(updateStatus).not.toHaveBeenCalled();+ });+ });++ describe('reason=error', () => {+ it('automation task → status="paused" (error always pauses)', async () => {+ const task = baseTask({ automationMode: 'heartbeat' });+ findById.mockResolvedValue(task);++ await service.onTopicComplete({+ errorMessage: 'boom',+ operationId: 'op-1',+ reason: 'error',+ taskId: 'task-1',+ taskIdentifier: 'TASK-1',+ topicId: 'topic-1',+ });++ expect(updateStatus).toHaveBeenCalledWith('task-1', 'paused');+ expect(updateStatus).not.toHaveBeenCalledWith('task-1', 'scheduled', expect.anything());+ });++ it('non-automation task → status="paused" (unchanged behavior)', async () => {+ const task = baseTask({ automationMode: null });+ findById.mockResolvedValue(task);++ await service.onTopicComplete({+ errorMessage: 'boom',+ operationId: 'op-1',+ reason: 'error',+ taskId: 'task-1',+ taskIdentifier: 'TASK-1',+ topicId: 'topic-1',+ });++ expect(updateStatus).toHaveBeenCalledWith('task-1', 'paused');+ });+ });+});diff --git a/src/server/services/taskRunner/buildTaskPrompt.ts b/src/server/services/taskRunner/buildTaskPrompt.tsindex 8471cc7f57c..e08c27e79e9 100644--- a/src/server/services/taskRunner/buildTaskPrompt.ts+++ b/src/server/services/taskRunner/buildTaskPrompt.ts@@ -27,7 +27,7 @@ export async function buildTaskPrompt(const [topics, briefs, comments, subtasks, dependencies, documents] = await Promise.all([task.totalTopics && task.totalTopics > 0- ? taskTopicModel.findWithHandoff(task.id).catch(() => [])+ ? taskTopicModel.findWithHandoff(task.id, 4).catch(() => []): Promise.resolve([]),briefModel.findByTaskId(task.id).catch(() => []),taskModel.getComments(task.id).catch(() => []),diff --git a/src/services/task.ts b/src/services/task.tsindex 963dff5d5c6..c67cbb11518 100644--- a/src/services/task.ts+++ b/src/services/task.ts@@ -75,6 +75,10 @@ class TaskService {instruction?: string;name?: string;priority?: number;+ // schedulePattern: cron expression for scheduled automation (e.g. '0 9 * * *')+ schedulePattern?: string | null;+ // scheduleTimezone: IANA timezone for the cron expression (e.g. 'Asia/Shanghai')+ scheduleTimezone?: string | null;},) => lambdaClient.task.update.mutate({ id, ...data });@@ -82,11 +86,8 @@ class TaskService {clearAll = async () => lambdaClient.task.clearAll.mutate();- updateStatus = async (- id: string,- status: 'backlog' | 'canceled' | 'completed' | 'failed' | 'paused' | 'running',- error?: string,- ) => lambdaClient.task.updateStatus.mutate({ error, id, status });+ updateStatus = async (id: string, status: TaskStatus, error?: string) =>+ lambdaClient.task.updateStatus.mutate({ error, id, status });run = async (id: string, params?: { continueTopicId?: string; prompt?: string }) =>lambdaClient.task.run.mutate({ id, ...params });diff --git a/src/store/task/selectors/detailSelectors.test.ts b/src/store/task/selectors/detailSelectors.test.tsindex 189cb900e27..44c3d864ed3 100644--- a/src/store/task/selectors/detailSelectors.test.ts+++ b/src/store/task/selectors/detailSelectors.test.ts@@ -162,6 +162,14 @@ describe('taskDetailSelectors', () => {});expect(taskDetailSelectors.canRunActiveTask(state)).toBe(true);});++ it('should return false for scheduled task (automation owns the next run)', () => {+ const state = createState({+ activeTaskId: 'T-1',+ taskDetailMap: { 'T-1': { ...mockDetail, status: 'scheduled' } },+ });+ expect(taskDetailSelectors.canRunActiveTask(state)).toBe(false);+ });});describe('canPauseActiveTask', () => {@@ -180,10 +188,18 @@ describe('taskDetailSelectors', () => {});expect(taskDetailSelectors.canPauseActiveTask(state)).toBe(false);});++ it('should return false for scheduled task', () => {+ const state = createState({+ activeTaskId: 'T-1',+ taskDetailMap: { 'T-1': { ...mockDetail, status: 'scheduled' } },+ });+ expect(taskDetailSelectors.canPauseActiveTask(state)).toBe(false);+ });});describe('canCancelActiveTask', () => {- it.each(['running', 'paused', 'backlog'] as const)(+ it.each(['running', 'paused', 'backlog', 'scheduled'] as const)('should return true for %s task',(status) => {const state = createState({diff --git a/src/store/task/selectors/detailSelectors.ts b/src/store/task/selectors/detailSelectors.tsindex 5c90d49a636..a4ba083ae92 100644--- a/src/store/task/selectors/detailSelectors.ts+++ b/src/store/task/selectors/detailSelectors.ts@@ -44,6 +44,16 @@ const activeTaskPeriodicInterval = (s: TaskStoreState) =>// Automation mode: 'heartbeat' | 'schedule' | null (null = no automation)const activeTaskAutomationMode = (s: TaskStoreState) => activeTaskDetail(s)?.automationMode ?? null;+// Schedule (cron) mode fields. pattern/timezone are columns; maxExecutions lives in config.schedule.+const activeTaskSchedulePattern = (s: TaskStoreState) =>+ activeTaskDetail(s)?.schedule?.pattern ?? null;++const activeTaskScheduleTimezone = (s: TaskStoreState) =>+ activeTaskDetail(s)?.schedule?.timezone ?? null;++const activeTaskScheduleMaxExecutions = (s: TaskStoreState) =>+ activeTaskDetail(s)?.schedule?.maxExecutions ?? null;+const activeTaskCheckpoint = (s: TaskStoreState) => activeTaskDetail(s)?.checkpoint;const activeTaskReview = (s: TaskStoreState) => activeTaskDetail(s)?.review;@@ -57,6 +67,8 @@ const activeTaskTopicCount = (s: TaskStoreState) => activeTaskDetail(s)?.topicCoconst canRunActiveTask = (s: TaskStoreState): boolean => {const detail = activeTaskDetail(s);if (!detail) return false;+ // 'scheduled' is intentionally excluded — automation owns the next run; the+ // user can only cancel, not force an immediate run.return ['backlog', 'failed', 'paused', 'completed'].includes(detail.status);};@@ -66,7 +78,7 @@ const canPauseActiveTask = (s: TaskStoreState): boolean =>const canCancelActiveTask = (s: TaskStoreState): boolean => {const detail = activeTaskDetail(s);if (!detail) return false;- return ['backlog', 'paused', 'running'].includes(detail.status);+ return ['backlog', 'paused', 'running', 'scheduled'].includes(detail.status);};const taskSaveStatus = (s: TaskStoreState) => s.taskSaveStatus;@@ -90,6 +102,9 @@ export const taskDetailSelectors = {activeTaskPriority,activeTaskProvider,activeTaskReview,+ activeTaskScheduleMaxExecutions,+ activeTaskSchedulePattern,+ activeTaskScheduleTimezone,activeTaskStatus,activeTaskSubtasks,activeTaskTopicCount,diff --git a/src/store/task/selectors/listSelectors.ts b/src/store/task/selectors/listSelectors.tsindex e7364cf030c..7e4456f958c 100644--- a/src/store/task/selectors/listSelectors.ts+++ b/src/store/task/selectors/listSelectors.ts@@ -16,6 +16,7 @@ const statusDisplayMap: Record<string, string> = {failed: 'Needs input',paused: 'Needs input',running: 'In progress',+ scheduled: 'Scheduled',};const getDisplayStatus = (status: string): string => statusDisplayMap[status] ?? status;diff --git a/src/store/task/slices/config/action.ts b/src/store/task/slices/config/action.tsindex 1a309ed8465..9d0a65d7320 100644--- a/src/store/task/slices/config/action.ts+++ b/src/store/task/slices/config/action.ts@@ -134,8 +134,33 @@ export class TaskConfigSliceActionImpl {}};- // TODO [LOBE-6587]: Scheduled tasks (cron mode)- // updateSchedule(id, { pattern, timezone }) — backend task.update schema does not yet expose schedulePattern/scheduleTimezone+ // Configure schedule mode: cron pattern + IANA timezone are columns; maxExecutions+ // (null = unlimited / continuous) lives in `tasks.config.schedule` JSONB pocket.+ // Whether the schedule actually fires depends on automationMode === 'schedule'.+ updateSchedule = async (+ id: string,+ schedule: { maxExecutions: number | null; pattern: string; timezone: string },+ ): Promise<void> => {+ const existingConfig =+ (this.#get().taskDetailMap[id]?.config as Record<string, unknown> | undefined) ?? {};+ const existingScheduleConfig =+ (existingConfig.schedule as Record<string, unknown> | undefined) ?? {};++ try {+ await taskService.update(id, {+ config: {+ ...existingConfig,+ schedule: { ...existingScheduleConfig, maxExecutions: schedule.maxExecutions },+ },+ schedulePattern: schedule.pattern,+ scheduleTimezone: schedule.timezone,+ });+ await this.#get().internal_refreshTaskDetail(id);+ } catch (error) {+ console.error('[TaskStore] Failed to update schedule:', error);+ await this.#get().internal_refreshTaskDetail(id);+ }+ };}export type TaskConfigSliceAction = Pick<diff --git a/src/store/task/slices/list/action.ts b/src/store/task/slices/list/action.tsindex e5704a83298..13044a84323 100644--- a/src/store/task/slices/list/action.ts+++ b/src/store/task/slices/list/action.ts@@ -16,9 +16,12 @@ const FETCH_TASK_GROUP_LIST_KEY = 'fetchTaskGroupList';export const ALL_AGENTS_LIST_KEY = '__all__';// Default kanban groups: 5 columns+// 'scheduled' shares the 'running' column — both represent "automation in+// progress" from the user's perspective (one is mid-tick, the other is+// waiting for the next tick).const DEFAULT_KANBAN_GROUPS = [{ key: 'backlog', statuses: ['backlog'] },- { key: 'running', statuses: ['running'] },+ { key: 'running', statuses: ['running', 'scheduled'] },{ key: 'needsInput', statuses: ['paused', 'failed'] },{ key: 'done', statuses: ['completed'] },{ key: 'canceled', statuses: ['canceled'] },