🤯 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(tasks/brief): subtask avatar polish, brief actions revamp & task drawer Gateway reconnect (#14208)
Arvin Xu92a848c69c35
diff --git a/locales/en-US/home.json b/locales/en-US/home.jsonindex 1ebf850fb09..7122b8ba0be 100644--- a/locales/en-US/home.json+++ b/locales/en-US/home.json@@ -5,12 +5,14 @@"agentSelection.search": "No matching agents found","brief.action.acknowledge": "Acknowledge","brief.action.approve": "Approve",+ "brief.action.confirmDone": "Confirm complete","brief.action.feedback": "Feedback","brief.action.retry": "Retry","brief.addFeedback": "Share feedback","brief.collapse": "Show less","brief.commentPlaceholder": "Share your feedback...","brief.commentSubmit": "Submit feedback",+ "brief.editResult": "Edit","brief.expandAll": "Show more","brief.feedbackSent": "Feedback shared","brief.resolved": "Marked as resolved",diff --git a/locales/zh-CN/home.json b/locales/zh-CN/home.jsonindex 796ab14dc8d..3d60e3be749 100644--- a/locales/zh-CN/home.json+++ b/locales/zh-CN/home.json@@ -5,12 +5,14 @@"agentSelection.search": "未找到匹配的助理","brief.action.acknowledge": "确认","brief.action.approve": "批准",+ "brief.action.confirmDone": "确认完成","brief.action.feedback": "反馈","brief.action.retry": "重试","brief.addFeedback": "分享反馈","brief.collapse": "收起","brief.commentPlaceholder": "分享你的反馈…","brief.commentSubmit": "提交反馈",+ "brief.editResult": "编辑","brief.expandAll": "展开全部","brief.feedbackSent": "反馈已提交","brief.resolved": "已标记为已解决",diff --git a/packages/database/src/models/recent.ts b/packages/database/src/models/recent.tsindex dc1c95077a9..966ae6d5e90 100644--- a/packages/database/src/models/recent.ts+++ b/packages/database/src/models/recent.ts@@ -23,6 +23,9 @@ export class RecentModel {}queryRecent = async (limit: number = 10): Promise<RecentDbItem[]> => {+ // System-trigger topics live in their own surfaces (Task Manager, cron,+ // eval, task runs) and would clutter the main "Recent" sidebar. Mirrors+ // `MAIN_SIDEBAR_EXCLUDE_TRIGGERS` in `src/const/topic.ts`.const query = sql`SELECT * FROM (SELECT@@ -41,6 +44,10 @@ export class RecentModel {OR ${agents.slug} = 'inbox'OR (${topics.groupId} IS NULL AND ${agents.virtual} != true))+ AND (+ ${topics.trigger} IS NULL+ OR ${topics.trigger} NOT IN ('cron', 'eval', 'task_manager', 'task')+ )UNION ALLdiff --git a/packages/database/src/models/taskTopic.ts b/packages/database/src/models/taskTopic.tsindex 20771cfd7e2..97e0442e0f1 100644--- a/packages/database/src/models/taskTopic.ts+++ b/packages/database/src/models/taskTopic.ts@@ -181,6 +181,7 @@ export class TaskTopicModel {.select({createdAt: taskTopics.createdAt,handoff: taskTopics.handoff,+ metadata: topics.metadata,seq: taskTopics.seq,status: taskTopics.status,title: topics.title,diff --git a/packages/types/src/task/index.ts b/packages/types/src/task/index.tsindex 478c97432d5..d74773ba95b 100644--- a/packages/types/src/task/index.ts+++ b/packages/types/src/task/index.ts@@ -210,6 +210,17 @@ export interface TaskDetailActivity {resolvedAction?: string | null;resolvedAt?: string | null;resolvedComment?: string | null;+ /**+ * Topic-only: currently running Gateway operation, mirrored from+ * `topics.metadata.runningOperation`. Lets the task topic drawer establish+ * a Gateway WebSocket reconnection without a separate topic lookup.+ */+ runningOperation?: {+ assistantMessageId: string;+ operationId: string;+ scope?: string;+ threadId?: string | null;+ } | null;seq?: number | null;status?: string | null;summary?: string;diff --git a/src/const/topic.ts b/src/const/topic.tsindex 4630ae395f3..1d4ef80aada 100644--- a/src/const/topic.ts+++ b/src/const/topic.ts@@ -1,11 +1,14 @@/*** Well-known `topic.trigger` values used to segment the same agent's topics* across different panels (Task Manager vs. main chat).+ *+ * `RunTask` is what `TaskRunnerService` writes when starting an agent run for+ * a task; the literal `'task'` is intentional and matches existing DB rows.*/export const TopicTrigger = {Cron: 'cron',Eval: 'eval',- RunTask: 'run_task',+ RunTask: 'task',TaskManager: 'task_manager',} as const;diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskSubtasks.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskSubtasks.tsxindex c169e3845fe..4560df7d996 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 { ActionIcon, Avatar, Block, ContextMenuTrigger, Flexbox, Icon, Text } from '@lobehub/ui';+import { ActionIcon, 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';@@ -12,6 +12,8 @@ import { useTaskStore } from '@/store/task';import { taskDetailSelectors } from '@/store/task/selectors';import CreateTaskInlineEntry from '../AgentTaskList/CreateTaskInlineEntry';+import AssigneeAgentSelector from '../features/AssigneeAgentSelector';+import AssigneeAvatar from '../features/AssigneeAvatar';import TaskPriorityTag from '../features/TaskPriorityTag';import TaskStatusTag from '../features/TaskStatusTag';import TaskSubtaskProgressTag from '../features/TaskSubtaskProgressTag';@@ -78,13 +80,15 @@ const SubtaskTitle = memo<{ task: TaskDetailSubtask }>(({ task }) => {status: task.status,});+ const isRunning = status === 'running';+return (<ContextMenuTrigger items={items} onContextMenu={onContextMenu}><Flexboxhorizontalalign="center"gap={8}- style={{ lineHeight: 1, minWidth: 0, overflow: 'hidden' }}+ style={{ lineHeight: 1, minWidth: 0, overflow: 'hidden', width: '100%' }}><spanstyle={{ alignItems: 'center', display: 'inline-flex', flex: 'none' }}@@ -101,21 +105,22 @@ const SubtaskTitle = memo<{ task: TaskDetailSubtask }>(({ task }) => {<Text ellipsis fontSize={13} style={{ flex: 1, minWidth: 0 }}>{task.name || task.identifier}</Text>- {task.assignee && (+ <AssigneeAgentSelector+ currentAgentId={task.assignee?.id ?? null}+ disabled={isRunning}+ taskIdentifier={task.identifier}+ ><span- style={{ alignItems: 'center', display: 'inline-flex', flex: 'none' }}- onClick={(e) => e.stopPropagation()}+ style={{+ alignItems: 'center',+ cursor: isRunning ? 'not-allowed' : 'pointer',+ display: 'inline-flex',+ flex: 'none',+ }}>- <Avatar- avatar={task.assignee.avatar ?? ''}- background={task.assignee.backgroundColor || cssVar.colorBgContainer}- shape="circle"- size={18}- title={task.assignee.title ?? ''}- variant="outlined"- />+ <AssigneeAvatar agentId={task.assignee?.id} size={18} /></span>- )}+ </AssigneeAgentSelector></Flexbox></ContextMenuTrigger>);diff --git a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsxindex 9dafab1607c..8522e691d1d 100644--- a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx+++ b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx@@ -7,6 +7,7 @@ import { memo, useCallback, useMemo } from 'react';import { useTranslation } from 'react-i18next';import { ChatList, ConversationProvider, MessageItem } from '@/features/Conversation';+import { useGatewayReconnect } from '@/hooks/useGatewayReconnect';import { useOperationState } from '@/hooks/useOperationState';import { useChatStore } from '@/store/chat';import { messageMapKey } from '@/store/chat/utils/messageMapKey';@@ -36,6 +37,11 @@ const TopicChatDrawerBody = memo<TopicChatDrawerBodyProps>(({ agentId, topicId }const replaceMessages = useChatStore((s) => s.replaceMessages);const operationState = useOperationState(context);+ const runningOperation = useTaskStore(+ (s) => taskActivitySelectors.activeDrawerTopicActivity(s)?.runningOperation,+ );+ useGatewayReconnect(topicId, runningOperation);+const itemContent = useCallback((index: number, id: string) => (<MessageItemdiff --git a/src/features/DailyBrief/BriefCardActions.tsx b/src/features/DailyBrief/BriefCardActions.tsxindex a0afa69a61e..d3531a7e6e3 100644--- a/src/features/DailyBrief/BriefCardActions.tsx+++ b/src/features/DailyBrief/BriefCardActions.tsx@@ -28,7 +28,7 @@ type CommentMode = { type: 'feedback' } | { key: string; type: 'comment' };const SuccessTag = memo<{ label: string }>(({ label }) => (<Flexbox horizontal align={'center'} gap={4}>- <Icon icon={Check} size={14} />+ <Icon color={cssVar.colorTextQuaternary} icon={Check} size={14} /><Text className={styles.resolvedTag}>{label}</Text></Flexbox>));@@ -58,15 +58,20 @@ const BriefCardActions = memo<BriefCardActionsProps>(return () => clearTimeout(timer);}, [feedbackSent]);- const actions = actionsProp ?? DEFAULT_BRIEF_ACTIONS[briefType] ?? [];+ const isResult = briefType === 'result';++ const actions: BriefAction[] = isResult+ ? [{ key: 'approve', label: t('brief.action.confirmDone'), type: 'resolve' }]+ : (actionsProp ?? DEFAULT_BRIEF_ACTIONS[briefType] ?? []);const getActionLabel = useCallback((action: BriefAction) => {+ if (isResult && action.key === 'approve') return t('brief.action.confirmDone');const i18nKey = `brief.action.${action.key}`;const translated = t(i18nKey, { defaultValue: '' });return !translated || translated === i18nKey ? action.label : translated;},- [t],+ [isResult, t],);const handleResolve = useCallback(@@ -119,12 +124,18 @@ const BriefCardActions = memo<BriefCardActionsProps>(.filter((a) => a.type !== 'comment').slice(1).reverse();+ const showEditButton = !!taskId && (isResult || !!commentActions);+ const editTooltip = isResult+ ? t('brief.editResult')+ : commentActions+ ? getActionLabel(commentActions) || t('brief.addFeedback')+ : t('brief.addFeedback');return (<Flexbox horizontal align={'center'} gap={8} justify={'flex-end'} wrap={'wrap'}><Flexbox horizontal align={'center'} gap={8}>- {taskId && commentActions && (- <Tooltip title={getActionLabel(commentActions) || t('brief.addFeedback')}>+ {showEditButton && (+ <Tooltip title={editTooltip}><ButtonclassName={'brief-comment-btn'}icon={SquarePen}diff --git a/src/features/DailyBrief/BriefIcon.tsx b/src/features/DailyBrief/BriefIcon.tsxindex 2b5bbd60346..b9873ca6c4e 100644--- a/src/features/DailyBrief/BriefIcon.tsx+++ b/src/features/DailyBrief/BriefIcon.tsx@@ -2,25 +2,25 @@ import { type BriefType } from '@lobechat/types';import { Block, Icon } from '@lobehub/ui';import { cssVar } from 'antd-style';import type { CircleDot } from 'lucide-react';-import { CheckCheckIcon, EyeIcon, Lightbulb, PencilRulerIcon, SirenIcon } from 'lucide-react';+import { CheckCheckIcon, EyeIcon, HandIcon, Lightbulb, SirenIcon } from 'lucide-react';import { memo } from 'react';const BRIEF_TYPE_ICON: Record<BriefType, typeof CircleDot> = {- decision: PencilRulerIcon,+ decision: HandIcon,error: SirenIcon,insight: EyeIcon,result: CheckCheckIcon,};const BRIEF_TYPE_COLOR: Record<BriefType, string | undefined> = {- decision: cssVar.colorWarning,+ decision: cssVar.colorInfo,error: cssVar.colorError,insight: cssVar.colorInfo,result: cssVar.colorSuccess,} as const;const BRIEF_TYPE_COLOR_BG: Record<BriefType, string | undefined> = {- decision: cssVar.colorWarningBgHover,+ decision: cssVar.colorInfoBgHover,error: cssVar.colorErrorBgHover,insight: cssVar.colorInfoBgHover,result: cssVar.colorSuccessBgHover,diff --git a/src/features/DailyBrief/__tests__/BriefCardActions.test.tsx b/src/features/DailyBrief/__tests__/BriefCardActions.test.tsxindex dce4c336b89..77240052672 100644--- a/src/features/DailyBrief/__tests__/BriefCardActions.test.tsx+++ b/src/features/DailyBrief/__tests__/BriefCardActions.test.tsx@@ -15,6 +15,8 @@ vi.mock('react-i18next', () => ({'cancel': 'Cancel','brief.commentPlaceholder': 'Share your feedback...','brief.commentSubmit': 'Submit feedback',+ 'brief.action.confirmDone': 'Confirm complete',+ 'brief.editResult': 'Edit',};return map[key] || key;},@@ -107,8 +109,34 @@ describe('BriefCardActions', () => {});it('should fallback to DEFAULT_BRIEF_ACTIONS when actions prop is null', () => {- render(<BriefCardActions actions={null} briefId="brief-2" briefType="result" />);+ render(<BriefCardActions actions={null} briefId="brief-2" briefType="decision" />);- expect(screen.getByText('✅ 通过')).toBeInTheDocument();+ expect(screen.getByText('✅ 确认')).toBeInTheDocument();+ });++ it('should hardcode primary action label to "Confirm complete" for result briefs', () => {+ render(+ <BriefCardActions+ actions={[{ key: 'approve', label: '✅ Custom approve', type: 'resolve' }]}+ briefId="brief-3"+ briefType="result"+ />,+ );++ expect(screen.getByText('Confirm complete')).toBeInTheDocument();+ expect(screen.queryByText('✅ Custom approve')).not.toBeInTheDocument();+ });++ it('should always show the Edit button for result briefs when taskId is set', () => {+ const { container } = render(+ <BriefCardActions+ actions={[{ key: 'approve', label: '✅ Custom', type: 'resolve' }]}+ briefId="brief-4"+ briefType="result"+ taskId="task-1"+ />,+ );++ expect(container.querySelector('.brief-comment-btn')).toBeInTheDocument();});});diff --git a/src/hooks/useGatewayReconnect.ts b/src/hooks/useGatewayReconnect.tsnew file mode 100644index 00000000000..69c0cb49fd2--- /dev/null+++ b/src/hooks/useGatewayReconnect.ts@@ -0,0 +1,49 @@+import useSWR from 'swr';++import { useChatStore } from '@/store/chat';++interface RunningOperation {+ assistantMessageId: string;+ operationId: string;+ scope?: string;+ threadId?: string | null;+}++/**+ * Auto-reconnect to a running Gateway operation on the given topic.+ *+ * The caller sources `runningOperation` itself — the chat-store topic map+ * (main agent) and the task-detail activity (task drawer) live in different+ * stores, so this hook stays source-agnostic.+ *+ * SWR key is the operationId, so the same operation deduplicates and only+ * one reconnect attempt fires per op.+ */+export const useGatewayReconnect = (+ topicId: string | null | undefined,+ runningOperation: RunningOperation | null | undefined,+) => {+ const isGatewayModeEnabled = useChatStore((s) => s.isGatewayModeEnabled);++ useSWR(+ runningOperation && topicId && isGatewayModeEnabled()+ ? ['reconnectGateway', runningOperation.operationId]+ : null,+ async () => {+ if (!runningOperation || !topicId) return;++ await useChatStore.getState().reconnectToGatewayOperation({+ assistantMessageId: runningOperation.assistantMessageId,+ operationId: runningOperation.operationId,+ scope: runningOperation.scope,+ threadId: runningOperation.threadId,+ topicId,+ });+ },+ {+ revalidateIfStale: false,+ revalidateOnFocus: false,+ revalidateOnReconnect: false,+ },+ );+};diff --git a/src/locales/default/home.ts b/src/locales/default/home.tsindex 0d410bf3d16..20af70631a1 100644--- a/src/locales/default/home.ts+++ b/src/locales/default/home.ts@@ -7,10 +7,12 @@ export default {'brief.action.acknowledge': 'Acknowledge','brief.action.approve': 'Approve','brief.action.feedback': 'Feedback',+ 'brief.action.confirmDone': 'Confirm complete','brief.action.retry': 'Retry','brief.collapse': 'Show less','brief.commentPlaceholder': 'Share your feedback...','brief.commentSubmit': 'Submit feedback',+ 'brief.editResult': 'Edit','brief.expandAll': 'Show more','brief.feedbackSent': 'Feedback shared','brief.resolved': 'Marked as resolved',diff --git a/src/routes/(main)/agent/features/Conversation/ConversationArea.tsx b/src/routes/(main)/agent/features/Conversation/ConversationArea.tsxindex 7f60c086679..27c9ca533c1 100644--- a/src/routes/(main)/agent/features/Conversation/ConversationArea.tsx+++ b/src/routes/(main)/agent/features/Conversation/ConversationArea.tsx@@ -8,10 +8,12 @@ import AgentHome from '@/features/AgentHome';import ChatMiniMap from '@/features/ChatMiniMap';import { ChatList, ConversationProvider, TodoProgress } from '@/features/Conversation';import ZenModeToast from '@/features/ZenModeToast';+import { useGatewayReconnect } from '@/hooks/useGatewayReconnect';import { useOperationState } from '@/hooks/useOperationState';import { useAgentStore } from '@/store/agent';import { agentSelectors } from '@/store/agent/selectors';import { useChatStore } from '@/store/chat';+import { topicSelectors } from '@/store/chat/selectors';import { messageMapKey } from '@/store/chat/utils/messageMapKey';import HeterogeneousChatInput from './HeterogeneousChatInput';@@ -20,7 +22,6 @@ import MessageFromUrl from './MainChatInput/MessageFromUrl';import ThreadHydration from './ThreadHydration';import { useActionsBarConfig } from './useActionsBarConfig';import { useAgentContext } from './useAgentContext';-import { useGatewayReconnect } from './useGatewayReconnect';const log = debug('lobe-render:agent:ConversationArea');@@ -55,7 +56,12 @@ const Conversation = memo(() => {const isHeterogeneousAgent = useAgentStore(agentSelectors.isCurrentAgentHeterogeneous);// Auto-reconnect to running Gateway operation on topic load- useGatewayReconnect(context.topicId);+ const runningOperation = useChatStore((s) =>+ context.topicId+ ? topicSelectors.getTopicById(context.topicId)(s)?.metadata?.runningOperation+ : undefined,+ );+ useGatewayReconnect(context.topicId, runningOperation);return (<ConversationProviderdiff --git a/src/routes/(main)/agent/features/Conversation/useGatewayReconnect.ts b/src/routes/(main)/agent/features/Conversation/useGatewayReconnect.tsdeleted file mode 100644index e7303f9c93f..00000000000--- a/src/routes/(main)/agent/features/Conversation/useGatewayReconnect.ts+++ /dev/null@@ -1,45 +0,0 @@-import useSWR from 'swr';--import { useChatStore } from '@/store/chat';-import { topicSelectors } from '@/store/chat/selectors';--/**- * Hook that detects a running Gateway operation on the current topic- * and automatically reconnects the WebSocket after page reload.- *- * Uses SWR to manage the reconnect lifecycle — it only fires when- * runningOperation exists and deduplicates by operationId.- */-export const useGatewayReconnect = (topicId?: string | null) => {- const isGatewayModeEnabled = useChatStore((s) => s.isGatewayModeEnabled);-- // Subscribe to topic's runningOperation — re-evaluates when topic data arrives from SWR- const runningOperation = useChatStore((s) =>- topicId ? topicSelectors.getTopicById(topicId)(s)?.metadata?.runningOperation : undefined,- );-- // SWR key is the operationId — null key means no fetch- // This naturally deduplicates: same operationId = same key = no re-fetch- useSWR(- runningOperation && isGatewayModeEnabled()- ? ['reconnectGateway', runningOperation.operationId]- : null,- async () => {- if (!runningOperation || !topicId) return;-- await useChatStore.getState().reconnectToGatewayOperation({- assistantMessageId: runningOperation.assistantMessageId,- operationId: runningOperation.operationId,- scope: runningOperation.scope,- threadId: runningOperation.threadId,- topicId,- });- },- {- // Don't revalidate on focus/reconnect — one attempt is enough- revalidateIfStale: false,- revalidateOnFocus: false,- revalidateOnReconnect: false,- },- );-};diff --git a/src/server/services/task/index.ts b/src/server/services/task/index.tsindex 391eab22bdf..620ce213669 100644--- a/src/server/services/task/index.ts+++ b/src/server/services/task/index.ts@@ -210,6 +210,7 @@ export class TaskService {return {author: task.assigneeAgentId ? authorMap.get(task.assigneeAgentId) : undefined,id: t.topicId ?? undefined,+ runningOperation: t.metadata?.runningOperation ?? null,seq: t.seq,status: t.status,summary: handoff?.summary,diff --git a/src/server/services/taskRunner/index.ts b/src/server/services/taskRunner/index.tsindex bf158654d73..4b261996bfc 100644--- a/src/server/services/taskRunner/index.ts+++ b/src/server/services/taskRunner/index.ts@@ -4,6 +4,7 @@ import type { ExecAgentResult } from '@lobechat/types';import { TRPCError } from '@trpc/server';import debug from 'debug';+import { TopicTrigger } from '@/const/topic';import { BriefModel } from '@/database/models/brief';import { TaskModel } from '@/database/models/task';import { TaskTopicModel } from '@/database/models/taskTopic';@@ -169,7 +170,7 @@ export class TaskRunnerService {prompt,taskId: task.id,title: extraPrompt ? extraPrompt.slice(0, 100) : task.name || task.identifier,- trigger: 'task',+ trigger: TopicTrigger.RunTask,userInterventionConfig: { approvalMode: 'headless' },...(continueTopicId && { appContext: { topicId: continueTopicId } }),});