🤯 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): expand run conversation viewing (#18285)
Arvin Xu3a03b38c8aba
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex 3189e0fc967..b4700b1df05 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -1422,10 +1422,13 @@"taskDetail.subtaskInstructionPlaceholder": "Describe the sub-task...","taskDetail.subtasks": "Subtasks","taskDetail.titlePlaceholder": "Task title",+ "taskDetail.topicDrawer.collapse": "Restore conversation panel",+ "taskDetail.topicDrawer.expand": "Expand conversation panel","taskDetail.topicDrawer.untitled": "Untitled","taskDetail.topicMenu.copyId": "Copy Topic ID","taskDetail.topicMenu.copyOperationId": "Copy Operation ID","taskDetail.topicMenu.open": "Open Run",+ "taskDetail.topicMenu.openAgentTopic": "Go to Agent conversation","taskDetail.topicMenu.stop": "Stop Run","taskDetail.topicMenu.stopConfirm.content": "The current run will be canceled. Generated messages are kept and you can re-run the task later.","taskDetail.topicMenu.stopConfirm.title": "Stop Run?",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex 8d77885737b..67c835d6628 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -1422,10 +1422,13 @@"taskDetail.subtaskInstructionPlaceholder": "描述这个子任务…","taskDetail.subtasks": "子任务","taskDetail.titlePlaceholder": "输入任务标题…",+ "taskDetail.topicDrawer.collapse": "恢复对话面板",+ "taskDetail.topicDrawer.expand": "展开对话面板","taskDetail.topicDrawer.untitled": "未命名","taskDetail.topicMenu.copyId": "复制话题 ID","taskDetail.topicMenu.copyOperationId": "复制 Operation ID","taskDetail.topicMenu.open": "打开运行",+ "taskDetail.topicMenu.openAgentTopic": "前往 Agent 对话","taskDetail.topicMenu.stop": "停止运行","taskDetail.topicMenu.stopConfirm.content": "当前运行将被取消。已生成的消息会保留,你可以稍后重新运行任务。","taskDetail.topicMenu.stopConfirm.title": "停止运行?",diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.tsindex a61467b4d40..274357dc419 100644--- a/packages/locales/src/default/chat.ts+++ b/packages/locales/src/default/chat.ts@@ -1531,9 +1531,12 @@ export default {'taskDetail.runAll.loading': 'Loading subtask plan...','taskDetail.reassignDisabled': 'Cannot reassign agent while task is running','taskDetail.titlePlaceholder': 'Task title',+ 'taskDetail.topicDrawer.collapse': 'Restore conversation panel',+ 'taskDetail.topicDrawer.expand': 'Expand conversation panel','taskDetail.topicDrawer.untitled': 'Untitled','taskDetail.topicMenu.copyId': 'Copy Topic ID','taskDetail.topicMenu.copyOperationId': 'Copy Operation ID',+ 'taskDetail.topicMenu.openAgentTopic': 'Go to Agent conversation','taskDetail.topicMenu.open': 'Open Run','taskDetail.topicMenu.stop': 'Stop Run','taskDetail.topicMenu.stopConfirm.content':diff --git a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.test.tsx b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.test.tsxindex e0461b8d08d..f8d55b761cb 100644--- a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.test.tsx+++ b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.test.tsx@@ -2,7 +2,7 @@* @vitest-environment happy-dom*/import type { TaskDetailActivity } from '@lobechat/types';-import { render } from '@testing-library/react';+import { fireEvent, render } from '@testing-library/react';import type { CSSProperties, ReactNode } from 'react';import { beforeEach, describe, expect, it, vi } from 'vitest';@@ -22,6 +22,7 @@ const mocks = vi.hoisted(() => ({allowed: true,reason: 'requires member',},+ navigate: vi.fn(),serverConfigState: {serverConfig: {enableBusinessFeatures: false,@@ -84,7 +85,24 @@ vi.mock('@lobehub/ui', () => ({</button>),copyToClipboard: vi.fn(),- DropdownMenu: ({ children }: { children?: ReactNode }) => <>{children}</>,+ DropdownMenu: ({+ children,+ items,+ }: {+ children?: ReactNode;+ items?: { key: string; label?: ReactNode; onClick?: () => void; type?: string }[];+ }) => (+ <>+ {children}+ {items?.map((item) =>+ item.type === 'divider' ? null : (+ <button key={item.key} onClick={item.onClick}>+ {item.label}+ </button>+ ),+ )}+ </>+ ),Flexbox: ({children,flex,@@ -185,6 +203,10 @@ vi.mock('@/features/ShareModal', () => ({}),}));+vi.mock('@/features/Workspace/useWorkspaceAwareNavigate', () => ({+ useWorkspaceAwareNavigate: () => mocks.navigate,+}));+vi.mock('@/hooks/useGatewayReconnect', () => ({useGatewayReconnect: vi.fn(),}));@@ -249,6 +271,7 @@ describe('TopicChatDrawer', () => {beforeEach(() => {mocks.agentState.useHydrateAgentConfig.mockClear();mocks.chatState.replaceMessages.mockClear();+ mocks.navigate.mockClear();mocks.taskState.closeTopicDrawer.mockClear();mocks.taskState.activeTopicDrawerTopicId = 'topic-1';mocks.taskState.taskDetailMap['T-1'].activities[0] = {@@ -342,9 +365,13 @@ describe('TopicChatDrawer', () => {const icons = getAllByTestId('header-action-icon');const moreIcon = icons.find((icon) => !icon.getAttribute('title'));+ const expandIcon = icons.find(+ (icon) => icon.getAttribute('title') === 'taskDetail.topicDrawer.expand',+ );const shareIcon = icons.find((icon) => icon.getAttribute('title') === 'share');expect(moreIcon).toBeDefined();+ expect(expandIcon).toBeDefined();expect(shareIcon).toBeDefined();expect(moreIcon!).toHaveAttribute('data-size', 'small');expect(shareIcon!).toHaveAttribute('data-size', JSON.stringify({ blockSize: 32, size: 16 }));@@ -352,6 +379,28 @@ describe('TopicChatDrawer', () => {expect(getByTestId('panel-close-icon')).toBeInTheDocument();});+ it('expands the conversation into a full-height reading panel', () => {+ const { getByTestId, getByTitle } = render(<TopicChatDrawer />);++ fireEvent.click(getByTitle('taskDetail.topicDrawer.expand'));++ expect(getByTestId('topic-panel')).toHaveAttribute(+ 'data-width',+ 'min(960px, calc(100vw - 16px))',+ );+ expect(getByTestId('topic-panel')).toHaveAttribute('data-height', 'calc(100dvh - 16px)');+ expect(getByTitle('taskDetail.topicDrawer.collapse')).toBeInTheDocument();+ });++ it('opens the run in its Agent conversation', () => {+ const { getByText } = render(<TopicChatDrawer />);++ fireEvent.click(getByText('taskDetail.topicMenu.openAgentTopic'));++ expect(mocks.taskState.closeTopicDrawer).toHaveBeenCalledOnce();+ expect(mocks.navigate).toHaveBeenCalledWith('/agent/agt_assignee/topic-1');+ });+it('uses a resizable bottom-right floating panel', () => {const { getByTestId } = render(<TopicChatDrawer />);diff --git a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsxindex 43afc52815a..432eed444a6 100644--- a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx+++ b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx@@ -1,12 +1,13 @@'use client';+import { AGENT_CHAT_TOPIC_URL } from '@lobechat/const';import type { ConversationContext } from '@lobechat/types';import type { DropdownItem } from '@lobehub/ui';import { ActionIcon, copyToClipboard, DropdownMenu, Flexbox, Freeze, Tag, Text } from '@lobehub/ui';import { FloatingPanel } from '@lobehub/ui/base-ui';import { cssVar } from 'antd-style';-import { Copy, MoreHorizontal, Share2 } from 'lucide-react';-import { memo, useCallback, useMemo } from 'react';+import { Copy, ExternalLink, Maximize2, Minimize2, MoreHorizontal, Share2 } from 'lucide-react';+import { memo, useCallback, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';import ChatList from '@/features/Conversation/ChatList';@@ -15,6 +16,7 @@ import { TaskCardScopeProvider } from '@/features/Conversation/Markdown/plugins/import MessageItem from '@/features/Conversation/Messages';import { useShareModal } from '@/features/ShareModal';import { LazySharePopover as SharePopover } from '@/features/SharePopover/lazy';+import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';import { useGatewayReconnect } from '@/hooks/useGatewayReconnect';import { useOperationState } from '@/hooks/useOperationState';import { usePermission } from '@/hooks/usePermission';@@ -32,6 +34,10 @@ import AssigneeAvatar from '../../features/AssigneeAvatar';import FeedbackInput from './FeedbackInput';const SHARE_ICON_SIZE = { blockSize: 32, size: 16 } as const;+const DEFAULT_PANEL_HEIGHT = 'min(640px, calc(100dvh - 16px))';+const DEFAULT_PANEL_WIDTH = 640;+const EXPANDED_PANEL_HEIGHT = 'calc(100dvh - 16px)';+const EXPANDED_PANEL_WIDTH = 'min(960px, calc(100vw - 16px))';export interface TopicChatDrawerBodyProps {agentId: string;@@ -114,6 +120,8 @@ TopicChatDrawerBody.displayName = 'TopicChatDrawerBody';const TopicChatDrawer = memo(() => {const { t } = useTranslation(['chat', 'common']);+ const navigate = useWorkspaceAwareNavigate();+ const [expanded, setExpanded] = useState(false);const topicId = useTaskStore(taskDetailSelectors.activeTopicDrawerTopicId);const activeTaskId = useTaskStore((s) => s.activeTaskId);const agentId = useTaskStore(taskDetailSelectors.topicDrawerAgentId);@@ -144,8 +152,22 @@ const TopicChatDrawer = memo(() => {if (activity?.operationId) void copyToClipboard(activity.operationId);}, [activity?.operationId]);+ const handleOpenAgentTopic = useCallback(() => {+ if (!agentId || !topicId) return;+ closeTopicDrawer();+ navigate(AGENT_CHAT_TOPIC_URL(agentId, topicId));+ }, [agentId, closeTopicDrawer, navigate, topicId]);+const menuItems = useMemo<DropdownItem[]>(() => [+ {+ disabled: !agentId || !topicId,+ icon: ExternalLink,+ key: 'openAgentTopic',+ label: t('taskDetail.topicMenu.openAgentTopic'),+ onClick: handleOpenAgentTopic,+ },+ { type: 'divider' },{disabled: !topicId,icon: Copy,@@ -161,7 +183,15 @@ const TopicChatDrawer = memo(() => {onClick: handleCopyOperationId,},],- [t, topicId, activity?.operationId, handleCopyTopicId, handleCopyOperationId],+ [+ activity?.operationId,+ agentId,+ handleCopyOperationId,+ handleCopyTopicId,+ handleOpenAgentTopic,+ t,+ topicId,+ ],);const title = (@@ -208,12 +238,22 @@ const TopicChatDrawer = memo(() => {/>);- const actions = !topicId ? null : enableTopicLinkShare && canShare ? (- <SharePopover topicId={topicId} onOpenModal={openShareModal}>- {shareIcon}- </SharePopover>- ) : (- shareIcon+ const actions = !topicId ? null : (+ <Flexbox horizontal align={'center'} gap={4}>+ <ActionIcon+ icon={expanded ? Minimize2 : Maximize2}+ size={SHARE_ICON_SIZE}+ title={t(expanded ? 'taskDetail.topicDrawer.collapse' : 'taskDetail.topicDrawer.expand')}+ onClick={() => setExpanded((value) => !value)}+ />+ {enableTopicLinkShare && canShare ? (+ <SharePopover topicId={topicId} onOpenModal={openShareModal}>+ {shareIcon}+ </SharePopover>+ ) : (+ shareIcon+ )}+ </Flexbox>);// Freeze title/actions/body during the close animation so the panel keeps@@ -223,14 +263,14 @@ const TopicChatDrawer = memo(() => {<FloatingPanelactions={<Freeze frozen={!open}>{actions}</Freeze>}getContainer={false}- height={'min(640px, calc(100dvh - 16px))'}+ height={expanded ? EXPANDED_PANEL_HEIGHT : DEFAULT_PANEL_HEIGHT}mask={false}minHeight={320}minWidth={360}open={open}placement={'bottomRight'}title={<Freeze frozen={!open}>{title}</Freeze>}- width={640}+ width={expanded ? EXPANDED_PANEL_WIDTH : DEFAULT_PANEL_WIDTH}styles={{body: { padding: 0 },panel: {