🤯 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(group): split add-member into create-new vs add-existing menu (#16162)
Arvin Xu58c8125f1c03
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex 4fe73775fac..ff7eebafdad 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -190,6 +190,9 @@"group.desc": "Move a task forward with multiple Agents in one shared space.","group.memberTooltip": "There are {{count}} members in the group","group.orchestratorThinking": "Orchestrator is thinking...",+ "group.profile.addMember.addExisting": "Add existing assistant",+ "group.profile.addMember.createNew": "New member",+ "group.profile.addMember.newMemberTitle": "New member","group.profile.contentPlaceholder": "Set the group objectives/work modes here. This information will be shared with all group members.","group.profile.external": "External","group.profile.externalAgentWarning": "This is an external agent. Changes made here will directly modify the original agent configuration.",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex 093a2c6cfd2..5b57650965b 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -190,6 +190,9 @@"group.desc": "在同一对话空间,让多个助理一起推进任务","group.memberTooltip": "群组内有 {{count}} 名成员","group.orchestratorThinking": "主持人思考中…",+ "group.profile.addMember.addExisting": "添加已有助手",+ "group.profile.addMember.createNew": "新建成员",+ "group.profile.addMember.newMemberTitle": "新成员","group.profile.contentPlaceholder": "在此设定群组的目标/工作模式等,这些信息将会共享给所有群组成员","group.profile.external": "外部","group.profile.externalAgentWarning": "这是一个外部代理。此处所做的更改将直接修改原始代理配置。",diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.tsindex 11e45fa6a69..f369be6e605 100644--- a/packages/locales/src/default/chat.ts+++ b/packages/locales/src/default/chat.ts@@ -124,6 +124,9 @@ export default {'group.desc': 'Move a task forward with multiple Agents in one shared space.','group.memberTooltip': 'There are {{count}} members in the group','group.orchestratorThinking': 'Orchestrator is thinking...',+ 'group.profile.addMember.addExisting': 'Add existing assistant',+ 'group.profile.addMember.createNew': 'New member',+ 'group.profile.addMember.newMemberTitle': 'New member','group.profile.contentPlaceholder':'Set the group objectives/work modes here. This information will be shared with all group members.','group.profile.external': 'External',diff --git a/src/routes/(main)/group/profile/features/Header/ChromeTabs/index.tsx b/src/routes/(main)/group/profile/features/Header/ChromeTabs/index.tsxindex a4d1aa3edb4..a6e43b086ba 100644--- a/src/routes/(main)/group/profile/features/Header/ChromeTabs/index.tsx+++ b/src/routes/(main)/group/profile/features/Header/ChromeTabs/index.tsx@@ -1,6 +1,6 @@'use client';-import { Avatar, Flexbox, Tooltip } from '@lobehub/ui';+import { Avatar, DropdownMenu, Flexbox, type MenuProps, Tooltip } from '@lobehub/ui';import { createStaticStyles, cx } from 'antd-style';import { Plus } from 'lucide-react';import { type ReactNode } from 'react';@@ -114,13 +114,18 @@ interface ChromeTabsProps {activeId: string;addDisabled?: boolean;addDisabledReason?: string;+ /**+ * When provided, the add button becomes a dropdown trigger showing these items.+ * Otherwise it falls back to calling `onAdd` directly on click.+ */+ addMenuItems?: MenuProps['items'];items: ChromeTabItem[];onAdd?: () => void;onChange: (id: string) => void;}const ChromeTabs = memo<ChromeTabsProps>(- ({ items, activeId, onChange, onAdd, addDisabled, addDisabledReason }) => {+ ({ items, activeId, onChange, onAdd, addMenuItems, addDisabled, addDisabledReason }) => {const { t } = useTranslation('chat');const containerRef = useRef<HTMLDivElement>(null);@@ -166,19 +171,35 @@ const ChromeTabs = memo<ChromeTabsProps>(</div>);})}- {onAdd && (- <Tooltip title={addDisabled ? addDisabledReason : undefined}>- <div- className={cx(styles.addButton, addDisabled && styles.addButtonDisabled)}- onClick={() => {- if (addDisabled) return;- onAdd();- }}+ {(addMenuItems || onAdd) &&+ (addMenuItems ? (+ <DropdownMenu+ disabled={addDisabled}+ items={addMenuItems}+ nativeButton={false}+ placement="bottomLeft"+ trigger={['click']}>- <Plus size={16} />- </div>- </Tooltip>- )}+ <div+ className={cx(styles.addButton, addDisabled && styles.addButtonDisabled)}+ title={addDisabled ? addDisabledReason : undefined}+ >+ <Plus size={16} />+ </div>+ </DropdownMenu>+ ) : (+ <Tooltip title={addDisabled ? addDisabledReason : undefined}>+ <div+ className={cx(styles.addButton, addDisabled && styles.addButtonDisabled)}+ onClick={() => {+ if (addDisabled) return;+ onAdd?.();+ }}+ >+ <Plus size={16} />+ </div>+ </Tooltip>+ ))}</div>);},diff --git a/src/routes/(main)/group/profile/features/Header/index.tsx b/src/routes/(main)/group/profile/features/Header/index.tsxindex d8b13b1baed..fd93dd441d7 100644--- a/src/routes/(main)/group/profile/features/Header/index.tsx+++ b/src/routes/(main)/group/profile/features/Header/index.tsx@@ -1,8 +1,8 @@'use client';-import { Flexbox } from '@lobehub/ui';+import { Flexbox, Icon, type MenuProps } from '@lobehub/ui';import { createStaticStyles } from 'antd-style';-import { Crown, Users } from 'lucide-react';+import { Crown, Sparkles, Users, UsersRound } from 'lucide-react';import { memo, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';import { useParams } from 'react-router';@@ -53,6 +53,7 @@ const Header = memo(() => {const members = useAgentGroupStore((s) => agentGroupSelectors.getGroupAgents(gid ?? '')(s));const activeGroupId = useAgentGroupStore(agentGroupSelectors.activeGroupId);const addAgentsToGroup = useAgentGroupStore((s) => s.addAgentsToGroup);+ const createAgentInGroup = useAgentGroupStore((s) => s.createAgentInGroup);const showLeftPanel = useGlobalStore(systemStatusSelectors.showLeftPanel);// Use URL query param for selected tab@@ -92,6 +93,34 @@ const Header = memo(() => {setShowAddModal(false);};+ const handleCreateMember = async () => {+ if (!activeGroupId) return;+ const newAgentId = await createAgentInGroup(activeGroupId, {+ title: t('group.profile.addMember.newMemberTitle'),+ });+ // Jump to the newly created member so the user can configure it right away+ if (newAgentId) setSelectedTabId(newAgentId);+ };++ const addMenuItems = useMemo<MenuProps['items']>(+ () => [+ {+ icon: <Icon icon={Sparkles} />,+ key: 'create-new',+ label: t('group.profile.addMember.createNew'),+ onClick: handleCreateMember,+ },+ {+ icon: <Icon icon={UsersRound} />,+ key: 'add-existing',+ label: t('group.profile.addMember.addExisting'),+ onClick: () => setShowAddModal(true),+ },+ ],+ // eslint-disable-next-line react-hooks/exhaustive-deps+ [activeGroupId, t],+ );+return (<><Flexbox horizontal align="center" className={styles.header} gap={4} justify="space-between">@@ -101,8 +130,8 @@ const Header = memo(() => {activeId={selectedTabId}addDisabled={!canEdit}addDisabledReason={reason}+ addMenuItems={addMenuItems}items={tabItems}- onAdd={() => setShowAddModal(true)}onChange={setSelectedTabId}/></div>diff --git a/src/store/agentGroup/slices/member.ts b/src/store/agentGroup/slices/member.tsindex 8195152ed91..5b6fc86db19 100644--- a/src/store/agentGroup/slices/member.ts+++ b/src/store/agentGroup/slices/member.ts@@ -1,7 +1,7 @@import { type LobeAgentConfig } from '@lobechat/types';import { type PartialDeep } from 'type-fest';-import { chatGroupService } from '@/services/chatGroup';+import { chatGroupService, type GroupMemberConfig } from '@/services/chatGroup';import { getAgentStoreState } from '@/store/agent';import { type ChatGroupStore } from '@/store/agentGroup/store';@@ -25,6 +25,19 @@ export class ChatGroupMemberAction {await this.#get().refreshGroupDetail(groupId);};+ /**+ * Create a blank virtual agent that lives only inside the group and add it as a member.+ * Returns the new agent id so the caller can navigate to it.+ */+ createAgentInGroup = async (+ groupId: string,+ config?: GroupMemberConfig,+ ): Promise<string | undefined> => {+ const { agentIds } = await chatGroupService.batchCreateAgentsInGroup(groupId, [config ?? {}]);+ await this.#get().refreshGroupDetail(groupId);+ return agentIds[0];+ };+removeAgentFromGroup = async (groupId: string, agentId: string) => {await chatGroupService.removeAgentsFromGroup(groupId, [agentId]);await this.#get().refreshGroupDetail(groupId);