Skip to content

🤯 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.

✨ feat(tasks): show scheduled tasks as a tab beside tasks and goals (#23622)

AmAzing-2d4d59bd1bc0
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index ffb03706375..bdbb663f7e6 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -2554,6 +2554,7 @@
"tab.mail": "Mail",
"tab.profile": "Agent Profile",
"tab.profileBasic": "Profile",
+ "tab.scheduled": "Scheduled",
"tab.search": "Search",
"tab.skills": "Skills",
"tab.tasks": "Tasks",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index 9a4b4f9a713..846dd598b86 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -2554,6 +2554,7 @@
"tab.mail": "邮箱",
"tab.profile": "助理档案",
"tab.profileBasic": "基础档案",
+ "tab.scheduled": "定时任务",
"tab.search": "搜索",
"tab.skills": "技能",
"tab.tasks": "任务",
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index e336b39cf2b..7ced8320f74 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -2156,6 +2156,7 @@ export default {
'tab.skills': 'Skills',
'tab.search': 'Search',
'tab.goalsAndTasks': 'Tasks and goals',
+ 'tab.scheduled': 'Scheduled',
'tab.tasks': 'Tasks',
'task.activity.calling': 'Calling Skill...',
'task.activity.clientExecuting': 'Executing locally...',
diff --git a/src/features/AgentTasks/AgentGoalsAndTasksTabs.test.ts b/src/features/AgentTasks/AgentGoalsAndTasksTabs.test.ts
new file mode 100644
index 00000000000..8d96bb6b460
--- /dev/null
+++ b/src/features/AgentTasks/AgentGoalsAndTasksTabs.test.ts
@@ -0,0 +1,48 @@
+import { describe, expect, it } from 'vitest';
+
+import { goalsAndTasksTabPath, resolveGoalsAndTasksTabAction } from './AgentGoalsAndTasksTabs';
+
+describe('goalsAndTasksTabPath', () => {
+ it('addresses scheduled tasks as a collection of the tasks route', () => {
+ expect(goalsAndTasksTabPath('tasks')).toBe('/tasks');
+ expect(goalsAndTasksTabPath('scheduled')).toBe('/tasks?collection=scheduled');
+ expect(goalsAndTasksTabPath('goals')).toBe('/goals');
+ });
+
+ it('scopes every tab to the agent', () => {
+ expect(goalsAndTasksTabPath('tasks', 'agt_1')).toBe('/agent/agt_1/tasks');
+ expect(goalsAndTasksTabPath('scheduled', 'agt_1')).toBe(
+ '/agent/agt_1/tasks?collection=scheduled',
+ );
+ expect(goalsAndTasksTabPath('goals', 'agt_1')).toBe('/agent/agt_1/goals');
+ });
+});
+
+describe('resolveGoalsAndTasksTabAction', () => {
+ it('opens scheduled tasks by navigation from the goals page', () => {
+ expect(resolveGoalsAndTasksTabAction('scheduled', { agentId: 'agt_1' })).toEqual({
+ path: '/agent/agt_1/tasks?collection=scheduled',
+ type: 'navigate',
+ });
+ expect(resolveGoalsAndTasksTabAction('tasks')).toEqual({ path: '/tasks', type: 'navigate' });
+ });
+
+ it('switches task collections in place on the tasks page', () => {
+ const options = { agentId: 'agt_1', switchesCollectionInPlace: true };
+
+ expect(resolveGoalsAndTasksTabAction('scheduled', options)).toEqual({
+ collection: 'scheduled',
+ type: 'collection',
+ });
+ expect(resolveGoalsAndTasksTabAction('tasks', options)).toEqual({
+ collection: 'tasks',
+ type: 'collection',
+ });
+ });
+
+ it('still leaves the tasks page for goals', () => {
+ expect(
+ resolveGoalsAndTasksTabAction('goals', { agentId: 'agt_1', switchesCollectionInPlace: true }),
+ ).toEqual({ path: '/agent/agt_1/goals', type: 'navigate' });
+ });
+});
diff --git a/src/features/AgentTasks/AgentGoalsAndTasksTabs.tsx b/src/features/AgentTasks/AgentGoalsAndTasksTabs.tsx
index fa5d06ed237..32c0ff75a2a 100644
--- a/src/features/AgentTasks/AgentGoalsAndTasksTabs.tsx
+++ b/src/features/AgentTasks/AgentGoalsAndTasksTabs.tsx
@@ -4,27 +4,82 @@ import { useTranslation } from 'react-i18next';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
+/** The two task collections this strip switches between, beside goals. */
+export type GoalsAndTasksCollection = 'scheduled' | 'tasks';
+export type GoalsAndTasksView = 'goals' | GoalsAndTasksCollection;
+
+/** Tab order: the two existing tabs keep their place, scheduled tasks join after them. */
+const GOALS_AND_TASKS_TABS: readonly GoalsAndTasksView[] = ['tasks', 'goals', 'scheduled'];
+
+const TAB_LABEL_KEYS = {
+ goals: 'goalList.title',
+ scheduled: 'tab.scheduled',
+ tasks: 'tab.tasks',
+} as const satisfies Record<GoalsAndTasksView, string>;
+
+/**
+ * Where a tab lives. Tasks and goals are routes; scheduled tasks are a
+ * collection of the tasks route, so that tab keeps its `collection=scheduled`
+ * address and every existing link to it still resolves.
+ */
+export const goalsAndTasksTabPath = (view: GoalsAndTasksView, agentId?: string): string => {
+ const base = agentId ? `/agent/${agentId}` : '';
+ if (view === 'goals') return `${base}/goals`;
+ return view === 'scheduled' ? `${base}/tasks?collection=scheduled` : `${base}/tasks`;
+};
+
+export type GoalsAndTasksTabAction =
+ { collection: GoalsAndTasksCollection; type: 'collection' } | { path: string; type: 'navigate' };
+
+/**
+ * What picking a tab does. On the tasks page (`switchesCollectionInPlace`) the
+ * two task collections switch through the page itself, which keeps its other
+ * search params and resets its own pagination; every other pick is a
+ * navigation.
+ */
+export const resolveGoalsAndTasksTabAction = (
+ next: GoalsAndTasksView,
+ options: { agentId?: string; switchesCollectionInPlace?: boolean } = {},
+): GoalsAndTasksTabAction =>
+ next !== 'goals' && options.switchesCollectionInPlace
+ ? { collection: next, type: 'collection' }
+ : { path: goalsAndTasksTabPath(next, options.agentId), type: 'navigate' };
+
interface AgentGoalsAndTasksTabsProps {
agentId?: string;
- view: 'goals' | 'tasks';
+ /** Passed by the tasks page to switch between its collections in place. */
+ onTaskCollectionChange?: (collection: GoalsAndTasksCollection) => void;
+ view: GoalsAndTasksView;
}
-export const AgentGoalsAndTasksTabs = memo<AgentGoalsAndTasksTabsProps>(({ agentId, view }) => {
- const { t } = useTranslation('chat');
- const navigate = useWorkspaceAwareNavigate();
-
- return (
- <TabsRoot
- size={'small'}
- value={view}
- variant={'square'}
- onValueChange={(value) => navigate(agentId ? `/agent/${agentId}/${value}` : `/${value}`)}
- >
- <TabsList aria-label={t('tab.goalsAndTasks')}>
- <TabsIndicator />
- <TabsTab value={'tasks'}>{t('tab.tasks')}</TabsTab>
- <TabsTab value={'goals'}>{t('goalList.title')}</TabsTab>
- </TabsList>
- </TabsRoot>
- );
-});
+export const AgentGoalsAndTasksTabs = memo<AgentGoalsAndTasksTabsProps>(
+ ({ agentId, onTaskCollectionChange, view }) => {
+ const { t } = useTranslation('chat');
+ const navigate = useWorkspaceAwareNavigate();
+
+ const handleChange = (value: string) => {
+ const action = resolveGoalsAndTasksTabAction(value as GoalsAndTasksView, {
+ agentId,
+ switchesCollectionInPlace: !!onTaskCollectionChange,
+ });
+ if (action.type === 'collection') {
+ onTaskCollectionChange?.(action.collection);
+ return;
+ }
+ navigate(action.path);
+ };
+
+ return (
+ <TabsRoot size={'small'} value={view} variant={'square'} onValueChange={handleChange}>
+ <TabsList aria-label={t('tab.goalsAndTasks')}>
+ <TabsIndicator />
+ {GOALS_AND_TASKS_TABS.map((tab) => (
+ <TabsTab key={tab} value={tab}>
+ {t(TAB_LABEL_KEYS[tab])}
+ </TabsTab>
+ ))}
+ </TabsList>
+ </TabsRoot>
+ );
+ },
+);
diff --git a/src/features/AgentTasks/AgentTaskList/AgentTasksPage.test.ts b/src/features/AgentTasks/AgentTaskList/AgentTasksPage.test.ts
index 6af540d5735..5cd9206fa76 100644
--- a/src/features/AgentTasks/AgentTaskList/AgentTasksPage.test.ts
+++ b/src/features/AgentTasks/AgentTaskList/AgentTasksPage.test.ts
@@ -82,7 +82,8 @@ describe('AgentTasksPage', () => {
}),
).toEqual({
...DEFAULT_TASK_LIST_VIEW_OPTIONS,
- groupBy: 'automationMode',
+ groupBy: 'none',
+ subGroupBy: 'none',
completedTasks: 'all',
orderBy: 'updatedAt',
orderDirection: 'asc',
@@ -90,6 +91,16 @@ describe('AgentTasksPage', () => {
});
});
+ it('lists scheduled tasks without group headers, whatever grouping is stored', () => {
+ const options = getScheduledTaskViewOptions({
+ ...DEFAULT_TASK_LIST_VIEW_OPTIONS,
+ groupBy: 'status',
+ subGroupBy: 'priority',
+ });
+ expect(options.groupBy).toBe('none');
+ expect(options.subGroupBy).toBe('none');
+ });
+
it('renders a page newest-first, like the server paginates it', () => {
const options = getScheduledTaskViewOptions(DEFAULT_TASK_LIST_VIEW_OPTIONS);
const newer = taskUpdatedAt('a', '2026-02-01');
@@ -101,17 +112,14 @@ describe('AgentTasksPage', () => {
describe('collectionGroupsByProject', () => {
const project = { ...DEFAULT_TASK_LIST_VIEW_OPTIONS, groupBy: 'project' as const };
- it('ignores a stored project grouping on the scheduled tab, which replaces it', () => {
+ it('ignores a stored project grouping on the scheduled tab, which is ungrouped', () => {
expect(collectionGroupsByProject('scheduled', project)).toBe(false);
- });
-
- it('still counts a project sub-grouping on the scheduled tab, which keeps it', () => {
expect(
collectionGroupsByProject('scheduled', {
...DEFAULT_TASK_LIST_VIEW_OPTIONS,
subGroupBy: 'project',
}),
- ).toBe(true);
+ ).toBe(false);
});
it('counts it on the tabs that render the stored grouping', () => {
diff --git a/src/features/AgentTasks/AgentTaskList/AgentTasksPage.tsx b/src/features/AgentTasks/AgentTaskList/AgentTasksPage.tsx
index 7afb1bae054..c1c82c5ef75 100644
--- a/src/features/AgentTasks/AgentTaskList/AgentTasksPage.tsx
+++ b/src/features/AgentTasks/AgentTaskList/AgentTasksPage.tsx
@@ -8,7 +8,7 @@ import {
TabsRoot,
TabsTab,
} from '@lobehub/ui';
-import { ClockIcon, Plus } from 'lucide-react';
+import { Plus } from 'lucide-react';
import { memo, type ReactNode, useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useLocation, useSearchParams } from 'react-router';
@@ -200,18 +200,24 @@ const PAGINATED_COLLECTION_VIEW = {
showSubTasks: true,
} as const;
+/**
+ * The scheduled tab is a plain list: no group headers, since each row already
+ * states its own rhythm (the schedule or heartbeat chip). A stored grouping
+ * belongs to the ordinary list and is set aside here.
+ */
export const getScheduledTaskViewOptions = (
viewOptions: TaskListViewOptions,
): TaskListViewOptions => ({
...viewOptions,
...PAGINATED_COLLECTION_VIEW,
- groupBy: 'automationMode',
+ groupBy: 'none',
+ subGroupBy: 'none',
});
/**
* Whether a collection's project groups need the project list to be told apart.
- * Judged on what the collection renders: the scheduled tab replaces the stored
- * grouping, so a stored `project` must not hold it behind the project request.
+ * Judged on what the collection renders: the scheduled tab is an ungrouped
+ * list, so a stored `project` must not hold it behind the project request.
*/
export const collectionGroupsByProject = (
collection: TaskCollection,
@@ -575,7 +581,11 @@ const AgentTasksPage = memo<AgentTasksPageProps>(({ agentId, headerActions, proj
const showGoalsAndTasksTabs = !!agentId || (!projectId && !activeWorkspaceId);
const headerLeft = showGoalsAndTasksTabs ? (
- <AgentGoalsAndTasksTabs agentId={agentId} view={'tasks'} />
+ <AgentGoalsAndTasksTabs
+ agentId={agentId}
+ view={isScheduledCollection ? 'scheduled' : 'tasks'}
+ onTaskCollectionChange={handleCollectionChange}
+ />
) : (
<Flexbox horizontal align={'center'} gap={8}>
{headerVisibility.showBreadcrumb && <Breadcrumb />}
@@ -611,21 +621,6 @@ const AgentTasksPage = memo<AgentTasksPageProps>(({ agentId, headerActions, proj
styles={showGoalsAndTasksTabs ? undefined : { left: { gap: 8, paddingLeft: 4 } }}
right={
<Flexbox horizontal align={'center'} gap={4}>
- {showGoalsAndTasksTabs && (
- <Button
- aria-label={t('taskList.scheduled.title')}
- aria-pressed={isScheduledCollection}
- icon={ClockIcon}
- size={'small'}
- title={t('taskList.scheduled.title')}
- type={isScheduledCollection ? 'fill' : 'text'}
- onClick={() =>
- handleCollectionChange(isScheduledCollection ? 'tasks' : 'scheduled')
- }
- >
- {isMobile ? undefined : t('taskList.scheduled.title')}
- </Button>
- )}
{showFind && <TaskListFind content={filter?.content} onChange={handleFindChange} />}
{(headerVisibility.showViewOptions || hasFilter) && (
<TaskFilterButton fields={filterFields} filter={filter} setFilter={setFilter} />