mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-27 13:29:15 +07:00
🐛 fix: fix group subagent task issue (#11589)
* improve WriteFile feeling * refactor exector * improve task title * fix flick * improve i18n * fix tests
This commit is contained in:
@@ -32,6 +32,7 @@ export const ExecuteAgentTaskInspector = memo<BuiltinInspectorProps<ExecuteTaskP
|
||||
const { t } = useTranslation('plugin');
|
||||
|
||||
const agentId = args?.agentId || partialArgs?.agentId;
|
||||
const taskTitle = args?.title || partialArgs?.title;
|
||||
|
||||
// Get active group ID and agent from store
|
||||
const activeGroupId = useAgentGroupStore(agentGroupSelectors.activeGroupId);
|
||||
@@ -42,12 +43,47 @@ export const ExecuteAgentTaskInspector = memo<BuiltinInspectorProps<ExecuteTaskP
|
||||
);
|
||||
const theme = useTheme();
|
||||
|
||||
if (isArgumentsStreaming && !agent) {
|
||||
return (
|
||||
<div className={cx(styles.root, shinyTextStyles.shinyText)}>
|
||||
<span>{t('builtins.lobe-group-management.apiName.executeAgentTask')}</span>
|
||||
</div>
|
||||
);
|
||||
if (isArgumentsStreaming) {
|
||||
if (!agent && !taskTitle)
|
||||
return (
|
||||
<div className={cx(styles.root, shinyTextStyles.shinyText)}>
|
||||
<span>{t('builtins.lobe-group-management.apiName.executeAgentTask')}</span>
|
||||
</div>
|
||||
);
|
||||
if (agent) {
|
||||
return (
|
||||
<Flexbox
|
||||
align={'center'}
|
||||
className={cx(styles.root, isArgumentsStreaming && shinyTextStyles.shinyText)}
|
||||
gap={8}
|
||||
horizontal
|
||||
>
|
||||
<span className={styles.title}>
|
||||
{t('builtins.lobe-group-management.inspector.executeAgentTask.assignTo')}
|
||||
</span>
|
||||
{agent && (
|
||||
<>
|
||||
<Avatar
|
||||
avatar={agent.avatar || DEFAULT_AVATAR}
|
||||
background={agent.backgroundColor || theme.colorBgContainer}
|
||||
shape={'square'}
|
||||
size={24}
|
||||
title={agent.title || undefined}
|
||||
/>
|
||||
<span>{agent?.title}</span>
|
||||
</>
|
||||
)}
|
||||
{taskTitle && (
|
||||
<>
|
||||
<span className={styles.title}>
|
||||
{t('builtins.lobe-group-management.inspector.executeAgentTask.task')}
|
||||
</span>
|
||||
<span className={highlightTextStyles.primary}>{taskTitle}</span>
|
||||
</>
|
||||
)}
|
||||
</Flexbox>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const agentName = agent?.title || agentId;
|
||||
@@ -60,7 +96,7 @@ export const ExecuteAgentTaskInspector = memo<BuiltinInspectorProps<ExecuteTaskP
|
||||
horizontal
|
||||
>
|
||||
<span className={styles.title}>
|
||||
{t('builtins.lobe-group-management.inspector.executeAgentTask.title')}
|
||||
{t('builtins.lobe-group-management.inspector.executeAgentTask.assignTo')}
|
||||
</span>
|
||||
{agent && (
|
||||
<Avatar
|
||||
@@ -71,7 +107,15 @@ export const ExecuteAgentTaskInspector = memo<BuiltinInspectorProps<ExecuteTaskP
|
||||
title={agent.title || undefined}
|
||||
/>
|
||||
)}
|
||||
{agentName && <span className={highlightTextStyles.primary}>{agentName}</span>}
|
||||
{agentName && <span>{agentName}</span>}
|
||||
{taskTitle && (
|
||||
<>
|
||||
<span className={styles.title}>
|
||||
{t('builtins.lobe-group-management.inspector.executeAgentTask.task')}
|
||||
</span>
|
||||
<span className={highlightTextStyles.primary}>{taskTitle}</span>
|
||||
</>
|
||||
)}
|
||||
</Flexbox>
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
'use client';
|
||||
|
||||
import { BuiltinRenderProps } from '@lobechat/types';
|
||||
import { Avatar, Flexbox, Text } from '@lobehub/ui';
|
||||
import { Flexbox, Text } from '@lobehub/ui';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { Clock } from 'lucide-react';
|
||||
import { memo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { useAgentGroupStore } from '@/store/agentGroup';
|
||||
import { agentGroupSelectors } from '@/store/agentGroup/selectors';
|
||||
|
||||
import type { ExecuteTaskParams, ExecuteTaskState } from '../../../types';
|
||||
|
||||
const styles = createStaticStyles(({ css, cssVar }) => ({
|
||||
@@ -40,14 +37,6 @@ const ExecuteTaskRender = memo<BuiltinRenderProps<ExecuteTaskParams, ExecuteTask
|
||||
({ args }) => {
|
||||
const { t } = useTranslation('tool');
|
||||
|
||||
// Get agent info from store
|
||||
const activeGroupId = useAgentGroupStore(agentGroupSelectors.activeGroupId);
|
||||
const agent = useAgentGroupStore((s) =>
|
||||
args?.agentId && activeGroupId
|
||||
? agentGroupSelectors.getAgentByIdFromGroup(activeGroupId, args.agentId)(s)
|
||||
: undefined,
|
||||
);
|
||||
|
||||
const timeoutMinutes = args?.timeout ? Math.round(args.timeout / 60_000) : 30;
|
||||
|
||||
return (
|
||||
@@ -55,15 +44,7 @@ const ExecuteTaskRender = memo<BuiltinRenderProps<ExecuteTaskParams, ExecuteTask
|
||||
{/* Header: Agent info + Timeout */}
|
||||
<Flexbox align={'center'} gap={12} horizontal justify={'space-between'}>
|
||||
<Flexbox align={'center'} flex={1} gap={12} horizontal style={{ minWidth: 0 }}>
|
||||
<Avatar
|
||||
avatar={agent?.avatar || '🤖'}
|
||||
background={agent?.backgroundColor || undefined}
|
||||
size={24}
|
||||
style={{ borderRadius: 8, flexShrink: 0 }}
|
||||
/>
|
||||
<span className={styles.agentTitle}>
|
||||
{agent?.title || t('agentGroupManagement.executeTask.intervention.unknownAgent')}
|
||||
</span>
|
||||
<span className={styles.agentTitle}>{args?.title}</span>
|
||||
</Flexbox>
|
||||
<Flexbox align="center" className={styles.timeout} gap={4} horizontal>
|
||||
<Clock size={14} />
|
||||
|
||||
@@ -280,7 +280,7 @@ describe('GroupManagementExecutor', () => {
|
||||
const ctx = createMockContext();
|
||||
|
||||
const result = await groupManagementExecutor.executeAgentTask(
|
||||
{ agentId: 'agent-1', task: 'Do something' },
|
||||
{ agentId: 'agent-1', task: 'Do something', title: 'Test Task' },
|
||||
ctx,
|
||||
);
|
||||
|
||||
@@ -291,6 +291,7 @@ describe('GroupManagementExecutor', () => {
|
||||
agentId: 'agent-1',
|
||||
task: 'Do something',
|
||||
timeout: undefined,
|
||||
title: 'Test Task',
|
||||
type: 'executeAgentTask',
|
||||
});
|
||||
});
|
||||
@@ -314,7 +315,7 @@ describe('GroupManagementExecutor', () => {
|
||||
);
|
||||
|
||||
await groupManagementExecutor.executeAgentTask(
|
||||
{ agentId: 'agent-1', task: 'Do something', timeout: 30000 },
|
||||
{ agentId: 'agent-1', task: 'Do something', timeout: 30000, title: 'Test Task' },
|
||||
ctx,
|
||||
);
|
||||
|
||||
@@ -339,7 +340,7 @@ describe('GroupManagementExecutor', () => {
|
||||
const ctx = createMockContext();
|
||||
|
||||
const result = await groupManagementExecutor.executeAgentTask(
|
||||
{ agentId: 'agent-1', task: 'Do something' },
|
||||
{ agentId: 'agent-1', task: 'Do something', title: 'Test Task' },
|
||||
ctx,
|
||||
);
|
||||
|
||||
@@ -351,7 +352,7 @@ describe('GroupManagementExecutor', () => {
|
||||
const ctx = createMockContext();
|
||||
|
||||
const result = await groupManagementExecutor.executeAgentTask(
|
||||
{ agentId: 'agent-1', task: 'Do something', timeout: 60000 },
|
||||
{ agentId: 'agent-1', task: 'Do something', timeout: 60000, title: 'Test Task' },
|
||||
ctx,
|
||||
);
|
||||
|
||||
@@ -360,6 +361,7 @@ describe('GroupManagementExecutor', () => {
|
||||
agentId: 'agent-1',
|
||||
task: 'Do something',
|
||||
timeout: 60000,
|
||||
title: 'Test Task',
|
||||
type: 'executeAgentTask',
|
||||
});
|
||||
});
|
||||
|
||||
@@ -95,6 +95,10 @@ export const GroupManagementManifest: BuiltinToolManifest = {
|
||||
description: 'The ID of the agent to execute the task.',
|
||||
type: 'string',
|
||||
},
|
||||
title: {
|
||||
description: 'Brief title describing what this task does (shown in UI).',
|
||||
type: 'string',
|
||||
},
|
||||
task: {
|
||||
description:
|
||||
'Clear description of the task to perform. Be specific about expected deliverables.',
|
||||
@@ -113,7 +117,7 @@ export const GroupManagementManifest: BuiltinToolManifest = {
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
required: ['agentId', 'task'],
|
||||
required: ['agentId', 'title', 'task'],
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
|
||||
@@ -80,6 +80,8 @@ export interface ExecuteTaskParams {
|
||||
skipCallSupervisor?: boolean;
|
||||
task: string;
|
||||
timeout?: number;
|
||||
/** Brief title describing what this task does (shown in UI) */
|
||||
title: string;
|
||||
}
|
||||
|
||||
export interface TaskItem {
|
||||
|
||||
Reference in New Issue
Block a user