🤯 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-detail): replace inline comment input with ChatInput that triggers a new run (#14873)
Arvin Xu9c4dadda4c28
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex e404778ec08..383e2d2743a 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -600,7 +600,6 @@"taskDetail.comment.edit": "Edit","taskDetail.comment.save": "Save","taskDetail.commentPlaceholder": "Leave feedback to guide the agent — your comments shape the next run...",- "taskDetail.commentSubmitAndRun": "Send & run now","taskDetail.deleteConfirm.content": "This action cannot be undone.","taskDetail.deleteConfirm.ok": "Delete","taskDetail.deleteConfirm.title": "Delete this task?",@@ -627,6 +626,8 @@"taskDetail.priority.urgent": "Urgent","taskDetail.properties": "Properties","taskDetail.reassignDisabled": "Cannot reassign agent while task is running",+ "taskDetail.replyInThread": "Reply in this thread",+ "taskDetail.replyPlaceholder": "Reply in this thread...","taskDetail.rerunTask": "Re-run task","taskDetail.runAll": "Run all","taskDetail.runAll.cancel": "Cancel",@@ -647,6 +648,7 @@"taskDetail.runNow": "Run now","taskDetail.runTask": "Run","taskDetail.saveModelConfig": "Save",+ "taskDetail.sendFollowUp": "Send follow up message","taskDetail.status.backlog": "Backlog","taskDetail.status.canceled": "Canceled","taskDetail.status.completed": "Completed",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex 36ad695ebc5..c4caed4f2ea 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -600,7 +600,6 @@"taskDetail.comment.edit": "编辑","taskDetail.comment.save": "保存","taskDetail.commentPlaceholder": "留下反馈,帮助 Agent 在下次执行时产出更准确的结果...",- "taskDetail.commentSubmitAndRun": "反馈并立即运行","taskDetail.deleteConfirm.content": "此操作不可撤销。","taskDetail.deleteConfirm.ok": "删除","taskDetail.deleteConfirm.title": "确认删除此任务?",@@ -627,6 +626,8 @@"taskDetail.priority.urgent": "紧急","taskDetail.properties": "属性","taskDetail.reassignDisabled": "任务运行中,无法切换 Agent",+ "taskDetail.replyInThread": "在此对话中回复",+ "taskDetail.replyPlaceholder": "在此对话中回复…","taskDetail.rerunTask": "重新运行","taskDetail.runAll": "全部运行","taskDetail.runAll.cancel": "取消",@@ -647,6 +648,7 @@"taskDetail.runNow": "立即运行","taskDetail.runTask": "运行","taskDetail.saveModelConfig": "保存",+ "taskDetail.sendFollowUp": "发送追加消息","taskDetail.status.backlog": "待办","taskDetail.status.canceled": "已取消","taskDetail.status.completed": "已完成",diff --git a/packages/types/src/message/ui/params.ts b/packages/types/src/message/ui/params.tsindex 150d5282c6c..514816f88c7 100644--- a/packages/types/src/message/ui/params.ts+++ b/packages/types/src/message/ui/params.ts@@ -111,6 +111,14 @@ export interface SendMessageParams {/** Lexical editor JSON state for rich text rendering */editorData?: Record<string, any>;files?: UploadFileItem[];+ /**+ * Force the agent runtime regardless of the agent's local/cloud/hetero+ * config. Injected straight into `selectRuntimeType` as `parentRuntime`,+ * so it wins over every other signal. Used by task topics (which were+ * spawned server-side via `runTask`) to keep follow-up sends pinned to+ * the gateway path even if the user's global runtime preference is local.+ */+ forceRuntime?: 'client' | 'gateway' | 'hetero';/**** https://github.com/lobehub/lobe-chat/pull/2086diff --git a/src/features/AgentTasks/AgentTaskDetail/CommentInput.tsx b/src/features/AgentTasks/AgentTaskDetail/CommentInput.tsxindex 67a88c6c57c..0619cda60da 100644--- a/src/features/AgentTasks/AgentTaskDetail/CommentInput.tsx+++ b/src/features/AgentTasks/AgentTaskDetail/CommentInput.tsx@@ -65,14 +65,14 @@ const CommentInput = memo<{ taskId: string }>(({ taskId }) => {return (<Flexbox className={styles.commentInputCard} gap={6}>- <Flexbox horizontal align={'flex-start'} gap={8}>- <Avatar avatar={userAvatar} size={24} style={{ flexShrink: 0, marginBlockStart: 4 }} />+ <Flexbox horizontal align={'center'} gap={8}>+ <Avatar avatar={userAvatar} size={24} style={{ flexShrink: 0 }} /><div style={{ flex: 1, minWidth: 0 }}><EditorCanvaseditor={editor}floatingToolbar={false}placeholder={t('taskDetail.commentPlaceholder')}- style={{ paddingBottom: 4 }}+ style={{ fontSize: 14, minHeight: 24, paddingBlock: 0 }}onContentChange={handleContentChange}onPressEnter={({ event }) => {if (shouldSendOnEnter(event)) {diff --git a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/FeedbackInput.tsx b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/FeedbackInput.tsxindex 0b25fc0616f..65c9329b416 100644--- a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/FeedbackInput.tsx+++ b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/FeedbackInput.tsx@@ -1,46 +1,35 @@-import { SendButton, useEditor } from '@lobehub/editor/react';-import { Avatar, Flexbox } from '@lobehub/ui';+import { ChatInput, ChatInputActionBar, SendButton, useEditor } from '@lobehub/editor/react';+import { Button } from '@lobehub/ui';import { $getRoot } from 'lexical';-import { memo, useCallback, useState } from 'react';+import { MessageCirclePlus } from 'lucide-react';+import { memo, useCallback, useEffect, useState } from 'react';import { useTranslation } from 'react-i18next';-import { shallow } from 'zustand/shallow';import { AttachmentUploadButton } from '@/features/AttachmentInput';+import { useConversationStore } from '@/features/Conversation';import { EditorCanvas } from '@/features/EditorCanvas';import {getAttachmentFileIdsFromEditor,insertFilesIntoEditor,} from '@/features/EditorCanvas/editorAttachments';import { useEnterToSend } from '@/hooks/useEnterToSend';-import { useUserAvatar } from '@/hooks/useUserAvatar';-import { useTaskStore } from '@/store/task';-import { styles } from '../../shared/style';--interface FeedbackInputProps {- taskId: string;- topicId: string;-}--const FeedbackInput = memo<FeedbackInputProps>(({ taskId, topicId }) => {+const FeedbackInput = memo(() => {const { t } = useTranslation('chat');const editor = useEditor();- const userAvatar = useUserAvatar();- const { addComment, runTask, closeTopicDrawer } = useTaskStore(- (s) => ({- addComment: s.addComment,- closeTopicDrawer: s.closeTopicDrawer,- runTask: s.runTask,- }),- shallow,- );+ const sendMessage = useConversationStore((s) => s.sendMessage);const [submitting, setSubmitting] = useState(false);const [hasContent, setHasContent] = useState(false);const [hasAttachments, setHasAttachments] = useState(false);+ const [expanded, setExpanded] = useState(false);const shouldSendOnEnter = useEnterToSend();const canSubmit = hasContent || hasAttachments;+ useEffect(() => {+ if (expanded) editor?.focus?.();+ }, [expanded, editor]);+const handleContentChange = useCallback(() => {const lexicalEditor = editor?.getLexicalEditor?.();if (!lexicalEditor) return;@@ -60,67 +49,81 @@ const FeedbackInput = memo<FeedbackInputProps>(({ taskId, topicId }) => {const handleSubmit = useCallback(async () => {if (submitting) return;- const json = editor?.getDocument?.('json') as unknown;+ const editorData = editor?.getDocument?.('json') as Record<string, any> | undefined;const markdown = String(editor?.getDocument?.('markdown') ?? '').trim();const hasFiles = getAttachmentFileIdsFromEditor(editor).length > 0;if (!markdown && !hasFiles) return;+ // Clear the editor synchronously BEFORE await so the input feels+ // responsive — sendMessage's optimistic-update pipeline keeps a copy+ // of the captured markdown / editorData for rendering. Keep the+ // ChatInput expanded after send: once the user has opened the reply+ // composer, treat it as the new resting state for this drawer session.+ editor?.cleanDocument?.();+ setHasContent(false);+ setHasAttachments(false);+setSubmitting(true);try {- await addComment(taskId, markdown, {- editorData: json,- topicId,- });- // Start a NEW topic run that picks up the comment we just attached to the- // current topic. Do NOT pass continueTopicId — that would flip the- // already-completed topic back to running and overwrite its operation id.- try {- await runTask(taskId);- } catch (error) {- console.warn('[FeedbackInput] runTask failed', error);- }- editor?.cleanDocument?.();- setHasContent(false);- setHasAttachments(false);- closeTopicDrawer();+ // sendMessage is bound to this drawer's ConversationProvider context+ // (agentId + topicId + isolatedTopic), so the message continues this+ // topic's conversation. Files attached inline in the editor travel as+ // part of editorData / markdown — no separate files array needed.+ // Force the gateway runtime so the follow-up runs on the same+ // server-side path as the original `runTask` that spawned this topic,+ // regardless of the user's global local/cloud preference.+ await sendMessage({ editorData, forceRuntime: 'gateway', message: markdown });} finally {setSubmitting(false);}- }, [taskId, topicId, editor, addComment, runTask, closeTopicDrawer, submitting]);+ }, [editor, sendMessage, submitting]);++ if (!expanded) {+ return (+ <Button block icon={MessageCirclePlus} variant={'filled'} onClick={() => setExpanded(true)}>+ {t('taskDetail.sendFollowUp')}+ </Button>+ );+ }return (- <Flexbox className={styles.commentInputCard} gap={6}>- <Flexbox horizontal align={'flex-start'} gap={8}>- <Avatar avatar={userAvatar} size={24} style={{ flexShrink: 0, marginBlockStart: 4 }} />- <div style={{ flex: 1, minWidth: 0 }}>- <EditorCanvas- editor={editor}- floatingToolbar={false}- placeholder={t('taskDetail.commentPlaceholder')}- style={{ paddingBottom: 4 }}- onContentChange={handleContentChange}- onPressEnter={({ event }) => {- if (shouldSendOnEnter(event)) {- handleSubmit();- return true;- }- }}- />- </div>- <Flexbox horizontal align={'center'} gap={4} style={{ flexShrink: 0 }}>- <AttachmentUploadButton onFiles={handleAttach} />- <SendButton- disabled={!canSubmit && !submitting}- loading={submitting}- shape={'round'}- title={t('taskDetail.commentSubmitAndRun')}- type={'text'}- onClick={handleSubmit}- />- </Flexbox>- </Flexbox>- </Flexbox>+ <ChatInput+ maxHeight={240}+ minHeight={64}+ footer={+ <ChatInputActionBar+ left={<AttachmentUploadButton onFiles={handleAttach} />}+ style={{ paddingInline: 8 }}+ right={+ <SendButton+ disabled={!canSubmit && !submitting}+ loading={submitting}+ shape={'round'}+ title={t('taskDetail.replyInThread')}+ type={'primary'}+ onClick={handleSubmit}+ />+ }+ />+ }+ >+ <EditorCanvas+ editor={editor}+ floatingToolbar={false}+ placeholder={t('taskDetail.replyPlaceholder')}+ style={{ paddingBlock: 0 }}+ onContentChange={handleContentChange}+ onPressEnter={({ event }) => {+ if (shouldSendOnEnter(event)) {+ handleSubmit();+ return true;+ }+ }}+ />+ </ChatInput>);});+FeedbackInput.displayName = 'FeedbackInput';+export default FeedbackInput;diff --git a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsxindex 828f4ac96e7..937ce411ed7 100644--- a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx+++ b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx@@ -37,11 +37,10 @@ import FeedbackInput from './FeedbackInput';interface TopicChatDrawerBodyProps {agentId: string;- taskId: string;topicId: string;}-const TopicChatDrawerBody = memo<TopicChatDrawerBodyProps>(({ agentId, taskId, topicId }) => {+const TopicChatDrawerBody = memo<TopicChatDrawerBodyProps>(({ agentId, topicId }) => {const isLogin = useUserStore(authSelectors.isLogin);const useHydrateAgentConfig = useAgentStore((s) => s.useHydrateAgentConfig);@@ -65,19 +64,8 @@ const TopicChatDrawerBody = memo<TopicChatDrawerBodyProps>(({ agentId, taskId, tconst runningOperation = useTaskStore((s) => taskActivitySelectors.activeDrawerTopicActivity(s)?.runningOperation,);- const topicStatus = useTaskStore(- (s) => taskActivitySelectors.activeDrawerTopicActivity(s)?.status,- );useGatewayReconnect(topicId, runningOperation);- // Only allow feedback when the topic run has terminated. While the topic is- // pending/running, a feedback comment can't safely steer the in-flight run.- const canLeaveFeedback =- topicStatus === 'completed' ||- topicStatus === 'failed' ||- topicStatus === 'canceled' ||- topicStatus === 'timeout';-const itemContent = useCallback((index: number, id: string) => (<MessageItem@@ -106,11 +94,9 @@ const TopicChatDrawerBody = memo<TopicChatDrawerBodyProps>(({ agentId, taskId, t<Flexbox flex={1} style={{ minHeight: 0, overflow: 'hidden' }}><ChatList disableActionsBar itemContent={itemContent} /></Flexbox>- {canLeaveFeedback && (- <Flexbox padding={12} style={{ flexShrink: 0 }}>- <FeedbackInput taskId={taskId} topicId={topicId} />- </Flexbox>- )}+ <Flexbox paddingBlock={'0 12px'} paddingInline={12} style={{ flexShrink: 0 }}>+ <FeedbackInput />+ </Flexbox></Flexbox></TaskCardScopeProvider></ConversationProvider>@@ -238,9 +224,7 @@ const TopicChatDrawer = memo(() => {onClose={closeTopicDrawer}><Freeze frozen={!open}>- {open && activeTaskId && (- <TopicChatDrawerBody agentId={agentId!} taskId={activeTaskId} topicId={topicId!} />- )}+ {open && activeTaskId && <TopicChatDrawerBody agentId={agentId!} topicId={topicId!} />}</Freeze></Drawer>);diff --git a/src/features/AgentTasks/shared/style.ts b/src/features/AgentTasks/shared/style.tsindex 2e8ea2e68c9..5e887632888 100644--- a/src/features/AgentTasks/shared/style.ts+++ b/src/features/AgentTasks/shared/style.ts@@ -130,7 +130,8 @@ export const styles = createStaticStyles(({ css, cssVar }) => ({`,commentInputCard: css`- padding: 8px;+ padding-block: 4px;+ padding-inline: 8px;border: 1px solid transparent;border-radius: ${cssVar.borderRadiusLG};diff --git a/src/locales/default/chat.ts b/src/locales/default/chat.tsindex b7759afcbfe..72a718a309c 100644--- a/src/locales/default/chat.ts+++ b/src/locales/default/chat.ts@@ -714,7 +714,9 @@ export default {'taskDetail.comment.save': 'Save','taskDetail.commentPlaceholder':'Leave feedback to guide the agent — your comments shape the next run...',- 'taskDetail.commentSubmitAndRun': 'Send & run now',+ 'taskDetail.replyInThread': 'Reply in this thread',+ 'taskDetail.replyPlaceholder': 'Reply in this thread...',+ 'taskDetail.sendFollowUp': 'Send follow up message','taskDetail.deleteConfirm.content': 'This action cannot be undone.','taskDetail.deleteConfirm.ok': 'Delete','taskDetail.deleteConfirm.title': 'Delete this task?',diff --git a/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts b/src/store/chat/slices/aiChat/actions/conversationLifecycle.tsindex da81f696736..173c0ed91d4 100644--- a/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts+++ b/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts@@ -211,6 +211,7 @@ export class ConversationLifecycleActionImpl {message,editorData: inputEditorData,files,+ forceRuntime,metadata,onlyAddUserMessage,context,@@ -251,6 +252,10 @@ export class ConversationLifecycleActionImpl {executionTarget: agentConfig?.agencyConfig?.executionTarget,heterogeneousProvider,isGatewayMode: this.#get().isGatewayModeEnabled(),+ // Callers that need to pin the runtime (e.g. task topics that were+ // started server-side via runTask) pass `forceRuntime` to override+ // the agent's local/cloud preference.+ parentRuntime: forceRuntime,});// ── Command Bus: extract and process built-in commands from editorData ──@@ -391,6 +396,7 @@ export class ConversationLifecycleActionImpl {editorData: editorData ?? undefined,files: fileIdList,filesPreview: filesPreview.length > 0 ? filesPreview : undefined,+ ...(forceRuntime ? { forceRuntime } : {}),interruptMode: 'soft',metadata: userMessageMetadata,createdAt: Date.now(),diff --git a/src/store/chat/slices/aiChat/actions/heterogeneousAgentExecutor.ts b/src/store/chat/slices/aiChat/actions/heterogeneousAgentExecutor.tsindex 57d3b5dd5ac..68c4ac25e5b 100644--- a/src/store/chat/slices/aiChat/actions/heterogeneousAgentExecutor.ts+++ b/src/store/chat/slices/aiChat/actions/heterogeneousAgentExecutor.ts@@ -1973,6 +1973,7 @@ export const executeHeterogeneousAgent = async (context: { ...context },editorData: merged.editorData,files: mergedFiles,+ ...(merged.forceRuntime ? { forceRuntime: merged.forceRuntime } : {}),message: merged.content,metadata: merged.metadata,})diff --git a/src/store/chat/slices/aiChat/actions/streamingExecutor.ts b/src/store/chat/slices/aiChat/actions/streamingExecutor.tsindex 3a45fce581a..62d47587bf4 100644--- a/src/store/chat/slices/aiChat/actions/streamingExecutor.ts+++ b/src/store/chat/slices/aiChat/actions/streamingExecutor.ts@@ -894,6 +894,7 @@ export class StreamingExecutorActionImpl {context: execContext,editorData: merged.editorData,files: mergedFiles,+ ...(merged.forceRuntime ? { forceRuntime: merged.forceRuntime } : {}),message: mergedContent,metadata: merged.metadata,})diff --git a/src/store/chat/slices/operation/types.ts b/src/store/chat/slices/operation/types.tsindex a9d3f5a6080..0ec8d1bbc60 100644--- a/src/store/chat/slices/operation/types.ts+++ b/src/store/chat/slices/operation/types.ts@@ -232,6 +232,9 @@ export interface QueuedMessage {files?: string[];/** Snapshot of file previews (id, name, mime, url) for tray rendering and optimistic resume */filesPreview?: QueuedFile[];+ /** Mirrors SendMessageParams.forceRuntime so a queued task-topic follow-up+ * keeps its gateway pin when the queue drains. */+ forceRuntime?: 'client' | 'gateway' | 'hetero';id: string;interruptMode: 'soft' | 'hard';metadata?: MessageMetadata;@@ -246,6 +249,7 @@ export interface MergedQueuedMessage {editorData?: Record<string, any>;files: string[];filesPreview: QueuedFile[];+ forceRuntime?: 'client' | 'gateway' | 'hetero';metadata?: MessageMetadata;}@@ -348,11 +352,16 @@ export const mergeQueuedMessages = (messages: QueuedMessage[]): MergedQueuedMess};}, undefined);+ // If any queued message pins the runtime, propagate it — a "server topic"+ // follow-up must stay on its rails even after merge.+ const forceRuntime = sorted.find((m) => m.forceRuntime)?.forceRuntime;+return {content: sorted.map((m) => m.content).join('\n\n'),editorData: mergeQueuedEditorData(sorted),files: sorted.flatMap((m) => m.files ?? []),filesPreview: sorted.flatMap((m) => m.filesPreview ?? []),+ ...(forceRuntime ? { forceRuntime } : {}),metadata,};};