diff --git a/src/app/chat/features/SessionListContent/CollapseGroup/Actions.tsx b/src/app/chat/features/SessionListContent/CollapseGroup/Actions.tsx index 4b6a6cf5a133..06692b940f4c 100644 --- a/src/app/chat/features/SessionListContent/CollapseGroup/Actions.tsx +++ b/src/app/chat/features/SessionListContent/CollapseGroup/Actions.tsx @@ -1,7 +1,7 @@ import { ActionIcon, Icon } from '@bentwnghk/ui'; import { App, Dropdown, DropdownProps, MenuProps } from 'antd'; import { createStyles } from 'antd-style'; -import { MoreVertical, PencilLine, Settings2, Trash } from 'lucide-react'; +import { MoreVertical, PencilLine, Plus, Settings2, Trash } from 'lucide-react'; import { memo, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; @@ -15,19 +15,51 @@ const useStyles = createStyles(({ css }) => ({ interface ActionsProps extends Pick { id?: string; isCustomGroup?: boolean; + isPinned?: boolean; openConfigModal: () => void; openRenameModal?: () => void; } +type ItemOfType = T extends (infer Item)[] ? Item : never; +type MenuItemType = ItemOfType; + const Actions = memo( - ({ id, openRenameModal, openConfigModal, onOpenChange, isCustomGroup }) => { + ({ id, openRenameModal, openConfigModal, onOpenChange, isCustomGroup, isPinned }) => { const { t } = useTranslation('chat'); const { styles } = useStyles(); const { modal } = App.useApp(); - const [removeSessionGroup] = useSessionStore((s) => [s.removeSessionGroup]); + const [createSession, removeSessionGroup] = useSessionStore((s) => [ + s.createSession, + s.removeSessionGroup, + ]); + + const sessionGroupConfigPublicItem: MenuItemType = { + icon: , + key: 'config', + label: t('sessionGroup.config'), + onClick: ({ domEvent }) => { + domEvent.stopPropagation(); + openConfigModal(); + }, + }; + + const newAgentPublicItem: MenuItemType = { + icon: , + key: 'newAgent', + label: t('newAgent'), + onClick: ({ domEvent }) => { + domEvent.stopPropagation(); + createSession({ group: id, pinned: isPinned }); + }, + }; + const customGroupItems: MenuProps['items'] = useMemo( () => [ + newAgentPublicItem, + { + type: 'divider', + }, { icon: , key: 'rename', @@ -37,15 +69,7 @@ const Actions = memo( openRenameModal?.(); }, }, - { - icon: , - key: 'config', - label: t('sessionGroup.config'), - onClick: ({ domEvent }) => { - domEvent.stopPropagation(); - openConfigModal(); - }, - }, + sessionGroupConfigPublicItem, { type: 'divider', }, @@ -74,15 +98,11 @@ const Actions = memo( const defaultItems: MenuProps['items'] = useMemo( () => [ + newAgentPublicItem, { - icon: , - key: 'config', - label: t('sessionGroup.config'), - onClick: ({ domEvent }) => { - domEvent.stopPropagation(); - openConfigModal(); - }, + type: 'divider', }, + sessionGroupConfigPublicItem, ], [], ); diff --git a/src/app/chat/features/SessionListContent/DefaultMode.tsx b/src/app/chat/features/SessionListContent/DefaultMode.tsx index 61106efc01f9..e09e95e80c99 100644 --- a/src/app/chat/features/SessionListContent/DefaultMode.tsx +++ b/src/app/chat/features/SessionListContent/DefaultMode.tsx @@ -40,7 +40,7 @@ const SessionListContent = memo(() => { [ pinnedSessions.length > 0 && { children: , - extra: setConfigGroupModalOpen(true)} />, + extra: setConfigGroupModalOpen(true)} />, key: SessionDefaultGroup.Pinned, label: t('pin'), }, diff --git a/src/database/models/session.ts b/src/database/models/session.ts index a12bb34b5695..91abda40e61f 100644 --- a/src/database/models/session.ts +++ b/src/database/models/session.ts @@ -23,7 +23,8 @@ class _SessionModel extends BaseModel { async create(type: 'agent' | 'group', defaultValue: Partial, id = uuid()) { const data = merge(DEFAULT_AGENT_LOBE_SESSION, { type, ...defaultValue }); - return this._add(data, id); + const dataDB = this.mapToDB_Session(data); + return this._add(dataDB, id); } async batchCreate(sessions: LobeAgentSession[]) { diff --git a/src/features/Conversation/Plugins/Inspector/index.tsx b/src/features/Conversation/Plugins/Inspector/index.tsx index e2182b93956f..c5dd491be75b 100644 --- a/src/features/Conversation/Plugins/Inspector/index.tsx +++ b/src/features/Conversation/Plugins/Inspector/index.tsx @@ -118,7 +118,7 @@ const Inspector = memo( label: t('debug.response'), }, ]} - style={{ display: 'grid', maxWidth: 800 }} + style={{ display: 'grid', maxWidth: 800, minWidth: 400 }} /> )}