🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(task): start a task by dragging it into In progress on the kanban (#20370)
Arvin Xu8a74e6742dbc
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex 34ef562111c..a4d78736e5f 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -2131,6 +2131,7 @@"taskList.kanban.hiddenColumns": "Hidden columns","taskList.kanban.hideColumn": "Hide column","taskList.kanban.needsInput": "Pending review",+ "taskList.kanban.runFailed": "Couldn't start the task","taskList.kanban.running": "In progress","taskList.kanban.showColumn": "Show column","taskList.mine.assigned": "Assigned",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex d00e6917c74..29330d23d2b 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -2131,6 +2131,7 @@"taskList.kanban.hiddenColumns": "隐藏的分组","taskList.kanban.hideColumn": "隐藏分组","taskList.kanban.needsInput": "待审阅",+ "taskList.kanban.runFailed": "任务启动失败","taskList.kanban.running": "进行中","taskList.kanban.showColumn": "显示分组","taskList.mine.assigned": "分配给我",diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.tsindex fb0344141fb..97ada5060ec 100644--- a/packages/locales/src/default/chat.ts+++ b/packages/locales/src/default/chat.ts@@ -2531,6 +2531,7 @@ export default {'taskList.kanban.hideColumn': 'Hide column','taskList.kanban.needsInput': 'Pending review','taskList.kanban.running': 'In progress',+ 'taskList.kanban.runFailed': "Couldn't start the task",'taskList.kanban.showColumn': 'Show column','taskList.view.board': 'Board','taskList.view.list': 'List',diff --git a/src/features/AgentTasks/AgentTaskList/KanbanBoard.tsx b/src/features/AgentTasks/AgentTaskList/KanbanBoard.tsxindex bc8e4d18c3c..63ec9a7fda4 100644--- a/src/features/AgentTasks/AgentTaskList/KanbanBoard.tsx+++ b/src/features/AgentTasks/AgentTaskList/KanbanBoard.tsx@@ -18,11 +18,14 @@ import { useTranslation } from 'react-i18next';import AsyncBoundary from '@/components/AsyncBoundary';import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';import { usePermission } from '@/hooks/usePermission';+import { useAgentStore } from '@/store/agent';+import { builtinAgentSelectors } from '@/store/agent/selectors';import { useGlobalStore } from '@/store/global';import { systemStatusSelectors } from '@/store/global/selectors';import { useTaskStore } from '@/store/task';import { taskListSelectors } from '@/store/task/selectors';import type { TaskListItem } from '@/store/task/slices/list/initialState';+import { saveToast } from '@/store/utils/saveToast';import { createTaskModal } from '../CreateTaskModal';import type { TaskItemRouteScope } from '../features/AgentTaskItem';@@ -34,6 +37,7 @@ import {buildKanbanColumns,buildKanbanGroupQuery,canDropTaskIntoKanbanColumn,+ findKanbanTask,getKanbanAssigneeUpdate,getKanbanTaskPatch,moveTaskBetweenKanbanGroups,@@ -99,6 +103,9 @@ const KanbanBoard = memo<KanbanBoardProps>((props) => {[isQueryScopeCurrent, taskGroups],);const updateTask = useTaskStore((s) => s.updateTask);+ const runTask = useTaskStore((s) => s.runTask);+ const refreshTaskList = useTaskStore((s) => s.refreshTaskList);+ const inboxAgentId = useAgentStore(builtinAgentSelectors.inboxAgentId);const changeTaskStatus = useTaskStatusChange();const hiddenColumns = useGlobalStore(systemStatusSelectors.taskKanbanHiddenColumns);@@ -125,6 +132,33 @@ const KanbanBoard = memo<KanbanBoardProps>((props) => {[canEditTask],);+ /**+ * Assign-then-run as one action: a failure toast's Retry repeats both steps,+ * so retrying a failed assignment still starts the task.+ */+ const startTask = useCallback(+ (task: TaskListItem, onAssigned?: () => void): Promise<void> => {+ const start = async (afterAssign?: () => void): Promise<void> => {+ const retry = () => {+ start().catch(() => {});+ };+ const current = findKanbanTask(useTaskStore.getState().taskGroups, task.identifier) ?? task;+ if (!current.assigneeAgentId && !current.assigneeUserId && inboxAgentId) {+ await updateTask(current.identifier, { assigneeAgentId: inboxAgentId }, { retry });+ afterAssign?.();+ }+ try {+ await runTask(current.identifier, undefined, { throwOnError: true });+ } catch (error) {+ saveToast(error, { retry, title: t('taskList.kanban.runFailed') });+ throw error;+ }+ };+ return start(onAssigned);+ },+ [inboxAgentId, runTask, t, updateTask],+ );+const handleDragEnd = useCallback(async (event: DragEndEvent) => {setActiveTask(null);@@ -155,7 +189,26 @@ const KanbanBoard = memo<KanbanBoardProps>((props) => {useTaskStore.setState({ taskGroups: nextGroups }, false, 'kanban/optimisticMove');try {- if (groupBy === 'status' && column.targetStatus) {+ if (groupBy === 'status' && column.targetStatus === 'running') {+ // Dropping into "In progress" starts the task, same as "Run now".+ await startTask(task, () => {+ // The assignment refetches the groups, where the task is still in+ // backlog until the run starts — keep the card in "In progress".+ const refreshedGroups = useTaskStore.getState().taskGroups;+ useTaskStore.setState(+ {+ taskGroups: moveTaskBetweenKanbanGroups(+ refreshedGroups,+ findKanbanTask(refreshedGroups, task.identifier) ?? task,+ targetColumnKey,+ patch,+ ),+ },+ false,+ 'kanban/optimisticMove',+ );+ });+ } else if (groupBy === 'status' && column.targetStatus) {const changed = await changeTaskStatus(task.identifier, column.targetStatus);if (!changed) {useTaskStore.setState({ taskGroups: prevGroups }, false, 'kanban/cancelMove');@@ -167,9 +220,11 @@ const KanbanBoard = memo<KanbanBoardProps>((props) => {}} catch {useTaskStore.setState({ taskGroups: prevGroups }, false, 'kanban/revertMove');+ // A failed start may already have persisted the fallback assignee.+ if (column.targetStatus === 'running') void refreshTaskList();}},- [canEditTask, changeTaskStatus, columns, groupBy, updateTask],+ [canEditTask, changeTaskStatus, columns, groupBy, refreshTaskList, startTask, updateTask],);const handleDragCancel = useCallback(() => {diff --git a/src/features/AgentTasks/AgentTaskList/kanbanBoardModel.test.ts b/src/features/AgentTasks/AgentTaskList/kanbanBoardModel.test.tsindex d6b4a950bce..a7b617bbeda 100644--- a/src/features/AgentTasks/AgentTaskList/kanbanBoardModel.test.ts+++ b/src/features/AgentTasks/AgentTaskList/kanbanBoardModel.test.ts@@ -181,6 +181,30 @@ describe('kanbanBoardModel', () => {expect(canDropTaskIntoKanbanColumn(privateTask, 'member', otherMemberColumn)).toBe(false);});+ it('accepts drops into the running column only from runnable statuses', () => {+ const running = buildKanbanColumns([], 'status').find((column) => column.key === 'running')!;++ for (const status of ['backlog', 'completed', 'failed', 'paused'] as const) {+ expect(+ canDropTaskIntoKanbanColumn(task('1', null, null, { status }), 'status', running),+ ).toBe(true);+ }+ for (const status of ['running', 'scheduled', 'canceled'] as const) {+ expect(+ canDropTaskIntoKanbanColumn(task('1', null, null, { status }), 'status', running),+ ).toBe(false);+ }+ expect(getKanbanTaskPatch('status', running)).toEqual({ status: 'running' });+ });++ it('keeps the needs-input column closed to drops', () => {+ const needsInput = buildKanbanColumns([], 'status').find(+ (column) => column.key === 'needsInput',+ )!;++ expect(canDropTaskIntoKanbanColumn(task('1'), 'status', needsInput)).toBe(false);+ });+it('preserves paginated group totals during an optimistic move', () => {const assignedTask = task('1', 'agent-1');const groups = [diff --git a/src/features/AgentTasks/AgentTaskList/kanbanBoardModel.ts b/src/features/AgentTasks/AgentTaskList/kanbanBoardModel.tsindex dfd4c65c8ab..96507193ba6 100644--- a/src/features/AgentTasks/AgentTaskList/kanbanBoardModel.ts+++ b/src/features/AgentTasks/AgentTaskList/kanbanBoardModel.ts@@ -18,9 +18,24 @@ export interface KanbanColumnDefinition {droppable: boolean;groupMeta?: TaskGroupMeta;key: string;- targetStatus: 'backlog' | 'canceled' | 'completed' | null;+ /**+ * `running` is not a plain status write: dropping a task there starts a run,+ * and the server moves it to `running` once the run is dispatched.+ */+ targetStatus: 'backlog' | 'canceled' | 'completed' | 'running' | null;}+/**+ * Statuses a task can be started from — mirrors the detail page's Run button.+ * `scheduled` is excluded because automation owns its next run.+ */+export const KANBAN_RUNNABLE_STATUSES = new Set<TaskStatus>([+ 'backlog',+ 'completed',+ 'failed',+ 'paused',+]);+export interface KanbanAssigneeUpdate {assigneeAgentId?: string | null;assigneeUserId?: string | null;@@ -41,7 +56,7 @@ export const getKanbanColumnHeaderVariant = ({export const STATUS_KANBAN_COLUMNS: KanbanColumnDefinition[] = [{ droppable: true, key: 'backlog', targetStatus: 'backlog' },- { droppable: false, key: 'running', targetStatus: null },+ { droppable: true, key: 'running', targetStatus: 'running' },{ droppable: false, key: 'needsInput', targetStatus: null },{ droppable: true, key: 'done', targetStatus: 'completed' },{ droppable: true, key: 'canceled', targetStatus: 'canceled' },@@ -160,6 +175,9 @@ export const canDropTaskIntoKanbanColumn = (column: KanbanColumnDefinition,): boolean => {if (!column.droppable) return false;+ if (groupBy === 'status' && column.targetStatus === 'running') {+ return KANBAN_RUNNABLE_STATUSES.has(task.status as TaskStatus);+ }if (groupBy !== 'member' || column.groupMeta?.groupBy !== 'member') return true;const targetAssigneeUserId = column.groupMeta.assigneeUserId;@@ -168,6 +186,14 @@ export const canDropTaskIntoKanbanColumn = (return task.visibility !== 'private' || task.createdByUserId === targetAssigneeUserId;};+export const findKanbanTask = (+ taskGroups: TaskGroupItem[],+ identifier: string,+): TaskListItem | undefined =>+ taskGroups+ .flatMap((group) => group.tasks as TaskListItem[])+ .find((item) => item.identifier === identifier);+export const moveTaskBetweenKanbanGroups = (taskGroups: TaskGroupItem[],task: TaskListItem,diff --git a/src/store/task/slices/detail/action.test.ts b/src/store/task/slices/detail/action.test.tsindex 3faf2699314..f079404deff 100644--- a/src/store/task/slices/detail/action.test.ts+++ b/src/store/task/slices/detail/action.test.ts@@ -565,6 +565,28 @@ describe('TaskDetailSliceAction', () => {});});+ it('lets the caller replace the failure toast Retry with its whole action', async () => {+ useTaskStore.setState({+ activeTaskId: 'T-1',+ taskDetailMap: { 'T-1': { identifier: 'T-1', instruction: 'x', status: 'backlog' } },+ });+ vi.mocked(taskService.update).mockRejectedValueOnce(new Error('fail'));+ const retry = vi.fn();++ await expect(+ useTaskStore.getState().updateTask('T-1', { assigneeAgentId: 'agt_inbox' }, { retry }),+ ).rejects.toThrow('fail');++ const toastOptions = vi.mocked(toast.error).mock.calls.at(-1)?.[0];+ if (!toastOptions || typeof toastOptions === 'string') {+ throw new Error('Expected the failed save toast to expose a Retry action.');+ }+ toastOptions.actions?.[0]?.onClick?.();++ expect(retry).toHaveBeenCalledTimes(1);+ expect(taskService.update).toHaveBeenCalledTimes(1);+ });+it('should refresh the cached parent on failure when updating from a subtask detail page', async () => {const { mutate } = await import('@/libs/swr');useTaskStore.setState({diff --git a/src/store/task/slices/detail/action.ts b/src/store/task/slices/detail/action.tsindex f4bde34ea94..829942b5b48 100644--- a/src/store/task/slices/detail/action.ts+++ b/src/store/task/slices/detail/action.ts@@ -64,6 +64,12 @@ export interface TaskUpdateOptions {* not resolve members itself (that source is a business-layer hook).*/optimisticAssignee?: TaskDetailActivityAuthor;+ /**+ * Replaces the failure toast's Retry when this update is one step of a larger+ * action (e.g. assign-then-run), so Retry repeats the whole action instead of+ * only this write.+ */+ retry?: () => void;/*** The mounted editor marks its own autosaves so they do not request an* external-content reload. Tool calls and refetches are authoritative by default.@@ -538,11 +544,13 @@ export class TaskDetailSliceActionImpl {* content. Treating Retry as another editor echo would update only the* Store and server, leaving the mounted editor on the rollback snapshot.*/- const retry = () =>- void this.#get().updateTask(id, data, {- ...options,- source: 'external',- });+ const retry =+ options?.retry ??+ (() =>+ void this.#get().updateTask(id, data, {+ ...options,+ source: 'external',+ }));saveToast(error, { retry });},setStatus: (status) => this.#get().internal_setTaskSaveStatus(id, status),