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): unified Tasks routes, detail polish & CC Agent streaming (#14109)

Arvin Xub3dc59f77ace
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index 407b7d38899..cc5138d1490 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -478,7 +478,7 @@
"taskDetail.comment.deleteConfirm.title": "Delete this comment?",
"taskDetail.comment.edit": "Edit",
"taskDetail.comment.save": "Save",
- "taskDetail.commentPlaceholder": "Leave a comment...",
+ "taskDetail.commentPlaceholder": "Leave feedback to guide the agent — your comments shape the next run...",
"taskDetail.deleteConfirm.content": "This action cannot be undone.",
"taskDetail.deleteConfirm.ok": "Delete",
"taskDetail.deleteConfirm.title": "Delete this task?",
@@ -520,21 +520,38 @@
"taskDetail.updateFailed": "Failed to update task",
"taskList.activeTasks": "Active Tasks",
"taskList.all": "All tasks",
+ "taskList.assigneeSearch.empty": "No matching agent",
+ "taskList.assigneeSearch.placeholder": "Search agent...",
"taskList.breadcrumb.task": "Task",
+ "taskList.contextMenu.copyId": "Copy ID",
+ "taskList.contextMenu.copyIdSuccess": "ID copied",
+ "taskList.contextMenu.copyLink": "Copy link",
+ "taskList.contextMenu.copyLinkSuccess": "Link copied",
+ "taskList.contextMenu.priority": "Priority",
+ "taskList.contextMenu.status": "Status",
"taskList.empty": "No tasks yet",
"taskList.form.grouping": "Grouping",
"taskList.form.orderCompletedByRecency": "Sort completed tasks by recency",
"taskList.form.ordering": "Ordering",
+ "taskList.form.showCompleted": "Show completed & canceled",
"taskList.form.subGrouping": "Sub-grouping",
"taskList.groupBy.assignee": "Assignee",
"taskList.groupBy.none": "No grouping",
"taskList.groupBy.priority": "Priority",
"taskList.groupBy.status": "Status",
+ "taskList.hiddenCompleted.count_one": "{{count}} task",
+ "taskList.hiddenCompleted.count_other": "{{count}} tasks",
+ "taskList.hiddenCompleted.show": "Show",
+ "taskList.hiddenCompleted.suffix": "hidden by display options",
+ "taskList.kanban.addTask": "Create task",
"taskList.kanban.backlog": "Backlog",
"taskList.kanban.done": "Done",
"taskList.kanban.emptyColumn": "No tasks",
+ "taskList.kanban.hiddenColumns": "Hidden columns",
+ "taskList.kanban.hideColumn": "Hide column",
"taskList.kanban.needsInput": "Needs input",
"taskList.kanban.running": "In progress",
+ "taskList.kanban.showColumn": "Show column",
"taskList.orderBy.assignee": "Assignee",
"taskList.orderBy.createdAt": "Created at",
"taskList.orderBy.priority": "Priority",
@@ -543,6 +560,7 @@
"taskList.orderBy.updatedAt": "Updated at",
"taskList.title": "Tasks",
"taskList.unassigned": "Unassigned",
+ "taskList.unassignedHint": "Lobe AI will run this task when no assignee is set",
"taskList.view.board": "Board",
"taskList.view.list": "List",
"taskList.viewAll": "View all",
diff --git a/locales/en-US/common.json b/locales/en-US/common.json
index 38bcf113a75..d43362be05a 100644
--- a/locales/en-US/common.json
+++ b/locales/en-US/common.json
@@ -146,6 +146,7 @@
"cmdk.keywords.starGitHub": "github star favorite like",
"cmdk.keywords.stats": "stats statistics analytics",
"cmdk.keywords.submitIssue": "issue bug problem feedback",
+ "cmdk.keywords.tasks": "tasks todo agent kanban",
"cmdk.keywords.usage": "usage statistics consumption quota",
"cmdk.keywords.video": "video,generate,seedance,kling",
"cmdk.memory": "Memory",
@@ -195,6 +196,7 @@
"cmdk.settings": "Settings",
"cmdk.starOnGitHub": "Star us on GitHub",
"cmdk.submitIssue": "Submit Issue",
+ "cmdk.tasks": "Tasks",
"cmdk.theme": "Theme",
"cmdk.themeAuto": "Auto",
"cmdk.themeCurrent": "Current",
@@ -433,6 +435,7 @@
"tab.resource": "Resources",
"tab.search": "Search",
"tab.setting": "Settings",
+ "tab.tasks": "Tasks",
"tab.video": "Video",
"telemetry.allow": "Allow",
"telemetry.deny": "Deny",
diff --git a/locales/en-US/electron.json b/locales/en-US/electron.json
index 7fbef1f27f3..cdc54f3dad6 100644
--- a/locales/en-US/electron.json
+++ b/locales/en-US/electron.json
@@ -35,6 +35,7 @@
"navigation.recentView": "Recent pages",
"navigation.resources": "Resources",
"navigation.settings": "Settings",
+ "navigation.tasks": "Tasks",
"navigation.unpin": "Unpin",
"notification.finishChatGeneration": "AI message generation completed",
"proxy.auth": "Authentication Required",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index a920ebaaa08..5cd9c67d60c 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -478,7 +478,7 @@
"taskDetail.comment.deleteConfirm.title": "删除这条评论?",
"taskDetail.comment.edit": "编辑",
"taskDetail.comment.save": "保存",
- "taskDetail.commentPlaceholder": "留下评论...",
+ "taskDetail.commentPlaceholder": "留下反馈,帮助 Agent 在下次执行时产出更准确的结果...",
"taskDetail.deleteConfirm.content": "此操作不可撤销。",
"taskDetail.deleteConfirm.ok": "删除",
"taskDetail.deleteConfirm.title": "确认删除此任务?",
@@ -520,21 +520,38 @@
"taskDetail.updateFailed": "任务更新失败",
"taskList.activeTasks": "进行中的任务",
"taskList.all": "全部任务",
+ "taskList.assigneeSearch.empty": "未找到匹配的 Agent",
+ "taskList.assigneeSearch.placeholder": "搜索 Agent...",
"taskList.breadcrumb.task": "任务",
+ "taskList.contextMenu.copyId": "复制 ID",
+ "taskList.contextMenu.copyIdSuccess": "ID 已复制",
+ "taskList.contextMenu.copyLink": "复制链接",
+ "taskList.contextMenu.copyLinkSuccess": "链接已复制",
+ "taskList.contextMenu.priority": "优先级",
+ "taskList.contextMenu.status": "状态",
"taskList.empty": "暂无任务",
"taskList.form.grouping": "分组",
"taskList.form.orderCompletedByRecency": "按最近完成排序",
"taskList.form.ordering": "排序",
+ "taskList.form.showCompleted": "显示已完成与已取消",
"taskList.form.subGrouping": "子分组",
"taskList.groupBy.assignee": "负责人",
"taskList.groupBy.none": "不分组",
"taskList.groupBy.priority": "优先级",
"taskList.groupBy.status": "状态",
+ "taskList.hiddenCompleted.count_one": "{{count}} 个任务",
+ "taskList.hiddenCompleted.count_other": "{{count}} 个任务",
+ "taskList.hiddenCompleted.show": "显示",
+ "taskList.hiddenCompleted.suffix": "已按显示选项隐藏",
+ "taskList.kanban.addTask": "新建任务",
"taskList.kanban.backlog": "待办",
"taskList.kanban.done": "已完成",
"taskList.kanban.emptyColumn": "暂无任务",
+ "taskList.kanban.hiddenColumns": "隐藏的分组",
+ "taskList.kanban.hideColumn": "隐藏分组",
"taskList.kanban.needsInput": "需要输入",
"taskList.kanban.running": "进行中",
+ "taskList.kanban.showColumn": "显示分组",
"taskList.orderBy.assignee": "负责人",
"taskList.orderBy.createdAt": "创建时间",
"taskList.orderBy.priority": "优先级",
@@ -543,6 +560,7 @@
"taskList.orderBy.updatedAt": "更新时间",
"taskList.title": "任务",
"taskList.unassigned": "未分配",
+ "taskList.unassignedHint": "未分配时将由 Lobe AI 执行该任务",
"taskList.view.board": "看板",
"taskList.view.list": "列表",
"taskList.viewAll": "查看全部",
diff --git a/locales/zh-CN/common.json b/locales/zh-CN/common.json
index 465ed782ba8..5704b98d489 100644
--- a/locales/zh-CN/common.json
+++ b/locales/zh-CN/common.json
@@ -146,6 +146,7 @@
"cmdk.keywords.starGitHub": "github star 收藏 喜欢 点赞",
"cmdk.keywords.stats": "统计 数据 分析",
"cmdk.keywords.submitIssue": "问题 错误 反馈 建议 提交",
+ "cmdk.keywords.tasks": "任务 todo agent 看板",
"cmdk.keywords.usage": "用量 统计 消耗 配额",
"cmdk.keywords.video": "视频,生成,Seedance,Kling",
"cmdk.memory": "记忆",
@@ -195,6 +196,7 @@
"cmdk.settings": "设置",
"cmdk.starOnGitHub": "在 GitHub 上给我们 Star",
"cmdk.submitIssue": "提交问题",
+ "cmdk.tasks": "任务",
"cmdk.theme": "主题",
"cmdk.themeAuto": "跟随系统",
"cmdk.themeCurrent": "当前",
@@ -433,6 +435,7 @@
"tab.resource": "资源",
"tab.search": "搜索",
"tab.setting": "设置",
+ "tab.tasks": "任务",
"tab.video": "视频",
"telemetry.allow": "允许",
"telemetry.deny": "拒绝",
diff --git a/locales/zh-CN/electron.json b/locales/zh-CN/electron.json
index 39df39ab260..c326d4df69b 100644
--- a/locales/zh-CN/electron.json
+++ b/locales/zh-CN/electron.json
@@ -35,6 +35,7 @@
"navigation.recentView": "最近访问",
"navigation.resources": "资源",
"navigation.settings": "设置",
+ "navigation.tasks": "任务",
"navigation.unpin": "取消固定",
"notification.finishChatGeneration": "AI 消息已生成完毕",
"proxy.auth": "需要认证",
diff --git a/packages/builtin-tool-claude-code/src/client/Streaming/Agent/index.tsx b/packages/builtin-tool-claude-code/src/client/Streaming/Agent/index.tsx
new file mode 100644
index 00000000000..4ee60756591
--- /dev/null
+++ b/packages/builtin-tool-claude-code/src/client/Streaming/Agent/index.tsx
@@ -0,0 +1,113 @@
+'use client';
+
+import type { BuiltinStreamingProps } from '@lobechat/types';
+import { Button, Flexbox, Markdown, Text } from '@lobehub/ui';
+import { createStaticStyles } from 'antd-style';
+import { ListTree } from 'lucide-react';
+import { memo, useCallback } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useChatStore } from '@/store/chat';
+import { portalThreadSelectors, threadSelectors } from '@/store/chat/selectors';
+
+import type { AgentArgs } from '../../../types';
+
+const styles = createStaticStyles(({ css, cssVar }) => ({
+ container: css`
+ padding-block: 4px;
+ `,
+ label: css`
+ padding-inline-start: 4px;
+ font-size: 12px;
+ color: ${cssVar.colorTextTertiary};
+ `,
+ labelRow: css`
+ margin-block-end: 4px;
+ `,
+ openThread: css`
+ height: 22px;
+ padding-inline: 6px;
+ font-size: 12px;
+ `,
+ promptBox: css`
+ padding-block: 8px;
+ padding-inline: 12px;
+ border-radius: ${cssVar.borderRadiusLG};
+ background: ${cssVar.colorFillTertiary};
+ `,
+}));
+
+/**
+ * Streaming view for CC's `Agent` tool — shown while the subagent is still
+ * running (args parsed, no tool_result yet). Mirrors `Render/Agent` but drops
+ * the result block, since it hasn't arrived. If the executor has already
+ * created the subagent Thread, surface the "open subtopic" toggle alongside
+ * the instruction so the user can jump into the live subagent conversation.
+ */
+const AgentStreaming = memo<BuiltinStreamingProps<AgentArgs>>(({ args, toolCallId }) => {
+ const { t } = useTranslation('plugin');
+ const { t: tChat } = useTranslation('chat');
+ const prompt = args?.prompt?.trim();
+
+ const subagentThread = useChatStore((s) =>
+ toolCallId
+ ? (threadSelectors.currentTopicThreads(s) ?? []).find(
+ (thread) => thread.metadata?.sourceToolCallId === toolCallId,
+ )
+ : undefined,
+ );
+ const openThreadInPortal = useChatStore((s) => s.openThreadInPortal);
+ const closeThreadPortal = useChatStore((s) => s.closeThreadPortal);
+ const portalThreadId = useChatStore(portalThreadSelectors.portalThreadId);
+ const isOpenInPortal = !!subagentThread && portalThreadId === subagentThread.id;
+
+ const handleToggleThread = useCallback(() => {
+ if (!subagentThread) return;
+ if (isOpenInPortal) {
+ closeThreadPortal();
+ } else {
+ openThreadInPortal(subagentThread.id, subagentThread.sourceMessageId);
+ }
+ }, [subagentThread, isOpenInPortal, openThreadInPortal, closeThreadPortal]);
+
+ if (!prompt && !subagentThread) return null;
+
+ return (
+ <Flexbox className={styles.container} gap={12}>
+ {prompt && (
+ <Flexbox>
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={styles.labelRow}
+ justify={'space-between'}
+ >
+ <Text className={styles.label}>{t('builtins.lobe-claude-code.agent.instruction')}</Text>
+ {subagentThread && (
+ <Button
+ className={styles.openThread}
+ icon={ListTree}
+ size={'small'}
+ type={'text'}
+ onClick={handleToggleThread}
+ >
+ {isOpenInPortal
+ ? tChat('thread.closeSubagentThread')
+ : tChat('thread.openSubagentThread')}
+ </Button>
+ )}
+ </Flexbox>
+ <Flexbox className={styles.promptBox}>
+ <Markdown style={{ maxHeight: 240, overflow: 'auto' }} variant={'chat'}>
+ {prompt}
+ </Markdown>
+ </Flexbox>
+ </Flexbox>
+ )}
+ </Flexbox>
+ );
+});
+
+AgentStreaming.displayName = 'ClaudeCodeAgentStreaming';
+
+export default AgentStreaming;
diff --git a/packages/builtin-tool-claude-code/src/client/Streaming/index.ts b/packages/builtin-tool-claude-code/src/client/Streaming/index.ts
new file mode 100644
index 00000000000..fd91910b1c5
--- /dev/null
+++ b/packages/builtin-tool-claude-code/src/client/Streaming/index.ts
@@ -0,0 +1,20 @@
+import type { BuiltinStreaming } from '@lobechat/types';
+
+import { ClaudeCodeApiName } from '../../types';
+import AgentStreaming from './Agent';
+
+/**
+ * Claude Code Streaming Components Registry.
+ *
+ * Rendered while a CC tool is still executing (args parsed, no tool_result
+ * yet). Without an entry here, the tool detail falls back to the generic
+ * `参数列表` argument table. Register only tools whose live state is more
+ * useful as bespoke UI than as an arg dump — e.g. `Agent`, where we want to
+ * surface the instruction and let the user jump into the subagent thread
+ * while the subagent is still running.
+ */
+export const ClaudeCodeStreamings: Record<string, BuiltinStreaming> = {
+ [ClaudeCodeApiName.Agent]: AgentStreaming as BuiltinStreaming,
+};
+
+export { default as AgentStreaming } from './Agent';
diff --git a/packages/builtin-tool-claude-code/src/client/index.ts b/packages/builtin-tool-claude-code/src/client/index.ts
index c2f4d31bea7..76bc5678b33 100644
--- a/packages/builtin-tool-claude-code/src/client/index.ts
+++ b/packages/builtin-tool-claude-code/src/client/index.ts
@@ -1,4 +1,5 @@
export { ClaudeCodeApiName, ClaudeCodeIdentifier } from '../types';
export { ClaudeCodeInspectors } from './Inspector';
export { ClaudeCodeRenderDisplayControls, ClaudeCodeRenders } from './Render';
+export { ClaudeCodeStreamings } from './Streaming';
export { CC_SUBAGENT_TYPES, type CCSubagentTypeInfo, resolveCCSubagentType } from './subagentTypes';
diff --git a/packages/builtin-tools/src/streamings.ts b/packages/builtin-tools/src/streamings.ts
index 307017543af..9dd550daf72 100644
--- a/packages/builtin-tools/src/streamings.ts
+++ b/packages/builtin-tools/src/streamings.ts
@@ -10,6 +10,10 @@ import {
AgentManagementManifest,
AgentManagementStreamings,
} from '@lobechat/builtin-tool-agent-management/client';
+import {
+ ClaudeCodeIdentifier,
+ ClaudeCodeStreamings,
+} from '@lobechat/builtin-tool-claude-code/client';
import {
CloudSandboxManifest,
CloudSandboxStreamings,
@@ -47,6 +51,7 @@ const BuiltinToolStreamings: Record<string, Record<string, BuiltinStreaming>> =
string,
BuiltinStreaming
>,
+ [ClaudeCodeIdentifier]: ClaudeCodeStreamings as Record<string, BuiltinStreaming>,
[CloudSandboxManifest.identifier]: CloudSandboxStreamings as Record<string, BuiltinStreaming>,
[GroupAgentBuilderManifest.identifier]: GroupAgentBuilderStreamings as Record<
string,
diff --git a/packages/database/src/models/recent.ts b/packages/database/src/models/recent.ts
index 9e79b6ff61d..dc1c95077a9 100644
--- a/packages/database/src/models/recent.ts
+++ b/packages/database/src/models/recent.ts
@@ -70,6 +70,7 @@ export class RecentModel {
NULL as metadata
FROM ${tasks}
WHERE ${tasks.createdByUserId} = ${this.userId}
+ AND ${tasks.status} NOT IN ('completed', 'canceled')
) AS combined
ORDER BY updated_at DESC
LIMIT ${limit}
diff --git a/src/app/(backend)/api/workflows/[[...route]]/route.ts b/src/app/(backend)/api/workflows/[[...route]]/route.ts
new file mode 100644
index 00000000000..433a41166d8
--- /dev/null
+++ b/src/app/(backend)/api/workflows/[[...route]]/route.ts
@@ -0,0 +1,3 @@
+import app from '@/server/workflows-hono';
+
+export const POST = (request: Request) => app.fetch(request);
diff --git a/src/app/(backend)/api/workflows/memory-user-memory/[[...route]]/route.ts b/src/app/(backend)/api/workflows/memory-user-memory/[[...route]]/route.ts
deleted file mode 100644
index fce1b3a02b4..00000000000
--- a/src/app/(backend)/api/workflows/memory-user-memory/[[...route]]/route.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import app from '@/server/workflows-hono/memory-user-memory/app';
-
-export const POST = (request: Request) => app.fetch(request);
diff --git a/src/config/routes/index.ts b/src/config/routes/index.ts
index 2015fe9c78f..185d71e7a9e 100644
--- a/src/config/routes/index.ts
+++ b/src/config/routes/index.ts
@@ -4,6 +4,7 @@ import {
FilePenIcon,
Image,
LibraryBigIcon,
+ ListTodoIcon,
Settings,
ShapesIcon,
Video,
@@ -96,6 +97,16 @@ export const NAVIGATION_ROUTES: NavigationRoute[] = [
path: '/memory',
pathPrefix: '/memory',
},
+ {
+ cmdkKey: 'cmdk.tasks',
+ electronKey: 'navigation.tasks',
+ icon: ListTodoIcon,
+ id: 'tasks',
+ keywords: ['tasks', 'todo', 'agent', 'kanban'],
+ keywordsKey: 'cmdk.keywords.tasks',
+ path: '/tasks',
+ pathPrefix: '/tasks',
+ },
{
cmdkKey: 'cmdk.settings',
electronKey: 'navigation.settings',
diff --git a/src/features/AgentTaskManager/Conversation.tsx b/src/features/AgentTaskManager/Conversation.tsx
index a44e5de7cd9..d1edf1f9452 100644
--- a/src/features/AgentTaskManager/Conversation.tsx
+++ b/src/features/AgentTaskManager/Conversation.tsx
@@ -61,14 +61,11 @@ const Conversation = memo(() => {
);
const { handleUploadFiles } = useUploadFiles({ model, provider });
- // Reset task topic when the route agent changes so a stale topicId from
- // the previous agent does not leak into this agent's messageMapKey.
useEffect(() => {
useTaskChatStore.getState().switchTopic(null);
}, [activeAgentId]);
- const detailMatch = useMatch('/agent/:aid/tasks/:taskId');
- const isListRoute = !!useMatch('/agent/:aid/tasks');
+ const detailMatch = useMatch('/task/:taskId');
const viewedTaskId = detailMatch?.params.taskId;
const context = useMemo<ConversationContext>(
@@ -78,13 +75,9 @@ const Conversation = memo(() => {
scope: 'main',
topicId: taskTopicId,
topicTrigger: TopicTrigger.TaskManager,
- viewedTask: viewedTaskId
- ? { taskId: viewedTaskId, type: 'detail' }
- : isListRoute
- ? { type: 'list' }
- : undefined,
+ viewedTask: viewedTaskId ? { taskId: viewedTaskId, type: 'detail' } : undefined,
}),
- [activeAgentId, taskTopicId, viewedTaskId, isListRoute],
+ [activeAgentId, taskTopicId, viewedTaskId],
);
const chatKey = messageMapKey(context);
diff --git a/src/features/AgentTaskManager/index.tsx b/src/features/AgentTaskManager/index.tsx
index e14224f5f94..8834814b454 100644
--- a/src/features/AgentTaskManager/index.tsx
+++ b/src/features/AgentTaskManager/index.tsx
@@ -4,17 +4,6 @@ import RightPanel from '@/features/RightPanel';
import Conversation from './Conversation';
-/**
- * Tasks page right-side chat panel.
- *
- * Holds its own `activeTopicId` in `useTaskChatStore` so switching a task
- * topic here does not mutate the main chat's `activeTopicId`. Messages are
- * still read from `useChatStore.dbMessagesMap` via a distinct `messageMapKey`
- * derived from the isolated topic id.
- *
- * The parent `_layout` sets `scenarioEnabledToolIds` on the chat store so
- * `lobe-task` is available for every LLM step here.
- */
const AgentTaskManager = memo(() => {
return (
<RightPanel defaultWidth={420} maxWidth={720} minWidth={320}>
diff --git a/src/features/AgentTasks/AgentTaskDetail/CommentInput.tsx b/src/features/AgentTasks/AgentTaskDetail/CommentInput.tsx
index 41e11608b54..5be449b09c8 100644
--- a/src/features/AgentTasks/AgentTaskDetail/CommentInput.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/CommentInput.tsx
@@ -6,6 +6,8 @@ import { useTranslation } from 'react-i18next';
import { useUserAvatar } from '@/hooks/useUserAvatar';
import { useTaskStore } from '@/store/task';
+import { styles } from '../shared/style';
+
const CommentInput = memo<{ taskId: string }>(({ taskId }) => {
const { t } = useTranslation('chat');
const editor = useEditor();
@@ -28,7 +30,7 @@ const CommentInput = memo<{ taskId: string }>(({ taskId }) => {
}, [taskId, editor, addComment, submitting]);
return (
- <Flexbox horizontal align={'center'} gap={8}>
+ <Flexbox horizontal align={'center'} className={styles.commentInputCard} gap={8}>
<Avatar avatar={userAvatar} size={24} style={{ flexShrink: 0 }} />
<div style={{ flex: 1, minWidth: 0 }}>
<Editor
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskActivities.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskActivities.tsx
index 69a2b5f54df..017a3ff1feb 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskActivities.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskActivities.tsx
@@ -3,7 +3,7 @@ import { Accordion, AccordionItem, Avatar, Empty, Flexbox, Icon, Tag, Text } fro
import { cssVar } from 'antd-style';
import dayjs from 'dayjs';
import type { TFunction } from 'i18next';
-import { BotMessageSquare, CirclePlus, MessageCircle, MessagesSquare } from 'lucide-react';
+import { BotMessageSquare, CircleDot, CirclePlus, MessageCircle } from 'lucide-react';
import { memo, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -21,7 +21,7 @@ import TopicCard from './TopicCard';
const ROW_TYPE_ICON = {
comment: MessageCircle,
created: CirclePlus,
- topic: MessagesSquare,
+ topic: CircleDot,
} as const;
/** Convert a brief-type activity to the BriefItem shape expected by BriefCard. */
@@ -97,7 +97,7 @@ const ActivityRow = memo<{ activity: TaskDetailActivity }>(({ activity }) => {
);
return (
- <Flexbox horizontal align={'center'} gap={8} paddingBlock={4}>
+ <Flexbox horizontal align={'center'} gap={8} paddingBlock={4} paddingInline={9}>
{isAgent && activity.author?.id ? (
<AgentProfilePopup
agent={{ avatar: activity.author.avatar, title: activity.author.name }}
@@ -133,11 +133,13 @@ const TaskActivities = memo(() => {
const items = useMemo(
() =>
- activities.map((act, i) => ({
- activity: act,
- brief: act.type === 'brief' ? toBriefItem(act) : null,
- key: act.id ?? `activity-${i}`,
- })),
+ activities
+ .map((act, i) => ({
+ activity: act,
+ brief: act.type === 'brief' ? toBriefItem(act) : null,
+ key: act.id ?? `activity-${i}`,
+ }))
+ .reverse(),
[activities],
);
@@ -157,6 +159,7 @@ const TaskActivities = memo(() => {
}
>
<Flexbox gap={12} paddingBlock={12} paddingInline={12}>
+ {activeTaskId && <CommentInput taskId={activeTaskId} />}
{items.length > 0 ? (
items.map(({ activity, brief, key }) => {
if (brief) {
@@ -185,7 +188,6 @@ const TaskActivities = memo(() => {
style={{ marginTop: 8 }}
/>
)}
- {activeTaskId && <CommentInput taskId={activeTaskId} />}
</Flexbox>
</AccordionItem>
</Accordion>
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskDetailAssignee.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskDetailAssignee.tsx
index 930d2d6869d..05d60582eda 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskDetailAssignee.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskDetailAssignee.tsx
@@ -1,7 +1,9 @@
import type { TaskStatus } from '@lobechat/types';
-import { Block, Text } from '@lobehub/ui';
-import { useThemeMode } from 'antd-style';
+import { Block, Icon, Text, Tooltip } from '@lobehub/ui';
+import { cssVar, useThemeMode } from 'antd-style';
+import { UserCircle2 } from 'lucide-react';
import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
import { useTaskStore } from '@/store/task';
import { taskDetailSelectors } from '@/store/task/selectors';
@@ -11,13 +13,14 @@ import AssigneeAvatar from '../features/AssigneeAvatar';
import { useAgentDisplayMeta } from '../shared/useAgentDisplayMeta';
const TaskDetailAssignee = memo(() => {
+ const { t } = useTranslation('chat');
const taskId = useTaskStore(taskDetailSelectors.activeTaskId);
const status = useTaskStore(taskDetailSelectors.activeTaskStatus) as TaskStatus | undefined;
const assigneeAgentId = useTaskStore(taskDetailSelectors.activeTaskAgentId);
const assigneeMeta = useAgentDisplayMeta(assigneeAgentId);
const { isDarkMode } = useThemeMode();
- if (!taskId || !assigneeAgentId) return null;
+ if (!taskId) return null;
return (
<AssigneeAgentSelector
@@ -25,19 +28,32 @@ const TaskDetailAssignee = memo(() => {
disabled={status === 'running'}
taskIdentifier={taskId}
>
- <Block
- clickable
- horizontal
- align="center"
- gap={8}
- paddingBlock={4}
- paddingInline={11}
- style={{ minHeight: 32 }}
- variant={isDarkMode ? 'filled' : 'outlined'}
- >
- <AssigneeAvatar agentId={assigneeAgentId} size={20} />
- <Text weight={500}>{assigneeMeta?.title}</Text>
- </Block>
+ <Tooltip title={assigneeAgentId ? undefined : t('taskList.unassignedHint')}>
+ <Block
+ clickable
+ horizontal
+ align="center"
+ gap={8}
+ paddingBlock={4}
+ paddingInline={11}
+ style={{ minHeight: 32 }}
+ variant={isDarkMode ? 'filled' : 'outlined'}
+ >
+ {assigneeAgentId ? (
+ <>
+ <AssigneeAvatar agentId={assigneeAgentId} size={20} />
+ <Text weight={500}>{assigneeMeta?.title}</Text>
+ </>
+ ) : (
+ <>
+ <Icon color={cssVar.colorTextDescription} icon={UserCircle2} size={18} />
+ <Text style={{ color: cssVar.colorTextDescription }} weight={500}>
+ {t('taskList.unassigned')}
+ </Text>
+ </>
+ )}
+ </Block>
+ </Tooltip>
</AssigneeAgentSelector>
);
});
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskDetailHeaderActions.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskDetailHeaderActions.tsx
index 910169047b0..5fa62967f24 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskDetailHeaderActions.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskDetailHeaderActions.tsx
@@ -1,47 +1,84 @@
-import { ActionIcon, type DropdownItem, DropdownMenu, Icon } from '@lobehub/ui';
+import { KeyEnum } from '@lobechat/const/hotkeys';
+import {
+ ActionIcon,
+ combineKeys,
+ copyToClipboard,
+ type DropdownItem,
+ DropdownMenu,
+ Hotkey,
+ Icon,
+} from '@lobehub/ui';
import { App } from 'antd';
-import { MoreHorizontal, Trash } from 'lucide-react';
-import { memo, useMemo } from 'react';
+import { CopyIcon, LinkIcon, MoreHorizontal, Trash } from 'lucide-react';
+import { memo, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
+import { useAppOrigin } from '@/hooks/useAppOrigin';
import { useTaskStore } from '@/store/task';
import { taskDetailSelectors } from '@/store/task/selectors';
const TaskDetailHeaderActions = memo(() => {
const { t } = useTranslation(['chat', 'common']);
- const { modal } = App.useApp();
+ const { modal, message } = App.useApp();
const navigate = useNavigate();
+ const appOrigin = useAppOrigin();
const taskId = useTaskStore(taskDetailSelectors.activeTaskId);
- const agentId = useTaskStore(taskDetailSelectors.activeTaskAgentId);
const deleteTask = useTaskStore((s) => s.deleteTask);
+ const triggerDelete = useCallback(() => {
+ if (!taskId) return;
+ modal.confirm({
+ centered: true,
+ content: t('taskDetail.deleteConfirm.content'),
+ okButtonProps: { danger: true },
+ okText: t('taskDetail.deleteConfirm.ok'),
+ onOk: async () => {
+ await deleteTask(taskId);
+ navigate('/tasks');
+ },
+ title: t('taskDetail.deleteConfirm.title'),
+ type: 'error',
+ });
+ }, [taskId, modal, t, deleteTask, navigate]);
+
const menuItems = useMemo<DropdownItem[]>(() => {
if (!taskId) return [];
+ const taskUrl = `${appOrigin}/task/${taskId}`;
+
return [
+ {
+ icon: <Icon icon={CopyIcon} />,
+ key: 'copyId',
+ label: t('taskList.contextMenu.copyId'),
+ onClick: async () => {
+ await copyToClipboard(taskId);
+ message.success(t('taskList.contextMenu.copyIdSuccess'));
+ },
+ },
+ {
+ icon: <Icon icon={LinkIcon} />,
+ key: 'copyLink',
+ label: t('taskList.contextMenu.copyLink'),
+ onClick: async () => {
+ await copyToClipboard(taskUrl);
+ message.success(t('taskList.contextMenu.copyLinkSuccess'));
+ },
+ },
+ { type: 'divider' },
{
danger: true,
+ extra: (
+ <Hotkey keys={combineKeys([KeyEnum.Mod, KeyEnum.Backspace])} variant={'borderless'} />
+ ),
icon: <Icon icon={Trash} />,
key: 'delete',
label: t('delete', { ns: 'common' }),
- onClick: () => {
- modal.confirm({
- centered: true,
- content: t('taskDetail.deleteConfirm.content'),
- okButtonProps: { danger: true },
- okText: t('taskDetail.deleteConfirm.ok'),
- onOk: async () => {
- await deleteTask(taskId);
- if (agentId) navigate(`/agent/${agentId}/tasks`);
- },
- title: t('taskDetail.deleteConfirm.title'),
- type: 'error',
- });
- },
+ onClick: triggerDelete,
},
];
- }, [taskId, agentId, deleteTask, modal, navigate, t]);
+ }, [taskId, appOrigin, t, message, triggerDelete]);
if (!taskId) return null;
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskDetailPage.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskDetailPage.tsx
index aa38eaacacc..b0c345ccebf 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskDetailPage.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskDetailPage.tsx
@@ -6,6 +6,7 @@ import Loading from '@/components/Loading/BrandTextLoading';
import NavHeader from '@/features/NavHeader';
import ToggleRightPanelButton from '@/features/RightPanel/ToggleRightPanelButton';
import WideScreenContainer from '@/features/WideScreenContainer';
+import { useChatStore } from '@/store/chat';
import { useTaskStore } from '@/store/task';
import { taskDetailSelectors } from '@/store/task/selectors';
@@ -23,7 +24,7 @@ import TaskSubtasks from './TaskSubtasks';
import TopicChatDrawer from './TopicChatDrawer';
interface TaskDetailPageProps {
- agentId: string;
+ agentId?: string;
taskId: string;
}
@@ -38,6 +39,19 @@ const TaskDetailPage = memo<TaskDetailPageProps>(({ agentId, taskId }) => {
return () => setActiveTaskId(undefined);
}, [taskId, setActiveTaskId]);
+ // Sync the task's assignee agent into chat store so the right-side
+ // AgentTaskManager conversation knows which agent to talk to.
+ useEffect(() => {
+ if (!agentId) return;
+ useChatStore.setState({ activeAgentId: agentId }, false, 'TaskDetailPage/syncAgentId');
+ return () => {
+ const current = useChatStore.getState().activeAgentId;
+ if (current === agentId) {
+ useChatStore.setState({ activeAgentId: undefined }, false, 'TaskDetailPage/clearAgentId');
+ }
+ };
+ }, [agentId]);
+
useFetchTaskDetail(taskId);
return (
@@ -46,7 +60,7 @@ const TaskDetailPage = memo<TaskDetailPageProps>(({ agentId, taskId }) => {
right={<ToggleRightPanelButton hideWhenExpanded />}
left={
<>
- <Breadcrumb agentId={agentId} taskId={taskId} />
+ <Breadcrumb taskId={taskId} />
<TaskDetailHeaderActions />
{saveStatus === 'saving' ? <AutoSaveHint saveStatus={saveStatus} /> : undefined}
</>
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskDetailRunPauseAction.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskDetailRunPauseAction.tsx
index 2ea3dafd1a0..1c4f989805d 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskDetailRunPauseAction.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskDetailRunPauseAction.tsx
@@ -1,9 +1,11 @@
import { Button } from '@lobehub/ui';
import { PlayIcon, RotateCcwIcon } from 'lucide-react';
-import { memo, useCallback } from 'react';
+import { memo, useCallback, useState } from 'react';
import { useTranslation } from 'react-i18next';
import StopLoadingIcon from '@/components/StopLoading';
+import { useAgentStore } from '@/store/agent';
+import { builtinAgentSelectors } from '@/store/agent/selectors';
import { useTaskStore } from '@/store/task';
import { taskDetailSelectors } from '@/store/task/selectors';
@@ -13,17 +15,52 @@ const TaskDetailRunPauseAction = memo(() => {
const canRun = useTaskStore(taskDetailSelectors.canRunActiveTask);
const canPause = useTaskStore(taskDetailSelectors.canPauseActiveTask);
const status = useTaskStore(taskDetailSelectors.activeTaskStatus);
+ const assigneeAgentId = useTaskStore(taskDetailSelectors.activeTaskAgentId);
+ const inboxAgentId = useAgentStore(builtinAgentSelectors.inboxAgentId);
const isRerun = status === 'completed';
const runTask = useTaskStore((s) => s.runTask);
+ const updateTask = useTaskStore((s) => s.updateTask);
const updateTaskStatus = useTaskStore((s) => s.updateTaskStatus);
- const handleRunOrPause = useCallback(() => {
+ const [isStarting, setIsStarting] = useState(false);
+
+ const handleRunOrPause = useCallback(async () => {
if (!taskId) return;
- if (canRun) runTask(taskId);
- else if (canPause) updateTaskStatus(taskId, 'paused');
- }, [taskId, canRun, canPause, runTask, updateTaskStatus]);
+ if (canPause) {
+ await updateTaskStatus(taskId, 'paused');
+ return;
+ }
+ if (!canRun) return;
+ setIsStarting(true);
+ try {
+ if (!assigneeAgentId && inboxAgentId) {
+ await updateTask(taskId, { assigneeAgentId: inboxAgentId });
+ }
+ await runTask(taskId);
+ } finally {
+ setIsStarting(false);
+ }
+ }, [
+ taskId,
+ canRun,
+ canPause,
+ assigneeAgentId,
+ inboxAgentId,
+ runTask,
+ updateTask,
+ updateTaskStatus,
+ ]);
+
+ if (!canRun && !canPause && !isStarting) return null;
- if (!canRun && !canPause) return null;
+ if (isStarting) {
+ const pendingLabel = isRerun ? t('taskDetail.rerunTask') : t('taskDetail.runTask');
+ return (
+ <Button disabled loading type={'primary'}>
+ {pendingLabel}
+ </Button>
+ );
+ }
if (canPause) {
return (
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskParentBar.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskParentBar.tsx
index 00d413a7cc0..60f27e0cbf8 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskParentBar.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskParentBar.tsx
@@ -29,7 +29,6 @@ const TaskParentBar = memo(() => {
const { t } = useTranslation('chat');
const navigate = useNavigate();
const parent = useTaskStore(taskDetailSelectors.activeTaskParent);
- const agentId = useTaskStore(taskDetailSelectors.activeTaskAgentId);
const currentIdentifier = useTaskStore(taskDetailSelectors.activeTaskDetail)?.identifier;
const [parentSubtasks, setParentSubtasks] = useState<TaskDetailSubtask[]>([]);
@@ -63,9 +62,7 @@ const TaskParentBar = memo(() => {
icon={<TaskStatusIcon size={16} status={parentStatus} />}
size={'small'}
type={'text'}
- onClick={() => {
- if (agentId) navigate(`/agent/${agentId}/tasks/${parent.identifier}`);
- }}
+ onClick={() => navigate(`/task/${parent.identifier}`)}
>
<Text weight={500}>{parent.name}</Text>
</Button>
@@ -73,9 +70,7 @@ const TaskParentBar = memo(() => {
<TaskSubtaskProgressTag
currentIdentifier={currentIdentifier}
subtasks={parentSubtasks}
- onSubtaskClick={(identifier) => {
- if (agentId) navigate(`/agent/${agentId}/tasks/${identifier}`);
- }}
+ onSubtaskClick={(identifier) => navigate(`/task/${identifier}`)}
/>
)}
</Flexbox>
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskSubtasks.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskSubtasks.tsx
index b11a65ccd83..c169e3845fe 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskSubtasks.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskSubtasks.tsx
@@ -1,5 +1,5 @@
import type { TaskDetailSubtask } from '@lobechat/types';
-import { Accordion, AccordionItem, ActionIcon, Avatar, Flexbox, Icon, Text } from '@lobehub/ui';
+import { ActionIcon, Avatar, Block, ContextMenuTrigger, Flexbox, Icon, Text } from '@lobehub/ui';
import { Button, ConfigProvider, Tree } from 'antd';
import type { DataNode } from 'antd/es/tree';
import { cssVar } from 'antd-style';
@@ -15,6 +15,7 @@ import CreateTaskInlineEntry from '../AgentTaskList/CreateTaskInlineEntry';
import TaskPriorityTag from '../features/TaskPriorityTag';
import TaskStatusTag from '../features/TaskStatusTag';
import TaskSubtaskProgressTag from '../features/TaskSubtaskProgressTag';
+import { useTaskItemContextMenu } from '../features/useTaskItemContextMenu';
import { styles } from '../shared/style';
type TaskStatus = 'backlog' | 'canceled' | 'completed' | 'failed' | 'paused' | 'running';
@@ -69,58 +70,63 @@ const buildTree = (subtasks: TaskDetailSubtask[]): TaskTreeNode[] => {
return roots;
};
-const toTreeData = (tree: TaskTreeNode[]): DataNode[] => {
- return tree.map((node) => {
- const status = toTaskStatus(node.task.status);
-
- return {
- children: toTreeData(node.children),
- key: node.task.identifier,
- title: (
- <Flexbox
- horizontal
- align="center"
- gap={8}
- style={{ lineHeight: 1, minWidth: 0, overflow: 'hidden' }}
+const SubtaskTitle = memo<{ task: TaskDetailSubtask }>(({ task }) => {
+ const status = toTaskStatus(task.status);
+ const { items, onContextMenu } = useTaskItemContextMenu({
+ identifier: task.identifier,
+ priority: task.priority,
+ status: task.status,
+ });
+
+ return (
+ <ContextMenuTrigger items={items} onContextMenu={onContextMenu}>
+ <Flexbox
+ horizontal
+ align="center"
+ gap={8}
+ style={{ lineHeight: 1, minWidth: 0, overflow: 'hidden' }}
+ >
+ <span
+ style={{ alignItems: 'center', display: 'inline-flex', flex: 'none' }}
+ onClick={(e) => e.stopPropagation()}
+ >
+ <TaskPriorityTag priority={task.priority} size={14} taskIdentifier={task.identifier} />
+ </span>
+ <span
+ style={{ alignItems: 'center', display: 'inline-flex', flex: 'none' }}
+ onClick={(e) => e.stopPropagation()}
>
+ <TaskStatusTag size={14} status={status} taskIdentifier={task.identifier} />
+ </span>
+ <Text ellipsis fontSize={13} style={{ flex: 1, minWidth: 0 }}>
+ {task.name || task.identifier}
+ </Text>
+ {task.assignee && (
<span
style={{ alignItems: 'center', display: 'inline-flex', flex: 'none' }}
onClick={(e) => e.stopPropagation()}
>
- <TaskPriorityTag
- priority={node.task.priority}
- size={14}
- taskIdentifier={node.task.identifier}
+ <Avatar
+ avatar={task.assignee.avatar ?? ''}
+ background={task.assignee.backgroundColor || cssVar.colorBgContainer}
+ shape="circle"
+ size={18}
+ title={task.assignee.title ?? ''}
+ variant="outlined"
/>
</span>
- <span
- style={{ alignItems: 'center', display: 'inline-flex', flex: 'none' }}
- onClick={(e) => e.stopPropagation()}
- >
- <TaskStatusTag size={14} status={status} taskIdentifier={node.task.identifier} />
- </span>
- <Text ellipsis fontSize={13} style={{ flex: 1, minWidth: 0 }}>
- {node.task.name || node.task.identifier}
- </Text>
- {node.task.assignee && (
- <span
- style={{ alignItems: 'center', display: 'inline-flex', flex: 'none' }}
- onClick={(e) => e.stopPropagation()}
- >
- <Avatar
- avatar={node.task.assignee.avatar ?? ''}
- background={node.task.assignee.backgroundColor || cssVar.colorBgContainer}
- shape="circle"
- size={18}
- title={node.task.assignee.title ?? ''}
- variant="outlined"
- />
- </span>
- )}
- </Flexbox>
- ),
- };
- });
+ )}
+ </Flexbox>
+ </ContextMenuTrigger>
+ );
+});
+
+const toTreeData = (tree: TaskTreeNode[]): DataNode[] => {
+ return tree.map((node) => ({
+ children: toTreeData(node.children),
+ key: node.task.identifier,
+ title: <SubtaskTitle task={node.task} />,
+ }));
};
const TaskSubtasks = memo(() => {
@@ -131,12 +137,13 @@ const TaskSubtasks = memo(() => {
const taskId = useTaskStore(taskDetailSelectors.activeTaskId);
const [isCreating, setIsCreating] = useState(false);
+ const [isExpanded, setIsExpanded] = useState(true);
const handleNavigate = useCallback(
(identifier: string) => {
- if (agentId) navigate(`/agent/${agentId}/tasks/${identifier}`);
+ navigate(`/task/${identifier}`);
},
- [agentId, navigate],
+ [navigate],
);
const treeData = useMemo(() => {
@@ -154,7 +161,39 @@ const TaskSubtasks = memo(() => {
<Flexbox gap={8}>
{hasSubtasks ? (
<>
- <Flexbox horizontal align="center" justify="flex-end">
+ <Flexbox horizontal align="center" justify="space-between">
+ <Flexbox horizontal align="center" gap={8}>
+ <Block
+ clickable
+ horizontal
+ align="center"
+ gap={8}
+ paddingBlock={4}
+ paddingInline={8}
+ style={{ cursor: 'pointer', width: 'fit-content' }}
+ variant="borderless"
+ onClick={() => setIsExpanded((prev) => !prev)}
+ >
+ <Icon color={cssVar.colorTextDescription} icon={ListTodoIcon} size={16} />
+ <Text color={cssVar.colorTextSecondary} fontSize={13} weight={500}>
+ {t('taskDetail.subtasks')}
+ </Text>
+ <Icon
+ color={cssVar.colorTextDescription}
+ icon={ChevronDown}
+ size={14}
+ style={{
+ transform: isExpanded ? 'rotate(0deg)' : 'rotate(-90deg)',
+ transition: 'transform 200ms',
+ }}
+ />
+ </Block>
+ <TaskSubtaskProgressTag
+ currentIdentifier={taskId}
+ subtasks={subtasks}
+ onSubtaskClick={handleNavigate}
+ />
+ </Flexbox>
<ActionIcon
icon={Plus}
size="small"
@@ -162,44 +201,24 @@ const TaskSubtasks = memo(() => {
onClick={toggleCreating}
/>
</Flexbox>
-
- {isCreating && (
- <CreateTaskInlineEntry
- autoFocus
- agentId={agentId ?? undefined}
- parentTaskId={taskId}
- placeholder={t('taskDetail.subtaskInstructionPlaceholder')}
- onCollapse={() => setIsCreating(false)}
- onCreated={() => setIsCreating(false)}
- />
- )}
-
- <Accordion defaultExpandedKeys={['subtasks']} gap={0}>
- <AccordionItem
- itemKey="subtasks"
- paddingBlock={4}
- paddingInline={8}
- title={
- <Flexbox horizontal align="center" gap={8}>
- <Icon color={cssVar.colorTextDescription} icon={ListTodoIcon} size={16} />
- <Text color={cssVar.colorTextSecondary} fontSize={13} weight={500}>
- {t('taskDetail.subtasks')}
- </Text>
- <TaskSubtaskProgressTag
- currentIdentifier={taskId}
- subtasks={subtasks}
- onSubtaskClick={handleNavigate}
- />
- </Flexbox>
- }
- >
+ {isExpanded && (
+ <>
+ {isCreating && (
+ <CreateTaskInlineEntry
+ autoFocus
+ agentId={agentId ?? undefined}
+ parentTaskId={taskId}
+ placeholder={t('taskDetail.subtaskInstructionPlaceholder')}
+ onCollapse={() => setIsCreating(false)}
+ onCreated={() => setIsCreating(false)}
+ />
+ )}
<ConfigProvider theme={{ components: { Tree: { titleHeight: 36 } } }}>
<Tree
blockNode
defaultExpandAll
showLine
className={styles.subtaskTree}
- style={{ marginTop: 8 }}
switcherIcon={<Icon icon={ChevronDown} size={14} />}
treeData={treeData}
onSelect={(keys) => {
@@ -209,8 +228,8 @@ const TaskSubtasks = memo(() => {
}}
/>
</ConfigProvider>
- </AccordionItem>
- </Accordion>
+ </>
+ )}
</>
) : (
<>
diff --git a/src/features/AgentTasks/AgentTaskDetail/TopicCard.tsx b/src/features/AgentTasks/AgentTaskDetail/TopicCard.tsx
index 43a7348a27d..6a1a43913cf 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TopicCard.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TopicCard.tsx
@@ -1,19 +1,23 @@
import type { TaskDetailActivity } from '@lobechat/types';
-import { Avatar, Block, Flexbox, Icon, Tag, Text } from '@lobehub/ui';
+import {
+ ActionIcon,
+ Avatar,
+ Block,
+ type DropdownItem,
+ DropdownMenu,
+ Flexbox,
+ Icon,
+ Text,
+} from '@lobehub/ui';
import { cssVar } from 'antd-style';
import dayjs from 'dayjs';
-import { MessagesSquare } from 'lucide-react';
+import { CalendarDays, Copy, ExternalLink, MoreHorizontal } from 'lucide-react';
import { memo, useCallback, useEffect, useState } from 'react';
+import { useTranslation } from 'react-i18next';
import { useTaskStore } from '@/store/task';
-const TOPIC_STATUS_COLOR: Record<string, string> = {
- canceled: cssVar.colorTextSecondary,
- completed: cssVar.colorSuccess,
- failed: cssVar.colorError,
- running: cssVar.colorInfo,
- timeout: cssVar.colorWarning,
-};
+import TopicStatusIcon from './TopicStatusIcon';
const formatDuration = (ms: number): string => {
const seconds = Math.floor(ms / 1000);
@@ -29,6 +33,7 @@ interface TopicCardProps {
}
const TopicCard = memo<TopicCardProps>(({ activity }) => {
+ const { t } = useTranslation('chat');
const openTopicDrawer = useTaskStore((s) => s.openTopicDrawer);
const isRunning = activity.status === 'running';
@@ -44,16 +49,32 @@ const TopicCard = memo<TopicCardProps>(({ activity }) => {
return () => clearInterval(interval);
}, [isRunning, activity.time]);
- const handleClick = useCallback(() => {
+ const handleOpen = useCallback(() => {
if (activity.id) openTopicDrawer(activity.id);
}, [activity.id, openTopicDrawer]);
- const statusColor = TOPIC_STATUS_COLOR[activity.status ?? ''] ?? cssVar.colorTextQuaternary;
- const timeDisplay = isRunning
- ? formatDuration(elapsed)
- : activity.time
- ? dayjs(activity.time).fromNow()
- : '';
+ const handleCopyId = useCallback(() => {
+ if (activity.id) void navigator.clipboard.writeText(activity.id);
+ }, [activity.id]);
+
+ const startedAt = activity.time ? dayjs(activity.time).fromNow() : '';
+ const durationText = isRunning ? formatDuration(elapsed) : '';
+
+ const menuItems: DropdownItem[] = [
+ {
+ icon: ExternalLink,
+ key: 'open',
+ label: t('taskDetail.topicMenu.open', { defaultValue: 'Open run' }),
+ onClick: handleOpen,
+ },
+ {
+ disabled: !activity.id,
+ icon: Copy,
+ key: 'copy',
+ label: t('taskDetail.topicMenu.copyId', { defaultValue: 'Copy run ID' }),
+ onClick: handleCopyId,
+ },
+ ];
return (
<Block
@@ -62,27 +83,52 @@ const TopicCard = memo<TopicCardProps>(({ activity }) => {
padding={12}
style={{ borderRadius: cssVar.borderRadiusLG }}
variant={'outlined'}
- onClick={activity.id ? handleClick : undefined}
+ onClick={activity.id ? handleOpen : undefined}
>
- <Flexbox horizontal align={'center'} gap={8} justify={'space-between'}>
- <Flexbox horizontal align={'center'} gap={8} style={{ overflow: 'hidden' }}>
- <Icon color={cssVar.colorTextDescription} icon={MessagesSquare} size={16} />
+ <Flexbox horizontal align={'center'} gap={12} justify={'space-between'}>
+ <Flexbox horizontal align={'center'} gap={8} style={{ minWidth: 0, overflow: 'hidden' }}>
+ <TopicStatusIcon size={16} status={activity.status} />
<Text ellipsis weight={500}>
{activity.title}
</Text>
{activity.seq != null && (
- <Text fontSize={12} type={'secondary'}>
+ <Text fontSize={12} style={{ flexShrink: 0 }} type={'secondary'}>
#{activity.seq}
</Text>
)}
+ {durationText && (
+ <Text fontSize={12} style={{ flexShrink: 0 }} type={'secondary'}>
+ · {durationText}
+ </Text>
+ )}
</Flexbox>
+
<Flexbox horizontal align={'center'} flex={'none'} gap={8}>
- <Tag size={'small'} style={{ color: statusColor }}>
- {activity.status ?? 'unknown'}
- </Tag>
- <Text fontSize={12} type={'secondary'}>
- {timeDisplay}
- </Text>
+ {activity.author && (
+ <Flexbox horizontal align={'center'} gap={6}>
+ {activity.author.avatar && <Avatar avatar={activity.author.avatar} size={20} />}
+ <Text fontSize={12} type={'secondary'}>
+ {activity.author.name}
+ </Text>
+ </Flexbox>
+ )}
+ {startedAt && (
+ <Flexbox horizontal align={'center'} gap={4}>
+ <Icon color={cssVar.colorTextTertiary} icon={CalendarDays} size={12} />
+ <Text fontSize={12} type={'secondary'}>
+ {startedAt}
+ </Text>
+ </Flexbox>
+ )}
+ <DropdownMenu items={menuItems}>
+ <ActionIcon
+ icon={MoreHorizontal}
+ size={'small'}
+ onClick={(e) => {
+ e.stopPropagation();
+ }}
+ />
+ </DropdownMenu>
</Flexbox>
</Flexbox>
@@ -91,15 +137,6 @@ const TopicCard = memo<TopicCardProps>(({ activity }) => {
{activity.summary}
</Text>
)}
-
- {activity.author && (
- <Flexbox horizontal align={'center'} gap={6}>
- {activity.author.avatar && <Avatar avatar={activity.author.avatar} size={20} />}
- <Text fontSize={12} type={'secondary'}>
- {activity.author.name}
- </Text>
- </Flexbox>
- )}
</Block>
);
});
diff --git a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx
index 071b658dab1..86fbd1bbab5 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx
@@ -1,25 +1,19 @@
'use client';
import { type ConversationContext } from '@lobechat/types';
-import { Drawer, Flexbox, Tag, Text } from '@lobehub/ui';
+import { Drawer, Flexbox, Text } from '@lobehub/ui';
import { cssVar } from 'antd-style';
-import { memo, useMemo } from 'react';
+import { memo, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
-import { ChatList, ConversationProvider } from '@/features/Conversation';
+import { ChatList, ConversationProvider, MessageItem } from '@/features/Conversation';
import { useOperationState } from '@/hooks/useOperationState';
import { useChatStore } from '@/store/chat';
import { messageMapKey } from '@/store/chat/utils/messageMapKey';
import { useTaskStore } from '@/store/task';
import { taskActivitySelectors, taskDetailSelectors } from '@/store/task/selectors';
-const TOPIC_STATUS_COLOR: Record<string, string> = {
- canceled: cssVar.colorTextSecondary,
- completed: cssVar.colorSuccess,
- failed: cssVar.colorError,
- running: cssVar.colorInfo,
- timeout: cssVar.colorWarning,
-};
+import TopicStatusIcon from '../TopicStatusIcon';
interface TopicChatDrawerBodyProps {
agentId: string;
@@ -42,6 +36,11 @@ const TopicChatDrawerBody = memo<TopicChatDrawerBodyProps>(({ agentId, topicId }
const replaceMessages = useChatStore((s) => s.replaceMessages);
const operationState = useOperationState(context);
+ const itemContent = useCallback(
+ (index: number, id: string) => <MessageItem disableEditing id={id} index={index} key={id} />,
+ [],
+ );
+
return (
<ConversationProvider
context={context}
@@ -53,7 +52,7 @@ const TopicChatDrawerBody = memo<TopicChatDrawerBodyProps>(({ agentId, topicId }
}}
>
<Flexbox flex={1} height={'100%'} style={{ overflow: 'hidden' }}>
- <ChatList />
+ <ChatList disableActionsBar itemContent={itemContent} />
</Flexbox>
</ConversationProvider>
);
@@ -70,10 +69,10 @@ const TopicChatDrawer = memo(() => {
const open = !!topicId && !!agentId;
const status = activity?.status;
- const statusColor = TOPIC_STATUS_COLOR[status ?? ''] ?? cssVar.colorTextQuaternary;
const title = (
<Flexbox horizontal align={'center'} gap={8} style={{ minWidth: 0 }}>
+ <TopicStatusIcon size={16} status={status} />
<Text ellipsis weight={500}>
{activity?.title || t('taskDetail.topicDrawer.untitled')}
</Text>
@@ -82,11 +81,6 @@ const TopicChatDrawer = memo(() => {
#{activity.seq}
</Text>
)}
- {status && (
- <Tag size={'small'} style={{ color: statusColor }}>
- {status}
- </Tag>
- )}
</Flexbox>
);
@@ -94,6 +88,7 @@ const TopicChatDrawer = memo(() => {
<Drawer
destroyOnHidden
containerMaxWidth={'auto'}
+ mask={false}
open={open}
placement={'right'}
push={false}
@@ -102,6 +97,16 @@ const TopicChatDrawer = memo(() => {
styles={{
body: { padding: 0 },
bodyContent: { height: '100%' },
+ wrapper: {
+ border: `1px solid ${cssVar.colorBorderSecondary}`,
+ borderRadius: 12,
+ bottom: 8,
+ boxShadow: '0 6px 24px 0 rgba(0, 0, 0, 0.08), 0 2px 6px 0 rgba(0, 0, 0, 0.04)',
+ height: 'auto',
+ overflow: 'hidden',
+ right: 8,
+ top: 8,
+ },
}}
onClose={closeTopicDrawer}
>
diff --git a/src/features/AgentTasks/AgentTaskDetail/TopicStatusIcon.tsx b/src/features/AgentTasks/AgentTaskDetail/TopicStatusIcon.tsx
new file mode 100644
index 00000000000..a20e66a328f
--- /dev/null
+++ b/src/features/AgentTasks/AgentTaskDetail/TopicStatusIcon.tsx
@@ -0,0 +1,65 @@
+import { Icon } from '@lobehub/ui';
+import { cssVar } from 'antd-style';
+import {
+ CircleAlert,
+ CircleCheck,
+ CircleDashed,
+ CircleSlash,
+ CircleX,
+ type LucideIcon,
+} from 'lucide-react';
+import { memo } from 'react';
+
+type TopicRunStatus = 'canceled' | 'completed' | 'failed' | 'pending' | 'running' | 'timeout';
+
+const STATIC_META: Record<
+ Exclude<TopicRunStatus, 'running'>,
+ { color: string; icon: LucideIcon }
+> = {
+ canceled: { color: cssVar.colorTextSecondary, icon: CircleSlash },
+ completed: { color: cssVar.colorSuccess, icon: CircleCheck },
+ failed: { color: cssVar.colorError, icon: CircleX },
+ pending: { color: cssVar.colorTextQuaternary, icon: CircleDashed },
+ timeout: { color: cssVar.colorWarning, icon: CircleAlert },
+};
+
+const RunningIcon = memo<{ size: number }>(({ size }) => {
+ const mainColor = cssVar.colorWarning;
+ const ringColor = `color-mix(in srgb, ${cssVar.colorWarning} 35%, transparent)`;
+ return (
+ <svg aria-hidden fill="none" height={size} viewBox="0 0 16 16" width={size}>
+ <circle cx="8" cy="8" r="6.5" stroke={ringColor} strokeWidth="1.5" />
+ <path
+ d="M14.5 8 A 6.5 6.5 0 0 1 8 14.5"
+ fill="none"
+ stroke={mainColor}
+ strokeLinecap="round"
+ strokeWidth="1.5"
+ >
+ <animateTransform
+ attributeName="transform"
+ dur="1s"
+ from="0 8 8"
+ repeatCount="indefinite"
+ to="360 8 8"
+ type="rotate"
+ />
+ </path>
+ <circle cx="8" cy="8" fill={mainColor} r="2.5" stroke={ringColor} strokeWidth="1" />
+ </svg>
+ );
+});
+
+interface TopicStatusIconProps {
+ size?: number;
+ status?: string | null;
+}
+
+const TopicStatusIcon = memo<TopicStatusIconProps>(({ size = 16, status }) => {
+ if (status === 'running') return <RunningIcon size={size} />;
+ const key = (status ?? 'pending') as keyof typeof STATIC_META;
+ const meta = STATIC_META[key] ?? STATIC_META.pending;
+ return <Icon color={meta.color} icon={meta.icon} size={size} />;
+});
+
+export default TopicStatusIcon;
diff --git a/src/features/AgentTasks/AgentTaskList/AgentTasksPage.tsx b/src/features/AgentTasks/AgentTaskList/AgentTasksPage.tsx
index c7c1369b9c7..2701f5154f1 100644
--- a/src/features/AgentTasks/AgentTaskList/AgentTasksPage.tsx
+++ b/src/features/AgentTasks/AgentTaskList/AgentTasksPage.tsx
@@ -3,14 +3,13 @@ import { Plus } from 'lucide-react';
import { memo, useCallback, useMemo } from 'react';
import { useNavigate } from 'react-router-dom';
-import AutoSaveHint from '@/components/Editor/AutoSaveHint';
import { DESKTOP_HEADER_ICON_SIZE } from '@/const/layoutTokens';
import NavHeader from '@/features/NavHeader';
import WideScreenContainer from '@/features/WideScreenContainer';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
import { useTaskStore } from '@/store/task';
-import { taskDetailSelectors, taskListSelectors } from '@/store/task/selectors';
+import { taskListSelectors } from '@/store/task/selectors';
import { createTaskModal } from '../CreateTaskModal';
import Breadcrumb from '../shared/Breadcrumb';
@@ -21,19 +20,11 @@ import { normalizeTaskListViewOptions } from './listViewOptions';
import TaskList from './TaskList';
import TasksGroupConfig from './TasksGroupConfig';
-interface AgentTasksPageProps {
- /**
- * When omitted, the page shows tasks across all agents (used by the `/tasks` route).
- */
- agentId?: string;
-}
-
-const AgentTasksPage = memo<AgentTasksPageProps>(({ agentId }) => {
+const AgentTasksPage = memo(() => {
const navigate = useNavigate();
const viewMode = useTaskStore(taskListSelectors.viewMode);
- const saveStatus = useTaskStore(taskDetailSelectors.taskSaveStatus);
const useFetchTaskList = useTaskStore((s) => s.useFetchTaskList);
- useFetchTaskList({ agentId, allAgents: !agentId });
+ useFetchTaskList({ allAgents: true });
const rawViewOptions = useGlobalStore(systemStatusSelectors.taskListViewOptions);
const viewOptions = useMemo(() => normalizeTaskListViewOptions(rawViewOptions), [rawViewOptions]);
const inlineCollapsed = useGlobalStore(systemStatusSelectors.taskCreateInlineCollapsed);
@@ -48,25 +39,20 @@ const AgentTasksPage = memo<AgentTasksPageProps>(({ agentId }) => {
const handleCreateTask = useCallback(() => {
createTaskModal({
- agentId,
onCreated: (task) => {
- const targetAgentId = task.agentId || agentId;
- if (targetAgentId) {
- navigate(`/agent/${targetAgentId}/tasks/${task.identifier}`);
- }
+ navigate(`/task/${task.identifier}`);
},
});
- }, [agentId, navigate]);
+ }, [navigate]);
+
+ const handleShowHiddenCompleted = useCallback(() => {
+ setViewOptions((prev) => ({ ...prev, hideCompleted: false }));
+ }, [setViewOptions]);
return (
<Flexbox flex={1} height={'100%'}>
<NavHeader
- left={
- <>
- <Breadcrumb agentId={agentId} />
- {saveStatus !== 'idle' && <AutoSaveHint saveStatus={saveStatus} />}
- </>
- }
+ left={<Breadcrumb />}
right={
<Flexbox horizontal align={'center'} gap={4}>
{inlineCollapsed && (
@@ -84,12 +70,16 @@ const AgentTasksPage = memo<AgentTasksPageProps>(({ agentId }) => {
/>
{viewMode === 'kanban' ? (
<Flexbox flex={1} style={{ overflowX: 'auto', overflowY: 'hidden' }}>
- <KanbanBoard agentId={agentId} />
+ <KanbanBoard />
</Flexbox>
) : (
- <WideScreenContainer gap={16} paddingBlock={16} wrapperStyle={{ flex: 1, overflowY: 'auto' }}>
- {!inlineCollapsed && <CreateTaskInlineEntry agentId={agentId} />}
- <TaskList options={viewOptions} />
+ <WideScreenContainer
+ gap={16}
+ paddingBlock={16}
+ wrapperStyle={{ flex: 1, overflowY: 'auto' }}
+ >
+ {!inlineCollapsed && <CreateTaskInlineEntry />}
+ <TaskList options={viewOptions} onShowHiddenCompleted={handleShowHiddenCompleted} />
</WideScreenContainer>
)}
</Flexbox>
diff --git a/src/features/AgentTasks/AgentTaskList/CreateTaskInlineEntry.tsx b/src/features/AgentTasks/AgentTaskList/CreateTaskInlineEntry.tsx
index ccedde131d6..3ec0498d5ca 100644
--- a/src/features/AgentTasks/AgentTaskList/CreateTaskInlineEntry.tsx
+++ b/src/features/AgentTasks/AgentTaskList/CreateTaskInlineEntry.tsx
@@ -67,9 +67,17 @@ const CreateTaskInlineEntry = memo<CreateTaskInlineEntryProps>((props) => {
const trimmed = instruction.trim();
if (!trimmed) return;
+ const firstLine =
+ trimmed
+ .split('\n')
+ .find((line) => line.trim())
+ ?.trim() ?? trimmed;
+ const name = firstLine.length > 30 ? `${firstLine.slice(0, 30)}…` : firstLine;
+
const result = await createTask({
assigneeAgentId,
instruction: trimmed,
+ name,
parentTaskId,
priority: priority || undefined,
});
@@ -121,7 +129,7 @@ const CreateTaskInlineEntry = memo<CreateTaskInlineEntryProps>((props) => {
title={t('createTask.collapse')}
onClick={handleCollapse}
/>
- <Flexbox style={{ fontSize: 14, minHeight: 120, padding: '12px 40px 0 16px' }}>
+ <Flexbox style={{ fontSize: 14, padding: '12px 40px 0 16px' }}>
<EditorCanvas
editor={editor}
floatingToolbar={false}
diff --git a/src/features/AgentTasks/AgentTaskList/HiddenColumnsPanel.tsx b/src/features/AgentTasks/AgentTaskList/HiddenColumnsPanel.tsx
new file mode 100644
index 00000000000..9ea44e869c8
--- /dev/null
+++ b/src/features/AgentTasks/AgentTaskList/HiddenColumnsPanel.tsx
@@ -0,0 +1,166 @@
+import type { TaskStatus } from '@lobechat/types';
+import { Icon, Text, Tooltip } from '@lobehub/ui';
+import { createStaticStyles, cx } from 'antd-style';
+import { PanelRightClose, PanelRightOpen } from 'lucide-react';
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import TaskStatusIcon from '../features/TaskStatusIcon';
+
+export const HIDDEN_PANEL_WIDTH = {
+ collapsed: 36,
+ expanded: 220,
+};
+
+const styles = createStaticStyles(({ css, cssVar }) => ({
+ card: css`
+ cursor: pointer;
+
+ display: flex;
+ gap: 8px;
+ align-items: center;
+
+ padding-block: 8px;
+ padding-inline: 10px;
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: ${cssVar.borderRadiusLG};
+
+ background: ${cssVar.colorBgContainer};
+
+ transition: border-color 0.2s;
+
+ &:hover {
+ border-color: ${cssVar.colorPrimaryBorder};
+ }
+ `,
+ collapsedHeader: css`
+ cursor: pointer;
+
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ align-items: center;
+
+ padding-block: 12px;
+ padding-inline: 6px;
+
+ color: ${cssVar.colorTextSecondary};
+ `,
+ count: css`
+ margin-inline-start: auto;
+ color: ${cssVar.colorTextTertiary};
+ `,
+ header: css`
+ cursor: pointer;
+
+ display: flex;
+ gap: 6px;
+ align-items: center;
+
+ padding-block: 10px 8px;
+ padding-inline: 6px;
+
+ color: ${cssVar.colorTextSecondary};
+ `,
+ list: css`
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+
+ padding-block: 4px 12px;
+ padding-inline: 2px;
+ `,
+ panel: css`
+ display: flex;
+ flex-direction: column;
+ flex-shrink: 0;
+
+ max-height: 100%;
+ margin-inline-start: auto;
+ padding-inline: 8px;
+ border-radius: ${cssVar.borderRadiusLG};
+
+ background: ${cssVar.colorFillQuaternary};
+ `,
+ verticalLabel: css`
+ writing-mode: vertical-rl;
+ font-size: 12px;
+ font-weight: 500;
+ letter-spacing: 0.02em;
+ `,
+}));
+
+interface HiddenColumn {
+ columnKey: string;
+ label: string;
+ statusIcon?: TaskStatus;
+ total: number;
+}
+
+interface HiddenColumnsPanelProps {
+ collapsed: boolean;
+ columns: HiddenColumn[];
+ onRestore: (columnKey: string) => void;
+ onToggleCollapsed: (next: boolean) => void;
+}
+
+const HiddenColumnsPanel = memo<HiddenColumnsPanelProps>(
+ ({ collapsed, columns, onRestore, onToggleCollapsed }) => {
+ const { t } = useTranslation('chat');
+
+ if (columns.length === 0) return null;
+
+ const title = t('taskList.kanban.hiddenColumns');
+
+ if (collapsed) {
+ return (
+ <div
+ className={styles.panel}
+ style={{ width: HIDDEN_PANEL_WIDTH.collapsed }}
+ onClick={() => onToggleCollapsed(false)}
+ >
+ <Tooltip title={title}>
+ <div className={styles.collapsedHeader}>
+ <Icon icon={PanelRightOpen} size={16} />
+ <Text className={styles.verticalLabel} type={'secondary'}>
+ {title} · {columns.length}
+ </Text>
+ </div>
+ </Tooltip>
+ </div>
+ );
+ }
+
+ return (
+ <div className={styles.panel} style={{ width: HIDDEN_PANEL_WIDTH.expanded }}>
+ <div className={styles.header} onClick={() => onToggleCollapsed(true)}>
+ <Text fontSize={13} weight={500}>
+ {title}
+ </Text>
+ <Text className={styles.count} fontSize={12}>
+ {columns.length}
+ </Text>
+ <Icon icon={PanelRightClose} size={16} />
+ </div>
+ <div className={styles.list}>
+ {columns.map((column) => (
+ <div
+ className={cx(styles.card)}
+ key={column.columnKey}
+ title={t('taskList.kanban.showColumn')}
+ onClick={() => onRestore(column.columnKey)}
+ >
+ {column.statusIcon && <TaskStatusIcon size={16} status={column.statusIcon} />}
+ <Text fontSize={13}>{column.label}</Text>
+ <Text className={styles.count} fontSize={12}>
+ {column.total}
+ </Text>
+ </div>
+ ))}
+ </div>
+ </div>
+ );
+ },
+);
+
+export default HiddenColumnsPanel;
diff --git a/src/features/AgentTasks/AgentTaskList/KanbanBoard.tsx b/src/features/AgentTasks/AgentTaskList/KanbanBoard.tsx
index 851eee45143..126934dd514 100644
--- a/src/features/AgentTasks/AgentTaskList/KanbanBoard.tsx
+++ b/src/features/AgentTasks/AgentTaskList/KanbanBoard.tsx
@@ -12,15 +12,20 @@ import {
import { Center, Empty, Flexbox } from '@lobehub/ui';
import { createStaticStyles } from 'antd-style';
import { ClipboardCheckIcon } from 'lucide-react';
-import { memo, useCallback, useState } from 'react';
+import { memo, useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { useNavigate } from 'react-router-dom';
+import { useGlobalStore } from '@/store/global';
+import { systemStatusSelectors } from '@/store/global/selectors';
import { useTaskStore } from '@/store/task';
import { taskListSelectors } from '@/store/task/selectors';
import type { TaskGroupItem, TaskListItem } from '@/store/task/slices/list/initialState';
+import { createTaskModal } from '../CreateTaskModal';
import AgentTaskItem from '../features/AgentTaskItem';
-import KanbanColumn, { COLUMN_WIDTH } from './KanbanColumn';
+import HiddenColumnsPanel from './HiddenColumnsPanel';
+import KanbanColumn, { COLUMN_I18N_KEYS, COLUMN_STATUS_ICON, COLUMN_WIDTH } from './KanbanColumn';
const styles = createStaticStyles(({ css }) => ({
board: css`
@@ -66,20 +71,21 @@ const optimisticMoveTask = (
});
};
-interface KanbanBoardProps {
- agentId?: string;
-}
-
-const KanbanBoard = memo<KanbanBoardProps>(({ agentId }) => {
+const KanbanBoard = memo(() => {
const { t } = useTranslation('chat');
+ const navigate = useNavigate();
const useFetchTaskGroupList = useTaskStore((s) => s.useFetchTaskGroupList);
- useFetchTaskGroupList(agentId);
+ useFetchTaskGroupList({ allAgents: true });
const taskGroups = useTaskStore(taskListSelectors.taskGroups);
const isInit = useTaskStore(taskListSelectors.isTaskGroupListInit);
const updateTaskStatus = useTaskStore((s) => s.updateTaskStatus);
+ const hiddenColumns = useGlobalStore(systemStatusSelectors.taskKanbanHiddenColumns);
+ const hiddenPanelCollapsed = useGlobalStore(systemStatusSelectors.taskKanbanHiddenPanelCollapsed);
+ const updateSystemStatus = useGlobalStore((s) => s.updateSystemStatus);
+
const [activeTask, setActiveTask] = useState<TaskListItem | null>(null);
const sensors = useSensors(
@@ -125,6 +131,56 @@ const KanbanBoard = memo<KanbanBoardProps>(({ agentId }) => {
setActiveTask(null);
}, []);
+ const handleCreateTask = useCallback(() => {
+ createTaskModal({
+ onCreated: (task) => {
+ navigate(`/task/${task.identifier}`);
+ },
+ showInlineToggle: false,
+ });
+ }, [navigate]);
+
+ const handleHideColumn = useCallback(
+ (columnKey: string) => {
+ const next = Array.from(new Set([...hiddenColumns, columnKey]));
+ updateSystemStatus({ taskKanbanHiddenColumns: next }, 'hideKanbanColumn');
+ },
+ [hiddenColumns, updateSystemStatus],
+ );
+
+ const handleRestoreColumn = useCallback(
+ (columnKey: string) => {
+ const next = hiddenColumns.filter((key) => key !== columnKey);
+ updateSystemStatus({ taskKanbanHiddenColumns: next }, 'restoreKanbanColumn');
+ },
+ [hiddenColumns, updateSystemStatus],
+ );
+
+ const handleToggleHiddenPanel = useCallback(
+ (collapsed: boolean) => {
+ updateSystemStatus({ taskKanbanHiddenPanelCollapsed: collapsed }, 'toggleKanbanHiddenPanel');
+ },
+ [updateSystemStatus],
+ );
+
+ const hiddenColumnSet = useMemo(() => new Set(hiddenColumns), [hiddenColumns]);
+
+ const visibleColumns = useMemo(
+ () => COLUMNS.filter((col) => !hiddenColumnSet.has(col.key)),
+ [hiddenColumnSet],
+ );
+
+ const hiddenColumnEntries = useMemo(
+ () =>
+ COLUMNS.filter((col) => hiddenColumnSet.has(col.key)).map((col) => ({
+ columnKey: col.key,
+ label: t(COLUMN_I18N_KEYS[col.key] as any),
+ statusIcon: COLUMN_STATUS_ICON[col.key],
+ total: taskGroups.find((group) => group.key === col.key)?.total ?? 0,
+ })),
+ [hiddenColumnSet, t, taskGroups],
+ );
+
if (!isInit) return null;
const totalTasks = taskGroups.reduce((sum, g) => sum + g.total, 0);
@@ -146,7 +202,7 @@ const KanbanBoard = memo<KanbanBoardProps>(({ agentId }) => {
onDragStart={handleDragStart}
>
<Flexbox horizontal className={styles.board}>
- {COLUMNS.map((col) => {
+ {visibleColumns.map((col) => {
const group = taskGroups.find((g) => g.key === col.key);
return (
<KanbanColumn
@@ -155,9 +211,17 @@ const KanbanBoard = memo<KanbanBoardProps>(({ agentId }) => {
key={col.key}
tasks={(group?.tasks ?? []) as TaskListItem[]}
total={group?.total ?? 0}
+ onCreate={col.key === 'backlog' ? handleCreateTask : undefined}
+ onHide={() => handleHideColumn(col.key)}
/>
);
})}
+ <HiddenColumnsPanel
+ collapsed={hiddenPanelCollapsed}
+ columns={hiddenColumnEntries}
+ onRestore={handleRestoreColumn}
+ onToggleCollapsed={handleToggleHiddenPanel}
+ />
</Flexbox>
<DragOverlay dropAnimation={null}>
{activeTask ? (
diff --git a/src/features/AgentTasks/AgentTaskList/KanbanColumn.tsx b/src/features/AgentTasks/AgentTaskList/KanbanColumn.tsx
index a349fbf1f92..996ac686c7b 100644
--- a/src/features/AgentTasks/AgentTaskList/KanbanColumn.tsx
+++ b/src/features/AgentTasks/AgentTaskList/KanbanColumn.tsx
@@ -1,8 +1,9 @@
import { useDndContext, useDraggable, useDroppable } from '@dnd-kit/core';
import type { TaskStatus } from '@lobechat/types';
-import { Text } from '@lobehub/ui';
+import { ActionIcon, type DropdownItem, DropdownMenu, Icon, Text } from '@lobehub/ui';
import { createStaticStyles, cx } from 'antd-style';
-import { memo } from 'react';
+import { EyeOff, MoreHorizontal, Plus } from 'lucide-react';
+import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import type { TaskListItem } from '@/store/task/slices/list/initialState';
@@ -14,17 +15,24 @@ export const COLUMN_WIDTH = 300;
const cardStyles = createStaticStyles(({ css, cssVar }) => ({
card: css`
- cursor: grab;
-
- border: 1px solid ${cssVar.colorBorderSecondary};
border-radius: ${cssVar.borderRadiusLG};
+ background: ${cssVar.colorBgElevated};
+ box-shadow:
+ 0 1px 2px rgb(0 0 0 / 4%),
+ 0 2px 6px rgb(0 0 0 / 3%);
- background: ${cssVar.colorBgContainer};
+ &,
+ & * {
+ cursor: default;
+ }
- transition: box-shadow 0.2s;
+ &:active,
+ &:active * {
+ cursor: grabbing;
+ }
- &:hover {
- box-shadow: ${cssVar.boxShadowTertiary};
+ &:hover > * {
+ background: ${cssVar.colorFillQuaternary};
}
`,
dragging: css`
@@ -51,6 +59,35 @@ const DraggableTaskCard = memo<{ task: TaskListItem }>(({ task }) => {
});
const styles = createStaticStyles(({ css, cssVar }) => ({
+ action: css`
+ opacity: 0;
+ transition: opacity 0.2s;
+ `,
+ addPill: css`
+ cursor: pointer;
+
+ display: flex;
+ gap: 6px;
+ align-items: center;
+ justify-content: center;
+
+ height: 36px;
+ border: 1px solid ${cssVar.colorBorder};
+ border-radius: 999px;
+
+ color: ${cssVar.colorTextTertiary};
+
+ transition:
+ border-color 0.2s,
+ color 0.2s,
+ background 0.2s;
+
+ &:hover {
+ border-color: ${cssVar.colorPrimaryBorder};
+ color: ${cssVar.colorPrimary};
+ background: ${cssVar.colorBgContainer};
+ }
+ `,
body: css`
overflow-y: auto;
display: flex;
@@ -58,8 +95,8 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
flex-direction: column;
gap: 6px;
- padding-block: 4px 16px;
- padding-inline: 4px;
+ padding-block: 4px 12px;
+ padding-inline: 8px;
`,
column: css`
display: flex;
@@ -68,12 +105,21 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
width: ${COLUMN_WIDTH}px;
max-height: 100%;
+ border-radius: ${cssVar.borderRadiusLG};
+
+ background: ${cssVar.colorFillQuaternary};
- transition: background 0.2s;
+ transition:
+ background 0.2s,
+ box-shadow 0.2s;
+
+ &:hover .kanban-col-action {
+ opacity: 1;
+ }
`,
dropActive: css`
- border-radius: ${cssVar.borderRadiusLG};
- background: ${cssVar.colorFillQuaternary};
+ background: ${cssVar.colorFillTertiary};
+ box-shadow: inset 0 0 0 1px ${cssVar.colorPrimaryBorderHover};
`,
emptyText: css`
padding-block: 24px;
@@ -85,11 +131,17 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
`,
header: css`
display: flex;
- gap: 8px;
+ gap: 6px;
align-items: center;
- padding-block: 8px 10px;
- padding-inline: 8px;
+ padding-block: 10px 8px;
+ padding-inline: 10px 6px;
+ `,
+ headerActions: css`
+ display: flex;
+ gap: 2px;
+ align-items: center;
+ margin-inline-start: auto;
`,
notDroppable: css`
pointer-events: none;
@@ -97,14 +149,14 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
`,
}));
-const COLUMN_I18N_KEYS: Record<string, string> = {
+export const COLUMN_I18N_KEYS: Record<string, string> = {
backlog: 'taskList.kanban.backlog',
done: 'taskList.kanban.done',
needsInput: 'taskList.kanban.needsInput',
running: 'taskList.kanban.running',
};
-const COLUMN_STATUS_ICON: Record<string, TaskStatus> = {
+export const COLUMN_STATUS_ICON: Record<string, TaskStatus> = {
backlog: 'backlog',
done: 'completed',
needsInput: 'paused',
@@ -114,54 +166,93 @@ const COLUMN_STATUS_ICON: Record<string, TaskStatus> = {
interface KanbanColumnProps {
columnKey: string;
droppable: boolean;
+ onCreate?: () => void;
+ onHide?: () => void;
tasks: TaskListItem[];
total: number;
}
-const KanbanColumn = memo<KanbanColumnProps>(({ columnKey, droppable, tasks, total }) => {
- const { t } = useTranslation('chat');
- const { active } = useDndContext();
- const { isOver, setNodeRef } = useDroppable({
- disabled: !droppable,
- id: columnKey,
- });
+const KanbanColumn = memo<KanbanColumnProps>(
+ ({ columnKey, droppable, onCreate, onHide, tasks, total }) => {
+ const { t } = useTranslation('chat');
+ const { active } = useDndContext();
+ const { isOver, setNodeRef } = useDroppable({
+ disabled: !droppable,
+ id: columnKey,
+ });
- const statusIcon = COLUMN_STATUS_ICON[columnKey];
- const i18nKey = COLUMN_I18N_KEYS[columnKey];
- const label = i18nKey ? t(i18nKey as any) : columnKey;
- const isDragActive = !!active;
+ const statusIcon = COLUMN_STATUS_ICON[columnKey];
+ const i18nKey = COLUMN_I18N_KEYS[columnKey];
+ const label = i18nKey ? t(i18nKey as any) : columnKey;
+ const isDragActive = !!active;
- // Don't highlight if dragging a card that's already in this column
- const activeTask = active?.data.current?.task as TaskListItem | undefined;
- const isFromThisColumn = activeTask && tasks.some((t) => t.identifier === activeTask.identifier);
- const showDropHighlight = isOver && droppable && !isFromThisColumn;
- const showDisabled = isDragActive && !droppable;
+ // Don't highlight if dragging a card that's already in this column
+ const activeTask = active?.data.current?.task as TaskListItem | undefined;
+ const isFromThisColumn =
+ activeTask && tasks.some((task) => task.identifier === activeTask.identifier);
+ const showDropHighlight = isOver && droppable && !isFromThisColumn;
+ const showDisabled = isDragActive && !droppable;
- return (
- <div
- ref={setNodeRef}
- className={cx(
- styles.column,
- showDropHighlight && styles.dropActive,
- showDisabled && styles.notDroppable,
- )}
- >
- <div className={styles.header}>
- {statusIcon && <TaskStatusIcon size={18} status={statusIcon} />}
- <Text weight={500}>{label}</Text>
- <Text fontSize={12} type={'secondary'}>
- {total}
- </Text>
- </div>
- <div className={styles.body}>
- {tasks.length > 0 ? (
- tasks.map((task) => <DraggableTaskCard key={task.identifier} task={task} />)
- ) : (
- <div className={styles.emptyText}>{t('taskList.kanban.emptyColumn')}</div>
+ const menuItems = useMemo<DropdownItem[]>(
+ () =>
+ onHide
+ ? [
+ {
+ icon: <Icon icon={EyeOff} />,
+ key: 'hide',
+ label: t('taskList.kanban.hideColumn'),
+ onClick: onHide,
+ },
+ ]
+ : [],
+ [onHide, t],
+ );
+
+ return (
+ <div
+ ref={setNodeRef}
+ className={cx(
+ styles.column,
+ showDropHighlight && styles.dropActive,
+ showDisabled && styles.notDroppable,
)}
+ >
+ <div className={styles.header}>
+ {statusIcon && <TaskStatusIcon size={18} status={statusIcon} />}
+ <Text weight={500}>{label}</Text>
+ <Text fontSize={12} type={'secondary'}>
+ {total}
+ </Text>
+ <div className={cx(styles.headerActions, 'kanban-col-action')}>
+ {menuItems.length > 0 && (
+ <DropdownMenu items={menuItems}>
+ <ActionIcon icon={MoreHorizontal} size={'small'} />
+ </DropdownMenu>
+ )}
+ {onCreate && (
+ <ActionIcon
+ icon={Plus}
+ size={'small'}
+ title={t('taskList.kanban.addTask')}
+ onClick={onCreate}
+ />
+ )}
+ </div>
+ </div>
+ <div className={styles.body}>
+ {tasks.length > 0 ? (
+ tasks.map((task) => <DraggableTaskCard key={task.identifier} task={task} />)
+ ) : onCreate ? (
+ <div className={styles.addPill} title={t('taskList.kanban.addTask')} onClick={onCreate}>
+ <Icon icon={Plus} size={16} />
+ </div>
+ ) : (
+ <div className={styles.emptyText}>{t('taskList.kanban.emptyColumn')}</div>
+ )}
+ </div>
</div>
- </div>
- );
-});
+ );
+ },
+);
export default KanbanColumn;
diff --git a/src/features/AgentTasks/AgentTaskList/TaskList.tsx b/src/features/AgentTasks/AgentTaskList/TaskList.tsx
index 38004abdec7..82a916509f3 100644
--- a/src/features/AgentTasks/AgentTaskList/TaskList.tsx
+++ b/src/features/AgentTasks/AgentTaskList/TaskList.tsx
@@ -18,12 +18,20 @@ import PriorityUrgentIcon from '../features/icons/PriorityUrgentIcon';
import TaskStatusIcon from '../features/TaskStatusIcon';
import { useAgentDisplayMeta } from '../shared/useAgentDisplayMeta';
import type { TaskGroupBy, TaskGroupMeta, TaskListViewOptions } from './listViewOptions';
-import { compareTaskItems, getTaskGroupMeta, sortGroupEntries } from './listViewOptions';
+import {
+ compareTaskItems,
+ getTaskGroupMeta,
+ HIDDEN_WHEN_COMPLETED_STATUSES,
+ sortGroupEntries,
+} from './listViewOptions';
interface TaskListProps {
+ onShowHiddenCompleted?: () => void;
options: TaskListViewOptions;
}
+const HIDDEN_COMPLETED_STATUS_SET = new Set<string>(HIDDEN_WHEN_COMPLETED_STATUSES);
+
const renderTaskRows = (items: ReturnType<typeof taskListSelectors.taskList>, sub?: boolean) =>
items.map((task, index) => (
<Fragment key={task.identifier}>
@@ -109,21 +117,29 @@ const renderGroupTitle = (group: TaskGroupMeta, count: number, sub?: boolean) =>
</Flexbox>
);
-const TaskList = memo<TaskListProps>(({ options }) => {
+const TaskList = memo<TaskListProps>(({ onShowHiddenCompleted, options }) => {
const { t } = useTranslation('chat');
const tasks = useTaskStore(taskListSelectors.taskList);
const isInit = useTaskStore(taskListSelectors.isTaskListInit);
const groupBy = normalizeGroupBy(options.groupBy, 'status');
const subGroupBy = normalizeGroupBy(options.subGroupBy, 'none');
const effectiveSubGroupBy = groupBy === 'none' ? 'none' : subGroupBy;
+ const visibleTasks = useMemo(
+ () =>
+ options.hideCompleted
+ ? tasks.filter((task) => !HIDDEN_COMPLETED_STATUS_SET.has(task.status))
+ : tasks,
+ [tasks, options.hideCompleted],
+ );
+ const hiddenCount = tasks.length - visibleTasks.length;
const groupedTaskEntries = useMemo(() => {
- const sortedTasks = [...tasks].sort((a, b) => compareTaskItems(a, b, options));
+ const sortedTasks = [...visibleTasks].sort((a, b) => compareTaskItems(a, b, options));
const primaryGroupOrderDirection =
options.orderBy === groupBy ? options.orderDirection : undefined;
const subGroupOrderDirection =
options.orderBy === effectiveSubGroupBy ? options.orderDirection : undefined;
- const primaryGroupMap = new Map<string, { items: typeof tasks; meta: TaskGroupMeta }>();
+ const primaryGroupMap = new Map<string, { items: typeof visibleTasks; meta: TaskGroupMeta }>();
for (const task of sortedTasks) {
const primaryGroup = getTaskGroupMeta(task, groupBy);
if (!primaryGroup?.key) continue;
@@ -147,11 +163,11 @@ const TaskList = memo<TaskListProps>(({ options }) => {
return {
items: groupedTasks,
meta,
- subGroups: [] as Array<[TaskGroupMeta, typeof tasks]>,
+ subGroups: [] as Array<[TaskGroupMeta, typeof visibleTasks]>,
};
}
- const subGroupMap = new Map<string, { items: typeof tasks; meta: TaskGroupMeta }>();
+ const subGroupMap = new Map<string, { items: typeof visibleTasks; meta: TaskGroupMeta }>();
for (const task of groupedTasks) {
const subGroup = getTaskGroupMeta(task, effectiveSubGroupBy);
if (!subGroup?.key) continue;
@@ -174,7 +190,7 @@ const TaskList = memo<TaskListProps>(({ options }) => {
),
};
});
- }, [effectiveSubGroupBy, groupBy, options, tasks]);
+ }, [effectiveSubGroupBy, groupBy, options, visibleTasks]);
if (!isInit) return null;
@@ -186,50 +202,79 @@ const TaskList = memo<TaskListProps>(({ options }) => {
);
}
+ const hiddenFooter = hiddenCount > 0 && (
+ <Flexbox
+ horizontal
+ align={'center'}
+ gap={16}
+ justify={'center'}
+ paddingBlock={16}
+ style={{ fontSize: 13 }}
+ >
+ <Flexbox horizontal align={'center'} gap={6}>
+ <Text weight={500}>{t('taskList.hiddenCompleted.count', { count: hiddenCount })}</Text>
+ <Text type={'secondary'}>{t('taskList.hiddenCompleted.suffix')}</Text>
+ </Flexbox>
+ {onShowHiddenCompleted && (
+ <Text style={{ cursor: 'pointer' }} weight={500} onClick={onShowHiddenCompleted}>
+ {t('taskList.hiddenCompleted.show')}
+ </Text>
+ )}
+ </Flexbox>
+ );
+
if (groupBy === 'none') {
- return renderTaskListBlock(groupedTaskEntries[0]?.items ?? []);
+ return (
+ <>
+ {renderTaskListBlock(groupedTaskEntries[0]?.items ?? [])}
+ {hiddenFooter}
+ </>
+ );
}
return (
- <Accordion gap={16}>
- {groupedTaskEntries.map((group) => {
- return (
- <AccordionItem
- defaultExpand
- indicatorPlacement={'end'}
- itemKey={`group-${group.meta.key}`}
- key={group.meta.key}
- paddingBlock={8}
- paddingInline={14}
- title={renderGroupTitle(group.meta, group.items.length)}
- variant={'filled'}
- styles={{
- header: { marginBottom: 8 },
- }}
- >
- {group.subGroups.length > 0 ? (
- <Accordion gap={6}>
- {group.subGroups.map(([subGroup, subGroupTasks]) => (
- <AccordionItem
- defaultExpand
- indicatorPlacement={'end'}
- itemKey={`sub-${group.meta.key}-${subGroup.key}`}
- key={`${group.meta.key}-${subGroup.key}`}
- paddingBlock={6}
- paddingInline={14}
- title={renderGroupTitle(subGroup, subGroupTasks.length, true)}
- >
- {renderTaskListBlock(subGroupTasks, true)}
- </AccordionItem>
- ))}
- </Accordion>
- ) : (
- renderTaskListBlock(group.items)
- )}
- </AccordionItem>
- );
- })}
- </Accordion>
+ <>
+ <Accordion gap={16}>
+ {groupedTaskEntries.map((group) => {
+ return (
+ <AccordionItem
+ defaultExpand
+ indicatorPlacement={'end'}
+ itemKey={`group-${group.meta.key}`}
+ key={group.meta.key}
+ paddingBlock={8}
+ paddingInline={14}
+ title={renderGroupTitle(group.meta, group.items.length)}
+ variant={'filled'}
+ styles={{
+ header: { marginBottom: 8 },
+ }}
+ >
+ {group.subGroups.length > 0 ? (
+ <Accordion gap={6}>
+ {group.subGroups.map(([subGroup, subGroupTasks]) => (
+ <AccordionItem
+ defaultExpand
+ indicatorPlacement={'end'}
+ itemKey={`sub-${group.meta.key}-${subGroup.key}`}
+ key={`${group.meta.key}-${subGroup.key}`}
+ paddingBlock={6}
+ paddingInline={14}
+ title={renderGroupTitle(subGroup, subGroupTasks.length, true)}
+ >
+ {renderTaskListBlock(subGroupTasks, true)}
+ </AccordionItem>
+ ))}
+ </Accordion>
+ ) : (
+ renderTaskListBlock(group.items)
+ )}
+ </AccordionItem>
+ );
+ })}
+ </Accordion>
+ {hiddenFooter}
+ </>
);
});
diff --git a/src/features/AgentTasks/AgentTaskList/TasksGroupConfig.tsx b/src/features/AgentTasks/AgentTaskList/TasksGroupConfig.tsx
index c111f9ca1fd..1da1e13fbd0 100644
--- a/src/features/AgentTasks/AgentTaskList/TasksGroupConfig.tsx
+++ b/src/features/AgentTasks/AgentTaskList/TasksGroupConfig.tsx
@@ -142,6 +142,19 @@ const TasksGroupConfig = memo<TasksHeaderProps>(({ options, setOptions }) => {
minWidth: undefined,
label: t('taskList.form.orderCompletedByRecency'),
},
+ {
+ children: (
+ <Switch
+ checked={!options.hideCompleted}
+ size={'small'}
+ onChange={(checked) => {
+ setOptions((prev) => ({ ...prev, hideCompleted: !checked }));
+ }}
+ />
+ ),
+ minWidth: undefined,
+ label: t('taskList.form.showCompleted'),
+ },
];
const panelContent = (
diff --git a/src/features/AgentTasks/AgentTaskList/listViewOptions.ts b/src/features/AgentTasks/AgentTaskList/listViewOptions.ts
index 23b5f90bfd4..6e436b49481 100644
--- a/src/features/AgentTasks/AgentTaskList/listViewOptions.ts
+++ b/src/features/AgentTasks/AgentTaskList/listViewOptions.ts
@@ -8,12 +8,18 @@ export type TaskOrderDirection = 'asc' | 'desc';
export interface TaskListViewOptions {
groupBy: TaskGroupBy;
+ hideCompleted: boolean;
orderBy: TaskOrderBy;
orderCompletedByRecency: boolean;
orderDirection: TaskOrderDirection;
subGroupBy: TaskGroupBy;
}
+export const HIDDEN_WHEN_COMPLETED_STATUSES: ReadonlyArray<NonNullable<TaskGroupMeta['status']>> = [
+ 'completed',
+ 'canceled',
+];
+
export interface TaskGroupMeta {
assigneeId?: string;
groupBy: TaskGroupBy;
@@ -25,6 +31,7 @@ export interface TaskGroupMeta {
export const DEFAULT_TASK_LIST_VIEW_OPTIONS: TaskListViewOptions = {
groupBy: 'status',
+ hideCompleted: true,
orderBy: 'updatedAt',
orderCompletedByRecency: true,
orderDirection: 'asc',
@@ -55,6 +62,10 @@ export const normalizeTaskListViewOptions = (
return {
groupBy,
+ hideCompleted:
+ typeof next.hideCompleted === 'boolean'
+ ? next.hideCompleted
+ : DEFAULT_TASK_LIST_VIEW_OPTIONS.hideCompleted,
orderBy: TASK_ORDER_BY_SET.has(next.orderBy as TaskOrderBy)
? (next.orderBy as TaskOrderBy)
: DEFAULT_TASK_LIST_VIEW_OPTIONS.orderBy,
diff --git a/src/features/AgentTasks/CreateTaskModal/CreateTaskContent.tsx b/src/features/AgentTasks/CreateTaskModal/CreateTaskContent.tsx
index b9638fdd322..3080f11a9f9 100644
--- a/src/features/AgentTasks/CreateTaskModal/CreateTaskContent.tsx
+++ b/src/features/AgentTasks/CreateTaskModal/CreateTaskContent.tsx
@@ -21,176 +21,185 @@ import { useAgentDisplayMeta } from '../shared/useAgentDisplayMeta';
export interface CreateTaskContentProps {
agentId?: string;
onCreated?: (task: { agentId?: string; identifier: string }) => void;
+ /**
+ * Whether to show the "minimize to inline entry" button. Only the list view has an
+ * inline entry target, so contexts like the Kanban board pass `false` to hide it.
+ */
+ showInlineToggle?: boolean;
}
-const CreateTaskContent = memo<CreateTaskContentProps>(({ agentId, onCreated }) => {
- const { t } = useTranslation('chat');
- const { close } = useModalContext();
+const CreateTaskContent = memo<CreateTaskContentProps>(
+ ({ agentId, onCreated, showInlineToggle = true }) => {
+ const { t } = useTranslation('chat');
+ const { close } = useModalContext();
- const createTask = useTaskStore((s) => s.createTask);
- const isCreating = useTaskStore((s) => s.isCreatingTask);
- const updateSystemStatus = useGlobalStore((s) => s.updateSystemStatus);
+ const createTask = useTaskStore((s) => s.createTask);
+ const isCreating = useTaskStore((s) => s.isCreatingTask);
+ const updateSystemStatus = useGlobalStore((s) => s.updateSystemStatus);
- const [title, setTitle] = useState('');
- const [priority, setPriority] = useState(0);
- const [assigneeAgentId, setAssigneeAgentId] = useState<string | undefined>(agentId);
+ const [title, setTitle] = useState('');
+ const [priority, setPriority] = useState(0);
+ const [assigneeAgentId, setAssigneeAgentId] = useState<string | undefined>(agentId);
- const editor = useEditor();
- const instructionRef = useRef('');
+ const editor = useEditor();
+ const instructionRef = useRef('');
- const assigneeMeta = useAgentDisplayMeta(assigneeAgentId);
+ const assigneeMeta = useAgentDisplayMeta(assigneeAgentId);
- const handleInline = useCallback(() => {
- updateSystemStatus({ taskCreateInlineCollapsed: false }, 'expandTaskCreateInline');
- close();
- }, [close, updateSystemStatus]);
-
- const handleContentChange = useCallback(() => {
- if (!editor) return;
- instructionRef.current = String(editor.getDocument('markdown') ?? '');
- }, [editor]);
-
- const handleSubmit = useCallback(async () => {
- const instruction = instructionRef.current.trim();
- if (!instruction && !title.trim()) return;
-
- const result = await createTask({
- assigneeAgentId,
- instruction: instruction || title.trim(),
- name: title.trim() || undefined,
- priority: priority || undefined,
- });
-
- if (result) {
+ const handleInline = useCallback(() => {
+ updateSystemStatus({ taskCreateInlineCollapsed: false }, 'expandTaskCreateInline');
close();
- onCreated?.({
- agentId: result.assigneeAgentId ?? undefined,
- identifier: result.identifier,
+ }, [close, updateSystemStatus]);
+
+ const handleContentChange = useCallback(() => {
+ if (!editor) return;
+ instructionRef.current = String(editor.getDocument('markdown') ?? '');
+ }, [editor]);
+
+ const handleSubmit = useCallback(async () => {
+ const instruction = instructionRef.current.trim();
+ if (!instruction && !title.trim()) return;
+
+ const result = await createTask({
+ assigneeAgentId,
+ instruction: instruction || title.trim(),
+ name: title.trim() || undefined,
+ priority: priority || undefined,
});
- }
- }, [assigneeAgentId, close, createTask, onCreated, priority, title]);
-
- const handleSubmitRef = useRef(handleSubmit);
- useEffect(() => {
- handleSubmitRef.current = handleSubmit;
- }, [handleSubmit]);
-
- const handleKeyDown = useCallback((e: KeyboardEvent<HTMLDivElement>) => {
- if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {
- e.preventDefault();
- e.stopPropagation();
- void handleSubmitRef.current?.();
- }
- }, []);
-
- return (
- <Flexbox onKeyDown={handleKeyDown}>
- <Flexbox horizontal style={{ padding: '16px 24px 0' }}>
- <Flexbox flex={1} style={{ minHeight: 180 }}>
- <input
- autoFocus
- placeholder={t('createTask.titlePlaceholder')}
- value={title}
- style={{
- background: 'transparent',
- border: 'none',
- color: 'inherit',
- fontFamily: 'inherit',
- fontSize: 20,
- fontWeight: 600,
- lineHeight: 1.4,
- outline: 'none',
- padding: '4px 0',
- width: '100%',
- }}
- onChange={(e) => setTitle(e.target.value)}
- />
- <EditorCanvas
- editor={editor}
- floatingToolbar={false}
- placeholder={t('createTask.instructionPlaceholder')}
- style={{ fontSize: 14, paddingBottom: 16 }}
- onContentChange={handleContentChange}
- />
- </Flexbox>
- <Flexbox horizontal gap={4} style={{ flexShrink: 0 }}>
- <ActionIcon
- icon={Minimize2}
- title={t('createTask.expandToInline')}
- onClick={handleInline}
- />
- <ActionIcon icon={X} onClick={close} />
- </Flexbox>
- </Flexbox>
- <Flexbox
- horizontal
- align={'center'}
- justify={'space-between'}
- style={{ borderTop: `1px solid ${cssVar.colorBorderSecondary}`, padding: '8px 16px' }}
- >
- <Flexbox horizontal gap={2} wrap={'wrap'}>
- <TaskPriorityTag priority={priority} onChange={setPriority}>
- <Block
- clickable
- horizontal
- align="center"
- gap={6}
- paddingBlock={4}
- paddingInline={8}
- variant={'borderless'}
- >
- <TaskPriorityTag disableDropdown priority={priority} size={14} />
- <Text fontSize={12}>
- {priority === 0
- ? t('taskDetail.priority.none')
- : t(
- `taskDetail.priority.${(['', 'urgent', 'high', 'normal', 'low'] as const)[priority]}` as never,
- )}
- </Text>
- </Block>
- </TaskPriorityTag>
-
- <AssigneeAgentSelector currentAgentId={assigneeAgentId} onChange={setAssigneeAgentId}>
- <Block
- clickable
- horizontal
- align="center"
- gap={6}
- paddingBlock={4}
- paddingInline={8}
- variant={'borderless'}
- >
- {assigneeAgentId ? (
- <>
- <AssigneeAvatar agentId={assigneeAgentId} size={18} />
- <Text fontSize={12}>{assigneeMeta?.title}</Text>
- </>
- ) : (
- <>
- <Icon color={cssVar.colorTextDescription} icon={UserCircle2} size={14} />
- <Text color={cssVar.colorTextDescription} fontSize={12}>
- {t('createTask.assignee')}
- </Text>
- </>
- )}
- </Block>
- </AssigneeAgentSelector>
+ if (result) {
+ close();
+ onCreated?.({
+ agentId: result.assigneeAgentId ?? undefined,
+ identifier: result.identifier,
+ });
+ }
+ }, [assigneeAgentId, close, createTask, onCreated, priority, title]);
+
+ const handleSubmitRef = useRef(handleSubmit);
+ useEffect(() => {
+ handleSubmitRef.current = handleSubmit;
+ }, [handleSubmit]);
+
+ const handleKeyDown = useCallback((e: KeyboardEvent<HTMLDivElement>) => {
+ if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {
+ e.preventDefault();
+ e.stopPropagation();
+ void handleSubmitRef.current?.();
+ }
+ }, []);
+
+ return (
+ <Flexbox onKeyDown={handleKeyDown}>
+ <Flexbox horizontal style={{ padding: '16px 24px 0' }}>
+ <Flexbox flex={1} style={{ minHeight: 180 }}>
+ <input
+ autoFocus
+ placeholder={t('createTask.titlePlaceholder')}
+ value={title}
+ style={{
+ background: 'transparent',
+ border: 'none',
+ color: 'inherit',
+ fontFamily: 'inherit',
+ fontSize: 20,
+ fontWeight: 600,
+ lineHeight: 1.4,
+ outline: 'none',
+ padding: '4px 0',
+ width: '100%',
+ }}
+ onChange={(e) => setTitle(e.target.value)}
+ />
+ <EditorCanvas
+ editor={editor}
+ floatingToolbar={false}
+ placeholder={t('createTask.instructionPlaceholder')}
+ style={{ fontSize: 14, paddingBottom: 16 }}
+ onContentChange={handleContentChange}
+ />
+ </Flexbox>
+ <Flexbox horizontal gap={4} style={{ flexShrink: 0 }}>
+ {showInlineToggle && (
+ <ActionIcon
+ icon={Minimize2}
+ title={t('createTask.expandToInline')}
+ onClick={handleInline}
+ />
+ )}
+ <ActionIcon icon={X} onClick={close} />
+ </Flexbox>
</Flexbox>
- <Button
- disabled={isCreating}
- loading={isCreating}
- shape={'round'}
- size={'small'}
- type={'primary'}
- onClick={handleSubmit}
+ <Flexbox
+ horizontal
+ align={'center'}
+ justify={'space-between'}
+ style={{ borderTop: `1px solid ${cssVar.colorBorderSecondary}`, padding: '8px 16px' }}
>
- {t('createTask.submit')}
- </Button>
+ <Flexbox horizontal gap={2} wrap={'wrap'}>
+ <TaskPriorityTag priority={priority} onChange={setPriority}>
+ <Block
+ clickable
+ horizontal
+ align="center"
+ gap={6}
+ paddingBlock={4}
+ paddingInline={8}
+ variant={'borderless'}
+ >
+ <TaskPriorityTag disableDropdown priority={priority} size={14} />
+ <Text fontSize={12}>
+ {priority === 0
+ ? t('taskDetail.priority.none')
+ : t(
+ `taskDetail.priority.${(['', 'urgent', 'high', 'normal', 'low'] as const)[priority]}` as never,
+ )}
+ </Text>
+ </Block>
+ </TaskPriorityTag>
+
+ <AssigneeAgentSelector currentAgentId={assigneeAgentId} onChange={setAssigneeAgentId}>
+ <Block
+ clickable
+ horizontal
+ align="center"
+ gap={6}
+ paddingBlock={4}
+ paddingInline={8}
+ variant={'borderless'}
+ >
+ {assigneeAgentId ? (
+ <>
+ <AssigneeAvatar agentId={assigneeAgentId} size={18} />
+ <Text fontSize={12}>{assigneeMeta?.title}</Text>
+ </>
+ ) : (
+ <>
+ <Icon color={cssVar.colorTextDescription} icon={UserCircle2} size={14} />
+ <Text color={cssVar.colorTextDescription} fontSize={12}>
+ {t('createTask.assignee')}
+ </Text>
+ </>
+ )}
+ </Block>
+ </AssigneeAgentSelector>
+ </Flexbox>
+
+ <Button
+ disabled={isCreating}
+ loading={isCreating}
+ shape={'round'}
+ size={'small'}
+ type={'primary'}
+ onClick={handleSubmit}
+ >
+ {t('createTask.submit')}
+ </Button>
+ </Flexbox>
</Flexbox>
- </Flexbox>
- );
-});
+ );
+ },
+);
export default CreateTaskContent;
diff --git a/src/features/AgentTasks/features/AgentTaskCardList.tsx b/src/features/AgentTasks/features/AgentTaskCardList.tsx
index aaa4533ddc2..412fe985169 100644
--- a/src/features/AgentTasks/features/AgentTaskCardList.tsx
+++ b/src/features/AgentTasks/features/AgentTaskCardList.tsx
@@ -8,15 +8,9 @@ import { useTaskStore } from '@/store/task';
import { taskListSelectors } from '@/store/task/selectors';
import AgentTaskItem from './AgentTaskItem';
+import { getDisplayTaskCardTasks, getVisibleTaskCardTasks } from './taskCardListDisplay';
import TaskListHeader from './TaskListHeader';
-const MAX_DISPLAY = 5;
-
-const toTime = (value: Date | string | null | undefined): number => {
- if (!value) return 0;
- return value instanceof Date ? value.getTime() : new Date(value).getTime();
-};
-
const AgentTaskCardList = memo(() => {
const agentId = useAgentStore((s) => s.activeAgentId);
const navigate = useNavigate();
@@ -27,27 +21,17 @@ const AgentTaskCardList = memo(() => {
const isInit = useTaskStore(taskListSelectors.isTaskListInit);
const handleViewAll = useCallback(() => {
- if (agentId) navigate(`/agent/${agentId}/tasks`);
- }, [agentId, navigate]);
+ navigate('/tasks');
+ }, [navigate]);
- const displayTasks = useMemo(
- () =>
- [...tasks]
- .sort((a, b) => {
- const updatedA = toTime(a.updatedAt) || toTime(a.createdAt);
- const updatedB = toTime(b.updatedAt) || toTime(b.createdAt);
- if (updatedA !== updatedB) return updatedB - updatedA;
- return a.identifier.localeCompare(b.identifier);
- })
- .slice(0, MAX_DISPLAY),
- [tasks],
- );
+ const visibleTasks = useMemo(() => getVisibleTaskCardTasks(tasks), [tasks]);
+ const displayTasks = useMemo(() => getDisplayTaskCardTasks(tasks), [tasks]);
- if (!isInit || tasks.length === 0) return null;
+ if (!isInit || visibleTasks.length === 0) return null;
return (
<Block shadow variant={'outlined'}>
- <TaskListHeader count={tasks.length} onViewAll={handleViewAll} />
+ <TaskListHeader count={visibleTasks.length} onViewAll={handleViewAll} />
<Divider style={{ margin: 0 }} />
<Flexbox gap={2} padding={2}>
{displayTasks.map((task, index) => (
diff --git a/src/features/AgentTasks/features/AgentTaskItem.tsx b/src/features/AgentTasks/features/AgentTaskItem.tsx
index a3c956cf494..dfd4438d0f4 100644
--- a/src/features/AgentTasks/features/AgentTaskItem.tsx
+++ b/src/features/AgentTasks/features/AgentTaskItem.tsx
@@ -1,32 +1,27 @@
-import { Block, Flexbox, Text } from '@lobehub/ui';
-import dayjs from 'dayjs';
+import { Block, ContextMenuTrigger, Flexbox, Text } from '@lobehub/ui';
import { memo, useCallback } from 'react';
+import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
-import { useAgentStore } from '@/store/agent';
import { useTaskStore } from '@/store/task';
import type { TaskListItem } from '@/store/task/slices/list/initialState';
import TaskScheduleConfig from '../AgentTaskDetail/TaskScheduleConfig';
import AssigneeAgentSelector from './AssigneeAgentSelector';
import AssigneeAvatar from './AssigneeAvatar';
+import { formatTaskItemDate } from './formatTaskItemDate';
import TaskLatestActivity from './TaskLatestActivity';
import TaskPriorityTag from './TaskPriorityTag';
import TaskStatusTag from './TaskStatusTag';
import TaskSubtaskProgressTag from './TaskSubtaskProgressTag';
import TaskTriggerTag from './TaskTriggerTag';
+import { useTaskItemContextMenu } from './useTaskItemContextMenu';
interface TaskItemProps {
task: TaskListItem;
variant?: 'compact' | 'default';
}
-const formatTime = (time?: string | Date | null) => {
- if (!time) return '';
- const d = dayjs(time);
- return d.isSame(dayjs(), 'day') ? d.format('HH:mm') : d.fromNow();
-};
-
const TASK_STATUS_SET = new Set([
'backlog',
'canceled',
@@ -42,92 +37,139 @@ const toTaskStatus = (status: string): TaskStatus =>
TASK_STATUS_SET.has(status) ? (status as TaskStatus) : 'backlog';
const AgentTaskItem = memo<TaskItemProps>(({ task, variant = 'default' }) => {
- const activeAgentId = useAgentStore((s) => s.activeAgentId);
+ const { t } = useTranslation('discover');
const useFetchTaskDetail = useTaskStore((s) => s.useFetchTaskDetail);
useFetchTaskDetail(task.identifier);
const taskDetail = useTaskStore((s) => s.taskDetailMap[task.identifier]);
+ const { items: contextMenuItems, onContextMenu: handleContextMenuOpen } =
+ useTaskItemContextMenu(task);
const navigate = useNavigate();
- const time = formatTime(task.updatedAt || task.createdAt);
+ const time = formatTaskItemDate(task.updatedAt || task.createdAt, {
+ formatOtherYear: t('time.formatOtherYear'),
+ formatThisYear: t('time.formatThisYear'),
+ });
const status = toTaskStatus(task.status);
-
- // Prefer the task's own assignee so navigation works from the cross-agent `/tasks` page
- // where `activeAgentId` is not scoped to any particular agent. Falls back to the
- // currently active agent for unassigned tasks viewed from a per-agent page.
- const targetAgentId = task.assigneeAgentId || activeAgentId;
+ const hasName = Boolean(task.name?.trim());
const handleClick = useCallback(() => {
- if (targetAgentId) navigate(`/agent/${targetAgentId}/tasks/${task.identifier}`);
- }, [targetAgentId, navigate, task.identifier]);
+ navigate(`/task/${task.identifier}`);
+ }, [navigate, task.identifier]);
+
+ const handleSubtaskClick = useCallback(
+ (identifier: string) => {
+ navigate(`/task/${identifier}`);
+ },
+ [navigate],
+ );
const titleRow = (
- <Flexbox horizontal align={'center'} gap={8}>
+ <Flexbox horizontal align={'center'} gap={8} style={{ minWidth: 0 }}>
<TaskPriorityTag priority={task.priority} taskIdentifier={task.identifier} />
<TaskStatusTag status={status} taskIdentifier={task.identifier} />
- <Text ellipsis weight={500}>
- {task.name || task.identifier}
- </Text>
+ {hasName ? (
+ <>
+ <Text style={{ flex: 'none' }} type={'secondary'}>
+ {task.identifier}
+ </Text>
+ <Text ellipsis style={{ minWidth: 0 }} weight={500}>
+ {task.name}
+ </Text>
+ </>
+ ) : (
+ <Text ellipsis style={{ minWidth: 0 }} weight={500}>
+ {task.identifier}
+ </Text>
+ )}
<TaskSubtaskProgressTag
currentIdentifier={task.identifier}
subtasks={taskDetail?.subtasks}
- onSubtaskClick={(identifier) => {
- if (targetAgentId) navigate(`/agent/${targetAgentId}/tasks/${identifier}`);
- }}
+ onSubtaskClick={handleSubtaskClick}
/>
</Flexbox>
);
- const metaRow = (
- <Flexbox horizontal align={'center'} flex={'none'} gap={8}>
- <TaskScheduleConfig
- currentInterval={taskDetail?.heartbeat?.interval ?? 0}
- taskId={task.identifier}
- >
- <TaskTriggerTag
- heartbeatInterval={taskDetail?.heartbeat?.interval}
- schedulePattern={task.schedulePattern}
- scheduleTimezone={task.scheduleTimezone}
- />
- </TaskScheduleConfig>
- <AssigneeAgentSelector
- currentAgentId={task.assigneeAgentId}
- disabled={status === 'running'}
- taskIdentifier={task.identifier}
- >
- <AssigneeAvatar agentId={task.assigneeAgentId} />
- </AssigneeAgentSelector>
- {time && (
- <Text
- align={'right'}
- fontSize={12}
- style={{ whiteSpace: 'nowrap', width: variant === 'compact' ? undefined : 76 }}
- type={'secondary'}
- >
- {time}
- </Text>
- )}
- </Flexbox>
+ const assigneeNode = (
+ <AssigneeAgentSelector
+ currentAgentId={task.assigneeAgentId}
+ disabled={status === 'running'}
+ taskIdentifier={task.identifier}
+ >
+ <AssigneeAvatar agentId={task.assigneeAgentId} />
+ </AssigneeAgentSelector>
);
+ const scheduleNode = task.automationMode ? (
+ <TaskScheduleConfig
+ currentInterval={taskDetail?.heartbeat?.interval ?? 0}
+ taskId={task.identifier}
+ >
+ <TaskTriggerTag
+ heartbeatInterval={taskDetail?.heartbeat?.interval}
+ schedulePattern={task.schedulePattern}
+ scheduleTimezone={task.scheduleTimezone}
+ />
+ </TaskScheduleConfig>
+ ) : null;
+
+ const timeNode = time ? (
+ <Text
+ align={'right'}
+ fontSize={12}
+ style={{ whiteSpace: 'nowrap', width: variant === 'compact' ? undefined : 76 }}
+ type={'secondary'}
+ >
+ {time}
+ </Text>
+ ) : null;
+
if (variant === 'compact') {
return (
- <Block clickable gap={4} padding={12} variant={'borderless'} onClick={handleClick}>
- {titleRow}
- <TaskLatestActivity activities={taskDetail?.activities} />
- {metaRow}
- </Block>
+ <ContextMenuTrigger items={contextMenuItems} onContextMenu={handleContextMenuOpen}>
+ <Block clickable gap={8} padding={12} variant={'borderless'} onClick={handleClick}>
+ <Flexbox horizontal align={'center'} gap={8} justify={'space-between'}>
+ <Text fontSize={12} style={{ flex: 'none' }} type={'secondary'}>
+ {task.identifier}
+ </Text>
+ {assigneeNode}
+ </Flexbox>
+ <Flexbox horizontal align={'center'} gap={8} style={{ minWidth: 0 }}>
+ <TaskStatusTag status={status} taskIdentifier={task.identifier} />
+ <Text ellipsis style={{ minWidth: 0 }} weight={500}>
+ {hasName ? task.name : task.identifier}
+ </Text>
+ <TaskSubtaskProgressTag
+ currentIdentifier={task.identifier}
+ subtasks={taskDetail?.subtasks}
+ onSubtaskClick={handleSubtaskClick}
+ />
+ </Flexbox>
+ <TaskLatestActivity activities={taskDetail?.activities} />
+ <Flexbox horizontal align={'center'} gap={8}>
+ <TaskPriorityTag priority={task.priority} taskIdentifier={task.identifier} />
+ {scheduleNode}
+ {timeNode}
+ </Flexbox>
+ </Block>
+ </ContextMenuTrigger>
);
}
return (
- <Block clickable gap={4} padding={12} variant={'borderless'} onClick={handleClick}>
- <Flexbox horizontal align={'center'} gap={4} justify={'space-between'}>
- {titleRow}
- {metaRow}
- </Flexbox>
- <TaskLatestActivity activities={taskDetail?.activities} />
- </Block>
+ <ContextMenuTrigger items={contextMenuItems} onContextMenu={handleContextMenuOpen}>
+ <Block clickable gap={4} padding={12} variant={'borderless'} onClick={handleClick}>
+ <Flexbox horizontal align={'center'} gap={4} justify={'space-between'}>
+ {titleRow}
+ <Flexbox horizontal align={'center'} flex={'none'} gap={8}>
+ {scheduleNode}
+ {assigneeNode}
+ {timeNode}
+ </Flexbox>
+ </Flexbox>
+ <TaskLatestActivity activities={taskDetail?.activities} />
+ </Block>
+ </ContextMenuTrigger>
);
});
diff --git a/src/features/AgentTasks/features/AssigneeAgentSelector.tsx b/src/features/AgentTasks/features/AssigneeAgentSelector.tsx
index e7a549fe624..43ba5a071bb 100644
--- a/src/features/AgentTasks/features/AssigneeAgentSelector.tsx
+++ b/src/features/AgentTasks/features/AssigneeAgentSelector.tsx
@@ -1,6 +1,17 @@
import { DEFAULT_INBOX_AVATAR } from '@lobechat/const';
-import { Flexbox, Popover, Tooltip } from '@lobehub/ui';
-import { memo, type ReactNode, Suspense, useCallback, useMemo, useState } from 'react';
+import { Flexbox, Popover, Text, Tooltip } from '@lobehub/ui';
+import { createStaticStyles } from 'antd-style';
+import {
+ type KeyboardEvent,
+ memo,
+ type ReactNode,
+ Suspense,
+ useCallback,
+ useEffect,
+ useMemo,
+ useRef,
+ useState,
+} from 'react';
import { useTranslation } from 'react-i18next';
import SkeletonList from '@/features/NavPanel/components/SkeletonList';
@@ -20,10 +31,34 @@ interface AssigneeAgentSelectorProps {
taskIdentifier?: string;
}
+const styles = createStaticStyles(({ css, cssVar }) => ({
+ searchInput: css`
+ width: 100%;
+ padding-block: 6px;
+ padding-inline: 10px;
+ border: none;
+ border-block-end: 1px solid ${cssVar.colorBorderSecondary};
+
+ font-family: inherit;
+ font-size: 13px;
+ color: ${cssVar.colorText};
+
+ background: transparent;
+ outline: none;
+
+ &::placeholder {
+ color: ${cssVar.colorTextPlaceholder};
+ }
+ `,
+}));
+
const AssigneeAgentSelector = memo<AssigneeAgentSelectorProps>(
({ children, currentAgentId, disabled, onChange, taskIdentifier }) => {
const { t } = useTranslation(['chat', 'common']);
const [key, setKey] = useState(0);
+ const [search, setSearch] = useState('');
+ const [activeIndex, setActiveIndex] = useState(0);
+ const listRef = useRef<HTMLDivElement>(null);
const updateTask = useTaskStore((s) => s.updateTask);
const agents = useHomeStore(homeAgentListSelectors.allAgents);
@@ -58,10 +93,26 @@ const AssigneeAgentSelector = memo<AssigneeAgentSelectorProps>(
return available;
}, [agents, inboxAgentId, inboxMeta, t]);
+ const filteredAgents = useMemo(() => {
+ const q = search.trim().toLowerCase();
+ if (!q) return agentList;
+ return agentList.filter((a) => (a.title || '').toLowerCase().includes(q));
+ }, [agentList, search]);
+
+ useEffect(() => {
+ if (search.trim()) {
+ setActiveIndex(0);
+ return;
+ }
+ const selectedIdx = filteredAgents.findIndex((a) => a.id === currentAgentId);
+ setActiveIndex(selectedIdx >= 0 ? selectedIdx : 0);
+ }, [search, filteredAgents, currentAgentId]);
+
const handleAgentChange = useCallback(
(agentId: string) => {
if (agentId === currentAgentId) return;
setKey((k) => k + 1);
+ setSearch('');
if (onChange) {
onChange(agentId);
return;
@@ -73,6 +124,32 @@ const AssigneeAgentSelector = memo<AssigneeAgentSelectorProps>(
[currentAgentId, onChange, taskIdentifier, updateTask],
);
+ const handleSearchKeyDown = useCallback(
+ (e: KeyboardEvent<HTMLInputElement>) => {
+ if (filteredAgents.length === 0) return;
+
+ if (e.key === 'ArrowDown') {
+ e.preventDefault();
+ setActiveIndex((i) => (i + 1) % filteredAgents.length);
+ } else if (e.key === 'ArrowUp') {
+ e.preventDefault();
+ setActiveIndex((i) => (i - 1 + filteredAgents.length) % filteredAgents.length);
+ } else if (e.key === 'Enter') {
+ e.preventDefault();
+ const target = filteredAgents[activeIndex];
+ if (target) handleAgentChange(target.id);
+ }
+ },
+ [activeIndex, filteredAgents, handleAgentChange],
+ );
+
+ useEffect(() => {
+ const list = listRef.current;
+ if (!list) return;
+ const active = list.querySelector<HTMLElement>(`[data-agent-index="${activeIndex}"]`);
+ active?.scrollIntoView({ block: 'nearest' });
+ }, [activeIndex]);
+
const trigger = disabled ? (
<Tooltip title={t('taskDetail.reassignDisabled', { ns: 'chat' })}>
<div style={{ cursor: 'not-allowed', opacity: 0.5 }} onClick={(e) => e.stopPropagation()}>
@@ -88,28 +165,51 @@ const AssigneeAgentSelector = memo<AssigneeAgentSelectorProps>(
disabled={disabled}
key={key}
placement="bottomLeft"
- styles={{ content: { padding: 0, width: 240 } }}
+ styles={{ content: { padding: 0, width: 260 } }}
trigger="click"
content={
<Suspense fallback={<SkeletonList rows={6} />}>
{isAgentListInit ? (
- <Flexbox
- gap={4}
- padding={8}
- style={{ maxHeight: '50vh', overflowY: 'auto', width: '100%' }}
- onClick={(e) => e.stopPropagation()}
- >
- {agentList.map((agent) => (
- <AgentItem
- active={agent.id === currentAgentId}
- agentId={agent.id}
- agentTitle={agent.title || t('untitledAgent', { ns: 'chat' })}
- avatar={agent.avatar}
- key={agent.id}
- onAgentChange={handleAgentChange}
- onClose={() => setKey((k) => k + 1)}
- />
- ))}
+ <Flexbox onClick={(e) => e.stopPropagation()}>
+ <input
+ autoFocus
+ className={styles.searchInput}
+ placeholder={t('taskList.assigneeSearch.placeholder', { ns: 'chat' })}
+ value={search}
+ onChange={(e) => setSearch(e.target.value)}
+ onKeyDown={handleSearchKeyDown}
+ />
+ {filteredAgents.length === 0 ? (
+ <Flexbox align={'center'} justify={'center'} padding={16}>
+ <Text fontSize={12} type={'secondary'}>
+ {t('taskList.assigneeSearch.empty', { ns: 'chat' })}
+ </Text>
+ </Flexbox>
+ ) : (
+ <Flexbox
+ gap={4}
+ padding={8}
+ ref={listRef}
+ style={{ maxHeight: '50vh', overflowY: 'auto', width: '100%' }}
+ >
+ {filteredAgents.map((agent, index) => (
+ <div
+ data-agent-index={index}
+ key={agent.id}
+ onMouseEnter={() => setActiveIndex(index)}
+ >
+ <AgentItem
+ active={index === activeIndex}
+ agentId={agent.id}
+ agentTitle={agent.title || t('untitledAgent', { ns: 'chat' })}
+ avatar={agent.avatar}
+ onAgentChange={handleAgentChange}
+ onClose={() => setKey((k) => k + 1)}
+ />
+ </div>
+ ))}
+ </Flexbox>
+ )}
</Flexbox>
) : (
<SkeletonList rows={6} />
diff --git a/src/features/AgentTasks/features/AssigneeAvatar.tsx b/src/features/AgentTasks/features/AssigneeAvatar.tsx
index 11d4a6282cb..e102a276add 100644
--- a/src/features/AgentTasks/features/AssigneeAvatar.tsx
+++ b/src/features/AgentTasks/features/AssigneeAvatar.tsx
@@ -1,5 +1,6 @@
-import { Avatar } from '@lobehub/ui';
+import { Avatar, Center, Icon } from '@lobehub/ui';
import { cssVar } from 'antd-style';
+import { UserRound } from 'lucide-react';
import { memo } from 'react';
import { useAgentDisplayMeta } from '../shared/useAgentDisplayMeta';
@@ -12,7 +13,22 @@ interface AssigneeAvatarProps {
const AssigneeAvatar = memo<AssigneeAvatarProps>(({ agentId, size = 18 }) => {
const displayMeta = useAgentDisplayMeta(agentId);
- if (!displayMeta) return null;
+ if (!displayMeta) {
+ return (
+ <Center
+ height={size}
+ width={size}
+ style={{
+ border: `1px dashed ${cssVar.colorBorder}`,
+ borderRadius: '50%',
+ color: cssVar.colorTextQuaternary,
+ flexShrink: 0,
+ }}
+ >
+ <Icon icon={UserRound} size={size - 6} />
+ </Center>
+ );
+ }
return (
<Avatar
diff --git a/src/features/AgentTasks/features/TaskPriorityTag.tsx b/src/features/AgentTasks/features/TaskPriorityTag.tsx
index d29fc6fb827..c7fc144b0e2 100644
--- a/src/features/AgentTasks/features/TaskPriorityTag.tsx
+++ b/src/features/AgentTasks/features/TaskPriorityTag.tsx
@@ -21,7 +21,7 @@ interface PriorityMeta {
level: number;
}
-const PRIORITY_META: Record<number, PriorityMeta> = {
+export const PRIORITY_META: Record<number, PriorityMeta> = {
0: { icon: PriorityNoneIcon, labelKey: 'priority.none', level: 0 },
1: { icon: PriorityUrgentIcon, labelKey: 'priority.urgent', level: 1 },
2: { icon: PriorityHighIcon, labelKey: 'priority.high', level: 2 },
diff --git a/src/features/AgentTasks/features/TaskStatusIcon.tsx b/src/features/AgentTasks/features/TaskStatusIcon.tsx
index f23fc881e1c..60824fb32b9 100644
--- a/src/features/AgentTasks/features/TaskStatusIcon.tsx
+++ b/src/features/AgentTasks/features/TaskStatusIcon.tsx
@@ -1,14 +1,7 @@
import { ActionIcon } from '@lobehub/ui';
import { cssVar } from 'antd-style';
import type { LucideIcon } from 'lucide-react';
-import {
- CircleCheck,
- CircleDashed,
- CircleDot,
- CirclePause,
- CircleSlash,
- CircleX,
-} from 'lucide-react';
+import { CircleCheck, CircleDashed, CircleDot, CircleSlash, CircleX, HandIcon } from 'lucide-react';
import { memo } from 'react';
import { taskListSelectors } from '@/store/task/selectors';
@@ -25,8 +18,8 @@ const STATUS_META: Record<TaskStatus, StatusMeta> = {
canceled: { color: cssVar.colorTextSecondary, icon: CircleSlash },
completed: { color: cssVar.colorSuccess, icon: CircleCheck },
failed: { color: cssVar.colorError, icon: CircleX },
- paused: { color: cssVar.colorWarning, icon: CirclePause },
- running: { color: cssVar.colorInfo, icon: CircleDot },
+ paused: { color: cssVar.colorInfo, icon: HandIcon },
+ running: { color: cssVar.colorWarning, icon: CircleDot },
};
interface TaskStatusIconProps {
@@ -36,18 +29,17 @@ interface TaskStatusIconProps {
const TaskStatusIcon = memo<TaskStatusIconProps>(({ size = 16, status }) => {
const displayStatus = taskListSelectors.getDisplayStatus(status);
- const { color, icon } = STATUS_META[status as TaskStatus] ?? STATUS_META.backlog;
+ const meta = STATUS_META[status as TaskStatus] ?? STATUS_META.backlog;
return (
<ActionIcon
- color={color}
- icon={icon}
+ color={meta.color}
+ icon={meta.icon}
title={displayStatus}
size={{
blockSize: size,
size,
borderRadius: '50%',
- strokeWidth: 3,
}}
/>
);
diff --git a/src/features/AgentTasks/features/TaskStatusTag.tsx b/src/features/AgentTasks/features/TaskStatusTag.tsx
index 242a722cc2d..03fb02c635e 100644
--- a/src/features/AgentTasks/features/TaskStatusTag.tsx
+++ b/src/features/AgentTasks/features/TaskStatusTag.tsx
@@ -7,9 +7,9 @@ import {
CircleCheck,
CircleDashed,
CircleDot,
- CirclePause,
CircleSlash,
CircleX,
+ HandIcon,
Loader2Icon,
} from 'lucide-react';
import type { ReactNode } from 'react';
@@ -25,7 +25,7 @@ interface StatusMeta {
labelKey: string;
}
-const STATUS_META: Record<TaskStatus, StatusMeta> = {
+export const STATUS_META: Record<TaskStatus, StatusMeta> = {
backlog: {
color: cssVar.colorTextQuaternary,
icon: CircleDashed,
@@ -51,20 +51,20 @@ const STATUS_META: Record<TaskStatus, StatusMeta> = {
labelKey: 'status.failed',
},
paused: {
- color: cssVar.colorWarning,
- icon: CirclePause,
+ color: cssVar.colorInfo,
+ icon: HandIcon,
label: 'Paused',
labelKey: 'status.paused',
},
running: {
- color: cssVar.colorInfo,
+ color: cssVar.colorWarning,
icon: CircleDot,
label: 'Running',
labelKey: 'status.running',
},
};
-const USER_SELECTABLE_STATUSES: TaskStatus[] = ['backlog', 'completed', 'canceled'];
+export const USER_SELECTABLE_STATUSES: TaskStatus[] = ['backlog', 'completed', 'canceled'];
const styles = createStaticStyles(({ css, cssVar }) => ({
trigger: css`
diff --git a/src/features/AgentTasks/features/formatTaskItemDate.test.ts b/src/features/AgentTasks/features/formatTaskItemDate.test.ts
new file mode 100644
index 00000000000..a135a6b3363
--- /dev/null
+++ b/src/features/AgentTasks/features/formatTaskItemDate.test.ts
@@ -0,0 +1,18 @@
+import { describe, expect, it } from 'vitest';
+
+import { formatTaskItemDate } from './formatTaskItemDate';
+
+describe('formatTaskItemDate', () => {
+ it('formats current-year dates with day precision', () => {
+ expect(formatTaskItemDate('2026-04-24', { now: '2026-05-01' })).toBe('Apr 24');
+ });
+
+ it('formats dates from other years with the year included', () => {
+ expect(formatTaskItemDate('2025-04-24', { now: '2026-05-01' })).toBe('Apr 24, 2025');
+ });
+
+ it('returns an empty string for invalid input', () => {
+ expect(formatTaskItemDate()).toBe('');
+ expect(formatTaskItemDate('invalid date')).toBe('');
+ });
+});
diff --git a/src/features/AgentTasks/features/formatTaskItemDate.ts b/src/features/AgentTasks/features/formatTaskItemDate.ts
new file mode 100644
index 00000000000..ca136b13c30
--- /dev/null
+++ b/src/features/AgentTasks/features/formatTaskItemDate.ts
@@ -0,0 +1,23 @@
+import dayjs from 'dayjs';
+
+export interface TaskItemDateFormatOptions {
+ formatOtherYear?: string;
+ formatThisYear?: string;
+ now?: Date | string;
+}
+
+export const formatTaskItemDate = (
+ time?: string | Date | null,
+ options: TaskItemDateFormatOptions = {},
+) => {
+ if (!time) return '';
+
+ const date = dayjs(time);
+
+ if (!date.isValid()) return '';
+
+ const { formatOtherYear = 'MMM D, YYYY', formatThisYear = 'MMM D', now = new Date() } = options;
+ const current = dayjs(now);
+
+ return date.format(date.isSame(current, 'year') ? formatThisYear : formatOtherYear);
+};
diff --git a/src/features/AgentTasks/features/taskCardListDisplay.test.ts b/src/features/AgentTasks/features/taskCardListDisplay.test.ts
new file mode 100644
index 00000000000..503dc7c0d01
--- /dev/null
+++ b/src/features/AgentTasks/features/taskCardListDisplay.test.ts
@@ -0,0 +1,35 @@
+import { describe, expect, it } from 'vitest';
+
+import { getDisplayTaskCardTasks, getVisibleTaskCardTasks } from './taskCardListDisplay';
+
+describe('taskCardListDisplay', () => {
+ it('filters completed tasks from the card list', () => {
+ const tasks = [
+ { identifier: 'T-1', status: 'backlog' },
+ { identifier: 'T-2', status: 'completed' },
+ { identifier: 'T-3', status: 'running' },
+ ] as any[];
+
+ expect(getVisibleTaskCardTasks(tasks).map((task) => task.identifier)).toEqual(['T-1', 'T-3']);
+ });
+
+ it('sorts by recency and limits the number of displayed tasks', () => {
+ const tasks = [
+ { createdAt: '2026-04-20', identifier: 'T-1', status: 'backlog', updatedAt: '2026-04-20' },
+ { createdAt: '2026-04-25', identifier: 'T-2', status: 'completed', updatedAt: '2026-04-25' },
+ { createdAt: '2026-04-24', identifier: 'T-3', status: 'running', updatedAt: '2026-04-24' },
+ { createdAt: '2026-04-23', identifier: 'T-4', status: 'paused', updatedAt: '2026-04-23' },
+ { createdAt: '2026-04-22', identifier: 'T-5', status: 'failed', updatedAt: '2026-04-22' },
+ { createdAt: '2026-04-21', identifier: 'T-6', status: 'backlog', updatedAt: '2026-04-21' },
+ { createdAt: '2026-04-19', identifier: 'T-7', status: 'backlog', updatedAt: '2026-04-19' },
+ ] as any[];
+
+ expect(getDisplayTaskCardTasks(tasks).map((task) => task.identifier)).toEqual([
+ 'T-3',
+ 'T-4',
+ 'T-5',
+ 'T-6',
+ 'T-1',
+ ]);
+ });
+});
diff --git a/src/features/AgentTasks/features/taskCardListDisplay.ts b/src/features/AgentTasks/features/taskCardListDisplay.ts
new file mode 100644
index 00000000000..bbbf412b98f
--- /dev/null
+++ b/src/features/AgentTasks/features/taskCardListDisplay.ts
@@ -0,0 +1,21 @@
+import type { TaskListItem } from '@/store/task/slices/list/initialState';
+
+const MAX_DISPLAY = 5;
+
+const toTime = (value: Date | string | null | undefined): number => {
+ if (!value) return 0;
+ return value instanceof Date ? value.getTime() : new Date(value).getTime();
+};
+
+export const getVisibleTaskCardTasks = (tasks: TaskListItem[]) =>
+ tasks.filter((task) => task.status !== 'completed');
+
+export const getDisplayTaskCardTasks = (tasks: TaskListItem[]) =>
+ [...getVisibleTaskCardTasks(tasks)]
+ .sort((a, b) => {
+ const updatedA = toTime(a.updatedAt) || toTime(a.createdAt);
+ const updatedB = toTime(b.updatedAt) || toTime(b.createdAt);
+ if (updatedA !== updatedB) return updatedB - updatedA;
+ return a.identifier.localeCompare(b.identifier);
+ })
+ .slice(0, MAX_DISPLAY);
diff --git a/src/features/AgentTasks/features/useTaskItemContextMenu.tsx b/src/features/AgentTasks/features/useTaskItemContextMenu.tsx
new file mode 100644
index 00000000000..4919ebfff02
--- /dev/null
+++ b/src/features/AgentTasks/features/useTaskItemContextMenu.tsx
@@ -0,0 +1,246 @@
+import { KeyEnum } from '@lobechat/const/hotkeys';
+import type { TaskStatus } from '@lobechat/types';
+import {
+ closeContextMenu,
+ combineKeys,
+ copyToClipboard,
+ Flexbox,
+ type GenericItemType,
+ Hotkey,
+ Icon,
+} from '@lobehub/ui';
+import { App } from 'antd';
+import { cssVar } from 'antd-style';
+import {
+ BarChart3Icon,
+ CheckIcon,
+ CircleDashedIcon,
+ CopyIcon,
+ LinkIcon,
+ Trash2Icon,
+} from 'lucide-react';
+import { useCallback, useEffect, useMemo, useRef } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useAppOrigin } from '@/hooks/useAppOrigin';
+import { useTaskStore } from '@/store/task';
+
+import { PRIORITY_META } from './TaskPriorityTag';
+import { STATUS_META, USER_SELECTABLE_STATUSES } from './TaskStatusTag';
+
+const PRIORITY_LEVELS = [0, 1, 2, 3, 4];
+
+interface TaskItemContextMenu {
+ items: GenericItemType[];
+ onContextMenu: () => void;
+}
+
+interface TaskContextMenuTarget {
+ identifier: string;
+ priority?: number | null;
+ status: string;
+}
+
+const renderCheck = () => <Icon color={cssVar.colorTextSecondary} icon={CheckIcon} size={14} />;
+
+const renderExtra = (shortcut: string, isCurrent: boolean) =>
+ isCurrent ? (
+ <Flexbox horizontal align={'center'} gap={6}>
+ {renderCheck()}
+ {shortcut}
+ </Flexbox>
+ ) : (
+ shortcut
+ );
+
+export const useTaskItemContextMenu = (task: TaskContextMenuTarget): TaskItemContextMenu => {
+ const { t } = useTranslation(['chat', 'common']);
+ const { modal, message } = App.useApp();
+ const appOrigin = useAppOrigin();
+
+ const updateTaskStatus = useTaskStore((s) => s.updateTaskStatus);
+ const updateTask = useTaskStore((s) => s.updateTask);
+ const refreshTaskList = useTaskStore((s) => s.refreshTaskList);
+ const deleteTask = useTaskStore((s) => s.deleteTask);
+
+ const currentStatus = task.status as TaskStatus;
+ const currentPriority = task.priority ?? 0;
+
+ const triggerDelete = useCallback(() => {
+ modal.confirm({
+ centered: true,
+ content: t('taskDetail.deleteConfirm.content'),
+ okButtonProps: { danger: true },
+ okText: t('taskDetail.deleteConfirm.ok'),
+ onOk: async () => {
+ await deleteTask(task.identifier);
+ },
+ title: t('taskDetail.deleteConfirm.title'),
+ type: 'error',
+ });
+ }, [modal, t, deleteTask, task.identifier]);
+
+ const items = useMemo<GenericItemType[]>(() => {
+ const statusChildren = USER_SELECTABLE_STATUSES.map((status, index) => {
+ const meta = STATUS_META[status];
+ const isCurrent = status === currentStatus;
+ return {
+ extra: renderExtra(String(index + 1), isCurrent),
+ icon: <Icon color={meta.color} icon={meta.icon} />,
+ key: `status-${status}`,
+ label: t(`taskDetail.status.${status}`, { defaultValue: meta.label }),
+ onClick: ({ domEvent }) => {
+ domEvent.stopPropagation();
+ if (status === currentStatus) return;
+ void updateTaskStatus(task.identifier, status);
+ },
+ } as GenericItemType;
+ });
+
+ const priorityChildren = PRIORITY_LEVELS.map((level, index) => {
+ const meta = PRIORITY_META[level];
+ const PriorityIcon = meta.icon;
+ const isUrgent = level === 1;
+ const isCurrent = level === currentPriority;
+ return {
+ extra: renderExtra(String(index + 1), isCurrent),
+ icon: (
+ <PriorityIcon color={isUrgent ? cssVar.orange : cssVar.colorTextDescription} size={16} />
+ ),
+ key: `priority-${level}`,
+ label: t(`taskDetail.${meta.labelKey}`, { defaultValue: '' }),
+ onClick: async ({ domEvent }) => {
+ domEvent.stopPropagation();
+ if (level === currentPriority) return;
+ await updateTask(task.identifier, { priority: level });
+ await refreshTaskList();
+ },
+ } as GenericItemType;
+ });
+
+ const taskUrl = `${appOrigin}/task/${task.identifier}`;
+
+ return [
+ {
+ children: statusChildren,
+ icon: <Icon icon={CircleDashedIcon} />,
+ key: 'status',
+ label: t('taskList.contextMenu.status'),
+ },
+ {
+ children: priorityChildren,
+ icon: <Icon icon={BarChart3Icon} />,
+ key: 'priority',
+ label: t('taskList.contextMenu.priority'),
+ },
+ { type: 'divider' },
+ {
+ icon: <Icon icon={CopyIcon} />,
+ key: 'copyId',
+ label: t('taskList.contextMenu.copyId'),
+ onClick: async ({ domEvent }) => {
+ domEvent.stopPropagation();
+ await copyToClipboard(task.identifier);
+ message.success(t('taskList.contextMenu.copyIdSuccess'));
+ },
+ },
+ {
+ icon: <Icon icon={LinkIcon} />,
+ key: 'copyLink',
+ label: t('taskList.contextMenu.copyLink'),
+ onClick: async ({ domEvent }) => {
+ domEvent.stopPropagation();
+ await copyToClipboard(taskUrl);
+ message.success(t('taskList.contextMenu.copyLinkSuccess'));
+ },
+ },
+ { type: 'divider' },
+ {
+ danger: true,
+ extra: (
+ <Hotkey keys={combineKeys([KeyEnum.Mod, KeyEnum.Backspace])} variant={'borderless'} />
+ ),
+ icon: <Icon icon={Trash2Icon} />,
+ key: 'delete',
+ label: t('delete', { ns: 'common' }),
+ onClick: ({ domEvent }) => {
+ domEvent.stopPropagation();
+ triggerDelete();
+ },
+ },
+ ];
+ }, [
+ task.identifier,
+ currentStatus,
+ currentPriority,
+ appOrigin,
+ t,
+ message,
+ updateTaskStatus,
+ updateTask,
+ refreshTaskList,
+ triggerDelete,
+ ]);
+
+ const cleanupRef = useRef<(() => void) | null>(null);
+
+ const onContextMenu = useCallback(() => {
+ cleanupRef.current?.();
+
+ const cleanup = () => {
+ document.removeEventListener('keydown', keyHandler, true);
+ window.removeEventListener('pointerdown', pointerHandler, true);
+ window.removeEventListener('contextmenu', contextHandler, true);
+ cleanupRef.current = null;
+ };
+
+ const keyHandler = (event: KeyboardEvent) => {
+ if (event.key === 'Escape') {
+ cleanup();
+ return;
+ }
+
+ if ((event.metaKey || event.ctrlKey) && event.key === 'Backspace') {
+ event.preventDefault();
+ event.stopPropagation();
+ closeContextMenu();
+ cleanup();
+ triggerDelete();
+ return;
+ }
+
+ const num = Number.parseInt(event.key, 10);
+ if (Number.isNaN(num)) return;
+ const idx = num - 1;
+ if (idx < 0 || idx >= USER_SELECTABLE_STATUSES.length) return;
+
+ event.preventDefault();
+ event.stopPropagation();
+
+ const nextStatus = USER_SELECTABLE_STATUSES[idx];
+ if (nextStatus !== currentStatus) {
+ void updateTaskStatus(task.identifier, nextStatus);
+ }
+ closeContextMenu();
+ cleanup();
+ };
+
+ const pointerHandler = () => {
+ cleanup();
+ };
+
+ const contextHandler = () => {
+ cleanup();
+ };
+
+ document.addEventListener('keydown', keyHandler, true);
+ window.addEventListener('pointerdown', pointerHandler, true);
+ window.addEventListener('contextmenu', contextHandler, true);
+
+ cleanupRef.current = cleanup;
+ }, [task.identifier, currentStatus, updateTaskStatus, triggerDelete]);
+
+ useEffect(() => () => cleanupRef.current?.(), []);
+
+ return { items, onContextMenu };
+};
diff --git a/src/features/AgentTasks/shared/Breadcrumb.tsx b/src/features/AgentTasks/shared/Breadcrumb.tsx
index c9cb7c3b5e7..b4267a66dee 100644
--- a/src/features/AgentTasks/shared/Breadcrumb.tsx
+++ b/src/features/AgentTasks/shared/Breadcrumb.tsx
@@ -1,5 +1,4 @@
-import { DEFAULT_AVATAR } from '@lobechat/const';
-import { Avatar, Flexbox, Icon, Text } from '@lobehub/ui';
+import { Icon, Text } from '@lobehub/ui';
import { Breadcrumb as AntBreadcrumb } from 'antd';
import { ChevronRight } from 'lucide-react';
import { memo } from 'react';
@@ -7,30 +6,16 @@ import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
import { useShallow } from 'zustand/react/shallow';
-import { DEFAULT_INBOX_AVATAR } from '@/const/meta';
-import { useAgentStore } from '@/store/agent';
-import { agentSelectors, builtinAgentSelectors } from '@/store/agent/selectors';
import { useTaskStore } from '@/store/task';
-import { isInboxAgentId } from './isInboxAgent';
import { styles } from './style';
interface BreadcrumbProps {
- /**
- * When omitted, the breadcrumb renders a single "All tasks" crumb for the
- * cross-agent `/tasks` route.
- */
- agentId?: string;
taskId?: string;
}
-const Breadcrumb = memo<BreadcrumbProps>(({ agentId, taskId }) => {
+const Breadcrumb = memo<BreadcrumbProps>(({ taskId }) => {
const { t } = useTranslation('chat');
- const { t: tCommon } = useTranslation('common');
- const inboxAgentId = useAgentStore(builtinAgentSelectors.inboxAgentId);
- const agentMeta = useAgentStore((s) =>
- agentId ? agentSelectors.getAgentMetaById(agentId)(s) : undefined,
- );
const taskTitle = useTaskStore((s) => (taskId ? s.taskDetailMap[taskId]?.name : undefined));
const taskIdentifier = useTaskStore((s) =>
taskId ? s.taskDetailMap[taskId]?.identifier : undefined,
@@ -50,27 +35,48 @@ const Breadcrumb = memo<BreadcrumbProps>(({ agentId, taskId }) => {
}),
);
- if (!agentId) {
- return (
- <AntBreadcrumb
- separator={<Icon icon={ChevronRight} />}
- items={[
- {
- title: (
- <Text color={'inherit'} weight={500}>
- {t('taskList.all')}
- </Text>
- ),
- },
- ]}
- />
- );
- }
+ const allTasksLabel = (
+ <Text color={'inherit'} weight={500}>
+ {t('taskList.all')}
+ </Text>
+ );
- const isInboxAgent = isInboxAgentId(agentId, inboxAgentId);
- const agentName =
- agentMeta?.title?.trim() || (isInboxAgent ? t('inbox.title') : tCommon('defaultSession'));
- const agentAvatar = agentMeta?.avatar || (isInboxAgent ? DEFAULT_INBOX_AVATAR : DEFAULT_AVATAR);
+ const ancestorCrumbs = ancestors.map((identifier) => ({
+ key: identifier,
+ title: (
+ <Link to={`/task/${identifier}`}>
+ <Text color={'inherit'} weight={500}>
+ {identifier}
+ </Text>
+ </Link>
+ ),
+ }));
+
+ const currentTaskCrumb = taskId
+ ? {
+ title: (
+ <span
+ style={{
+ alignItems: 'center',
+ display: 'inline-flex',
+ gap: 6,
+ lineHeight: 1,
+ minWidth: 0,
+ overflow: 'hidden',
+ }}
+ >
+ {taskIdentifier && (
+ <Text color={'inherit'} style={{ flexShrink: 0 }} type={'secondary'} weight={500}>
+ {taskIdentifier}
+ </Text>
+ )}
+ <Text ellipsis color={'inherit'} style={{ maxWidth: 240 }} weight={500}>
+ {taskTitle || taskId}
+ </Text>
+ </span>
+ ),
+ }
+ : undefined;
return (
<AntBreadcrumb
@@ -78,79 +84,10 @@ const Breadcrumb = memo<BreadcrumbProps>(({ agentId, taskId }) => {
separator={<Icon icon={ChevronRight} />}
items={[
{
- title: (
- <Link to={`/agent/${agentId}`}>
- <Flexbox
- horizontal
- align={'center'}
- gap={6}
- style={{ minWidth: 0, overflow: 'hidden' }}
- >
- <Flexbox style={{ flexShrink: 0 }}>
- <Avatar avatar={agentAvatar} background={agentMeta?.backgroundColor} size={18} />
- </Flexbox>
- <Text ellipsis color={'inherit'} weight={500}>
- {agentName}
- </Text>
- </Flexbox>
- </Link>
- ),
+ title: taskId ? <Link to={'/tasks'}>{allTasksLabel}</Link> : allTasksLabel,
},
- ...(taskId
- ? []
- : [
- {
- title: (
- <Link to={`/agent/${agentId}/tasks`}>
- <Text color={'inherit'} weight={500}>
- {t('taskList.breadcrumb.task')}
- </Text>
- </Link>
- ),
- },
- ]),
- ...ancestors.map((identifier) => ({
- key: identifier,
- title: (
- <Link to={`/agent/${agentId}/tasks/${identifier}`}>
- <Text color={'inherit'} weight={500}>
- {identifier}
- </Text>
- </Link>
- ),
- })),
- ...(taskId
- ? [
- {
- title: (
- <span
- style={{
- alignItems: 'center',
- display: 'inline-flex',
- gap: 6,
- lineHeight: 1,
- minWidth: 0,
- overflow: 'hidden',
- }}
- >
- {taskIdentifier && (
- <Text
- color={'inherit'}
- style={{ flexShrink: 0 }}
- type={'secondary'}
- weight={500}
- >
- {taskIdentifier}
- </Text>
- )}
- <Text ellipsis color={'inherit'} style={{ maxWidth: 240 }} weight={500}>
- {taskTitle || taskId}
- </Text>
- </span>
- ),
- },
- ]
- : []),
+ ...ancestorCrumbs,
+ ...(currentTaskCrumb ? [currentTaskCrumb] : []),
]}
/>
);
diff --git a/src/features/AgentTasks/shared/style.ts b/src/features/AgentTasks/shared/style.ts
index 2b815f3a612..29300ffb83b 100644
--- a/src/features/AgentTasks/shared/style.ts
+++ b/src/features/AgentTasks/shared/style.ts
@@ -39,20 +39,19 @@ export const styles = createStaticStyles(({ css, cssVar }) => ({
overflow: visible;
flex-shrink: 0;
min-width: auto;
+ margin-inline: 2px;
}
- .ant-breadcrumb-link {
- overflow: hidden;
- display: flex;
- align-items: center;
- min-width: 0;
- }
-
+ .ant-breadcrumb-link,
.ant-breadcrumb-link > a {
overflow: hidden;
display: flex;
align-items: center;
+
min-width: 0;
+ padding-block: 2px;
+ padding-inline: 6px;
+ border-radius: ${cssVar.borderRadius};
}
`,
@@ -133,4 +132,20 @@ export const styles = createStaticStyles(({ css, cssVar }) => ({
color: ${cssVar.colorText};
}
`,
+
+ commentInputCard: css`
+ padding-block: 4px;
+ padding-inline: 8px;
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: ${cssVar.borderRadiusLG};
+
+ background: ${cssVar.colorBgElevated};
+
+ transition: border-color 0.15s ease;
+
+ &:hover,
+ &:focus-within {
+ border-color: ${cssVar.colorBorder};
+ }
+ `,
}));
diff --git a/src/features/Conversation/Messages/Assistant/index.tsx b/src/features/Conversation/Messages/Assistant/index.tsx
index 2d1687ddb11..bf2ebcb0326 100644
--- a/src/features/Conversation/Messages/Assistant/index.tsx
+++ b/src/features/Conversation/Messages/Assistant/index.tsx
@@ -110,7 +110,7 @@ const AssistantMessage = memo<AssistantMessageProps>(({ id, index, disableEditin
messageId={id}
/>
)}
- {actionBarHolder}
+ {!disableEditing && actionBarHolder}
</>
}
error={
diff --git a/src/features/DailyBrief/BriefCard.tsx b/src/features/DailyBrief/BriefCard.tsx
index 8beb94de2f7..bf8d8e4e0a0 100644
--- a/src/features/DailyBrief/BriefCard.tsx
+++ b/src/features/DailyBrief/BriefCard.tsx
@@ -7,8 +7,6 @@ import { useNavigate } from 'react-router-dom';
import { DEFAULT_INBOX_AVATAR } from '@/const/meta';
import Time from '@/routes/(main)/home/features/components/Time';
-import { useAgentStore } from '@/store/agent';
-import { builtinAgentSelectors } from '@/store/agent/selectors';
import BriefCardActions from './BriefCardActions';
import BriefCardSummary from './BriefCardSummary';
@@ -54,11 +52,8 @@ interface BriefCardProps {
const BriefCard = memo<BriefCardProps>(
({ brief, enableNavigation = true, onAfterResolve, onAfterAddComment }) => {
const navigate = useNavigate();
- const activeAgentId = useAgentStore((s) => s.activeAgentId);
- const inboxAgentId = useAgentStore(builtinAgentSelectors.inboxAgentId);
- const targetAgentId = brief.agents[0]?.id || activeAgentId || inboxAgentId;
- const canNavigate = enableNavigation && Boolean(brief.taskId && targetAgentId);
+ const canNavigate = enableNavigation && Boolean(brief.taskId);
return (
<Block
@@ -74,11 +69,7 @@ const BriefCard = memo<BriefCardProps>(
className={canNavigate ? styles.clickableHeader : undefined}
gap={16}
justify={'space-between'}
- onClick={
- canNavigate
- ? () => navigate(`/agent/${targetAgentId}/tasks/${brief.taskId}`)
- : undefined
- }
+ onClick={canNavigate ? () => navigate(`/task/${brief.taskId}`) : undefined}
>
<Flexbox horizontal align={'center'} gap={8} style={{ overflow: 'hidden' }}>
<BriefIcon type={brief.type} />
diff --git a/src/features/Electron/navigation/routeMetadata.ts b/src/features/Electron/navigation/routeMetadata.ts
index c26f3abc660..712b6eb351c 100644
--- a/src/features/Electron/navigation/routeMetadata.ts
+++ b/src/features/Electron/navigation/routeMetadata.ts
@@ -31,6 +31,7 @@ const memoryIcon = getRouteById('memory')?.icon;
const imageIcon = getRouteById('image')?.icon;
const pageIcon = getRouteById('page')?.icon;
const settingsIcon = getRouteById('settings')?.icon;
+const tasksIcon = getRouteById('tasks')?.icon;
/**
* Route patterns ordered by specificity (most specific first)
@@ -113,6 +114,13 @@ const routePatterns: RoutePattern[] = [
titleKey: 'navigation.resources',
},
+ // Tasks routes (cross-agent global view + singular task detail)
+ {
+ icon: tasksIcon,
+ test: (p) => p.startsWith('/tasks') || p.startsWith('/task/'),
+ titleKey: 'navigation.tasks',
+ },
+
// Memory routes
{
icon: memoryIcon,
diff --git a/src/hooks/useNavLayout.ts b/src/hooks/useNavLayout.ts
index d92e6abfaa5..c5404005fee 100644
--- a/src/hooks/useNavLayout.ts
+++ b/src/hooks/useNavLayout.ts
@@ -35,7 +35,7 @@ export interface NavLayout {
export const useNavLayout = (): NavLayout => {
const { t } = useTranslation('common');
const toggleCommandMenu = useGlobalStore((s) => s.toggleCommandMenu);
- const { showMarket, hideGitHub } = useServerConfigStore(featureFlagsSelectors);
+ const { showMarket, hideGitHub, enableAgentTask } = useServerConfigStore(featureFlagsSelectors);
const topNavItems = useMemo(
() =>
@@ -52,6 +52,13 @@ export const useNavLayout = (): NavLayout => {
title: t('tab.home'),
url: '/',
},
+ {
+ hidden: !enableAgentTask,
+ icon: getRouteById('tasks')!.icon,
+ key: SidebarTabKey.Tasks,
+ title: t('tab.tasks'),
+ url: '/tasks',
+ },
{
icon: getRouteById('page')!.icon,
key: SidebarTabKey.Pages,
@@ -59,7 +66,7 @@ export const useNavLayout = (): NavLayout => {
url: '/page',
},
] as NavItem[],
- [t, toggleCommandMenu],
+ [t, toggleCommandMenu, enableAgentTask],
);
const bottomMenuItems = useMemo(
diff --git a/src/locales/default/chat.ts b/src/locales/default/chat.ts
index 95817a4f9ef..cd20d37b2ef 100644
--- a/src/locales/default/chat.ts
+++ b/src/locales/default/chat.ts
@@ -540,7 +540,8 @@ export default {
'taskDetail.comment.deleteConfirm.title': 'Delete this comment?',
'taskDetail.comment.edit': 'Edit',
'taskDetail.comment.save': 'Save',
- 'taskDetail.commentPlaceholder': 'Leave a comment...',
+ 'taskDetail.commentPlaceholder':
+ 'Leave feedback to guide the agent — your comments shape the next run...',
'taskDetail.deleteConfirm.content': 'This action cannot be undone.',
'taskDetail.deleteConfirm.ok': 'Delete',
'taskDetail.deleteConfirm.title': 'Delete this task?',
@@ -595,7 +596,12 @@ export default {
'taskList.form.grouping': 'Grouping',
'taskList.form.orderCompletedByRecency': 'Sort completed tasks by recency',
'taskList.form.ordering': 'Ordering',
+ 'taskList.form.showCompleted': 'Show completed & canceled',
'taskList.form.subGrouping': 'Sub-grouping',
+ 'taskList.hiddenCompleted.count_one': '{{count}} task',
+ 'taskList.hiddenCompleted.count_other': '{{count}} tasks',
+ 'taskList.hiddenCompleted.show': 'Show',
+ 'taskList.hiddenCompleted.suffix': 'hidden by display options',
'taskList.groupBy.assignee': 'Assignee',
'taskList.groupBy.none': 'No grouping',
'taskList.groupBy.priority': 'Priority',
@@ -608,11 +614,24 @@ export default {
'taskList.orderBy.updatedAt': 'Updated at',
'taskList.title': 'Tasks',
'taskList.unassigned': 'Unassigned',
+ 'taskList.unassignedHint': 'Lobe AI will run this task when no assignee is set',
+ 'taskList.assigneeSearch.empty': 'No matching agent',
+ 'taskList.assigneeSearch.placeholder': 'Search agent...',
+ 'taskList.contextMenu.copyId': 'Copy ID',
+ 'taskList.contextMenu.copyIdSuccess': 'ID copied',
+ 'taskList.contextMenu.copyLink': 'Copy link',
+ 'taskList.contextMenu.copyLinkSuccess': 'Link copied',
+ 'taskList.contextMenu.priority': 'Priority',
+ 'taskList.contextMenu.status': 'Status',
+ 'taskList.kanban.addTask': 'Create task',
'taskList.kanban.backlog': 'Backlog',
'taskList.kanban.done': 'Done',
'taskList.kanban.emptyColumn': 'No tasks',
+ 'taskList.kanban.hiddenColumns': 'Hidden columns',
+ 'taskList.kanban.hideColumn': 'Hide column',
'taskList.kanban.needsInput': 'Needs input',
'taskList.kanban.running': 'In progress',
+ 'taskList.kanban.showColumn': 'Show column',
'taskList.view.board': 'Board',
'taskList.view.list': 'List',
'taskList.viewAll': 'View all',
diff --git a/src/locales/default/common.ts b/src/locales/default/common.ts
index dbcf721b14a..610f9ecc1d6 100644
--- a/src/locales/default/common.ts
+++ b/src/locales/default/common.ts
@@ -188,6 +188,8 @@ export default {
'cmdk.keywords.submitIssue': 'issue bug problem feedback',
+ 'cmdk.keywords.tasks': 'tasks todo agent kanban',
+
'cmdk.keywords.usage': 'usage statistics consumption quota',
'cmdk.keywords.video': 'video,generate,seedance,kling',
@@ -268,6 +270,7 @@ export default {
'cmdk.settings': 'Settings',
'cmdk.starOnGitHub': 'Star us on GitHub',
'cmdk.submitIssue': 'Submit Issue',
+ 'cmdk.tasks': 'Tasks',
'cmdk.theme': 'Theme',
'cmdk.themeAuto': 'Auto',
'cmdk.themeCurrent': 'Current',
@@ -513,6 +516,7 @@ export default {
'tab.resource': 'Resources',
'tab.search': 'Search',
'tab.setting': 'Settings',
+ 'tab.tasks': 'Tasks',
'tab.video': 'Video',
'telemetry.allow': 'Allow',
'telemetry.deny': 'Deny',
diff --git a/src/locales/default/electron.ts b/src/locales/default/electron.ts
index 7622ce741b3..4a5a6cb25a9 100644
--- a/src/locales/default/electron.ts
+++ b/src/locales/default/electron.ts
@@ -26,6 +26,7 @@ export default {
'navigation.recentView': 'Recent pages',
'navigation.resources': 'Resources',
'navigation.settings': 'Settings',
+ 'navigation.tasks': 'Tasks',
'navigation.unpin': 'Unpin',
'notification.finishChatGeneration': 'AI message generation completed',
'tab.closeCurrentTab': 'Close Tab',
diff --git a/src/routes/(main)/agent/_layout/Sidebar/Header/Nav.tsx b/src/routes/(main)/agent/_layout/Sidebar/Header/Nav.tsx
index c59b7033112..4f8bbcc44a3 100644
--- a/src/routes/(main)/agent/_layout/Sidebar/Header/Nav.tsx
+++ b/src/routes/(main)/agent/_layout/Sidebar/Header/Nav.tsx
@@ -2,7 +2,7 @@
import { Flexbox } from '@lobehub/ui';
import { BotPromptIcon } from '@lobehub/ui/icons';
-import { ListTodoIcon, MessageSquarePlusIcon, RadioTowerIcon, SearchIcon } from 'lucide-react';
+import { MessageSquarePlusIcon, RadioTowerIcon, SearchIcon } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';
@@ -26,9 +26,8 @@ const Nav = memo(() => {
const pathname = usePathname();
const isProfileActive = pathname.includes('/profile');
const isChannelActive = pathname.includes('/channel');
- const isTasksActive = pathname.includes('/tasks');
const router = useQueryRoute();
- const { isAgentEditable, enableAgentTask } = useServerConfigStore(featureFlagsSelectors);
+ const { isAgentEditable } = useServerConfigStore(featureFlagsSelectors);
const toggleCommandMenu = useGlobalStore((s) => s.toggleCommandMenu);
const isHeterogeneousAgent = useAgentStore(agentSelectors.isCurrentAgentHeterogeneous);
const hideProfile = !isAgentEditable;
@@ -39,7 +38,7 @@ const Nav = memo(() => {
const { mutate } = useActionSWR('openNewTopicOrSaveTopic', openNewTopicOrSaveTopic);
const handleNewTopic = () => {
// If in agent sub-route, navigate back to agent chat first
- if ((isProfileActive || isChannelActive || isTasksActive) && agentId) {
+ if ((isProfileActive || isChannelActive) && agentId) {
router.push(urlJoin('/agent', agentId));
}
mutate();
@@ -81,17 +80,6 @@ const Nav = memo(() => {
}}
/>
)}
- {enableAgentTask && (
- <NavItem
- active={isTasksActive}
- icon={ListTodoIcon}
- title={t('tab.tasks')}
- onClick={() => {
- switchTopic(null, { skipRefreshMessage: true });
- router.push(urlJoin('/agent', agentId!, 'tasks'));
- }}
- />
- )}
</Flexbox>
);
});
diff --git a/src/routes/(main)/agent/tasks/[taskId]/index.tsx b/src/routes/(main)/agent/tasks/[taskId]/index.tsx
deleted file mode 100644
index 2dea9adb08e..00000000000
--- a/src/routes/(main)/agent/tasks/[taskId]/index.tsx
+++ /dev/null
@@ -1,16 +0,0 @@
-'use client';
-
-import { memo } from 'react';
-import { useParams } from 'react-router-dom';
-
-import { TaskDetailPage } from '@/features/AgentTasks';
-
-const TaskDetailRoute = memo(() => {
- const { aid, taskId } = useParams<{ aid?: string; taskId?: string }>();
-
- if (!aid || !taskId) return null;
-
- return <TaskDetailPage agentId={aid} taskId={taskId} />;
-});
-
-export default TaskDetailRoute;
diff --git a/src/routes/(main)/agent/tasks/index.tsx b/src/routes/(main)/agent/tasks/index.tsx
deleted file mode 100644
index a2cac70bcc2..00000000000
--- a/src/routes/(main)/agent/tasks/index.tsx
+++ /dev/null
@@ -1,16 +0,0 @@
-'use client';
-
-import { memo } from 'react';
-import { useParams } from 'react-router-dom';
-
-import { AgentTasksPage } from '@/features/AgentTasks';
-
-const TasksRoute = memo(() => {
- const { aid } = useParams<{ aid?: string }>();
-
- if (!aid) return null;
-
- return <AgentTasksPage agentId={aid} />;
-});
-
-export default TasksRoute;
diff --git a/src/routes/(main)/home/_layout/Body/CustomizeSidebarModal.tsx b/src/routes/(main)/home/_layout/Body/CustomizeSidebarModal.tsx
index 0d4b0adc1a7..2ab84ef797f 100644
--- a/src/routes/(main)/home/_layout/Body/CustomizeSidebarModal.tsx
+++ b/src/routes/(main)/home/_layout/Body/CustomizeSidebarModal.tsx
@@ -49,6 +49,7 @@ interface SidebarItemConfig {
const ALL_SIDEBAR_ITEMS: SidebarItemConfig[] = [
{ id: 'pages', labelKey: 'tab.pages', routeId: 'page' },
+ { id: 'tasks', labelKey: 'tab.tasks', routeId: 'tasks' },
{ id: 'recents', labelKey: 'recents' },
{ alwaysVisible: true, id: 'agent', labelKey: 'navPanel.agent' },
{ id: 'community', labelKey: 'tab.community', routeId: 'community' },
diff --git a/src/routes/(main)/home/features/Recents/AllRecentsDrawer.tsx b/src/routes/(main)/home/features/Recents/AllRecentsDrawer.tsx
index e266b0c666e..fb6d8741896 100644
--- a/src/routes/(main)/home/features/Recents/AllRecentsDrawer.tsx
+++ b/src/routes/(main)/home/features/Recents/AllRecentsDrawer.tsx
@@ -10,8 +10,6 @@ import SkeletonList from '@/features/NavPanel/components/SkeletonList';
import SideBarDrawer from '@/features/NavPanel/SideBarDrawer';
import { useClientDataSWR } from '@/libs/swr';
import { recentService } from '@/services/recent';
-import { useAgentStore } from '@/store/agent';
-import { builtinAgentSelectors } from '@/store/agent/selectors';
import { ALL_RECENTS_DRAWER_SWR_PREFIX } from '@/store/home/slices/recent/action';
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
@@ -25,8 +23,6 @@ interface AllRecentsDrawerProps {
const AllRecentsDrawer = memo<AllRecentsDrawerProps>(({ open, onClose }) => {
const { t } = useTranslation('common');
const [searchKeyword, setSearchKeyword] = useState('');
- const activeAgentId = useAgentStore((s) => s.activeAgentId);
- const inboxAgentId = useAgentStore(builtinAgentSelectors.inboxAgentId);
const { enableAgentTask } = useServerConfigStore(featureFlagsSelectors);
@@ -43,18 +39,13 @@ const AllRecentsDrawer = memo<AllRecentsDrawerProps>(({ open, onClose }) => {
return baseRecents.filter((item) => item.title.toLowerCase().includes(keyword));
}, [recents, searchKeyword, enableAgentTask]);
- const fallbackAgentId = activeAgentId || inboxAgentId;
- const getRecentRoute = useCallback(
- (item: (typeof filteredRecents)[number]) => {
- if (item.type !== 'task') return item.routePath;
- const targetAgentId = item.agentId || fallbackAgentId;
- const taskId = item.id;
- if (!targetAgentId || !taskId) return item.routePath;
+ const getRecentRoute = useCallback((item: (typeof filteredRecents)[number]) => {
+ if (item.type !== 'task') return item.routePath;
+ const taskId = item.id;
+ if (!taskId) return item.routePath;
- return `/agent/${targetAgentId}/tasks/${taskId}`;
- },
- [fallbackAgentId],
- );
+ return `/task/${taskId}`;
+ }, []);
return (
<SideBarDrawer
diff --git a/src/routes/(main)/home/features/Recents/List.tsx b/src/routes/(main)/home/features/Recents/List.tsx
index 759d0f9cb69..07c1c89c629 100644
--- a/src/routes/(main)/home/features/Recents/List.tsx
+++ b/src/routes/(main)/home/features/Recents/List.tsx
@@ -6,8 +6,6 @@ import { Link } from 'react-router-dom';
import NavItem from '@/features/NavPanel/components/NavItem';
import SkeletonList from '@/features/NavPanel/components/SkeletonList';
-import { useAgentStore } from '@/store/agent';
-import { builtinAgentSelectors } from '@/store/agent/selectors';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
import { useHomeStore } from '@/store/home';
@@ -21,8 +19,6 @@ const RecentsList = memo(() => {
const { t } = useTranslation('chat');
const recents = useHomeStore(homeRecentSelectors.recents);
const isInit = useHomeStore(homeRecentSelectors.isRecentsInit);
- const activeAgentId = useAgentStore((s) => s.activeAgentId);
- const inboxAgentId = useAgentStore(builtinAgentSelectors.inboxAgentId);
const recentPageSize = useGlobalStore(systemStatusSelectors.recentPageSize);
const { enableAgentTask } = useServerConfigStore(featureFlagsSelectors);
const [drawerOpen, openDrawer, closeDrawer] = useHomeStore((s) => [
@@ -40,19 +36,14 @@ const RecentsList = memo(() => {
[filteredRecents, recentPageSize],
);
const hasMore = filteredRecents.length > recentPageSize;
- const fallbackAgentId = activeAgentId || inboxAgentId;
- const getRecentRoute = useCallback(
- (item: (typeof displayItems)[number]) => {
- if (item.type !== 'task') return item.routePath;
- const targetAgentId = item.agentId || fallbackAgentId;
- const taskId = item.id;
- if (!targetAgentId || !taskId) return item.routePath;
+ const getRecentRoute = useCallback((item: (typeof displayItems)[number]) => {
+ if (item.type !== 'task') return item.routePath;
+ const taskId = item.id;
+ if (!taskId) return item.routePath;
- return `/agent/${targetAgentId}/tasks/${taskId}`;
- },
- [fallbackAgentId],
- );
+ return `/task/${taskId}`;
+ }, []);
if (!isInit) {
return <SkeletonList rows={3} />;
diff --git a/src/routes/(main)/task/[taskId]/index.tsx b/src/routes/(main)/task/[taskId]/index.tsx
new file mode 100644
index 00000000000..55c339cad55
--- /dev/null
+++ b/src/routes/(main)/task/[taskId]/index.tsx
@@ -0,0 +1,21 @@
+'use client';
+
+import { memo } from 'react';
+import { useParams } from 'react-router-dom';
+
+import { TaskDetailPage } from '@/features/AgentTasks';
+import { useTaskStore } from '@/store/task';
+
+const TaskDetailRoute = memo(() => {
+ const { taskId } = useParams<{ taskId?: string }>();
+
+ const agentId = useTaskStore((s) =>
+ taskId ? (s.taskDetailMap[taskId]?.agentId ?? undefined) : undefined,
+ );
+
+ if (!taskId) return null;
+
+ return <TaskDetailPage agentId={agentId} taskId={taskId} />;
+});
+
+export default TaskDetailRoute;
diff --git a/src/routes/(main)/agent/tasks/_layout/index.tsx b/src/routes/(main)/task/_layout/index.tsx
similarity index 51%
rename from src/routes/(main)/agent/tasks/_layout/index.tsx
rename to src/routes/(main)/task/_layout/index.tsx
index ddc822daab9..31168aed20c 100644
--- a/src/routes/(main)/agent/tasks/_layout/index.tsx
+++ b/src/routes/(main)/task/_layout/index.tsx
@@ -3,32 +3,19 @@
import { TaskIdentifier } from '@lobechat/builtin-tool-task';
import { Flexbox } from '@lobehub/ui';
import { memo } from 'react';
-import { Navigate, Outlet, useParams } from 'react-router-dom';
-import urlJoin from 'url-join';
+import { Navigate, Outlet } from 'react-router-dom';
import AgentTaskManager from '@/features/AgentTaskManager';
import { useScenarioEnabledTools } from '@/hooks/useScenarioEnabledTools';
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
-/**
- * Tasks pages layout.
- *
- * - Horizontal split: task content on the left (list / detail), main-conversation
- * chat panel on the right. Right panel reuses the same agentId + activeTopicId
- * as the `/agent/:aid` page via `useAgentContext()` inside ConversationArea.
- *
- * - Enables `lobe-task` for every LLM step while the user is on any tasks
- * sub-page via the page-level `scenarioEnabledToolIds` chat state.
- */
-const TasksLayout = memo(() => {
+const TaskDetailLayout = memo(() => {
useScenarioEnabledTools(TaskIdentifier);
- const params = useParams();
- const agentId = params.aid;
const serverConfigInit = useServerConfigStore((s) => s.serverConfigInit);
const { enableAgentTask } = useServerConfigStore(featureFlagsSelectors);
if (serverConfigInit && !enableAgentTask) {
- return <Navigate replace to={agentId ? urlJoin('/agent', agentId) : '/'} />;
+ return <Navigate replace to="/" />;
}
return (
@@ -41,6 +28,6 @@ const TasksLayout = memo(() => {
);
});
-TasksLayout.displayName = 'TasksLayout';
+TaskDetailLayout.displayName = 'TaskDetailLayout';
-export default TasksLayout;
+export default TaskDetailLayout;
diff --git a/src/routes/(main)/tasks/_layout/index.tsx b/src/routes/(main)/tasks/_layout/index.tsx
index facbc054c72..e2fc5ba8fc0 100644
--- a/src/routes/(main)/tasks/_layout/index.tsx
+++ b/src/routes/(main)/tasks/_layout/index.tsx
@@ -8,11 +8,6 @@ import { Navigate, Outlet } from 'react-router-dom';
import { useScenarioEnabledTools } from '@/hooks/useScenarioEnabledTools';
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
-/**
- * Layout for the cross-agent `/tasks` page. Full-width single column — no
- * right-side chat panel like `/agent/:aid/tasks/_layout` has, because this view
- * is not scoped to any single agent.
- */
const AllTasksLayout = memo(() => {
useScenarioEnabledTools(TaskIdentifier);
const serverConfigInit = useServerConfigStore((s) => s.serverConfigInit);
diff --git a/src/server/routers/lambda/task.ts b/src/server/routers/lambda/task.ts
index 069e1f9acd9..d7dbe9d1fd7 100644
--- a/src/server/routers/lambda/task.ts
+++ b/src/server/routers/lambda/task.ts
@@ -920,7 +920,7 @@ export const taskRouter = router({
id: 'task-on-complete',
type: 'onComplete' as const,
webhook: {
- body: { taskId, userId },
+ body: { taskId, taskIdentifier, userId },
url: '/api/workflows/task/on-topic-complete',
},
},
diff --git a/src/server/workflows-hono/index.ts b/src/server/workflows-hono/index.ts
new file mode 100644
index 00000000000..6a7018dcf9f
--- /dev/null
+++ b/src/server/workflows-hono/index.ts
@@ -0,0 +1,11 @@
+import { Hono } from 'hono';
+
+import memoryUserMemoryApp from './memory-user-memory';
+import taskApp from './task';
+
+const app = new Hono().basePath('/api/workflows');
+
+app.route('/memory-user-memory', memoryUserMemoryApp);
+app.route('/task', taskApp);
+
+export default app;
diff --git a/src/server/workflows-hono/memory-user-memory/app.ts b/src/server/workflows-hono/memory-user-memory/index.ts
similarity index 92%
rename from src/server/workflows-hono/memory-user-memory/app.ts
rename to src/server/workflows-hono/memory-user-memory/index.ts
index de95cd10ac4..2fdd0cf01e9 100644
--- a/src/server/workflows-hono/memory-user-memory/app.ts
+++ b/src/server/workflows-hono/memory-user-memory/index.ts
@@ -1,7 +1,7 @@
import { serve, serveMany } from '@upstash/workflow/hono';
import { Hono } from 'hono';
-import { createWorkflowQstashClient } from './qstashClient';
+import { createWorkflowQstashClient } from '../qstashClient';
import { hourlyWorkflowHandler, hourlyWorkflowOptions } from './workflows/hourly';
import { personaUpdateHandler } from './workflows/personaUpdate';
import { processTopicWorkflow } from './workflows/processTopic';
@@ -9,7 +9,7 @@ import { processTopicsHandler } from './workflows/processTopics';
import { processUsersHandler } from './workflows/processUsers';
import { processUserTopicsHandler } from './workflows/processUserTopics';
-const app = new Hono().basePath('/api/workflows/memory-user-memory');
+const app = new Hono();
app.post(
'/call-cron-hourly-analysis',
diff --git a/src/server/workflows-hono/memory-user-memory/workflows/processTopic.ts b/src/server/workflows-hono/memory-user-memory/workflows/processTopic.ts
index f660c286363..c8a6f6fda2b 100644
--- a/src/server/workflows-hono/memory-user-memory/workflows/processTopic.ts
+++ b/src/server/workflows-hono/memory-user-memory/workflows/processTopic.ts
@@ -17,7 +17,7 @@ import {
normalizeMemoryExtractionPayload,
} from '@/server/services/memory/userMemory/extract';
-import { createWorkflowQstashClient } from '../qstashClient';
+import { createWorkflowQstashClient } from '../../qstashClient';
const CEPA_LAYERS: LayersEnum[] = [
LayersEnum.Context,
diff --git a/src/server/workflows-hono/memory-user-memory/qstashClient.ts b/src/server/workflows-hono/qstashClient.ts
similarity index 100%
rename from src/server/workflows-hono/memory-user-memory/qstashClient.ts
rename to src/server/workflows-hono/qstashClient.ts
diff --git a/src/server/workflows-hono/task/handlers/onTopicComplete.ts b/src/server/workflows-hono/task/handlers/onTopicComplete.ts
new file mode 100644
index 00000000000..45072b39fe4
--- /dev/null
+++ b/src/server/workflows-hono/task/handlers/onTopicComplete.ts
@@ -0,0 +1,66 @@
+import debug from 'debug';
+import type { Context } from 'hono';
+
+import { getServerDB } from '@/database/server';
+import { TaskLifecycleService } from '@/server/services/taskLifecycle';
+
+const log = debug('lobe-server:workflows:task:on-topic-complete');
+
+export interface OnTopicCompletePayload {
+ errorMessage?: string;
+ hookId?: string;
+ hookType?: string;
+ lastAssistantContent?: string;
+ operationId: string;
+ reason?: string;
+ taskId: string;
+ taskIdentifier: string;
+ topicId?: string;
+ userId: string;
+}
+
+export async function onTopicComplete(c: Context) {
+ try {
+ const body = (await c.req.json()) as OnTopicCompletePayload;
+ const {
+ errorMessage,
+ lastAssistantContent,
+ operationId,
+ reason,
+ taskId,
+ taskIdentifier,
+ topicId,
+ userId,
+ } = body;
+
+ if (!taskId || !userId || !taskIdentifier || !operationId) {
+ return c.json({ error: 'Missing required fields' }, 400);
+ }
+
+ log(
+ 'Received: taskId=%s topicId=%s reason=%s operationId=%s',
+ taskId,
+ topicId,
+ reason,
+ operationId,
+ );
+
+ const db = await getServerDB();
+ const taskLifecycle = new TaskLifecycleService(db, userId);
+
+ await taskLifecycle.onTopicComplete({
+ errorMessage,
+ lastAssistantContent,
+ operationId,
+ reason: reason || 'done',
+ taskId,
+ taskIdentifier,
+ topicId,
+ });
+
+ return c.json({ success: true });
+ } catch (error) {
+ console.error('[task/on-topic-complete] Error:', error);
+ return c.json({ error: error instanceof Error ? error.message : 'Internal error' }, 500);
+ }
+}
diff --git a/src/server/workflows-hono/task/index.ts b/src/server/workflows-hono/task/index.ts
new file mode 100644
index 00000000000..96bb4817190
--- /dev/null
+++ b/src/server/workflows-hono/task/index.ts
@@ -0,0 +1,9 @@
+import { Hono } from 'hono';
+
+import { onTopicComplete } from './handlers/onTopicComplete';
+
+const app = new Hono();
+
+app.post('/on-topic-complete', onTopicComplete);
+
+export default app;
diff --git a/src/spa/router/desktopRouter.config.desktop.tsx b/src/spa/router/desktopRouter.config.desktop.tsx
index bbed7de7195..6cc84a93ddb 100644
--- a/src/spa/router/desktopRouter.config.desktop.tsx
+++ b/src/spa/router/desktopRouter.config.desktop.tsx
@@ -19,9 +19,6 @@ import DesktopChatLayout from '@/routes/(main)/agent/_layout';
import AgentChannelPage from '@/routes/(main)/agent/channel';
import AgentCronDetailPage from '@/routes/(main)/agent/cron/[cronId]';
import AgentProfilePage from '@/routes/(main)/agent/profile';
-import AgentTasksPage from '@/routes/(main)/agent/tasks';
-import AgentTasksLayout from '@/routes/(main)/agent/tasks/_layout';
-import AgentTaskDetailPage from '@/routes/(main)/agent/tasks/[taskId]';
import CommunityLayout from '@/routes/(main)/community/_layout';
import CommunityDetailLayout from '@/routes/(main)/community/(detail)/_layout';
import CommunityDetailAgentPage from '@/routes/(main)/community/(detail)/agent';
@@ -73,6 +70,8 @@ import ResourceLibrarySlugPage from '@/routes/(main)/resource/library/[slug]';
import SettingsTabPage from '@/routes/(main)/settings';
import SettingsLayout from '@/routes/(main)/settings/_layout';
import { ProviderDetailPage, ProviderLayout } from '@/routes/(main)/settings/provider';
+import TaskDetailLayout from '@/routes/(main)/task/_layout';
+import TaskDetailRoute from '@/routes/(main)/task/[taskId]';
import AllTasksPage from '@/routes/(main)/tasks';
import AllTasksLayout from '@/routes/(main)/tasks/_layout';
import ShareTopicPage from '@/routes/share/t/[id]';
@@ -110,20 +109,6 @@ export const desktopRoutes: RouteObject[] = [
element: <AgentChannelPage />,
path: 'channel',
},
- {
- children: [
- {
- element: <AgentTasksPage />,
- index: true,
- },
- {
- element: <AgentTaskDetailPage />,
- path: ':taskId',
- },
- ],
- element: <AgentTasksLayout />,
- path: 'tasks',
- },
],
element: <DesktopChatLayout />,
errorElement: <ErrorBoundary />,
@@ -444,6 +429,19 @@ export const desktopRoutes: RouteObject[] = [
path: 'tasks',
},
+ // Task detail route (cross-agent entry — resolves by task identifier)
+ {
+ children: [
+ {
+ element: <TaskDetailRoute />,
+ path: ':taskId',
+ },
+ ],
+ element: <TaskDetailLayout />,
+ errorElement: <ErrorBoundary resetPath="/tasks" />,
+ path: 'task',
+ },
+
// Pages routes
{
children: [
diff --git a/src/spa/router/desktopRouter.config.tsx b/src/spa/router/desktopRouter.config.tsx
index 2286e81767a..dcc0f1afba8 100644
--- a/src/spa/router/desktopRouter.config.tsx
+++ b/src/spa/router/desktopRouter.config.tsx
@@ -48,29 +48,6 @@ export const desktopRoutes: RouteObject[] = [
),
path: 'channel',
},
- {
- children: [
- {
- element: dynamicElement(
- () => import('@/routes/(main)/agent/tasks'),
- 'Desktop > Chat > Tasks',
- ),
- index: true,
- },
- {
- element: dynamicElement(
- () => import('@/routes/(main)/agent/tasks/[taskId]'),
- 'Desktop > Chat > Task Detail',
- ),
- path: ':taskId',
- },
- ],
- element: dynamicLayout(
- () => import('@/routes/(main)/agent/tasks/_layout'),
- 'Desktop > Chat > Tasks > Layout',
- ),
- path: 'tasks',
- },
],
element: dynamicLayout(
() => import('@/routes/(main)/agent/_layout'),
@@ -555,6 +532,25 @@ export const desktopRoutes: RouteObject[] = [
path: 'tasks',
},
+ // Task detail route (cross-agent entry — resolves by task identifier)
+ {
+ children: [
+ {
+ element: dynamicElement(
+ () => import('@/routes/(main)/task/[taskId]'),
+ 'Desktop > Task Detail',
+ ),
+ path: ':taskId',
+ },
+ ],
+ element: dynamicLayout(
+ () => import('@/routes/(main)/task/_layout'),
+ 'Desktop > Task > Layout',
+ ),
+ errorElement: <ErrorBoundary resetPath="/tasks" />,
+ path: 'task',
+ },
+
// Pages routes
{
children: [
diff --git a/src/store/global/initialState.ts b/src/store/global/initialState.ts
index 5e1cc853b69..2305b5c9085 100644
--- a/src/store/global/initialState.ts
+++ b/src/store/global/initialState.ts
@@ -17,6 +17,7 @@ export enum SidebarTabKey {
Pages = 'pages',
Resource = 'resource',
Setting = 'settings',
+ Tasks = 'tasks',
Video = 'video',
}
@@ -199,8 +200,18 @@ export interface SystemStatus {
* When true, the tasks page shows a "+" button in the header that opens the create modal.
*/
taskCreateInlineCollapsed?: boolean;
+ /**
+ * Kanban columns hidden from the main board. Each column renders as a collapsible
+ * entry in the right-side "Hidden columns" panel until restored.
+ */
+ taskKanbanHiddenColumns?: string[];
+ /**
+ * Whether the right-side "Hidden columns" panel on the Kanban board is collapsed.
+ */
+ taskKanbanHiddenPanelCollapsed?: boolean;
taskListViewOptions?: {
groupBy: 'assignee' | 'none' | 'priority' | 'status';
+ hideCompleted: boolean;
orderBy: 'assignee' | 'createdAt' | 'priority' | 'status' | 'title' | 'updatedAt';
orderCompletedByRecency: boolean;
orderDirection: 'asc' | 'desc';
@@ -267,11 +278,14 @@ export const INITIAL_STATUS = {
recentPageSize: 5,
taskListViewOptions: {
groupBy: 'status',
+ hideCompleted: true,
orderBy: 'updatedAt',
orderCompletedByRecency: true,
orderDirection: 'asc',
subGroupBy: 'none',
},
+ taskKanbanHiddenColumns: ['done'],
+ taskKanbanHiddenPanelCollapsed: false,
disabledModelProvidersSortType: 'default',
disabledModelsSortType: 'default',
dismissedBannerIds: [],
diff --git a/src/store/global/selectors/systemStatus.test.ts b/src/store/global/selectors/systemStatus.test.ts
index 33d071ef56d..548bdb4f79b 100644
--- a/src/store/global/selectors/systemStatus.test.ts
+++ b/src/store/global/selectors/systemStatus.test.ts
@@ -95,7 +95,7 @@ describe('systemStatusSelectors', () => {
});
it('should return stored items when set', () => {
- const custom = ['agent', 'recents', 'pages', 'community', 'resource', 'memory'];
+ const custom = ['agent', 'recents', 'pages', 'tasks', 'community', 'resource', 'memory'];
const s: GlobalState = merge(initialState, {
status: { sidebarItems: custom },
});
@@ -122,7 +122,15 @@ describe('systemStatusSelectors', () => {
});
const items = systemStatusSelectors.sidebarItems(s);
// accordion slot in the default list now uses the user's legacy order
- expect(items).toEqual(['pages', 'agent', 'recents', 'community', 'resource', 'memory']);
+ expect(items).toEqual([
+ 'pages',
+ 'tasks',
+ 'agent',
+ 'recents',
+ 'community',
+ 'resource',
+ 'memory',
+ ]);
});
it('should fall back to default when legacy `sidebarSectionOrder` is the default order', () => {
diff --git a/src/store/global/selectors/systemStatus.ts b/src/store/global/selectors/systemStatus.ts
index d0368604076..156d2b5b572 100644
--- a/src/store/global/selectors/systemStatus.ts
+++ b/src/store/global/selectors/systemStatus.ts
@@ -20,6 +20,7 @@ const pagePageSize = (s: GlobalState): number => s.status.pagePageSize || 20;
const taskListViewOptions = (s: GlobalState) =>
s.status.taskListViewOptions || {
groupBy: 'status',
+ hideCompleted: true,
orderBy: 'updatedAt',
orderCompletedByRecency: true,
orderDirection: 'asc',
@@ -29,6 +30,14 @@ const taskListViewOptions = (s: GlobalState) =>
const taskCreateInlineCollapsed = (s: GlobalState): boolean =>
s.status.taskCreateInlineCollapsed ?? false;
+export const DEFAULT_KANBAN_HIDDEN_COLUMNS: string[] = ['done'];
+
+const taskKanbanHiddenColumns = (s: GlobalState): string[] =>
+ s.status.taskKanbanHiddenColumns ?? DEFAULT_KANBAN_HIDDEN_COLUMNS;
+
+const taskKanbanHiddenPanelCollapsed = (s: GlobalState): boolean =>
+ s.status.taskKanbanHiddenPanelCollapsed ?? false;
+
export const DEFAULT_HIDDEN_SECTIONS: string[] = ['memory'];
const hiddenSidebarSections = (s: GlobalState): string[] =>
@@ -36,6 +45,7 @@ const hiddenSidebarSections = (s: GlobalState): string[] =>
export const DEFAULT_SIDEBAR_ITEMS: string[] = [
'pages',
+ 'tasks',
'recents',
'agent',
'community',
@@ -247,6 +257,8 @@ export const systemStatusSelectors = {
portalWidth,
recentPageSize,
taskCreateInlineCollapsed,
+ taskKanbanHiddenColumns,
+ taskKanbanHiddenPanelCollapsed,
taskListViewOptions,
sidebarItems,
sessionGroupKeys,
diff --git a/src/store/task/selectors/detailSelectors.test.ts b/src/store/task/selectors/detailSelectors.test.ts
index 506aef92b46..189cb900e27 100644
--- a/src/store/task/selectors/detailSelectors.test.ts
+++ b/src/store/task/selectors/detailSelectors.test.ts
@@ -155,12 +155,12 @@ describe('taskDetailSelectors', () => {
expect(taskDetailSelectors.canRunActiveTask(state)).toBe(false);
});
- it('should return false when no agentId', () => {
+ it('should return true when no agentId is assigned yet', () => {
const state = createState({
activeTaskId: 'T-1',
- taskDetailMap: { 'T-1': { ...mockDetail, agentId: null } },
+ taskDetailMap: { 'T-1': { ...mockDetail, agentId: null, status: 'backlog' } },
});
- expect(taskDetailSelectors.canRunActiveTask(state)).toBe(false);
+ expect(taskDetailSelectors.canRunActiveTask(state)).toBe(true);
});
});
diff --git a/src/store/task/selectors/detailSelectors.ts b/src/store/task/selectors/detailSelectors.ts
index e906652ef60..5c90d49a636 100644
--- a/src/store/task/selectors/detailSelectors.ts
+++ b/src/store/task/selectors/detailSelectors.ts
@@ -57,7 +57,7 @@ const activeTaskTopicCount = (s: TaskStoreState) => activeTaskDetail(s)?.topicCo
const canRunActiveTask = (s: TaskStoreState): boolean => {
const detail = activeTaskDetail(s);
if (!detail) return false;
- return ['backlog', 'failed', 'paused', 'completed'].includes(detail.status) && !!detail.agentId;
+ return ['backlog', 'failed', 'paused', 'completed'].includes(detail.status);
};
const canPauseActiveTask = (s: TaskStoreState): boolean =>
diff --git a/src/store/task/slices/list/action.ts b/src/store/task/slices/list/action.ts
index 0c9c94301c8..c96ac2e5afb 100644
--- a/src/store/task/slices/list/action.ts
+++ b/src/store/task/slices/list/action.ts
@@ -62,16 +62,24 @@ export class TaskListSliceActionImpl {
this.#set({ viewMode: mode }, false, 'setViewMode');
};
- useFetchTaskGroupList = (agentId?: string, enabled: boolean = true) => {
- if (agentId && this.#get().listAgentId !== agentId) {
- this.#set({ listAgentId: agentId }, false, 'useFetchTaskGroupList/syncAgentId');
+ useFetchTaskGroupList = (
+ options: {
+ agentId?: string;
+ allAgents?: boolean;
+ enabled?: boolean;
+ } = {},
+ ) => {
+ const { agentId, allAgents = false, enabled = true } = options;
+ const effectiveKey = allAgents ? ALL_AGENTS_LIST_KEY : agentId;
+ if (effectiveKey && this.#get().listAgentId !== effectiveKey) {
+ this.#set({ listAgentId: effectiveKey }, false, 'useFetchTaskGroupList/syncAgentId');
}
return useClientDataSWR(
- enabled && agentId ? [FETCH_TASK_GROUP_LIST_KEY, agentId] : null,
- async ([, id]: [string, string]) => {
+ enabled && effectiveKey ? [FETCH_TASK_GROUP_LIST_KEY, effectiveKey] : null,
+ async () => {
return taskService.groupList({
- assigneeAgentId: id,
+ assigneeAgentId: allAgents ? undefined : agentId,
groups: DEFAULT_KANBAN_GROUPS,
});
},