π€― 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-board): create tasks from priority and agent columns (#21000)
Rdmclin2eb0ddcdbd1fe
diff --git a/src/features/AgentTasks/AgentTaskList/KanbanBoard.tsx b/src/features/AgentTasks/AgentTaskList/KanbanBoard.tsxindex 9ec7e3e0c90..a86b360ab05 100644--- a/src/features/AgentTasks/AgentTaskList/KanbanBoard.tsx+++ b/src/features/AgentTasks/AgentTaskList/KanbanBoard.tsx@@ -16,7 +16,6 @@ import { memo, useCallback, useMemo, useState } from 'react';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';@@ -27,11 +26,9 @@ 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';import AgentTaskItem from '../features/AgentTaskItem';import { useTaskStatusChange } from '../features/useTaskStatusChange';-import { taskDetailPath } from '../shared/taskDetailPath';import HiddenColumnsPanel from './HiddenColumnsPanel';import {buildKanbanColumns,@@ -39,6 +36,7 @@ import {canDropTaskIntoKanbanColumn,findKanbanTask,getKanbanAssigneeUpdate,+ getKanbanColumnCreateDefaults,getKanbanTaskPatch,moveTaskBetweenKanbanGroups,normalizeKanbanGroupBy,@@ -78,7 +76,6 @@ interface KanbanBoardProps {const KanbanBoard = memo<KanbanBoardProps>((props) => {const { agentId, emptyDescription, myTaskScope, options, projectId, routeScope } = props;const { t } = useTranslation('chat');- const navigate = useWorkspaceAwareNavigate();const { allowed: canEditTask } = usePermission('create_content');const groupBy = normalizeKanbanGroupBy(options.groupBy);const excludeStatuses = options.hideCompleted ? HIDDEN_WHEN_COMPLETED_STATUSES : undefined;@@ -229,19 +226,6 @@ const KanbanBoard = memo<KanbanBoardProps>((props) => {setActiveTask(null);}, []);- const handleCreateTask = useCallback(() => {- if (!canEditTask) return;- createTaskModal({- agentId,- lockAssignee: !!agentId,- projectId,- onCreated: (task) => {- navigate(taskDetailPath(task.identifier, agentId ? task.agentId : undefined, task.name));- },- showInlineToggle: false,- });- }, [agentId, canEditTask, navigate, projectId]);-const handleHideColumn = useCallback((columnKey: string) => {const next = Array.from(new Set([...hiddenColumns, columnKey]));@@ -331,30 +315,31 @@ const KanbanBoard = memo<KanbanBoardProps>((props) => {<Flexbox horizontal className={styles.board}>{visibleColumns.map((col) => {const group = currentTaskGroups.find((item) => item.key === col.key);+ // "My tasks" offers no create entry (its list view has none either):+ // a task created there carries neither the member assignment nor β+ // under `created` β any guarantee it lands in the column it was+ // started from.+ const createDefaults = myTaskScope+ ? undefined+ : getKanbanColumnCreateDefaults(groupBy, col);const droppable =canEditTask &&col.droppable &&(!activeTask || canDropTaskIntoKanbanColumn(activeTask, groupBy, col));return (<KanbanColumn+ agentId={agentId}columnKey={col.key}+ createDefaults={canEditTask ? createDefaults : undefined}droppable={droppable}groupBy={groupBy}groupMeta={col.groupMeta}key={col.key}+ projectId={projectId}routeScope={routeScope}tasks={(group?.tasks ?? []) as TaskListItem[]}total={group?.total ?? 0}onHide={groupBy === 'status' ? () => handleHideColumn(col.key) : undefined}- onCreate={- // "My tasks" offers no create entry (its list view has none- // either): a task created here carries neither the member- // assignment nor β under `created` β any guarantee it lands- // in the column it was started from.- groupBy === 'status' && col.key === 'backlog' && !myTaskScope- ? handleCreateTask- : undefined- }/>);})}diff --git a/src/features/AgentTasks/AgentTaskList/KanbanColumn.tsx b/src/features/AgentTasks/AgentTaskList/KanbanColumn.tsxindex 4f314b23d54..c6299c5f6e9 100644--- a/src/features/AgentTasks/AgentTaskList/KanbanColumn.tsx+++ b/src/features/AgentTasks/AgentTaskList/KanbanColumn.tsx@@ -4,7 +4,7 @@ import { type DropdownItem, DropdownMenu, Icon } from '@lobehub/ui';import { ActionIcon, Skeleton, Text } from '@lobehub/ui/base-ui';import { createStaticStyles, cx } from 'antd-style';import { EyeOff, MoreHorizontal, Plus } from 'lucide-react';-import { memo, useMemo } from 'react';+import { memo, useCallback, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';import type { TaskKanbanGroupBy, TaskListItem } from '@/store/task/slices/list/initialState';@@ -12,7 +12,8 @@ import type { TaskKanbanGroupBy, TaskListItem } from '@/store/task/slices/list/iimport type { TaskItemRouteScope } from '../features/AgentTaskItem';import AgentTaskItem from '../features/AgentTaskItem';import TaskStatusIcon from '../features/TaskStatusIcon';-import { getKanbanColumnHeaderVariant } from './kanbanBoardModel';+import { getKanbanColumnHeaderVariant, type KanbanColumnCreateDefaults } from './kanbanBoardModel';+import KanbanInlineCreate from './KanbanInlineCreate';import type { TaskGroupMeta } from './listViewOptions';import TaskGroupLabel from './TaskGroupLabel';import TaskItemSkeleton from './TaskItemSkeleton';@@ -67,9 +68,15 @@ const DraggableTaskCard = memo<{ routeScope?: TaskItemRouteScope; task: TaskList);const styles = createStaticStyles(({ css, cssVar }) => ({+ // The empty-column add pill stays hidden until the column is hovered, or+ // keyboard focus lands inside it.action: css`opacity: 0;transition: opacity 0.2s;++ &:focus-within {+ opacity: 1;+ }`,addPill: css`cursor: pointer;@@ -174,13 +181,17 @@ export const COLUMN_STATUS_ICON: Record<string, TaskStatus> = {};interface KanbanColumnProps {+ /** Board scope agent, inherited by tasks created from this column. */+ agentId?: string;columnKey: string;+ /** Offers the in-column create entry, pinning these fields on the new task. */+ createDefaults?: KanbanColumnCreateDefaults;droppable: boolean;groupBy: TaskKanbanGroupBy;groupMeta?: TaskGroupMeta;loading?: boolean;- onCreate?: () => void;onHide?: () => void;+ projectId?: string;routeScope?: TaskItemRouteScope;tasks: TaskListItem[];total: number;@@ -188,13 +199,15 @@ interface KanbanColumnProps {const KanbanColumn = memo<KanbanColumnProps>(({+ agentId,columnKey,+ createDefaults,droppable,groupBy,groupMeta,loading,- onCreate,onHide,+ projectId,routeScope,tasks,total,@@ -215,6 +228,11 @@ const KanbanColumn = memo<KanbanColumnProps>(});const isDragActive = !!active;+ const [creating, setCreating] = useState(false);+ const openCreate = useCallback(() => setCreating(true), []);+ const closeCreate = useCallback(() => setCreating(false), []);+ const canCreate = !!createDefaults;+// Don't highlight if dragging a card that's already in this columnconst activeTask = active?.data.current?.task as TaskListItem | undefined;const isFromThisColumn =@@ -279,17 +297,25 @@ const KanbanColumn = memo<KanbanColumnProps>(<ActionIcon icon={MoreHorizontal} size={'small'} /></DropdownMenu>)}- {onCreate && (+ {canCreate && (<ActionIconicon={Plus}size={'small'}title={t('taskList.kanban.addTask')}- onClick={onCreate}+ onClick={openCreate}/>)}</div></div><div className={styles.body}>+ {creating && createDefaults && (+ <KanbanInlineCreate+ agentId={agentId}+ defaults={createDefaults}+ projectId={projectId}+ onClose={closeCreate}+ />+ )}{loading ? (Array.from({ length: 3 }).map((_, index) => (<div className={cardStyles.card} key={`kanban-skeleton-${columnKey}-${index}`}>@@ -300,8 +326,12 @@ const KanbanColumn = memo<KanbanColumnProps>(tasks.map((task) => (<DraggableTaskCard key={task.identifier} routeScope={routeScope} task={task} />))- ) : onCreate ? (- <div className={styles.addPill} title={t('taskList.kanban.addTask')} onClick={onCreate}>+ ) : creating ? null : canCreate ? (+ <div+ className={cx(styles.addPill, styles.action, 'kanban-col-action')}+ title={t('taskList.kanban.addTask')}+ onClick={openCreate}+ ><Icon icon={Plus} size={16} /></div>) : (diff --git a/src/features/AgentTasks/AgentTaskList/KanbanInlineCreate.tsx b/src/features/AgentTasks/AgentTaskList/KanbanInlineCreate.tsxnew file mode 100644index 00000000000..25dfa28a50e--- /dev/null+++ b/src/features/AgentTasks/AgentTaskList/KanbanInlineCreate.tsx@@ -0,0 +1,171 @@+'use client';++import { Flexbox } from '@lobehub/ui';+import { Button, Text, TextArea, toast } from '@lobehub/ui/base-ui';+import { createStaticStyles } from 'antd-style';+import { type KeyboardEvent, memo, useCallback, useState } from 'react';+import { useTranslation } from 'react-i18next';++import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';+import { useTaskStore } from '@/store/task';++import AssigneeAvatar from '../features/AssigneeAvatar';+import TaskPriorityTag from '../features/TaskPriorityTag';+import { useAgentDisplayMeta } from '../shared/useAgentDisplayMeta';+import { useAgentVisibility } from '../shared/useAgentVisibility';+import type { KanbanColumnCreateDefaults } from './kanbanBoardModel';++const PRIORITY_LABEL_KEYS = ['none', 'urgent', 'high', 'normal', 'low'] as const;++const styles = createStaticStyles(({ css, cssVar }) => ({+ chip: css`+ display: inline-flex;+ gap: 6px;+ align-items: center;++ height: 24px;+ padding-inline: 8px;+ border-radius: ${cssVar.borderRadius};++ background: ${cssVar.colorFillTertiary};+ `,+ container: css`+ flex: none;++ padding: 8px;+ border: 1px solid ${cssVar.colorPrimaryBorder};+ 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%);+ `,+}));++interface KanbanInlineCreateProps {+ /** Board scope agent, used when the column does not pin one. */+ agentId?: string;+ defaults: KanbanColumnCreateDefaults;+ onClose: () => void;+ projectId?: string;+}++/**+ * Quick-create composer rendered inside a Kanban column. The column's pinned+ * fields are shown as read-only chips, so the new task lands in this column.+ */+const KanbanInlineCreate = memo<KanbanInlineCreateProps>(+ ({ agentId, defaults, onClose, projectId }) => {+ const { t } = useTranslation(['chat', 'common']);+ const createTask = useTaskStore((s) => s.createTask);+ const activeWorkspaceId = useActiveWorkspaceId();++ const [title, setTitle] = useState('');+ const [submitting, setSubmitting] = useState(false);++ const assigneeAgentId = defaults.assigneeAgentId ?? agentId;+ const agentMeta = useAgentDisplayMeta(defaults.assigneeAgentId);+ // A private agent can only run private tasks; otherwise workspace tasks+ // default to workspace-visible, same as the create modal.+ const isPrivateAgent = useAgentVisibility(assigneeAgentId) === 'private';++ const handleSubmit = useCallback(async () => {+ const name = title.trim();+ if (!name || submitting) return;++ setSubmitting(true);+ try {+ const result = await createTask({+ assigneeAgentId,+ instruction: name,+ name,+ priority: defaults.priority || undefined,+ projectId,+ visibility: activeWorkspaceId ? (isPrivateAgent ? 'private' : 'public') : undefined,+ });+ if (result) onClose();+ } catch {+ toast.error(t('createTask.createFailed'));+ } finally {+ setSubmitting(false);+ }+ }, [+ activeWorkspaceId,+ assigneeAgentId,+ createTask,+ defaults.priority,+ isPrivateAgent,+ onClose,+ projectId,+ submitting,+ t,+ title,+ ]);++ const handleKeyDown = useCallback(+ (e: KeyboardEvent<HTMLTextAreaElement>) => {+ if (e.nativeEvent.isComposing) return;+ if (e.key === 'Enter' && !e.shiftKey) {+ e.preventDefault();+ void handleSubmit();+ } else if (e.key === 'Escape') {+ e.preventDefault();+ onClose();+ }+ },+ [handleSubmit, onClose],+ );++ return (+ <Flexbox className={styles.container} data-testid={'kanban-inline-create'} gap={8}>+ <TextArea+ autoFocus+ autoSize={{ maxRows: 6, minRows: 1 }}+ disabled={submitting}+ placeholder={t('createTask.titlePlaceholder')}+ value={title}+ variant={'borderless'}+ onChange={(e) => setTitle(e.target.value)}+ onKeyDown={handleKeyDown}+ />+ <Flexbox horizontal align={'center'} gap={6} justify={'space-between'}>+ <Flexbox horizontal align={'center'} gap={4} style={{ minWidth: 0 }}>+ {defaults.priority !== undefined && (+ <span className={styles.chip}>+ <TaskPriorityTag disableDropdown priority={defaults.priority} size={14} />+ <Text fontSize={12}>+ {t(`taskDetail.priority.${PRIORITY_LABEL_KEYS[defaults.priority]}` as never)}+ </Text>+ </span>+ )}+ {defaults.assigneeAgentId && (+ <span className={styles.chip}>+ <AssigneeAvatar agentId={defaults.assigneeAgentId} size={16} />+ <Text ellipsis fontSize={12}>+ {agentMeta?.title}+ </Text>+ </span>+ )}+ </Flexbox>+ <Flexbox horizontal gap={4}>+ <Button size={'small'} type={'text'} onClick={onClose}>+ {t('cancel', { ns: 'common' })}+ </Button>+ <Button+ disabled={!title.trim()}+ loading={submitting}+ size={'small'}+ type={'primary'}+ onClick={() => void handleSubmit()}+ >+ {t('createTask.submit')}+ </Button>+ </Flexbox>+ </Flexbox>+ </Flexbox>+ );+ },+);++export default KanbanInlineCreate;diff --git a/src/features/AgentTasks/AgentTaskList/kanbanBoardModel.test.ts b/src/features/AgentTasks/AgentTaskList/kanbanBoardModel.test.tsindex a7b617bbeda..a6ebcb92059 100644--- a/src/features/AgentTasks/AgentTaskList/kanbanBoardModel.test.ts+++ b/src/features/AgentTasks/AgentTaskList/kanbanBoardModel.test.ts@@ -7,6 +7,7 @@ import {buildKanbanGroupQuery,canDropTaskIntoKanbanColumn,getKanbanAssigneeUpdate,+ getKanbanColumnCreateDefaults,getKanbanColumnHeaderVariant,getKanbanTaskPatch,moveTaskBetweenKanbanGroups,@@ -272,4 +273,52 @@ describe('kanbanBoardModel', () => {});});});++ describe('getKanbanColumnCreateDefaults', () => {+ it('pins the column priority on tasks created from a priority column', () => {+ const groups = [+ { ...group('priority:2', []), priority: 2 },+ { ...group('priority:0', []), priority: 0 },+ ] as TaskGroupItem[];+ const columns = buildKanbanColumns(groups, 'priority');++ expect(+ columns.map((column) => getKanbanColumnCreateDefaults('priority', column)?.priority),+ ).toEqual([2, 0]);+ });++ it('offers status creation only from the backlog column, without pinned fields', () => {+ const columns = buildKanbanColumns([], 'status');++ expect(columns.map((column) => getKanbanColumnCreateDefaults('status', column))).toEqual([+ {},+ undefined,+ undefined,+ undefined,+ undefined,+ ]);+ });++ it('pins the column agent on tasks created from an agent column', () => {+ const [agentColumn] = buildKanbanColumns(+ [group('assignee:agent-1', [], 'agent-1')],+ 'assignee',+ );++ expect(getKanbanColumnCreateDefaults('assignee', agentColumn)).toEqual({+ assigneeAgentId: 'agent-1',+ });+ });++ it('offers no create entry on the unassigned and member columns', () => {+ const [unassignedColumn] = buildKanbanColumns([group('assignee:unassigned', [])], 'assignee');+ const [memberColumn] = buildKanbanColumns(+ [group('member:user-1', [], undefined, 'user-1')],+ 'member',+ );++ expect(getKanbanColumnCreateDefaults('assignee', unassignedColumn)).toBeUndefined();+ expect(getKanbanColumnCreateDefaults('member', memberColumn)).toBeUndefined();+ });+ });});diff --git a/src/features/AgentTasks/AgentTaskList/kanbanBoardModel.ts b/src/features/AgentTasks/AgentTaskList/kanbanBoardModel.tsindex 96507193ba6..7c63b26926f 100644--- a/src/features/AgentTasks/AgentTaskList/kanbanBoardModel.ts+++ b/src/features/AgentTasks/AgentTaskList/kanbanBoardModel.ts@@ -169,6 +169,32 @@ export const getKanbanTaskPatch = (}};+/** Pinned on the new task, so it lands in the column it was created from. */+export interface KanbanColumnCreateDefaults {+ assigneeAgentId?: string;+ priority?: number;+}++/**+ * Whether a column offers a create entry, and what the new task is pinned to.+ * `undefined` means no entry: a task created there could not be guaranteed to+ * land in that column.+ */+export const getKanbanColumnCreateDefaults = (+ groupBy: TaskKanbanGroupBy,+ column: KanbanColumnDefinition,+): KanbanColumnCreateDefaults | undefined => {+ if (groupBy === 'status' && column.key === 'backlog') return {};+ if (groupBy === 'priority' && column.groupMeta?.groupBy === 'priority') {+ return { priority: column.groupMeta.priority ?? 0 };+ }+ // The unassigned column has no entry: the modal cannot pin "no agent".+ if (groupBy === 'assignee' && column.groupMeta?.groupBy === 'assignee') {+ const { assigneeId } = column.groupMeta;+ return assigneeId ? { assigneeAgentId: assigneeId } : undefined;+ }+};+export const canDropTaskIntoKanbanColumn = (task: TaskListItem,groupBy: TaskKanbanGroupBy,