mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-27 13:29:15 +07:00
🔨 chore: clean up unnecessary comments (#11659)
* 🔨 chore: clean up unnecessary comments Remove 358 lines of unnecessary comments across 33 files: - Remove commented-out code blocks and unused implementations - Remove redundant single-line comments that repeat code logic - Remove empty comments and placeholder comments - Remove commented-out import/export statements This improves code readability and reduces visual clutter without affecting functionality. * 🔨 chore: clean up additional unnecessary comments Remove 28 more lines of unnecessary comments: - Remove commented-out PostgresViewer menu item in DevPanel - Remove commented-out OAuth fallback endpoints in SSO helpers - Remove commented-out copy menu item in page dropdown - Remove commented-out debugger script in root layout - Remove commented-out Tooltip component in ModelItem This further improves code cleanliness and maintainability. * 🔨 chore: clean up additional unnecessary comments (round 3) Removed commented-out code and empty comment blocks: - GlobalProvider: removed commented FaviconTestPanel - TaskDetailPanel: removed commented Instruction Header section - ImportDetail: removed commented duplicate data handling UI - Header: removed commented MarketSourceSwitch - router: removed empty if block with placeholder comments * 🔨 chore: clean up commented-out code (round 4) Removed unnecessary commented code: - parseModels: removed commented deploymentName fallback - I18nManager: removed commented window notification code - conversationLifecycle: removed commented file addition note * 🔨 chore: clean up commented-out tests (round 5) Removed commented-out test blocks: - session.test.ts: removed commented getAgentConfigById describe block (29 lines) - app.test.ts: removed commented OPENAI_FUNCTION_REGIONS test (5 lines)
This commit is contained in:
@@ -149,17 +149,6 @@ export class I18nManager {
|
||||
*/
|
||||
private notifyRendererProcess(lng: string) {
|
||||
logger.debug(`Notifying renderer process of language change: ${lng}`);
|
||||
|
||||
// Send language change event to all windows
|
||||
// const windows = this.app.browserManager.windows;
|
||||
//
|
||||
// if (windows && windows.length > 0) {
|
||||
// windows.forEach((window) => {
|
||||
// if (window?.webContents) {
|
||||
// window.webContents.send('language-changed', lng);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
|
||||
private async loadLocale(language: string) {
|
||||
|
||||
@@ -235,35 +235,6 @@ describe('SessionModel', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// describe('getAgentConfigById', () => {
|
||||
// it('should return agent config by id', async () => {
|
||||
// await serverDB.transaction(async (trx) => {
|
||||
// await trx.insert(agents).values([
|
||||
// { id: '1', userId, model: 'gpt-3.5-turbo' },
|
||||
// { id: '2', userId, model: 'gpt-3.5' },
|
||||
// ]);
|
||||
//
|
||||
// // @ts-ignore
|
||||
// await trx.insert(plugins).values([
|
||||
// { id: 1, userId, identifier: 'abc', title: 'A1', locale: 'en-US', manifest: {} },
|
||||
// { id: 2, userId, identifier: 'b2', title: 'A2', locale: 'en-US', manifest: {} },
|
||||
// ]);
|
||||
//
|
||||
// await trx.insert(agentsPlugins).values([
|
||||
// { agentId: '1', pluginId: 1 },
|
||||
// { agentId: '2', pluginId: 2 },
|
||||
// { agentId: '1', pluginId: 2 },
|
||||
// ]);
|
||||
// });
|
||||
//
|
||||
// const result = await sessionModel.getAgentConfigById('1');
|
||||
//
|
||||
// expect(result?.id).toBe('1');
|
||||
// expect(result?.plugins).toBe(['abc', 'b2']);
|
||||
// expect(result?.model).toEqual('gpt-3.5-turbo');
|
||||
// expect(result?.chatConfig).toBeDefined();
|
||||
// });
|
||||
// });
|
||||
describe('count', () => {
|
||||
it('should return the count of sessions for the user', async () => {
|
||||
// 创建测试数据
|
||||
|
||||
@@ -7,8 +7,6 @@ import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { useConversationStore } from '@/features/Conversation';
|
||||
|
||||
// import { useSend } from '../../features/ChatInput/useSend';
|
||||
|
||||
const styles = createStaticStyles(({ css, cssVar }) => ({
|
||||
card: css`
|
||||
padding-block: 8px;
|
||||
|
||||
@@ -16,42 +16,6 @@ const TocList = memo(() => {
|
||||
const { t } = useTranslation('discover');
|
||||
const { toc = [] } = useToc();
|
||||
const { activeTab = AssistantNavKey.Overview } = useQuery() as { activeTab: AssistantNavKey };
|
||||
// const { deploymentOptions = [], tools = [], prompts = [] } = useDetailContext();
|
||||
//
|
||||
// const schemaToc: AnchorProps['items'] = useMemo(() => {
|
||||
// return [
|
||||
// {
|
||||
// href: `#tools`,
|
||||
// key: `tools`,
|
||||
// level: 2,
|
||||
// title: t('mcp.details.schema.tools.title'),
|
||||
// },
|
||||
// ...tools.map((item) => ({
|
||||
// href: `#tools-${item.name}`,
|
||||
// key: `tools-${item.name}`,
|
||||
// level: 3,
|
||||
// title: item.name,
|
||||
// })),
|
||||
// {
|
||||
// href: `#prompts`,
|
||||
// key: `prompts`,
|
||||
// level: 2,
|
||||
// title: t('mcp.details.schema.prompts.title'),
|
||||
// },
|
||||
// ...prompts.map((item) => ({
|
||||
// href: `#prompts-${item.name}`,
|
||||
// key: `prompts-${item.name}`,
|
||||
// level: 3,
|
||||
// title: item.name,
|
||||
// })),
|
||||
// {
|
||||
// href: `#resources`,
|
||||
// key: `resources`,
|
||||
// level: 2,
|
||||
// title: t('mcp.details.schema.resources.title'),
|
||||
// },
|
||||
// ].filter(Boolean) as AnchorProps['items'];
|
||||
// }, [tools, prompts, t]);
|
||||
|
||||
const items: AnchorProps['items'] | undefined = useMemo(() => {
|
||||
switch (activeTab) {
|
||||
|
||||
@@ -13,7 +13,6 @@ import { styles } from './Header/style';
|
||||
|
||||
const Header = memo(() => {
|
||||
const location = useLocation();
|
||||
// const { activeKey } = useNav();
|
||||
const isHome = location.pathname === '/';
|
||||
|
||||
const cssVariables: Record<string, string> = {
|
||||
@@ -27,7 +26,6 @@ const Header = memo(() => {
|
||||
right={
|
||||
!isHome && (
|
||||
<>
|
||||
{/*{activeKey === DiscoverTab.Assistants && <MarketSourceSwitch />}*/}
|
||||
<SortButton />
|
||||
<UserAvatar />
|
||||
</>
|
||||
|
||||
@@ -41,12 +41,8 @@ const GroupMember = memo<GroupMemberProps>(({ addModalOpen, onAddModalOpenChange
|
||||
const toggleThread = useAgentGroupStore((s) => s.toggleThread);
|
||||
const pushPortalView = useChatStore((s) => s.pushPortalView);
|
||||
|
||||
// Get members from store (excluding supervisor)
|
||||
const groupMembers = useAgentGroupStore(agentGroupSelectors.getGroupMembers(groupId || ''));
|
||||
|
||||
// const [agentSettingsOpen, setAgentSettingsOpen] = useState(false);
|
||||
// const [selectedAgentId, setSelectedAgentId] = useState<string | undefined>();
|
||||
|
||||
const handleAddMembers = async (selectedAgents: string[]) => {
|
||||
if (!groupId) {
|
||||
console.error('No active group to add members to');
|
||||
|
||||
@@ -18,8 +18,6 @@ import ThreadHydration from './ThreadHydration';
|
||||
import { useActionsBarConfig } from './useActionsBarConfig';
|
||||
import { useGroupContext } from './useGroupContext';
|
||||
|
||||
// import { useGroupHooks } from './useGroupHooks';
|
||||
|
||||
interface ConversationAreaProps {
|
||||
mobile?: boolean;
|
||||
}
|
||||
@@ -45,18 +43,13 @@ const Conversation = memo<ConversationAreaProps>(({ mobile = false }) => {
|
||||
// Get operation state from ChatStore for reactive updates
|
||||
const operationState = useOperationState(context);
|
||||
|
||||
// Get actionsBar config with branching support from ChatStore
|
||||
const actionsBarConfig = useActionsBarConfig();
|
||||
|
||||
// Get group-specific hooks for send logic
|
||||
// const groupHooks = useGroupHooks(context);
|
||||
|
||||
return (
|
||||
<ConversationProvider
|
||||
actionsBar={actionsBarConfig}
|
||||
context={context}
|
||||
hasInitMessages={!!messages}
|
||||
// hooks={groupHooks}
|
||||
messages={messages}
|
||||
onMessagesChange={(messages, ctx) => {
|
||||
replaceMessages(messages, { context: ctx });
|
||||
|
||||
@@ -35,7 +35,6 @@ const rightActions: ActionKeys[] = [];
|
||||
*/
|
||||
const Desktop = memo((props: { targetMemberId?: string }) => {
|
||||
const { t } = useTranslation('chat');
|
||||
// const { send, generating, disabled, stop } = useSendGroupMessage();
|
||||
|
||||
const isDMPortal = !!props.targetMemberId;
|
||||
const currentGroupMembers = useAgentGroupStore(agentGroupSelectors.currentGroupAgents, isEqual);
|
||||
@@ -93,7 +92,6 @@ const Desktop = memo((props: { targetMemberId?: string }) => {
|
||||
useChatStore.setState({ inputMessage: content });
|
||||
}}
|
||||
rightActions={isDMPortal ? [] : rightActions}
|
||||
// sendButtonProps={{ disabled, generating, onStop: stop }}
|
||||
sendMenu={{
|
||||
items: sendMenuItems,
|
||||
}}
|
||||
|
||||
@@ -12,11 +12,9 @@ export enum GroupKey {
|
||||
}
|
||||
|
||||
const Body = memo(() => {
|
||||
// const { enableKnowledgeBase } = useServerConfigStore(featureFlagsSelectors);
|
||||
return (
|
||||
<Flexbox paddingInline={4}>
|
||||
<Accordion defaultExpandedKeys={[GroupKey.Project, GroupKey.Agent]} gap={8}>
|
||||
{/*{enableKnowledgeBase && <Repo itemKey={GroupKey.Project} />}*/}
|
||||
<Agent itemKey={GroupKey.Agent} />
|
||||
<BottomMenu />
|
||||
</Accordion>
|
||||
|
||||
@@ -56,12 +56,6 @@ export const useDropdownMenu = ({
|
||||
label: t('rename'),
|
||||
onClick: () => toggleEditing(true),
|
||||
},
|
||||
// {
|
||||
// icon: <Icon icon={Copy} />,
|
||||
// key: 'copy',
|
||||
// label: t('pageList.copyContent', { ns: 'file' }),
|
||||
// onClick: handleCopy,
|
||||
// },
|
||||
{
|
||||
icon: <Icon icon={CopyPlus} />,
|
||||
key: 'duplicate',
|
||||
|
||||
@@ -32,21 +32,6 @@ export const useDropdownMenu = (): MenuProps['items'] => {
|
||||
}));
|
||||
|
||||
return [
|
||||
// {
|
||||
// icon: <Icon icon={Check} style={{ opacity: !showOnlyPagesNotInLibrary ? 1 : 0 }} />,
|
||||
// key: 'all',
|
||||
// label: t('pageList.filter.all'),
|
||||
// onClick: () => setShowOnlyPagesNotInLibrary(false),
|
||||
// },
|
||||
// {
|
||||
// icon: <Icon icon={Check} style={{ opacity: showOnlyPagesNotInLibrary ? 1 : 0 }} />,
|
||||
// key: 'onlyInPages',
|
||||
// label: t('pageList.filter.onlyInPages'),
|
||||
// onClick: () => setShowOnlyPagesNotInLibrary(true),
|
||||
// },
|
||||
// {
|
||||
// type: 'divider' as const,
|
||||
// },
|
||||
{
|
||||
children: pageSizeItems,
|
||||
icon: <Icon icon={Hash} />,
|
||||
|
||||
@@ -141,11 +141,6 @@ export const DndContextWrapper = memo<PropsWithChildren>(({ children }) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// Save current drag data before clearing state
|
||||
// const draggedItemId = currentDrag.id;
|
||||
// const draggedItemData = currentDrag.data;
|
||||
|
||||
// Clear drag state immediately for better UX
|
||||
setCurrentDrag(null);
|
||||
|
||||
// Show loading toast
|
||||
|
||||
@@ -51,7 +51,6 @@ const ModelConfigModal = memo<ModelConfigModalProps>(({ open, setOpen }) => {
|
||||
setLoading(false);
|
||||
closeModal();
|
||||
} catch {
|
||||
/* */
|
||||
setLoading(false);
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -240,16 +240,6 @@ const ModelItem = memo<ModelItemProps>(
|
||||
{...abilities}
|
||||
contextWindowTokens={contextWindowTokens}
|
||||
/>
|
||||
{/*{removed && (*/}
|
||||
{/* <Tooltip*/}
|
||||
{/* overlayStyle={{ maxWidth: 300 }}*/}
|
||||
{/* placement={'top'}*/}
|
||||
{/* style={{ pointerEvents: 'none' }}*/}
|
||||
{/* title={t('ModelSelect.removed')}*/}
|
||||
{/* >*/}
|
||||
{/* <ActionIcon icon={Recycle} style={{ color: theme.colorWarning }} />*/}
|
||||
{/* </Tooltip>*/}
|
||||
{/*)}*/}
|
||||
</Flexbox>
|
||||
</Flexbox>
|
||||
<div>
|
||||
|
||||
@@ -66,7 +66,6 @@ const Actions = memo<ActionProps>(({ group, id, openCreateGroupModal, parentType
|
||||
const { modal, message } = App.useApp();
|
||||
|
||||
const isDefault = group === SessionDefaultGroup.Default;
|
||||
// const hasDivider = !isDefault || Object.keys(sessionByGroup).length > 0;
|
||||
|
||||
const items = useMemo(
|
||||
() =>
|
||||
|
||||
@@ -52,8 +52,6 @@ const RootLayout = async ({ children, params }: RootLayoutProps) => {
|
||||
<head>
|
||||
{/* eslint-disable-next-line @typescript-eslint/no-use-before-define */}
|
||||
<script dangerouslySetInnerHTML={{ __html: `(${outdateBrowserScript.toString()})();` }} />
|
||||
|
||||
{/* <script dangerouslySetInnerHTML={{ __html: 'setTimeout(() => {debugger}, 16)' }} /> */}
|
||||
{process.env.DEBUG_REACT_SCAN === '1' && (
|
||||
<Script
|
||||
crossOrigin={'anonymous'}
|
||||
|
||||
@@ -7,12 +7,6 @@ describe('getServerConfig', () => {
|
||||
vi.resetModules();
|
||||
});
|
||||
|
||||
// it('correctly handles values for OPENAI_FUNCTION_REGIONS', () => {
|
||||
// process.env.OPENAI_FUNCTION_REGIONS = 'iad1,sfo1';
|
||||
// const config = getAppConfig();
|
||||
// expect(config.OPENAI_FUNCTION_REGIONS).toStrictEqual(['iad1', 'sfo1']);
|
||||
// });
|
||||
|
||||
describe('index url', () => {
|
||||
it('should return default URLs when no environment variables are set', async () => {
|
||||
const { getAppConfig } = await import('../app');
|
||||
|
||||
@@ -33,28 +33,6 @@ export const useControls = ({
|
||||
]);
|
||||
|
||||
const items: ItemType[] = [
|
||||
// {
|
||||
// children: [
|
||||
// {
|
||||
// icon: <RepoIcon />,
|
||||
// key: 'allFiles',
|
||||
// label: <KnowledgeBaseItem id={'all'} label={t('knowledgeBase.allFiles')} />,
|
||||
// },
|
||||
// {
|
||||
// icon: <RepoIcon />,
|
||||
// key: 'allRepos',
|
||||
// label: <KnowledgeBaseItem id={'all'} label={t('knowledgeBase.allLibraries')} />,
|
||||
// },
|
||||
// ],
|
||||
// key: 'all',
|
||||
// label: (
|
||||
// <Flexbox horizontal justify={'space-between'}>
|
||||
// {t('knowledgeBase.all')}
|
||||
// {/*<Link href={'/files'}>{t('knowledgeBase.more')}</Link>*/}
|
||||
// </Flexbox>
|
||||
// ),
|
||||
// type: 'group',
|
||||
// },
|
||||
{
|
||||
children: [
|
||||
// first the files
|
||||
|
||||
@@ -15,8 +15,6 @@ export interface Action {
|
||||
|
||||
export type Store = Action & State;
|
||||
|
||||
// const t = setNamespace('ChatInput');
|
||||
|
||||
type CreateStore = (
|
||||
initState?: Partial<PublicState>,
|
||||
) => StateCreator<Store, [['zustand/devtools', never]]>;
|
||||
|
||||
@@ -19,16 +19,6 @@ interface TaskDetailPanelProps {
|
||||
const TaskDetailPanel = memo<TaskDetailPanelProps>(({ taskDetail, content, messageId }) => {
|
||||
return (
|
||||
<>
|
||||
{/* Instruction Header */}
|
||||
{/*{instruction && (*/}
|
||||
{/* <Block padding={12}>*/}
|
||||
{/* <Text fontSize={13} type={'secondary'}>*/}
|
||||
{/* {instruction}*/}
|
||||
{/* </Text>*/}
|
||||
{/* </Block>*/}
|
||||
{/*)}*/}
|
||||
|
||||
{/* Status Content */}
|
||||
<StatusContent content={content} messageId={messageId} taskDetail={taskDetail} />
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -170,26 +170,6 @@ const ImportPreviewModal = ({
|
||||
size="small"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/*<Flexbox>*/}
|
||||
{/* 重复数据处理方式:*/}
|
||||
{/* <div className={styles.duplicateOptions}>*/}
|
||||
{/* <Radio.Group*/}
|
||||
{/* onChange={(e) => setDuplicateAction(e.target.value)}*/}
|
||||
{/* value={duplicateAction}*/}
|
||||
{/* >*/}
|
||||
{/* <Space>*/}
|
||||
{/* <Radio value="skip">跳过</Radio>*/}
|
||||
{/* <Radio value="overwrite">覆盖</Radio>*/}
|
||||
{/* </Space>*/}
|
||||
{/* </Radio.Group>*/}
|
||||
{/* </div>*/}
|
||||
{/* <div className={styles.duplicateDescription}>*/}
|
||||
{/* {duplicateAction === 'skip'*/}
|
||||
{/* ? '选择跳过将仅导入不重复的数据,保留现有数据不变。'*/}
|
||||
{/* : '选择覆盖将使用导入数据替换系统中具有相同 ID 的现有记录。'}*/}
|
||||
{/* </div>*/}
|
||||
{/*</Flexbox>*/}
|
||||
</Flexbox>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
@@ -2,27 +2,6 @@ import dayjs from 'dayjs';
|
||||
import { get, isDate } from 'es-toolkit/compat';
|
||||
import React, { useMemo } from 'react';
|
||||
|
||||
// import TooltipContent from './TooltipContent';
|
||||
|
||||
// const { Text } = Typography;
|
||||
|
||||
// const useStyles = createStyles(({ token, css }) => ({
|
||||
// cell: css`
|
||||
// font-family: ${token.fontFamilyCode};
|
||||
// font-size: ${token.fontSizeSM}px;
|
||||
// `,
|
||||
// tooltip: css`
|
||||
// border: 1px solid ${token.colorBorder};
|
||||
//
|
||||
// font-family: ${token.fontFamilyCode};
|
||||
// font-size: ${token.fontSizeSM}px;
|
||||
// color: ${token.colorText} !important;
|
||||
// word-break: break-all;
|
||||
//
|
||||
// background: ${token.colorBgElevated} !important;
|
||||
// `,
|
||||
// }));
|
||||
|
||||
interface TableCellProps {
|
||||
column: string;
|
||||
dataItem: any;
|
||||
@@ -30,7 +9,6 @@ interface TableCellProps {
|
||||
}
|
||||
|
||||
const TableCell = ({ dataItem, column, rowIndex }: TableCellProps) => {
|
||||
// const { styles } = useStyles();
|
||||
const data = get(dataItem, column);
|
||||
const content = useMemo(() => {
|
||||
if (isDate(data)) return dayjs(data).format('YYYY-MM-DD HH:mm:ss');
|
||||
@@ -52,21 +30,8 @@ const TableCell = ({ dataItem, column, rowIndex }: TableCellProps) => {
|
||||
|
||||
return (
|
||||
<td key={column} onDoubleClick={() => console.log('Edit cell:', rowIndex, column)}>
|
||||
{content}
|
||||
|
||||
{/* 不能使用 antd 的 Text, 会有大量的重渲染导致滚动极其卡顿 */}
|
||||
{/*<Text*/}
|
||||
{/* className={styles.cell}*/}
|
||||
{/* ellipsis={{*/}
|
||||
{/* tooltip: {*/}
|
||||
{/* arrow: false,*/}
|
||||
{/* classNames: { body: styles.tooltip },*/}
|
||||
{/* title: <TooltipContent>{content}</TooltipContent>,*/}
|
||||
{/* },*/}
|
||||
{/* }}*/}
|
||||
{/*>*/}
|
||||
{/* {content}*/}
|
||||
{/*</Text>*/}
|
||||
{content}
|
||||
</td>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -15,15 +15,6 @@ const FloatPanel = dynamic(() => import('./features/FloatPanel'), {
|
||||
const DevPanel = () => (
|
||||
<FloatPanel
|
||||
items={[
|
||||
// ...(isDesktop
|
||||
// ? [
|
||||
// {
|
||||
// children: <PostgresViewer />,
|
||||
// icon: <DatabaseIcon size={16} />,
|
||||
// key: 'Postgres Viewer',
|
||||
// },
|
||||
// ]
|
||||
// : []),
|
||||
{
|
||||
children: <MetadataViewer />,
|
||||
icon: <BookText size={16} />,
|
||||
|
||||
@@ -3,20 +3,14 @@
|
||||
import { Flexbox } from '@lobehub/ui';
|
||||
import { memo } from 'react';
|
||||
|
||||
// import ChatInput from '@/app/[variants]/(main)/chat/features/Conversation/ChatInput';
|
||||
// import { useChatGroupStore } from '@/store/chatGroup';
|
||||
|
||||
import ThreadChatList from './ThreadChatList';
|
||||
|
||||
const Body = memo(() => {
|
||||
// const activeThreadAgentId = useChatGroupStore((s) => s.activeThreadAgentId);
|
||||
|
||||
return (
|
||||
<Flexbox height={'100%'}>
|
||||
<Flexbox flex={1} style={{ overflow: 'hidden', position: 'relative' }}>
|
||||
<ThreadChatList />
|
||||
</Flexbox>
|
||||
{/*{activeThreadAgentId && <ChatInput targetMemberId={activeThreadAgentId} />}*/}
|
||||
</Flexbox>
|
||||
);
|
||||
});
|
||||
|
||||
@@ -187,22 +187,6 @@ const AddButton = () => {
|
||||
label: 'Notion',
|
||||
onClick: handleOpenNotionGuide,
|
||||
},
|
||||
// {
|
||||
// icon: <Icon icon={Notion} />,
|
||||
// key: 'connect-google-drive',
|
||||
// label: 'Google Drive',
|
||||
// onClick: () => {
|
||||
// // TODO: Implement Google Drive connection
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// icon: <Icon icon={Notion} />,
|
||||
// key: 'connect-onedrive',
|
||||
// label: 'OneDrive',
|
||||
// onClick: () => {
|
||||
// // TODO: Implement OneDrive connection
|
||||
// },
|
||||
// },
|
||||
],
|
||||
icon: <Icon icon={Link} />,
|
||||
key: 'connect',
|
||||
|
||||
@@ -56,14 +56,6 @@ const ShareImage = memo<{ mobile?: boolean }>(() => {
|
||||
name: 'withSystemRole',
|
||||
valuePropName: 'checked',
|
||||
},
|
||||
// {
|
||||
// children: <Switch />,
|
||||
// label: t('shareModal.withBackground'),
|
||||
// layout: 'horizontal',
|
||||
// minWidth: undefined,
|
||||
// name: 'withBackground',
|
||||
// valuePropName: 'checked',
|
||||
// },
|
||||
{
|
||||
children: <Switch />,
|
||||
label: t('shareModal.withFooter'),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { DEFAULT_MODEL_PROVIDER_LIST } from 'model-bank/modelProviders';
|
||||
|
||||
export const useProviderName = (provider: string) => {
|
||||
// const { t } = useTranslation('modelProvider');
|
||||
const providerCard = DEFAULT_MODEL_PROVIDER_LIST.find((p) => p.id === provider);
|
||||
|
||||
return providerCard?.name || provider;
|
||||
|
||||
@@ -12,7 +12,6 @@ import { getAntdLocale } from '@/utils/locale';
|
||||
import Editor from './Editor';
|
||||
|
||||
const updateDayjs = async (lang: string) => {
|
||||
// load default lang
|
||||
let dayJSLocale;
|
||||
try {
|
||||
// dayjs locale is using `en` instead of `en-US`
|
||||
@@ -38,21 +37,10 @@ const Locale = memo<LocaleLayoutProps>(({ children, defaultLang, antdLocale }) =
|
||||
const [lang, setLang] = useState(defaultLang);
|
||||
const [locale, setLocale] = useState(antdLocale);
|
||||
|
||||
// if run on server side, init i18n instance everytime
|
||||
if (isOnServerSide) {
|
||||
// use sync mode to init instantly
|
||||
i18n.init({ initAsync: false });
|
||||
|
||||
// load the dayjs locale
|
||||
// if (lang) {
|
||||
// const dayJSLocale = require(`dayjs/locale/${lang!.toLowerCase()}.js`);
|
||||
//
|
||||
// dayjs.locale(dayJSLocale);
|
||||
// }
|
||||
} else {
|
||||
// if on browser side, init i18n instance only once
|
||||
if (!i18n.instance.isInitialized)
|
||||
// console.debug('locale', lang);
|
||||
i18n.init().then(async () => {
|
||||
if (!lang) return;
|
||||
|
||||
|
||||
@@ -67,7 +67,6 @@ const GlobalLayout = async ({
|
||||
<QueryProvider>
|
||||
<StoreInitialization />
|
||||
<FaviconProvider>
|
||||
{/* {process.env.NODE_ENV === 'development' && <FaviconTestPanel />} */}
|
||||
<GroupWizardProvider>
|
||||
<DragUploadProvider>
|
||||
<LazyMotion features={domMax}>
|
||||
|
||||
@@ -55,7 +55,6 @@ export const buildOidcConfig = ({
|
||||
pkce,
|
||||
providerId,
|
||||
scopes,
|
||||
// ...fallbackEndpoints,
|
||||
...overrides,
|
||||
} satisfies GenericOAuthConfig;
|
||||
};
|
||||
|
||||
@@ -45,21 +45,6 @@ export const createI18nNext = (lang?: string) => {
|
||||
return instance.init({
|
||||
debug: debugMode,
|
||||
defaultNS: ['error', 'common', 'chat'],
|
||||
|
||||
// detection: {
|
||||
// caches: ['cookie'],
|
||||
// cookieMinutes: 60 * 24 * COOKIE_CACHE_DAYS,
|
||||
// /**
|
||||
// Set `sameSite` to `lax` so that the i18n cookie can be passed to the
|
||||
// server side when returning from the OAuth authorization website.
|
||||
// ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
||||
// discussion: https://github.com/lobehub/lobe-chat/pull/1474
|
||||
// */
|
||||
// cookieOptions: {
|
||||
// sameSite: 'lax',
|
||||
// },
|
||||
// lookupCookie: LOBE_LOCALE_COOKIE,
|
||||
// },
|
||||
fallbackLng: DEFAULT_LANG,
|
||||
|
||||
initAsync,
|
||||
@@ -67,8 +52,6 @@ export const createI18nNext = (lang?: string) => {
|
||||
interpolation: {
|
||||
escapeValue: false,
|
||||
},
|
||||
// Use flat keys with dots (e.g. "notFound.title") instead of nested objects.
|
||||
// This keeps both runtime lookup and TS key inference consistent.
|
||||
keySeparator: false,
|
||||
|
||||
lng: lang,
|
||||
|
||||
@@ -20,10 +20,6 @@ class AiChatService {
|
||||
signal: abortController?.signal,
|
||||
});
|
||||
};
|
||||
|
||||
// sendGroupMessageInServer = async (params: SendMessageServerParams) => {
|
||||
// return lambdaClient.aiChat.sendGroupMessageInServer.mutate(cleanObject(params));
|
||||
// };
|
||||
}
|
||||
|
||||
export const aiChatService = new AiChatService();
|
||||
|
||||
@@ -1,38 +1,5 @@
|
||||
class DebugService {
|
||||
async insertLargeDataToDB() {
|
||||
// await DEBUG_MODEL.createRandomData({
|
||||
// messageCount: 100_000,
|
||||
// sessionCount: 40,
|
||||
// startIndex: 0,
|
||||
// topicCount: 200,
|
||||
// });
|
||||
//
|
||||
// console.log('Inserted 100k');
|
||||
//
|
||||
// await DEBUG_MODEL.createRandomData({
|
||||
// messageCount: 300_000,
|
||||
// sessionCount: 40,
|
||||
// startIndex: 100_001,
|
||||
// topicCount: 200,
|
||||
// });
|
||||
// console.log('Inserted 400k');
|
||||
//
|
||||
// await DEBUG_MODEL.createRandomData({
|
||||
// messageCount: 300_000,
|
||||
// sessionCount: 40,
|
||||
// startIndex: 400_001,
|
||||
// topicCount: 200,
|
||||
// });
|
||||
// console.log('Inserted 700k');
|
||||
//
|
||||
// await DEBUG_MODEL.createRandomData({
|
||||
// messageCount: 300_000,
|
||||
// sessionCount: 40,
|
||||
// startIndex: 700_001,
|
||||
// topicCount: 200,
|
||||
// });
|
||||
// console.log('Inserted 1M');
|
||||
}
|
||||
async insertLargeDataToDB() {}
|
||||
}
|
||||
|
||||
export const debugService = new DebugService();
|
||||
|
||||
@@ -25,10 +25,8 @@ export type ProgressCallback = (progress: ModelProgressInfo) => void;
|
||||
export type ErrorCallback = (error: { message: string }) => void;
|
||||
|
||||
export class ModelsService {
|
||||
// Controller for aborting downloads
|
||||
private _abortController: AbortController | null = null;
|
||||
|
||||
// Get model list
|
||||
getModels = async (provider: string): Promise<ChatModelCard[] | undefined> => {
|
||||
const headers = await createHeaderWithAuth({
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
@@ -66,7 +64,6 @@ export class ModelsService {
|
||||
{ onProgress }: { onError?: ErrorCallback; onProgress?: ProgressCallback } = {},
|
||||
): Promise<void> => {
|
||||
try {
|
||||
// Create a new AbortController
|
||||
this._abortController = new AbortController();
|
||||
const signal = this._abortController.signal;
|
||||
|
||||
@@ -99,7 +96,6 @@ export class ModelsService {
|
||||
throw await getMessageError(res);
|
||||
}
|
||||
|
||||
// Process response stream
|
||||
if (res.body) {
|
||||
await this.processModelPullStream(res, { onProgress });
|
||||
}
|
||||
@@ -112,14 +108,11 @@ export class ModelsService {
|
||||
console.error('download model error:', error);
|
||||
throw error;
|
||||
} finally {
|
||||
// Clean up AbortController
|
||||
this._abortController = null;
|
||||
}
|
||||
};
|
||||
|
||||
// Abort model download
|
||||
abortPull = () => {
|
||||
// Use AbortController to abort download
|
||||
if (this._abortController) {
|
||||
this._abortController.abort();
|
||||
this._abortController = null;
|
||||
@@ -136,17 +129,14 @@ export class ModelsService {
|
||||
response: Response,
|
||||
{ onProgress, onError }: { onError?: ErrorCallback; onProgress?: ProgressCallback },
|
||||
): Promise<void> => {
|
||||
// Process response stream
|
||||
const reader = response.body?.getReader();
|
||||
if (!reader) return;
|
||||
|
||||
// Read and process stream data
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) break;
|
||||
|
||||
// Parse progress data
|
||||
const progressText = new TextDecoder().decode(value);
|
||||
// One line may contain multiple progress updates
|
||||
const progressUpdates = progressText.trim().split('\n');
|
||||
@@ -162,10 +152,6 @@ export class ModelsService {
|
||||
|
||||
if (progress.status === 'canceled') {
|
||||
console.log('progress:', progress);
|
||||
// const abortError = new Error('abort');
|
||||
// abortError.name = 'AbortError';
|
||||
//
|
||||
// throw abortError;
|
||||
}
|
||||
|
||||
if (progress.status === 'error') {
|
||||
@@ -173,7 +159,6 @@ export class ModelsService {
|
||||
throw new Error(progress.error);
|
||||
}
|
||||
|
||||
// Call progress callback
|
||||
if (progress.completed !== undefined || progress.status) {
|
||||
onProgress?.(progress);
|
||||
}
|
||||
|
||||
@@ -120,11 +120,6 @@ export const createGroupOrchestrationExecutors = (
|
||||
};
|
||||
}
|
||||
|
||||
// Variable to capture the decision from tool handler
|
||||
// let decision: ExecutorResult['type'] | undefined;
|
||||
// let decisionParams: Record<string, unknown> = {};
|
||||
// let skipCallSupervisor = false;
|
||||
|
||||
// Execute Supervisor agent with the supervisor's agentId in context
|
||||
// Mark isSupervisor=true so assistant messages get metadata.isSupervisor for UI rendering
|
||||
// Note: Don't pass operationId - let it create a new child operation (same as call_agent)
|
||||
@@ -139,10 +134,6 @@ export const createGroupOrchestrationExecutors = (
|
||||
|
||||
log(`[${sessionLogId}] Supervisor agent finished`);
|
||||
|
||||
// Check what decision was made by the supervisor
|
||||
// This is captured from the groupOrchestration callbacks registered by tools
|
||||
// const orchestrationCallbacks = get().getGroupOrchestrationCallbacks();
|
||||
|
||||
// If no tool was called (supervisor finished normally), end orchestration
|
||||
// The actual decision is captured via the afterCompletion callbacks
|
||||
// For now, return a finish decision if we reach here
|
||||
|
||||
@@ -399,9 +399,6 @@ export const conversationLifecycle: StateCreator<
|
||||
skipCreateFirstMessage: true,
|
||||
});
|
||||
|
||||
//
|
||||
// // if there is relative files, then add files to agent
|
||||
// // only available in server mode
|
||||
const userFiles = dbMessageSelectors
|
||||
.dbUserFiles(get())
|
||||
.map((f) => f?.id)
|
||||
|
||||
@@ -14,9 +14,7 @@ export interface ChatAIChatAction
|
||||
ConversationLifecycleAction,
|
||||
ConversationControlAction,
|
||||
StreamingExecutorAction,
|
||||
StreamingStatesAction {
|
||||
/**/
|
||||
}
|
||||
StreamingStatesAction {}
|
||||
|
||||
export const chatAiChat: StateCreator<
|
||||
ChatStore,
|
||||
|
||||
@@ -16,7 +16,6 @@ vi.mock('@/components/AntdStaticMethods', () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
// mock the arrayBuffer
|
||||
beforeAll(() => {
|
||||
Object.defineProperty(File.prototype, 'arrayBuffer', {
|
||||
writable: true,
|
||||
@@ -33,7 +32,6 @@ beforeAll(() => {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
// Reset all mocks before each test
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
@@ -41,7 +39,6 @@ describe('useFileStore:chat', () => {
|
||||
it('clearChatUploadFileList should clear the inputFilesList', () => {
|
||||
const { result } = renderHook(() => useStore());
|
||||
|
||||
// Populate the list to clear it later
|
||||
act(() => {
|
||||
useStore.setState({ chatUploadFileList: [{ id: 'abc' }] as any });
|
||||
});
|
||||
@@ -54,90 +51,4 @@ describe('useFileStore:chat', () => {
|
||||
|
||||
expect(result.current.chatUploadFileList).toEqual([]);
|
||||
});
|
||||
|
||||
// it('removeFile should call fileService.removeFile and update the store', async () => {
|
||||
// const { result } = renderHook(() => useStore());
|
||||
//
|
||||
// const fileId = 'test-id';
|
||||
//
|
||||
// // Mock the fileService.removeFile to resolve
|
||||
// vi.spyOn(fileService, 'removeFile').mockResolvedValue(undefined);
|
||||
//
|
||||
// // Populate the list to remove an item later
|
||||
// act(() => {
|
||||
// useStore.setState(({ inputFilesList }) => ({ inputFilesList: [...inputFilesList, fileId] }));
|
||||
// // // result.current.inputFilesList.push(fileId);
|
||||
// });
|
||||
//
|
||||
// await act(async () => {
|
||||
// await result.current.removeFile(fileId);
|
||||
// });
|
||||
//
|
||||
// expect(fileService.removeFile).toHaveBeenCalledWith(fileId);
|
||||
// expect(result.current.inputFilesList).toEqual([]);
|
||||
// });
|
||||
|
||||
// describe('uploadFile', () => {
|
||||
// it('uploadFile should handle errors', async () => {
|
||||
// const { result } = renderHook(() => useStore());
|
||||
// const testFile = new File(['content'], 'test.png', { type: 'image/png' });
|
||||
//
|
||||
// // 模拟 fileService.uploadFile 抛出错误
|
||||
// const errorMessage = 'Upload failed';
|
||||
// vi.spyOn(uploadService, 'uploadFile').mockRejectedValue(new Error(errorMessage));
|
||||
//
|
||||
// // Mock console.error for testing
|
||||
//
|
||||
// await act(async () => {
|
||||
// await result.current.uploadFile(testFile);
|
||||
// });
|
||||
//
|
||||
// expect(uploadService.uploadFile).toHaveBeenCalledWith({
|
||||
// createdAt: testFile.lastModified,
|
||||
// data: await testFile.arrayBuffer(),
|
||||
// fileType: testFile.type,
|
||||
// name: testFile.name,
|
||||
// saveMode: 'local',
|
||||
// size: testFile.size,
|
||||
// });
|
||||
// // 由于上传失败,inputFilesList 应该没有变化
|
||||
// expect(result.current.inputFilesList).toEqual([]);
|
||||
//
|
||||
// // 确保错误提示被调用
|
||||
// expect(notification.error).toHaveBeenCalled();
|
||||
// });
|
||||
//
|
||||
// it('uploadFile should upload the file and update inputFilesList', async () => {
|
||||
// const { result } = renderHook(() => useStore());
|
||||
// const testFile = new File(['content'], 'test.png', { type: 'image/png' });
|
||||
//
|
||||
// // 模拟 fileService.uploadFile 返回的数据
|
||||
// const uploadedFileData = {
|
||||
// createdAt: testFile.lastModified,
|
||||
// data: await testFile.arrayBuffer(),
|
||||
// fileType: testFile.type,
|
||||
// name: testFile.name,
|
||||
// saveMode: 'local',
|
||||
// size: testFile.size,
|
||||
// };
|
||||
//
|
||||
// // Mock the fileService.uploadFile to resolve with uploadedFileData
|
||||
// vi.spyOn(uploadService, 'uploadFile').mockResolvedValue(uploadedFileData as DB_File);
|
||||
// vi.spyOn(fileService, 'createFile').mockResolvedValue({ id: 'new-file-id', url: '' });
|
||||
//
|
||||
// await act(async () => {
|
||||
// await result.current.uploadFile(testFile);
|
||||
// });
|
||||
//
|
||||
// expect(fileService.createFile).toHaveBeenCalledWith({
|
||||
// createdAt: testFile.lastModified,
|
||||
// data: await testFile.arrayBuffer(),
|
||||
// fileType: testFile.type,
|
||||
// name: testFile.name,
|
||||
// saveMode: 'local',
|
||||
// size: testFile.size,
|
||||
// });
|
||||
// expect(result.current.inputFilesList).toContain('new-file-id');
|
||||
// });
|
||||
// });
|
||||
});
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// import { FileStore } from '../../store';
|
||||
import { type FilesStoreState } from '@/store/file/initialState';
|
||||
|
||||
const showSimilaritySearchResult = (s: FilesStoreState) => s.isSimilaritySearch;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// import { FileStore } from '../../store';
|
||||
import { type FilesStoreState } from '@/store/file/initialState';
|
||||
import { type FileUploadStatus } from '@/types/files/upload';
|
||||
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
// import { FileStore } from '../../store';
|
||||
|
||||
export const ttsFilesSelectors = {};
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
export * from './action';
|
||||
export * from './initialState';
|
||||
// export * from './selectors';
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
export * from './action';
|
||||
export * from './initialState';
|
||||
// export * from './selectors';
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
export * from './action';
|
||||
export * from './initialState';
|
||||
// export * from './selectors';
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
export * from './action';
|
||||
export * from './initialState';
|
||||
// export * from './selectors';
|
||||
|
||||
@@ -147,12 +147,6 @@ export function renderRoutes(routes: RouteConfig[]): ReactElement[] {
|
||||
return routes.map((route, index) => {
|
||||
const { path, element, children, index: isIndex, loader } = route;
|
||||
|
||||
// Handle redirect loaders (convert to Navigate element)
|
||||
if (loader && !element && isIndex) {
|
||||
// Check if loader is a redirect by inspecting it
|
||||
// For now, we'll handle this case in the config itself
|
||||
}
|
||||
|
||||
const childRoutes = children ? renderRoutes(children) : undefined;
|
||||
|
||||
if (isIndex) {
|
||||
|
||||
@@ -26,7 +26,6 @@ export const parseModelString = async (
|
||||
|
||||
if (withDeploymentName) {
|
||||
[id, deploymentName] = id.split('->');
|
||||
// if (!deploymentName) deploymentName = id;
|
||||
}
|
||||
|
||||
if (disable) {
|
||||
|
||||
Reference in New Issue
Block a user