🤯 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
💄 style: add feedback input at bottom of TopicChatDrawer (#14392)
Arvin Xu3f82249ed149
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex a80f897af08..e9c10218d00 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -490,6 +490,7 @@"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?",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex 8fe879002e6..484eeac0b02 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -490,6 +490,7 @@"taskDetail.comment.edit": "编辑","taskDetail.comment.save": "保存","taskDetail.commentPlaceholder": "留下反馈,帮助 Agent 在下次执行时产出更准确的结果...",+ "taskDetail.commentSubmitAndRun": "反馈并立即运行","taskDetail.deleteConfirm.content": "此操作不可撤销。","taskDetail.deleteConfirm.ok": "删除","taskDetail.deleteConfirm.title": "确认删除此任务?",diff --git a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/FeedbackInput.tsx b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/FeedbackInput.tsxnew file mode 100644index 00000000000..764e4856f16--- /dev/null+++ b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/FeedbackInput.tsx@@ -0,0 +1,96 @@+import { Editor, SendButton, useEditor } from '@lobehub/editor/react';+import { Avatar, Flexbox } from '@lobehub/ui';+import { memo, useCallback, useState } from 'react';+import { useTranslation } from 'react-i18next';+import { shallow } from 'zustand/shallow';++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 { 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 [submitting, setSubmitting] = useState(false);+ const [hasContent, setHasContent] = useState(false);++ const handleSubmit = useCallback(async () => {+ const trimmed = String(editor?.getDocument?.('markdown') ?? '').trim();+ if (!trimmed || submitting) return;+ setSubmitting(true);+ try {+ await addComment(taskId, trimmed, { 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);+ closeTopicDrawer();+ } finally {+ setSubmitting(false);+ }+ }, [taskId, topicId, editor, addComment, runTask, closeTopicDrawer, submitting]);++ return (+ <Flexbox horizontal align={'center'} className={styles.commentInputCard} gap={8}>+ <Avatar avatar={userAvatar} size={24} style={{ flexShrink: 0 }} />+ <div style={{ flex: 1, minWidth: 0 }}>+ <Editor+ content={''}+ editor={editor}+ enablePasteMarkdown={false}+ markdownOption={false}+ placeholder={t('taskDetail.commentPlaceholder')}+ type={'text'}+ variant={'chat'}+ onPressEnter={({ event }) => {+ if (event.metaKey || event.ctrlKey) {+ handleSubmit();+ return true;+ }+ }}+ onTextChange={(ed) => {+ setHasContent(!!String(ed?.getDocument?.('markdown') ?? '').trim());+ }}+ />+ </div>+ <div+ style={{+ flexShrink: 0,+ opacity: hasContent || submitting ? 1 : 0,+ pointerEvents: hasContent || submitting ? 'auto' : 'none',+ }}+ >+ <SendButton+ loading={submitting}+ shape={'round'}+ title={t('taskDetail.commentSubmitAndRun')}+ type={'text'}+ onClick={handleSubmit}+ />+ </div>+ </Flexbox>+ );+});++export default FeedbackInput;diff --git a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.test.tsx b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.test.tsxindex 1d228e0c404..71c9831c5bb 100644--- a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.test.tsx+++ b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.test.tsx@@ -131,6 +131,10 @@ vi.mock('../TopicStatusIcon', () => ({default: () => <span data-testid="topic-status-icon" />,}));+vi.mock('./FeedbackInput', () => ({+ default: () => <div data-testid="feedback-input" />,+}));+describe('TopicChatDrawer', () => {beforeEach(() => {mocks.agentState.useHydrateAgentConfig.mockClear();diff --git a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsxindex c2373160005..51e25bf5c1f 100644--- a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx+++ b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx@@ -25,15 +25,17 @@ import { useUserStore } from '@/store/user';import { authSelectors } from '@/store/user/selectors';import TopicStatusIcon from '../TopicStatusIcon';+import FeedbackInput from './FeedbackInput';const SharePopover = dynamic(() => import('@/features/SharePopover'));interface TopicChatDrawerBodyProps {agentId: string;+ taskId: string;topicId: string;}-const TopicChatDrawerBody = memo<TopicChatDrawerBodyProps>(({ agentId, topicId }) => {+const TopicChatDrawerBody = memo<TopicChatDrawerBodyProps>(({ agentId, taskId, topicId }) => {const isLogin = useUserStore(authSelectors.isLogin);const useHydrateAgentConfig = useAgentStore((s) => s.useHydrateAgentConfig);@@ -83,8 +85,13 @@ const TopicChatDrawerBody = memo<TopicChatDrawerBodyProps>(({ agentId, topicId }}}><TaskCardScopeProvider value={true}>- <Flexbox flex={1} height={'100%'} style={{ overflow: 'hidden' }}>- <ChatList disableActionsBar itemContent={itemContent} />+ <Flexbox height={'100%'} style={{ overflow: 'hidden' }}>+ <Flexbox flex={1} style={{ minHeight: 0, overflow: 'hidden' }}>+ <ChatList disableActionsBar itemContent={itemContent} />+ </Flexbox>+ <Flexbox padding={12} style={{ flexShrink: 0 }}>+ <FeedbackInput taskId={taskId} topicId={topicId} />+ </Flexbox></Flexbox></TaskCardScopeProvider></ConversationProvider>@@ -208,7 +215,9 @@ const TopicChatDrawer = memo(() => {}}onClose={closeTopicDrawer}>- {open && <TopicChatDrawerBody agentId={agentId!} topicId={topicId!} />}+ {open && activeTaskId && (+ <TopicChatDrawerBody agentId={agentId!} taskId={activeTaskId} topicId={topicId!} />+ )}</Drawer>);});diff --git a/src/locales/default/chat.ts b/src/locales/default/chat.tsindex 9df1123791c..3272874fbdb 100644--- a/src/locales/default/chat.ts+++ b/src/locales/default/chat.ts@@ -581,6 +581,7 @@ 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.deleteConfirm.content': 'This action cannot be undone.','taskDetail.deleteConfirm.ok': 'Delete','taskDetail.deleteConfirm.title': 'Delete this task?',