🤯 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: update actions bar
canisminor19907367093191b9
diff --git a/src/app/[variants]/(main)/chat/features/Conversation/MainChatInput/index.tsx b/src/app/[variants]/(main)/chat/features/Conversation/MainChatInput/index.tsxindex 28704ecb0d7..b6df38ab712 100644--- a/src/app/[variants]/(main)/chat/features/Conversation/MainChatInput/index.tsx+++ b/src/app/[variants]/(main)/chat/features/Conversation/MainChatInput/index.tsx@@ -13,10 +13,8 @@ const leftActions: ActionKeys[] = ['search','typo','fileUpload',- 'knowledgeBase',- 'tools','---',- ['params', 'history', 'stt', 'clear'],+ ['tools', 'params', 'clear'],'mainToken',];diff --git a/src/app/[variants]/(main)/group/features/Conversation/MainChatInput/GroupChat.tsx b/src/app/[variants]/(main)/group/features/Conversation/MainChatInput/GroupChat.tsxindex eafd8f05fe3..e84b7d42e4a 100644--- a/src/app/[variants]/(main)/group/features/Conversation/MainChatInput/GroupChat.tsx+++ b/src/app/[variants]/(main)/group/features/Conversation/MainChatInput/GroupChat.tsx@@ -21,13 +21,12 @@ import { useSendMenuItems } from './useSendMenuItems';const leftActions: ActionKeys[] = ['typo','fileUpload',- 'knowledgeBase','---',- ['stt', 'clear'],+ ['tools', 'params', 'clear'],'mainToken',];-const dmLeftActions: ActionKeys[] = ['typo', 'fileUpload', 'knowledgeBase', '---', ['stt']];+const dmLeftActions: ActionKeys[] = ['typo', 'fileUpload', '---', ['stt']];const rightActions: ActionKeys[] = [];diff --git a/src/app/[variants]/(main)/group/features/Conversation/MainChatInput/index.tsx b/src/app/[variants]/(main)/group/features/Conversation/MainChatInput/index.tsxindex 38970539aa1..b6df38ab712 100644--- a/src/app/[variants]/(main)/group/features/Conversation/MainChatInput/index.tsx+++ b/src/app/[variants]/(main)/group/features/Conversation/MainChatInput/index.tsx@@ -13,10 +13,8 @@ const leftActions: ActionKeys[] = ['search','typo','fileUpload',- 'knowledgeBase',- 'tools','---',- 'clear',+ ['tools', 'params', 'clear'],'mainToken',];diff --git a/src/features/ChatInput/ActionBar/Upload/ServerMode.tsx b/src/features/ChatInput/ActionBar/Upload/ServerMode.tsxindex 7070d1c38d9..6ed00500a6a 100644--- a/src/features/ChatInput/ActionBar/Upload/ServerMode.tsx+++ b/src/features/ChatInput/ActionBar/Upload/ServerMode.tsx@@ -1,19 +1,27 @@import { validateVideoFileSize } from '@lobechat/utils/client';-import { type MenuProps, Tooltip } from '@lobehub/ui';+import { Icon, type ItemType, type MenuProps, Tooltip } from '@lobehub/ui';import { Upload } from 'antd';import { css, cx } from 'antd-style';-import { FileUp, FolderUp, ImageUp, Paperclip } from 'lucide-react';-import { memo } from 'react';+import isEqual from 'fast-deep-equal';+import { ArrowRight, FileUp, FolderUp, ImageUp, LibraryBig, Paperclip } from 'lucide-react';+import { Suspense, memo, useState } from 'react';import { useTranslation } from 'react-i18next';import { message } from '@/components/AntdStaticMethods';+import FileIcon from '@/components/FileIcon';+import RepoIcon from '@/components/LibIcon';+import TipGuide from '@/components/TipGuide';+import { AttachKnowledgeModal } from '@/features/LibraryModal';import { useModelSupportVision } from '@/hooks/useModelSupportVision';import { useAgentStore } from '@/store/agent';import { agentByIdSelectors } from '@/store/agent/selectors';import { useFileStore } from '@/store/file';+import { useUserStore } from '@/store/user';+import { preferenceSelectors } from '@/store/user/selectors';import { useAgentId } from '../../hooks/useAgentId';import Action from '../components/Action';+import CheckboxItem from '../components/CheckbokWithLoading';const hotArea = css`&::before {@@ -35,7 +43,25 @@ const FileUpload = memo(() => {const canUploadImage = useModelSupportVision(model, provider);- const items: MenuProps['items'] = [+ const [showTip, updateGuideState] = useUserStore((s) => [+ preferenceSelectors.showUploadFileInKnowledgeBaseTip(s),+ s.updateGuideState,+ ]);+ const [modalOpen, setModalOpen] = useState(false);+ const [updating, setUpdating] = useState(false);++ const files = useAgentStore((s) => agentByIdSelectors.getAgentFilesById(agentId)(s), isEqual);+ const knowledgeBases = useAgentStore(+ (s) => agentByIdSelectors.getAgentKnowledgeBasesById(agentId)(s),+ isEqual,+ );++ const [toggleFile, toggleKnowledgeBase] = useAgentStore((s) => [+ s.toggleFile,+ s.toggleKnowledgeBase,+ ]);++ const uploadItems: MenuProps['items'] = [{disabled: !canUploadImage,icon: ImageUp,@@ -124,16 +150,109 @@ const FileUpload = memo(() => {},];- return (+ const knowledgeItems: ItemType[] = [];++ // Only add knowledge base items if there are files or knowledge bases+ if (files.length > 0 || knowledgeBases.length > 0) {+ knowledgeItems.push({+ children: [+ // first the files+ ...files.map((item) => ({+ icon: <FileIcon fileName={item.name} fileType={item.type} size={20} />,+ key: item.id,+ label: (+ <CheckboxItem+ checked={item.enabled}+ id={item.id}+ label={item.name}+ onUpdate={async (id, enabled) => {+ setUpdating(true);+ await toggleFile(id, enabled);+ setUpdating(false);+ }}+ />+ ),+ })),++ // then the knowledge bases+ ...knowledgeBases.map((item) => ({+ icon: <RepoIcon />,+ key: item.id,+ label: (+ <CheckboxItem+ checked={item.enabled}+ id={item.id}+ label={item.name}+ onUpdate={async (id, enabled) => {+ setUpdating(true);+ await toggleKnowledgeBase(id, enabled);+ setUpdating(false);+ }}+ />+ ),+ })),+ ],+ key: 'relativeFilesOrLibraries',+ label: t('knowledgeBase.relativeFilesOrLibraries'),+ type: 'group',+ });+ }++ // Always add the "View More" option+ knowledgeItems.push(+ {+ type: 'divider',+ },+ {+ extra: <Icon icon={ArrowRight} />,+ icon: LibraryBig,+ key: 'knowledge-base-store',+ label: t('knowledgeBase.viewMore'),+ onClick: () => {+ setModalOpen(true);+ },+ },+ );++ const items: MenuProps['items'] = [+ ...uploadItems,+ ...(knowledgeItems.length > 0 ? knowledgeItems : []),+ ];++ const content = (<Actiondropdown={{+ maxHeight: 500,+ maxWidth: 480,menu: { items },+ minWidth: 240,}}icon={Paperclip}+ loading={updating}showTooltip={false}title={t('upload.action.tooltip')}/>);++ return (+ <Suspense fallback={<Action disabled icon={Paperclip} title={t('upload.action.tooltip')} />}>+ {showTip ? (+ <TipGuide+ onOpenChange={() => {+ updateGuideState({ uploadFileInKnowledgeBase: false });+ }}+ open={showTip}+ placement={'top'}+ title={t('knowledgeBase.uploadGuide')}+ >+ {content}+ </TipGuide>+ ) : (+ content+ )}+ <AttachKnowledgeModal open={modalOpen} setOpen={setModalOpen} />+ </Suspense>+ );});export default FileUpload;diff --git a/src/features/ChatInput/ActionBar/config.ts b/src/features/ChatInput/ActionBar/config.tsindex b70618dd1e8..8e1bde9622a 100644--- a/src/features/ChatInput/ActionBar/config.ts+++ b/src/features/ChatInput/ActionBar/config.ts@@ -1,7 +1,6 @@import AgentMode from './AgentMode';import Clear from './Clear';import History from './History';-import Knowledge from './Knowledge';import Mention from './Mention';import Model from './Model';import Params from './Params';@@ -18,7 +17,6 @@ export const actionMap = {clear: Clear,fileUpload: Upload,history: History,- knowledgeBase: Knowledge,mainToken: MainToken,mention: Mention,model: Model,