Skip to content

🤯 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.

♻️ refactor: remove orphaned UI code (#17185)

René Wang21a31fdc05cb
diff --git a/apps/desktop/src/main/exports.ts b/apps/desktop/src/main/exports.ts
deleted file mode 100644
index 428af0a6430..00000000000
--- a/apps/desktop/src/main/exports.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-// Export types for renderer/server to use
-export type { DesktopIpcServices } from './controllers/registry';
diff --git a/apps/server/src/services/doc/index.tsx b/apps/server/src/services/doc/index.tsx
deleted file mode 100644
index bc04618b0d5..00000000000
--- a/apps/server/src/services/doc/index.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import { existsSync, readdirSync, readFileSync } from 'node:fs';
-import { join } from 'node:path';
-
-import matter from 'gray-matter';
-
-const LAST_MODIFIED = new Date().toISOString();
-
-export class DocService {
- async getDocByPath(locale: string, path: string) {
- const extra = locale === 'zh-CN' ? '.zh-CN.mdx' : '.mdx';
-
- const localPath = join(process.cwd(), 'docs/', path) + extra;
-
- const isLocalePathExist = existsSync(localPath);
-
- if (!isLocalePathExist) return;
-
- const text: string = readFileSync(localPath, 'utf8');
-
- if (!text) return;
-
- const { data, content } = matter(text);
-
- const regex = /^#\s(.+)/;
- const match = regex.exec(content);
- const matches = content.split(regex);
- const description = matches[1] ? matches[1].trim() : '';
- return {
- date: data?.date ? new Date(data.date) : new Date(LAST_MODIFIED),
- description: description.replaceAll('\n', '').replaceAll(' ', ' ').slice(0, 160),
- tags: [],
- title: match ? match[1] : '',
- ...data,
- content,
- };
- }
-}
-
-// Strangely, this `readdirSync` call is needed to read md files after Vercel deployment
-// Otherwise, mdx files cannot be found properly
-readdirSync(join(process.cwd(), 'docs'));
diff --git a/packages/builtin-tool-local-system/src/client/components/FilePathDisplay.tsx b/packages/builtin-tool-local-system/src/client/components/FilePathDisplay.tsx
deleted file mode 100644
index 2da993b8173..00000000000
--- a/packages/builtin-tool-local-system/src/client/components/FilePathDisplay.tsx
+++ /dev/null
@@ -1,69 +0,0 @@
-'use client';
-
-import { MaterialFileTypeIcon, Text } from '@lobehub/ui';
-import { createStaticStyles, cssVar } from 'antd-style';
-import path from 'path-browserify-esm';
-import { memo, useMemo } from 'react';
-
-const styles = createStaticStyles(({ css }) => ({
- icon: css`
- flex-shrink: 0;
- margin-inline-end: 4px;
- `,
- text: css`
- overflow: hidden;
- color: ${cssVar.colorText};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
-}));
-
-interface FilePathDisplayProps {
- filePath: string;
- isDirectory?: boolean;
-}
-
-/**
- * Reusable component for displaying file/folder icon + path in LocalSystem inspectors
- * Used by Read, Write, Edit, Delete, Rename, List inspectors
- */
-export const FilePathDisplay = memo<FilePathDisplayProps>(({ filePath, isDirectory }) => {
- const { displayPath, name } = useMemo(() => {
- if (!filePath) return { displayPath: '', name: '' };
- const { base, dir } = path.parse(filePath);
- const parentDir = path.basename(dir);
- return {
- displayPath: parentDir ? `${parentDir}/${base}` : base,
- name: base,
- };
- }, [filePath]);
-
- if (!filePath) return null;
-
- return (
- <>
- {name && (
- <MaterialFileTypeIcon
- className={styles.icon}
- fallbackUnknownType={false}
- filename={name}
- size={16}
- type={isDirectory ? 'folder' : 'file'}
- variant={'raw'}
- />
- )}
- {displayPath && (
- <Text
- className={styles.text}
- ellipsis={{
- tooltipWhenOverflow: true,
- }}
- >
- {displayPath}
- </Text>
- )}
- </>
- );
-});
-
-FilePathDisplay.displayName = 'FilePathDisplay';
diff --git a/src/components/CircleLoader/index.tsx b/src/components/CircleLoader/index.tsx
deleted file mode 100644
index 98d8ec1a84c..00000000000
--- a/src/components/CircleLoader/index.tsx
+++ /dev/null
@@ -1,65 +0,0 @@
-import { createStaticStyles, keyframes } from 'antd-style';
-import { memo } from 'react';
-
-const smallLoaderAnim = keyframes`
- 100% {
- transform: rotate(1turn);
- }
-`;
-
-const styles = createStaticStyles(({ css, cssVar }) => ({
- background: css`
- position: absolute;
- inset: 0;
-
- aspect-ratio: 1;
- width: 100%;
- border-radius: 50%;
-
- background: ${cssVar.colorFill};
-
- mask: radial-gradient(
- farthest-side,
- #0000 calc(100% - var(--circle-loader-border-width, 2.5px)),
- #000 0
- );
- `,
- container: css`
- position: relative;
- width: 13px;
- height: 13px;
- `,
-
- loader: css`
- position: absolute;
- inset: 0;
-
- aspect-ratio: 1;
- width: 100%;
- border-radius: 50%;
-
- background:
- radial-gradient(farthest-side, ${cssVar.colorTextSecondary} 94%, #0000) top/
- var(--circle-loader-border-width, 2.5px) var(--circle-loader-border-width, 2.5px) no-repeat,
- conic-gradient(#0000 50%, ${cssVar.colorTextSecondary});
-
- mask: radial-gradient(
- farthest-side,
- #0000 calc(100% - var(--circle-loader-border-width, 2.5px)),
- #000 0
- );
-
- animation: ${smallLoaderAnim} 1s infinite linear;
- `,
-}));
-
-const CircleLoader = memo(() => {
- return (
- <div className={styles.container}>
- <div className={styles.loader} />
- <div className={styles.background} />
- </div>
- );
-});
-
-export default CircleLoader;
diff --git a/src/components/FeatureList/index.tsx b/src/components/FeatureList/index.tsx
deleted file mode 100644
index eff52a30359..00000000000
--- a/src/components/FeatureList/index.tsx
+++ /dev/null
@@ -1,78 +0,0 @@
-import { Center, Flexbox, Icon } from '@lobehub/ui';
-import { createStaticStyles, responsive } from 'antd-style';
-import { type LucideIcon } from 'lucide-react';
-import { memo } from 'react';
-
-import { useIsDark } from '@/hooks/useIsDark';
-
-const styles = createStaticStyles(({ css, cssVar }) => ({
- desc: css`
- width: 280px;
- margin-block-end: 0;
- color: ${cssVar.colorTextSecondary};
-
- ${responsive.sm} {
- line-height: ${cssVar.lineHeight};
- }
- `,
- iconCtnDark: css`
- width: 72px;
- height: 72px;
- border-radius: 50%;
- background: ${cssVar.blue1};
- `,
- iconCtnLight: css`
- width: 72px;
- height: 72px;
- border-radius: 50%;
- background: ${cssVar.geekblue1};
- `,
- iconDark: css`
- color: ${cssVar.blue};
- `,
- iconLight: css`
- color: ${cssVar.geekblue};
- `,
- title: css`
- margin-block-end: 0;
- font-size: ${cssVar.fontSizeLG};
- font-weight: bold;
- `,
-}));
-
-export interface FeatureItem {
- avatar: LucideIcon;
- desc: string;
- title: string;
-}
-interface FeatureListProps {
- data: FeatureItem[];
-}
-
-const FeatureList = memo<FeatureListProps>(({ data }) => {
- const isDarkMode = useIsDark();
-
- return (
- <Flexbox gap={32}>
- {data.map((item) => {
- return (
- <Flexbox horizontal align={'flex-start'} gap={24} key={item.title}>
- <Center className={isDarkMode ? styles.iconCtnDark : styles.iconCtnLight}>
- <Icon
- className={isDarkMode ? styles.iconDark : styles.iconLight}
- icon={item.avatar}
- size={36}
- />
- </Center>
- <Flexbox gap={8}>
- <p className={styles.title}>{item.title}</p>
- <p className={styles.desc}>{item.desc}</p>
- </Flexbox>
- </Flexbox>
- );
- })}
- </Flexbox>
- );
-});
-
-export default FeatureList;
diff --git a/src/components/InitProgress/index.tsx b/src/components/InitProgress/index.tsx
deleted file mode 100644
index 132bb9b4036..00000000000
--- a/src/components/InitProgress/index.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { Center, Flexbox, Icon, Text } from '@lobehub/ui';
-import { Progress } from 'antd';
-import { cssVar } from 'antd-style';
-import { Loader2 } from 'lucide-react';
-import { type ReactNode } from 'react';
-import { memo } from 'react';
-
-export interface StageObjectItem {
- icon?: ReactNode;
- text: string;
-}
-export type StageItem = string | StageObjectItem;
-
-interface InitingProps {
- activeStage: number;
- stages: StageItem[];
-}
-
-const InitProgress = memo<InitingProps>(({ activeStage, stages }) => {
- const outStage = stages[activeStage];
- const percent = (activeStage / (stages.length - 1)) * 100;
-
- const stage = typeof outStage === 'string' ? { text: outStage } : outStage;
-
- return (
- <Center gap={8} width={180}>
- <Progress
- percent={parseInt(percent.toFixed(0))}
- showInfo={false}
- strokeColor={cssVar.colorPrimary}
- />
- <Flexbox horizontal align={'center'} gap={4}>
- {stage?.icon ? stage?.icon : <Icon spin icon={Loader2} />}
- <Text type={'secondary'}>{stage?.text}</Text>
- </Flexbox>
- </Center>
- );
-});
-
-export default InitProgress;
diff --git a/src/components/InvalidAPIKey/Bedrock.tsx b/src/components/InvalidAPIKey/Bedrock.tsx
deleted file mode 100644
index a4a5a89a580..00000000000
--- a/src/components/InvalidAPIKey/Bedrock.tsx
+++ /dev/null
@@ -1,183 +0,0 @@
-import { Aws } from '@lobehub/icons';
-import { Icon, InputPassword } from '@lobehub/ui';
-import { Button, Select, Tabs, type TabsItem } from '@lobehub/ui/base-ui';
-import { cssVar } from 'antd-style';
-import { Network, ShieldPlus } from 'lucide-react';
-import { ModelProvider } from 'model-bank';
-import { memo, useCallback, useEffect, useMemo, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { FormAction } from '@/features/Conversation/Error/style';
-import { usePermission } from '@/hooks/usePermission';
-import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
-import {
- BedrockAuthMode,
- inferBedrockAuthMode,
- normalizeBedrockKeyVaultsForAuthMode,
-} from '@/utils/bedrockAuthMode';
-
-const BedrockForm = memo<{ description: string }>(({ description }) => {
- const { t } = useTranslation('modelProvider');
- const { allowed: canManageProvider } = usePermission('manage_provider_key');
- const [showRegion, setShow] = useState(false);
- const [showSessionToken, setShowSessionToken] = useState(false);
-
- const config = useAiInfraStore(aiProviderSelectors.providerKeyVaults(ModelProvider.Bedrock));
- const setConfig = useAiInfraStore((s) => s.updateAiProviderConfig);
- const { accessKeyId, apiKey, secretAccessKey, sessionToken, region } = config || {};
-
- const [authMode, setAuthMode] = useState(() => inferBedrockAuthMode(config));
-
- useEffect(() => {
- const hasAuthShape = !!(config?.accessKeyId || config?.apiKey || config?.secretAccessKey);
-
- if (!hasAuthShape) return;
-
- setAuthMode(inferBedrockAuthMode(config));
- }, [config?.accessKeyId, config?.apiKey, config?.secretAccessKey]);
-
- const authModeOptions = useMemo<TabsItem[]>(
- () => [
- { key: BedrockAuthMode.ApiKey, label: t('bedrock.authMode.options.apiKey') },
- {
- key: BedrockAuthMode.AwsCredentials,
- label: t('bedrock.authMode.options.awsCredentials'),
- },
- ],
- [t],
- );
-
- const updateKeyVaults = useCallback(
- (params: Record<string, string | undefined>, nextMode = authMode) => {
- if (!canManageProvider) return;
-
- void setConfig(ModelProvider.Bedrock, {
- keyVaults: normalizeBedrockKeyVaultsForAuthMode(nextMode, params),
- });
- },
- [authMode, canManageProvider, setConfig],
- );
-
- const handleAuthModeChange = useCallback(
- (mode: string) => {
- if (!canManageProvider) return;
-
- const nextMode = mode as BedrockAuthMode;
-
- setAuthMode(nextMode);
- updateKeyVaults({}, nextMode);
- },
- [canManageProvider, updateKeyVaults],
- );
-
- return (
- <FormAction
- avatar={<Aws.Color color={cssVar.colorText} size={56} />}
- description={description}
- title={t('bedrock.unlock.title')}
- >
- <Tabs
- activeKey={authMode}
- items={authModeOptions}
- style={{ width: '100%' }}
- styles={{
- list: { display: 'flex', width: '100%' },
- tab: { flex: 1 },
- }}
- onChange={handleAuthModeChange}
- />
- {authMode === BedrockAuthMode.ApiKey ? (
- <InputPassword
- autoComplete={'new-password'}
- disabled={!canManageProvider}
- placeholder={t('bedrock.apiKey.placeholder')}
- value={apiKey}
- variant={'filled'}
- onChange={(e) => {
- updateKeyVaults({ apiKey: e.target.value });
- }}
- />
- ) : (
- <>
- <InputPassword
- autoComplete={'new-password'}
- disabled={!canManageProvider}
- placeholder={t('bedrock.accessKeyId.placeholder')}
- value={accessKeyId}
- variant={'filled'}
- onChange={(e) => {
- updateKeyVaults({ accessKeyId: e.target.value });
- }}
- />
- <InputPassword
- autoComplete={'new-password'}
- disabled={!canManageProvider}
- placeholder={t('bedrock.secretAccessKey.placeholder')}
- value={secretAccessKey}
- variant={'filled'}
- onChange={(e) => {
- updateKeyVaults({ secretAccessKey: e.target.value });
- }}
- />
- {showSessionToken ? (
- <InputPassword
- autoComplete={'new-password'}
- disabled={!canManageProvider}
- placeholder={t('bedrock.sessionToken.placeholder')}
- value={sessionToken}
- variant={'filled'}
- onChange={(e) => {
- updateKeyVaults({ sessionToken: e.target.value });
- }}
- />
- ) : (
- <Button
- block
- disabled={!canManageProvider}
- icon={ShieldPlus}
- type={'text'}
- onClick={() => {
- if (!canManageProvider) return;
-
- setShowSessionToken(true);
- }}
- >
- {t('bedrock.unlock.customSessionToken')}
- </Button>
- )}
- </>
- )}
- {showRegion ? (
- <Select
- disabled={!canManageProvider}
- placeholder={t('bedrock.region.placeholder')}
- style={{ width: '100%' }}
- value={region}
- options={['us-east-1', 'us-west-2', 'ap-southeast-1', 'eu-central-1'].map((i) => ({
- label: i,
- value: i,
- }))}
- onChange={(region) => {
- updateKeyVaults({ region });
- }}
- />
- ) : (
- <Button
- block
- disabled={!canManageProvider}
- icon={<Icon icon={Network} />}
- type={'text'}
- onClick={() => {
- if (!canManageProvider) return;
-
- setShow(true);
- }}
- >
- {t('bedrock.unlock.customRegion')}
- </Button>
- )}
- </FormAction>
- );
-});
-
-export default BedrockForm;
diff --git a/src/components/InvalidAPIKey/ComfyUIForm.tsx b/src/components/InvalidAPIKey/ComfyUIForm.tsx
deleted file mode 100644
index 81159e7192d..00000000000
--- a/src/components/InvalidAPIKey/ComfyUIForm.tsx
+++ /dev/null
@@ -1,260 +0,0 @@
-'use client';
-
-import { ComfyUI } from '@lobehub/icons';
-import { Center, Flexbox, Icon } from '@lobehub/ui';
-import { Button, Select } from '@lobehub/ui/base-ui';
-import { createStaticStyles, cssVar } from 'antd-style';
-import { Loader2Icon, Network } from 'lucide-react';
-import { memo, use, useEffect, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { FormInput, FormPassword } from '@/components/FormInput';
-import KeyValueEditor from '@/components/KeyValueEditor';
-import { FormAction } from '@/features/Conversation/Error/style';
-import { usePermission } from '@/hooks/usePermission';
-import { useAiInfraStore } from '@/store/aiInfra';
-import { type ComfyUIKeyVault } from '@/types/user/settings';
-
-import { LoadingContext } from './LoadingContext';
-
-interface ComfyUIFormProps {
- description: string;
-}
-
-const styles = createStaticStyles(({ css }) => ({
- comfyuiFormWide: css`
- max-width: 900px !important;
-
- /* Hide the avatar - target the first child which is the Avatar component */
- > *:first-child {
- display: none !important;
- }
- `,
- container: css`
- width: 100%;
- max-width: 900px;
- border: 1px solid ${cssVar.colorSplit};
- border-radius: 8px;
-
- color: ${cssVar.colorText};
-
- background: ${cssVar.colorBgContainer};
- `,
-}));
-
-const ComfyUIForm = memo<ComfyUIFormProps>(({ description }) => {
- const { t } = useTranslation('error');
- const { t: s } = useTranslation('modelProvider');
- const { allowed: canManageProvider } = usePermission('manage_provider_key');
-
- // Use aiInfraStore for updating config (same as settings page)
- const updateAiProviderConfig = useAiInfraStore((s) => s.updateAiProviderConfig);
- const useFetchAiProviderRuntimeState = useAiInfraStore((s) => s.useFetchAiProviderRuntimeState);
-
- const { loading, setLoading } = use(LoadingContext);
-
- // Fetch the runtime state to ensure config is loaded
- // Pass true since this is for auth dialog (not initialization)
- const fetchRuntimeState = useFetchAiProviderRuntimeState(true);
-
- // Get ComfyUI config from aiInfraStore (same as settings page)
- const comfyUIConfig = useAiInfraStore(
- (s) => s.aiProviderRuntimeConfig?.['comfyui']?.keyVaults,
- ) as ComfyUIKeyVault | undefined;
-
- // State for showing base URL input - initially hidden
- const [showBaseURL, setShowBaseURL] = useState(false);
-
- // State management for form values - initialize without config first
- const [formValues, setFormValues] = useState({
- apiKey: '',
- authType: 'none' as string,
- baseURL: 'http://127.0.0.1:8000',
- customHeaders: {} as Record<string, string>,
- password: '',
- username: '',
- });
-
- // Update form values when comfyUIConfig changes (config read-back)
- // Use individual primitive values to avoid infinite re-renders
- useEffect(() => {
- if (comfyUIConfig) {
- const newValues = {
- apiKey: comfyUIConfig.apiKey || '',
- authType: comfyUIConfig.authType || 'none',
- baseURL: comfyUIConfig.baseURL || 'http://127.0.0.1:8000',
- customHeaders: comfyUIConfig.customHeaders || {},
- password: comfyUIConfig.password || '',
- username: comfyUIConfig.username || '',
- };
- setFormValues(newValues);
- }
- }, [
- comfyUIConfig?.apiKey,
- comfyUIConfig?.authType,
- comfyUIConfig?.baseURL,
- comfyUIConfig?.password,
- comfyUIConfig?.username,
- JSON.stringify(comfyUIConfig?.customHeaders),
- ]);
-
- const authTypeOptions = [
- { label: s('comfyui.authType.options.none'), value: 'none' },
- { label: s('comfyui.authType.options.basic'), value: 'basic' },
- { label: s('comfyui.authType.options.bearer'), value: 'bearer' },
- { label: s('comfyui.authType.options.custom'), value: 'custom' },
- ];
-
- const handleValueChange = async (field: string, value: any) => {
- if (!canManageProvider) return;
-
- const newValues = {
- ...formValues,
- [field]: value,
- };
- setFormValues(newValues);
-
- // Skip validation for certain fields that can be empty
- const skipValidation = ['customHeaders', 'apiKey', 'username', 'password'];
-
- // Basic validation before saving
- if (!skipValidation.includes(field) && field === 'baseURL' && !value) {
- return; // Don't save if baseURL is empty
- }
-
- // Real-time save like other providers
- setLoading(true);
- try {
- await updateAiProviderConfig('comfyui', {
- keyVaults: newValues,
- });
- // Refetch the runtime state to ensure config is synced
- await fetchRuntimeState.mutate();
- } catch (error) {
- console.error('Failed to update ComfyUI config:', error);
- } finally {
- setLoading(false);
- }
- };
-
- return (
- <Center className={styles.container} gap={24} padding={24}>
- <Center gap={16} paddingBlock={32} style={{ width: '100%' }}>
- <ComfyUI.Combine size={64} type={'color'} />
- <FormAction
- avatar={<div />}
- className={styles.comfyuiFormWide}
- description={description}
- title={t('unlock.comfyui.title', { name: 'ComfyUI' })}
- >
- <Flexbox gap={16} width="100%">
- {/* Base URL */}
- {showBaseURL ? (
- <Flexbox gap={4}>
- <div style={{ fontSize: 14, fontWeight: 500 }}>{s('comfyui.baseURL.title')}</div>
- <FormInput
- disabled={!canManageProvider}
- placeholder={s('comfyui.baseURL.placeholder')}
- suffix={<div>{loading && <Icon spin icon={Loader2Icon} />}</div>}
- value={formValues.baseURL}
- onChange={(value) => handleValueChange('baseURL', value)}
- />
- </Flexbox>
- ) : (
- <Button
- disabled={!canManageProvider}
- icon={<Icon icon={Network} />}
- type={'text'}
- onClick={() => setShowBaseURL(true)}
- >
- {t('unlock.comfyui.modifyBaseUrl')}
- </Button>
- )}
-
- {/* Auth Type */}
- <Flexbox gap={4}>
- <div style={{ fontSize: 14, fontWeight: 500 }}>{s('comfyui.authType.title')}</div>
- <Select
- allowClear={false}
- disabled={!canManageProvider}
- options={authTypeOptions}
- placeholder={s('comfyui.authType.placeholder')}
- value={formValues.authType}
- onChange={(value) => handleValueChange('authType', value)}
- />
- </Flexbox>
-
- {/* Basic Auth Fields */}
- {formValues.authType === 'basic' && (
- <>
- <Flexbox gap={4}>
- <div style={{ fontSize: 14, fontWeight: 500 }}>{s('comfyui.username.title')}</div>
- <FormInput
- autoComplete="username"
- disabled={!canManageProvider}
- placeholder={s('comfyui.username.placeholder')}
- suffix={<div>{loading && <Icon spin icon={Loader2Icon} />}</div>}
- value={formValues.username}
- onChange={(value) => handleValueChange('username', value)}
- />
- </Flexbox>
- <Flexbox gap={4}>
- <div style={{ fontSize: 14, fontWeight: 500 }}>{s('comfyui.password.title')}</div>
- <FormPassword
- autoComplete="new-password"
- disabled={!canManageProvider}
- placeholder={s('comfyui.password.placeholder')}
- suffix={<div>{loading && <Icon spin icon={Loader2Icon} />}</div>}
- value={formValues.password}
- onChange={(value) => handleValueChange('password', value)}
- />
- </Flexbox>
- </>
- )}
-
- {/* Bearer Token Field */}
- {formValues.authType === 'bearer' && (
- <Flexbox gap={4}>
- <div style={{ fontSize: 14, fontWeight: 500 }}>{s('comfyui.apiKey.title')}</div>
- <FormPassword
- autoComplete="new-password"
- disabled={!canManageProvider}
- placeholder={s('comfyui.apiKey.placeholder')}
- suffix={<div>{loading && <Icon spin icon={Loader2Icon} />}</div>}
- value={formValues.apiKey}
- onChange={(value) => handleValueChange('apiKey', value)}
- />
- </Flexbox>
- )}
-
- {/* Custom Headers Field */}
- {formValues.authType === 'custom' && (
- <Flexbox gap={4}>
- <div style={{ fontSize: 14, fontWeight: 500 }}>
- {s('comfyui.customHeaders.title')}
- </div>
- <div style={{ color: cssVar.colorTextSecondary, fontSize: 12, marginBottom: 4 }}>
- {s('comfyui.customHeaders.desc')}
- </div>
- <KeyValueEditor
- addButtonText={s('comfyui.customHeaders.addButton')}
- deleteTooltip={s('comfyui.customHeaders.deleteTooltip')}
- disabled={!canManageProvider}
- duplicateKeyErrorText={s('comfyui.customHeaders.duplicateKeyError')}
- keyPlaceholder={s('comfyui.customHeaders.keyPlaceholder')}
- value={formValues.customHeaders}
- valuePlaceholder={s('comfyui.customHeaders.valuePlaceholder')}
- onChange={(value) => handleValueChange('customHeaders', value)}
- />
- </Flexbox>
- )}
- </Flexbox>
- </FormAction>
- </Center>
- </Center>
- );
-});
-
-ComfyUIForm.displayName = 'ComfyUIForm';
-
-export default ComfyUIForm;
diff --git a/src/components/InvalidAPIKey/LoadingContext.ts b/src/components/InvalidAPIKey/LoadingContext.ts
deleted file mode 100644
index 43fbff5eb8e..00000000000
--- a/src/components/InvalidAPIKey/LoadingContext.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { createContext } from 'react';
-
-interface LoadingContextValue {
- loading: boolean;
- setLoading: (loading: boolean) => void;
-}
-
-export const LoadingContext = createContext<LoadingContextValue>({
- loading: false,
- setLoading: () => {},
-});
diff --git a/src/components/InvalidAPIKey/ProviderApiKeyForm.tsx b/src/components/InvalidAPIKey/ProviderApiKeyForm.tsx
deleted file mode 100644
index 7d158c3be95..00000000000
--- a/src/components/InvalidAPIKey/ProviderApiKeyForm.tsx
+++ /dev/null
@@ -1,82 +0,0 @@
-import { Icon } from '@lobehub/ui';
-import { Button } from '@lobehub/ui/base-ui';
-import { Loader2Icon, Network } from 'lucide-react';
-import { type ReactNode } from 'react';
-import { memo, use, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { FormInput, FormPassword } from '@/components/FormInput';
-import { FormAction } from '@/features/Conversation/Error/style';
-import { useProviderName } from '@/hooks/useProviderName';
-import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
-import { type GlobalLLMProviderKey } from '@/types/user/settings';
-
-import { LoadingContext } from './LoadingContext';
-import { useApiKey } from './useApiKey';
-
-interface ProviderApiKeyFormProps {
- apiKeyPlaceholder?: string;
- avatar?: ReactNode;
- description: string;
- provider: GlobalLLMProviderKey;
- showEndpoint?: boolean;
-}
-
-const ProviderApiKeyForm = memo<ProviderApiKeyFormProps>(
- ({ provider, avatar, showEndpoint = false, apiKeyPlaceholder, description }) => {
- const { t } = useTranslation(['modelProvider', 'error']);
- const { t: errorT } = useTranslation('error');
- const [showProxy, setShow] = useState(false);
-
- const { apiKey, baseURL, canManageProvider, setConfig } = useApiKey(provider);
- const { showOpenAIProxyUrl } = useServerConfigStore(featureFlagsSelectors);
- const providerName = useProviderName(provider);
- const { loading } = use(LoadingContext);
-
- return (
- <FormAction
- avatar={avatar}
- description={description}
- title={t(`unlock.apiKey.title`, { name: providerName, ns: 'error' })}
- >
- <FormPassword
- autoComplete={'new-password'}
- disabled={!canManageProvider}
- placeholder={apiKeyPlaceholder || 'sk-***********************'}
- suffix={<div>{loading && <Icon spin icon={Loader2Icon} />}</div>}
- value={apiKey}
- onChange={(value) => {
- setConfig(provider, { apiKey: value });
- }}
- />
-
- {showEndpoint &&
- showOpenAIProxyUrl &&
- (showProxy ? (
- <FormInput
- disabled={!canManageProvider}
- placeholder={'https://api.openai.com/v1'}
- suffix={<div>{loading && <Icon spin icon={Loader2Icon} />}</div>}
- value={baseURL}
- onChange={(value) => {
- setConfig(provider, { baseURL: value });
- }}
- />
- ) : (
- <Button
- disabled={!canManageProvider}
- icon={<Icon icon={Network} />}
- type={'text'}
- onClick={() => {
- setShow(true);
- }}
- >
- {errorT('unlock.addProxyUrl')}
- </Button>
- ))}
- </FormAction>
- );
- },
-);
-
-export default ProviderApiKeyForm;
diff --git a/src/components/InvalidAPIKey/useApiKey.ts b/src/components/InvalidAPIKey/useApiKey.ts
deleted file mode 100644
index 9b07a99d98a..00000000000
--- a/src/components/InvalidAPIKey/useApiKey.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import isEqual from 'fast-deep-equal';
-import { useContext } from 'react';
-
-import { usePermission } from '@/hooks/usePermission';
-import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
-
-import { LoadingContext } from './LoadingContext';
-
-export const useApiKey = (provider: string) => {
- const { setLoading } = useContext(LoadingContext);
- const { allowed: canManageProvider } = usePermission('manage_provider_key');
- const updateAiProviderConfig = useAiInfraStore((s) => s.updateAiProviderConfig);
- const data = useAiInfraStore(aiProviderSelectors.providerConfigById(provider), isEqual);
-
- return {
- apiKey: data?.keyVaults.apiKey,
- baseURL: data?.keyVaults?.baseURL,
- canManageProvider,
- setConfig: async (id: string, params: Record<string, string>) => {
- if (!canManageProvider) return;
-
- const next = { ...data?.keyVaults, ...params };
- if (isEqual(data?.keyVaults, next)) return;
-
- setLoading(true);
- await updateAiProviderConfig(id, {
- keyVaults: { ...data?.keyVaults, ...params },
- });
- setLoading(false);
- },
- };
-};
diff --git a/src/components/SidebarHeader/index.tsx b/src/components/SidebarHeader/index.tsx
deleted file mode 100644
index 502bb15409d..00000000000
--- a/src/components/SidebarHeader/index.tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-import { type FlexboxProps } from '@lobehub/ui';
-import { Flexbox } from '@lobehub/ui';
-import { createStaticStyles } from 'antd-style';
-import { type ReactNode } from 'react';
-import { memo } from 'react';
-
-const styles = createStaticStyles(({ css }) => ({
- header: css`
- z-index: 10;
- `,
-}));
-
-interface SidebarHeaderProps extends Omit<FlexboxProps, 'title'> {
- actions?: ReactNode;
- onClick?: () => void;
- title: ReactNode;
-}
-
-const SidebarHeader = memo<SidebarHeaderProps>(({ title, style, actions, onClick, ...rest }) => {
- return (
- <Flexbox
- horizontal
- align={'center'}
- className={styles.header}
- distribution={'space-between'}
- flex={'none'}
- padding={8}
- style={style}
- onClick={onClick}
- {...rest}
- >
- <Flexbox horizontal align={'center'} gap={4} width={'100%'}>
- {title}
- </Flexbox>
- <Flexbox horizontal align={'center'} gap={2}>
- {actions}
- </Flexbox>
- </Flexbox>
- );
-});
-
-export default SidebarHeader;
diff --git a/src/features/AgentHome/SectionHeader.tsx b/src/features/AgentHome/SectionHeader.tsx
deleted file mode 100644
index ea4a0c0be47..00000000000
--- a/src/features/AgentHome/SectionHeader.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-'use client';
-
-import { Flexbox, Icon, Text } from '@lobehub/ui';
-import { cssVar } from 'antd-style';
-import { type LucideIcon } from 'lucide-react';
-import { memo } from 'react';
-
-import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
-
-interface SectionHeaderProps {
- actionLabel?: string;
- actionUrl?: string;
- icon: LucideIcon;
- title: string;
-}
-
-const SectionHeader = memo<SectionHeaderProps>(({ icon, title, actionLabel, actionUrl }) => {
- return (
- <Flexbox horizontal align={'center'} justify={'space-between'}>
- <Flexbox horizontal align={'center'} gap={8}>
- <Icon color={cssVar.colorTextDescription} icon={icon} size={18} />
- <Text color={cssVar.colorTextSecondary}>{title}</Text>
- </Flexbox>
- {actionLabel && actionUrl && (
- <WorkspaceLink style={{ color: 'inherit', textDecoration: 'none' }} to={actionUrl}>
- <Text fontSize={12} type={'secondary'}>
- {actionLabel}
- </Text>
- </WorkspaceLink>
- )}
- </Flexbox>
- );
-});
-
-export default SectionHeader;
diff --git a/src/features/AgentInfo/index.tsx b/src/features/AgentInfo/index.tsx
deleted file mode 100644
index 26b422b4ec1..00000000000
--- a/src/features/AgentInfo/index.tsx
+++ /dev/null
@@ -1,69 +0,0 @@
-import { Avatar, Center, Markdown, Tag } from '@lobehub/ui';
-import { Divider } from 'antd';
-import { createStaticStyles, cssVar } from 'antd-style';
-import { startCase } from 'es-toolkit/compat';
-import { type CSSProperties } from 'react';
-import { memo } from 'react';
-
-import { type MetaData } from '@/types/meta';
-
-const styles = createStaticStyles(({ css, cssVar }) => ({
- avatar: css`
- flex: none;
- `,
- desc: css`
- color: ${cssVar.colorTextDescription};
- text-align: center;
- `,
- title: css`
- font-size: 20px;
- font-weight: 600;
- text-align: center;
- `,
-}));
-
-export interface AgentInfoProps {
- meta?: MetaData;
- onAvatarClick?: () => void;
- style?: CSSProperties;
- systemRole?: string;
-}
-
-const AgentInfo = memo<AgentInfoProps>(({ systemRole, style, meta, onAvatarClick }) => {
- if (!meta) return;
-
- return (
- <Center gap={16} style={style}>
- {meta.avatar && (
- <Avatar
- animation
- avatar={meta.avatar}
- background={meta.backgroundColor || cssVar.colorFillTertiary}
- className={styles.avatar}
- shape={'square'}
- size={100}
- onClick={onAvatarClick}
- />
- )}
- {meta.title && <div className={styles.title}>{meta.title}</div>}
- {(meta?.tags as string[])?.length > 0 && (
- <Center horizontal gap={6} style={{ flexWrap: 'wrap' }}>
- {(meta.tags as string[]).map((tag: string, index) => (
- <Tag key={index} style={{ margin: 0 }}>
- {startCase(tag).trim()}
- </Tag>
- ))}
- </Center>
- )}
- {meta.description && <div className={styles.desc}>{meta.description}</div>}
- {systemRole && (
- <>
- <Divider style={{ margin: '8px 0' }} />
- <Markdown variant={'chat'}>{systemRole}</Markdown>
- </>
- )}
- </Center>
- );
-});
-
-export default AgentInfo;
diff --git a/src/features/AgentMockDevtools/DevtoolsLayout.tsx b/src/features/AgentMockDevtools/DevtoolsLayout.tsx
deleted file mode 100644
index 4e26877f8bf..00000000000
--- a/src/features/AgentMockDevtools/DevtoolsLayout.tsx
+++ /dev/null
@@ -1,167 +0,0 @@
-import { Flexbox, Tag, Text } from '@lobehub/ui';
-import { Tabs, type TabsItem } from '@lobehub/ui/base-ui';
-import { createStaticStyles, cssVar } from 'antd-style';
-import { memo, useCallback, useEffect, useMemo, useRef } from 'react';
-
-import { CaseTrigger } from './CaseTrigger';
-import { StatsStrip } from './components/StatsStrip';
-import { StatusPill } from './components/StatusPill';
-import { TransportBar } from './components/TransportBar';
-import { useAgentMockPlayer } from './hooks/useAgentMockPlayer';
-import { useAgentMockReplayTarget } from './hooks/useAgentMockReplayTarget';
-import { useMockCases } from './hooks/useMockCases';
-import { type DevtoolsTab, useAgentMockStore } from './store/agentMockStore';
-import { FixtureView } from './views/FixtureView';
-import { TimelineView } from './views/TimelineView';
-
-const TAB_OPTIONS: TabsItem[] = [
- { key: 'timeline', label: 'Timeline' },
- { key: 'fixture', label: 'Fixture' },
-];
-
-const styles = createStaticStyles(({ css }) => ({
- body: css`
- overflow: hidden;
- display: flex;
- flex: 1;
- flex-direction: column;
- gap: 12px;
-
- padding: 16px;
- `,
- hint: css`
- font-size: 11px;
- color: ${cssVar.colorTextTertiary};
- `,
- layout: css`
- display: flex;
- flex-direction: column;
- height: min(720px, 80vh);
- min-height: 480px;
- `,
- meta: css`
- overflow: hidden;
- flex: 1;
-
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- rowOne: css`
- padding-block: 12px;
- padding-inline: 16px;
- `,
- rowTwo: css`
- padding-block: 8px;
- padding-inline: 16px;
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
- `,
- view: css`
- overflow: hidden;
- display: flex;
- flex: 1;
- flex-direction: column;
-
- min-height: 0;
- `,
-}));
-
-export const DevtoolsLayout = memo(() => {
- const activeTab = useAgentMockStore((s) => s.activeTab);
- const setActiveTab = useAgentMockStore((s) => s.setActiveTab);
- const playback = useAgentMockStore((s) => s.playback);
- const speed = useAgentMockStore((s) => s.speed);
- const selectedCaseId = useAgentMockStore((s) => s.selectedCaseId);
- const loop = useAgentMockStore((s) => s.loop);
-
- const { all } = useMockCases();
- const selected = all.find((c) => c.id === selectedCaseId);
-
- const { start } = useAgentMockPlayer();
- const resolveReplayTarget = useAgentMockReplayTarget();
-
- const lastReplayedId = useRef<string | null>(null);
-
- const launchCase = useCallback(() => {
- if (!selected) return;
- const { agentId, threadId, topicId } = resolveReplayTarget();
- if (!agentId || !topicId) return;
- start({ agentId, case: selected, threadId, topicId });
- }, [resolveReplayTarget, selected, start]);
-
- useEffect(() => {
- if (!loop) {
- lastReplayedId.current = null;
- return;
- }
- if (!playback || playback.status !== 'complete') return;
- if (!selected) return;
- if (lastReplayedId.current === selected.id) return;
- lastReplayedId.current = selected.id;
- launchCase();
- }, [loop, playback, selected, launchCase]);
-
- useEffect(() => {
- if (playback?.status === 'running') {
- lastReplayedId.current = null;
- }
- }, [playback?.status]);
-
- const meta = useMemo(() => {
- if (!selected) return null;
- const events =
- selected.source.type === 'fixture'
- ? selected.source.events.length
- : (selected.source.events?.length ?? 0);
- const tools = selected.meta?.toolCount;
- const totalSec = selected.meta?.estimatedDurationMs
- ? `~${(selected.meta.estimatedDurationMs / 1000).toFixed(1)}s`
- : null;
- return [`${events} events`, tools != null ? `${tools} tools` : null, totalSec]
- .filter(Boolean)
- .join(' · ');
- }, [selected]);
-
- return (
- <div className={styles.layout}>
- <Flexbox horizontal align="center" className={styles.rowOne} gap={12}>
- <CaseTrigger />
- <span className={styles.meta}>
- {selected ? (
- <Flexbox horizontal align="center" gap={8}>
- {selected.tags?.map((t) => (
- <Tag key={t}>{t}</Tag>
- ))}
- {meta && <Text type="secondary">{meta}</Text>}
- </Flexbox>
- ) : (
- <Text type="secondary">No case selected</Text>
- )}
- </span>
- <StatusPill playback={playback} speed={speed} />
- </Flexbox>
-
- <Flexbox horizontal align="center" className={styles.rowTwo} justify="space-between">
- <Tabs
- activeKey={activeTab}
- items={TAB_OPTIONS}
- size="small"
- onChange={(key) => setActiveTab(key as DevtoolsTab)}
- />
- <span className={styles.hint}>⌘K open palette</span>
- </Flexbox>
-
- <div className={styles.body}>
- <StatsStrip />
- <div className={styles.view}>
- {activeTab === 'timeline' ? <TimelineView /> : <FixtureView />}
- </div>
- </div>
-
- <TransportBar />
- </div>
- );
-});
-
-DevtoolsLayout.displayName = 'AgentMockDevtoolsLayout';
diff --git a/src/features/AgentMockDevtools/Timeline/EventRow.tsx b/src/features/AgentMockDevtools/Timeline/EventRow.tsx
deleted file mode 100644
index e7cd9db4f87..00000000000
--- a/src/features/AgentMockDevtools/Timeline/EventRow.tsx
+++ /dev/null
@@ -1,103 +0,0 @@
-import type { MockEvent } from '@lobechat/agent-mock';
-import { createStaticStyles, cssVar } from 'antd-style';
-import { memo } from 'react';
-
-type EventTone = 'info' | 'neutral' | 'muted' | 'error';
-
-const TONE_BY_TYPE: Record<string, EventTone> = {
- error: 'error',
- step_complete: 'neutral',
- step_start: 'neutral',
- stream_chunk: 'neutral',
- stream_end: 'muted',
- stream_start: 'muted',
- tool_end: 'info',
- tool_execute: 'info',
- tool_start: 'info',
-};
-
-const toneVar: Record<EventTone, string> = {
- error: cssVar.colorError,
- info: cssVar.colorText,
- muted: cssVar.colorTextQuaternary,
- neutral: cssVar.colorTextTertiary,
-};
-
-const styles = createStaticStyles(({ css }) => ({
- active: css`
- background: ${cssVar.colorFillSecondary};
- `,
- dot: css`
- width: 6px;
- height: 6px;
- margin-block-start: 5px;
- border-radius: 50%;
- `,
- preview: css`
- overflow: hidden;
- color: ${cssVar.colorText};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- row: css`
- cursor: pointer;
-
- display: grid;
- grid-template-columns: 64px 16px 140px 1fr;
- gap: 8px;
-
- padding-block: 4px;
- padding-inline: 12px;
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
-
- font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
- font-size: 11px;
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
- `,
- type: css`
- color: ${cssVar.colorTextSecondary};
- `,
-}));
-
-interface Props {
- cumulativeMs: number;
- event: MockEvent;
- index: number;
- isActive: boolean;
- onClick?: () => void;
-}
-
-const previewOf = (event: MockEvent): string => {
- const data =
- typeof event.data === 'object' && event.data !== null
- ? (event.data as Record<string, unknown>)
- : {};
- if (event.type === 'stream_chunk') {
- return String(data.content ?? data.reasoning ?? data.chunkType ?? '').slice(0, 100);
- }
- if (event.type === 'tool_start' || event.type === 'tool_end') {
- return JSON.stringify(data).slice(0, 100);
- }
- if (event.type === 'error') return String(data.message ?? '');
- return JSON.stringify(data).slice(0, 80);
-};
-
-export const EventRow = memo<Props>(({ event, index, cumulativeMs, isActive, onClick }) => {
- const tone = TONE_BY_TYPE[event.type] ?? 'neutral';
-
- return (
- <div className={`${styles.row} ${isActive ? styles.active : ''}`} onClick={onClick}>
- <span className={styles.type}>+{(cumulativeMs / 1000).toFixed(2)}s</span>
- <span className={styles.dot} style={{ background: toneVar[tone] }} />
- <span className={styles.type}>
- #{index} {event.type}
- </span>
- <span className={styles.preview}>{previewOf(event)}</span>
- </div>
- );
-});
-
-EventRow.displayName = 'AgentMockEventRow';
diff --git a/src/features/AgentMockDevtools/components/StatsStrip.tsx b/src/features/AgentMockDevtools/components/StatsStrip.tsx
deleted file mode 100644
index a087feb9102..00000000000
--- a/src/features/AgentMockDevtools/components/StatsStrip.tsx
+++ /dev/null
@@ -1,82 +0,0 @@
-import { Flexbox } from '@lobehub/ui';
-import { createStaticStyles, cssVar } from 'antd-style';
-import { memo } from 'react';
-
-import { useAgentMockStore } from '../store/agentMockStore';
-
-const styles = createStaticStyles(({ css }) => ({
- card: css`
- flex: 1;
-
- padding: 12px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: 8px;
-
- background: ${cssVar.colorBgContainer};
- `,
- empty: css`
- color: ${cssVar.colorTextTertiary};
- `,
- label: css`
- margin-block-end: 4px;
- font-size: 11px;
- color: ${cssVar.colorTextTertiary};
- `,
- sub: css`
- margin-block-start: 2px;
- font-size: 11px;
- color: ${cssVar.colorTextSecondary};
- `,
- value: css`
- font-size: 18px;
- font-feature-settings: 'tnum';
- font-weight: 600;
- color: ${cssVar.colorText};
- `,
-}));
-
-const placeholder = '—';
-
-export const StatsStrip = memo(() => {
- const playback = useAgentMockStore((s) => s.playback);
- const speed = useAgentMockStore((s) => s.speed);
-
- const stepValue = playback
- ? `${playback.currentStepIndex + 1} / ${playback.totalSteps}`
- : placeholder;
- const eventValue = playback
- ? `${playback.currentEventIndex} / ${playback.totalEvents}`
- : placeholder;
- const toolValue = playback ? `${playback.toolsExecuted} / ${playback.totalTools}` : placeholder;
- const elapsed = playback ? `${(playback.elapsedMs / 1000).toFixed(1)}s` : placeholder;
- const total = playback ? `${(playback.totalDurationMs / 1000).toFixed(1)}s` : placeholder;
- const speedLabel = speed === 'instant' ? '∞' : `${speed}×`;
- const status = playback?.status ?? 'idle';
-
- return (
- <Flexbox horizontal gap={12}>
- <div className={styles.card}>
- <div className={styles.label}>Step</div>
- <div className={`${styles.value} ${playback ? '' : styles.empty}`}>{stepValue}</div>
- <div className={styles.sub}>{status}</div>
- </div>
- <div className={styles.card}>
- <div className={styles.label}>Event</div>
- <div className={`${styles.value} ${playback ? '' : styles.empty}`}>{eventValue}</div>
- </div>
- <div className={styles.card}>
- <div className={styles.label}>Tools</div>
- <div className={`${styles.value} ${playback ? '' : styles.empty}`}>{toolValue}</div>
- </div>
- <div className={styles.card}>
- <div className={styles.label}>Elapsed</div>
- <div className={`${styles.value} ${playback ? '' : styles.empty}`}>{elapsed}</div>
- <div className={styles.sub}>
- @ {speedLabel} · total {total}
- </div>
- </div>
- </Flexbox>
- );
-});
-
-StatsStrip.displayName = 'AgentMockStatsStrip';
diff --git a/src/features/AgentMockDevtools/components/StatusPill.tsx b/src/features/AgentMockDevtools/components/StatusPill.tsx
deleted file mode 100644
index 045c3b7c4f6..00000000000
--- a/src/features/AgentMockDevtools/components/StatusPill.tsx
+++ /dev/null
@@ -1,71 +0,0 @@
-import type { PlaybackState } from '@lobechat/agent-mock';
-import { Flexbox } from '@lobehub/ui';
-import { createStaticStyles, cssVar } from 'antd-style';
-import { memo, useMemo } from 'react';
-
-const styles = createStaticStyles(({ css }) => ({
- dot: css`
- width: 6px;
- height: 6px;
- border-radius: 50%;
- `,
- dotIdle: css`
- background: ${cssVar.colorTextTertiary};
- `,
- dotPlaying: css`
- background: ${cssVar.colorText};
- box-shadow: 0 0 0 3px ${cssVar.colorFillTertiary};
- `,
- dotError: css`
- background: ${cssVar.colorError};
- `,
- pill: css`
- display: inline-flex;
- gap: 8px;
- align-items: center;
-
- padding-block: 3px;
- padding-inline: 10px;
- border-radius: 999px;
-
- font-size: 11px;
- font-feature-settings: 'tnum';
- color: ${cssVar.colorTextSecondary};
-
- background: ${cssVar.colorFillTertiary};
- `,
-}));
-
-interface StatusPillProps {
- playback: PlaybackState | null;
- speed: PlaybackState['speedMultiplier'];
-}
-
-export const StatusPill = memo<StatusPillProps>(({ playback, speed }) => {
- const tone = useMemo<'idle' | 'playing' | 'error'>(() => {
- if (!playback) return 'idle';
- if (playback.status === 'error') return 'error';
- if (playback.status === 'running' || playback.status === 'complete') return 'playing';
- return 'idle';
- }, [playback]);
-
- const dotClass =
- tone === 'error' ? styles.dotError : tone === 'playing' ? styles.dotPlaying : styles.dotIdle;
-
- const speedLabel = speed === 'instant' ? '∞' : `${speed}×`;
-
- return (
- <Flexbox horizontal align="center" className={styles.pill} gap={8}>
- <span className={`${styles.dot} ${dotClass}`} />
- {playback ? (
- <span>
- {playback.currentEventIndex}/{playback.totalEvents} · {speedLabel}
- </span>
- ) : (
- <span>idle · {speedLabel}</span>
- )}
- </Flexbox>
- );
-});
-
-StatusPill.displayName = 'AgentMockStatusPill';
diff --git a/src/features/AgentMockDevtools/components/TransportBar.tsx b/src/features/AgentMockDevtools/components/TransportBar.tsx
deleted file mode 100644
index 2c98dea4604..00000000000
--- a/src/features/AgentMockDevtools/components/TransportBar.tsx
+++ /dev/null
@@ -1,212 +0,0 @@
-import type { SpeedMultiplier } from '@lobechat/agent-mock';
-import { ActionIcon, type DropdownItem, DropdownMenu, Flexbox, toast } from '@lobehub/ui';
-import { Tabs, type TabsItem } from '@lobehub/ui/base-ui';
-import { createStaticStyles, cssVar } from 'antd-style';
-import { Pause, Play, Repeat, RotateCcw, SkipForward } from 'lucide-react';
-import { memo, useCallback, useMemo, useRef } from 'react';
-
-import { useAgentMockPlayer } from '../hooks/useAgentMockPlayer';
-import { useAgentMockReplayTarget } from '../hooks/useAgentMockReplayTarget';
-import { useMockCases } from '../hooks/useMockCases';
-import { useAgentMockStore } from '../store/agentMockStore';
-
-const SPEED_OPTIONS: Array<{ key: string; label: string; value: SpeedMultiplier }> = [
- { key: '0.5', label: '0.5×', value: 0.5 },
- { key: '1', label: '1×', value: 1 },
- { key: '2', label: '2×', value: 2 },
- { key: '5', label: '5×', value: 5 },
- { key: 'instant', label: '∞', value: 'instant' },
-];
-
-const styles = createStaticStyles(({ css }) => ({
- bar: css`
- padding-block: 12px;
- padding-inline: 16px;
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
- `,
- loopOn: css`
- color: ${cssVar.colorBgContainer};
- background: ${cssVar.colorText};
-
- &:hover {
- color: ${cssVar.colorBgContainer};
- background: ${cssVar.colorText};
- }
- `,
- progress: css`
- cursor: pointer;
-
- flex: 1;
-
- height: 6px;
- border-radius: 3px;
-
- background: ${cssVar.colorFillSecondary};
- `,
- progressFill: css`
- height: 100%;
- border-radius: inherit;
- background: ${cssVar.colorText};
- transition: width 0.16s linear;
- `,
- progressTrack: css`
- position: relative;
- overflow: hidden;
- height: 100%;
- `,
- time: css`
- min-width: 64px;
-
- font-size: 11px;
- font-feature-settings: 'tnum';
- color: ${cssVar.colorTextSecondary};
- text-align: end;
- `,
-}));
-
-export const TransportBar = memo(() => {
- const { all } = useMockCases();
- const selectedCaseId = useAgentMockStore((s) => s.selectedCaseId);
- const playback = useAgentMockStore((s) => s.playback);
- const speed = useAgentMockStore((s) => s.speed);
- const setSpeedStore = useAgentMockStore((s) => s.setSpeed);
- const loop = useAgentMockStore((s) => s.loop);
- const setLoop = useAgentMockStore((s) => s.setLoop);
-
- const { pause, resume, seekToEventIndex, setSpeed, start, stepEvent, stepStep, stepTool } =
- useAgentMockPlayer();
- const resolveReplayTarget = useAgentMockReplayTarget();
-
- const trackRef = useRef<HTMLDivElement | null>(null);
-
- const selected = all.find((c) => c.id === selectedCaseId);
- const disabled = !selected;
-
- const status = playback?.status;
- const running = status === 'running';
- const paused = status === 'paused';
- const idleOrComplete = !playback || status === 'idle' || status === 'complete';
-
- const launchCase = useCallback(() => {
- if (!selected) return;
- const { agentId, threadId, topicId } = resolveReplayTarget();
- if (!agentId) {
- toast.warning('Open an agent conversation first.');
- return;
- }
- if (!topicId) {
- toast.warning('Open a topic before playing a mock case.');
- return;
- }
- start({ agentId, case: selected, threadId, topicId });
- }, [resolveReplayTarget, selected, start]);
-
- const handlePlay = useCallback(() => {
- if (idleOrComplete) {
- launchCase();
- return;
- }
- if (paused) resume();
- else if (running) pause();
- }, [idleOrComplete, launchCase, paused, pause, resume, running]);
-
- const handleReplay = useCallback(() => {
- if (!selected) return;
- if (playback && status !== 'idle') {
- seekToEventIndex(0);
- }
- launchCase();
- }, [launchCase, playback, seekToEventIndex, selected, status]);
-
- const stepMenu: DropdownItem[] = useMemo(
- () => [
- { key: 'event', label: 'Next event', onClick: stepEvent },
- { key: 'step', label: 'Next step', onClick: stepStep },
- { key: 'tool', label: 'Next tool', onClick: stepTool },
- ],
- [stepEvent, stepStep, stepTool],
- );
-
- const handleProgressClick = useCallback(
- (e: React.MouseEvent<HTMLDivElement>) => {
- if (!playback || playback.totalEvents === 0) return;
- const el = trackRef.current;
- if (!el) return;
- const rect = el.getBoundingClientRect();
- const ratio = Math.min(1, Math.max(0, (e.clientX - rect.left) / rect.width));
- const idx = Math.round(ratio * playback.totalEvents);
- seekToEventIndex(idx);
- },
- [playback, seekToEventIndex],
- );
-
- const pct = playback?.totalEvents
- ? Math.min(100, (playback.currentEventIndex / playback.totalEvents) * 100)
- : 0;
-
- const elapsed = playback ? `${(playback.elapsedMs / 1000).toFixed(1)}s` : '0.0s';
- const total = playback ? `${(playback.totalDurationMs / 1000).toFixed(1)}s` : '0.0s';
-
- const playIcon = running ? Pause : Play;
-
- return (
- <Flexbox horizontal align="center" className={styles.bar} gap={12}>
- <ActionIcon
- disabled={disabled}
- icon={playIcon}
- size="small"
- title={running ? 'Pause' : paused ? 'Resume' : 'Play'}
- onClick={handlePlay}
- />
- <DropdownMenu items={stepMenu} placement="topLeft">
- <ActionIcon disabled={disabled} icon={SkipForward} size="small" title="Step" />
- </DropdownMenu>
- <ActionIcon
- disabled={disabled}
- icon={RotateCcw}
- size="small"
- title="Replay from start"
- onClick={handleReplay}
- />
- <ActionIcon
- active={loop}
- aria-pressed={loop}
- className={loop ? styles.loopOn : undefined}
- icon={Repeat}
- size="small"
- title={loop ? 'Loop on' : 'Loop off'}
- onClick={() => setLoop(!loop)}
- />
- <div
- aria-valuemax={playback?.totalEvents ?? 0}
- aria-valuemin={0}
- aria-valuenow={playback?.currentEventIndex ?? 0}
- className={styles.progress}
- ref={trackRef}
- role="slider"
- tabIndex={0}
- onClick={handleProgressClick}
- >
- <div className={styles.progressTrack}>
- <div className={styles.progressFill} style={{ width: `${pct}%` }} />
- </div>
- </div>
- <span className={styles.time}>
- {elapsed} / {total}
- </span>
- <Tabs
- activeKey={String(speed)}
- items={SPEED_OPTIONS.map((o): TabsItem => ({ disabled, key: o.key, label: o.label }))}
- size="small"
- onChange={(key) => {
- const next = SPEED_OPTIONS.find((o) => o.key === key)?.value;
- if (next === undefined) return;
- setSpeedStore(next);
- setSpeed(next);
- }}
- />
- </Flexbox>
- );
-});
-
-TransportBar.displayName = 'AgentMockTransportBar';
diff --git a/src/features/AgentMockDevtools/views/FixtureView.tsx b/src/features/AgentMockDevtools/views/FixtureView.tsx
deleted file mode 100644
index 0c89418c75f..00000000000
--- a/src/features/AgentMockDevtools/views/FixtureView.tsx
+++ /dev/null
@@ -1,76 +0,0 @@
-import { Center, Flexbox, Text } from '@lobehub/ui';
-import { Button } from '@lobehub/ui/base-ui';
-import { createStaticStyles, cssVar } from 'antd-style';
-import { Copy } from 'lucide-react';
-import { memo, useMemo } from 'react';
-
-import { useMockCases } from '../hooks/useMockCases';
-import { useAgentMockStore } from '../store/agentMockStore';
-
-const styles = createStaticStyles(({ css }) => ({
- pre: css`
- overflow: auto;
- flex: 1;
-
- margin: 0;
- padding: 12px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: 8px;
-
- font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
- font-size: 11.5px;
- line-height: 1.6;
- color: ${cssVar.colorText};
-
- background: ${cssVar.colorFillAlter};
- `,
- wrap: css`
- display: flex;
- flex: 1;
- flex-direction: column;
- gap: 8px;
-
- height: 100%;
- min-height: 0;
- `,
-}));
-
-export const FixtureView = memo(() => {
- const { all } = useMockCases();
- const selectedCaseId = useAgentMockStore((s) => s.selectedCaseId);
- const c = all.find((x) => x.id === selectedCaseId);
-
- const json = useMemo(() => (c ? JSON.stringify(c, null, 2) : ''), [c]);
-
- if (!c) {
- return (
- <Center flex={1}>
- <Text type="secondary">Pick a case to begin.</Text>
- </Center>
- );
- }
-
- return (
- <div className={styles.wrap}>
- <Flexbox horizontal align="center" justify="space-between">
- <Text style={{ fontSize: 11 }} type="secondary">
- {c.id}
- </Text>
- <Button
- icon={<Copy size={14} />}
- size="small"
- onClick={() =>
- navigator.clipboard
- .writeText(json)
- .catch((err) => console.error('[AgentMock] Copy failed:', err))
- }
- >
- Copy
- </Button>
- </Flexbox>
- <pre className={styles.pre}>{json}</pre>
- </div>
- );
-});
-
-FixtureView.displayName = 'AgentMockFixtureView';
diff --git a/src/features/AgentMockDevtools/views/TimelineView.tsx b/src/features/AgentMockDevtools/views/TimelineView.tsx
deleted file mode 100644
index 10e55bca3c7..00000000000
--- a/src/features/AgentMockDevtools/views/TimelineView.tsx
+++ /dev/null
@@ -1,95 +0,0 @@
-import type { MockEvent } from '@lobechat/agent-mock';
-import { Center, Text } from '@lobehub/ui';
-import { createStaticStyles, cssVar } from 'antd-style';
-import { memo, useCallback, useMemo } from 'react';
-import { Virtuoso } from 'react-virtuoso';
-
-import { useAgentMockPlayer } from '../hooks/useAgentMockPlayer';
-import { useMockCases } from '../hooks/useMockCases';
-import { useAgentMockStore } from '../store/agentMockStore';
-import { EventRow } from '../Timeline/EventRow';
-
-const styles = createStaticStyles(({ css }) => ({
- list: css`
- overflow: hidden;
- flex: 1;
-
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: 8px;
-
- background: ${cssVar.colorBgContainer};
- `,
- meta: css`
- margin-block-end: 8px;
- font-size: 11px;
- color: ${cssVar.colorTextTertiary};
- `,
- wrap: css`
- display: flex;
- flex: 1;
- flex-direction: column;
-
- height: 100%;
- min-height: 0;
- `,
-}));
-
-export const TimelineView = memo(() => {
- const { all } = useMockCases();
- const selectedCaseId = useAgentMockStore((s) => s.selectedCaseId);
- const playback = useAgentMockStore((s) => s.playback);
- const { seekToEventIndex } = useAgentMockPlayer();
- const c = all.find((x) => x.id === selectedCaseId);
-
- const events = useMemo<MockEvent[]>(() => {
- if (!c) return [];
- if (c.source.type === 'fixture') return c.source.events;
- if (c.source.type === 'snapshot') return c.source.events ?? [];
- if (c.source.type === 'generator') return c.source.events ?? [];
- return [];
- }, [c]);
-
- const cumulative = useMemo(() => {
- const out: number[] = [];
- let acc = 0;
- for (const e of events) {
- acc += e.delay ?? 0;
- out.push(acc);
- }
- return out;
- }, [events]);
-
- const renderItem = useCallback(
- (idx: number, ev: MockEvent) => (
- <EventRow
- cumulativeMs={cumulative[idx] ?? 0}
- event={ev}
- index={idx}
- isActive={playback?.currentEventIndex === idx}
- onClick={() => seekToEventIndex(idx)}
- />
- ),
- [cumulative, playback?.currentEventIndex, seekToEventIndex],
- );
-
- if (!c) {
- return (
- <Center flex={1}>
- <Text type="secondary">Pick a case to begin.</Text>
- </Center>
- );
- }
-
- return (
- <div className={styles.wrap}>
- <div className={styles.meta}>
- {events.length} events · {((cumulative.at(-1) ?? 0) / 1000).toFixed(1)}s total
- </div>
- <div className={styles.list}>
- <Virtuoso data={events} itemContent={renderItem} />
- </div>
- </div>
- );
-});
-
-TimelineView.displayName = 'AgentMockTimelineView';
diff --git a/src/features/AgentSetting/AgentMeta/AutoGenerateAvatar.tsx b/src/features/AgentSetting/AgentMeta/AutoGenerateAvatar.tsx
deleted file mode 100644
index 16449fd4ba0..00000000000
--- a/src/features/AgentSetting/AgentMeta/AutoGenerateAvatar.tsx
+++ /dev/null
@@ -1,70 +0,0 @@
-import { ActionIcon, Flexbox } from '@lobehub/ui';
-import { cssVar } from 'antd-style';
-import { Wand2 } from 'lucide-react';
-import { memo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import EmojiPicker from '@/components/EmojiPicker';
-import { useGlobalStore } from '@/store/global';
-import { globalGeneralSelectors } from '@/store/global/selectors';
-
-export interface AutoGenerateAvatarProps {
- background?: string;
- canAutoGenerate?: boolean;
- disabled?: boolean;
- loading?: boolean;
- onChange?: (value: string) => void;
- onGenerate?: () => void;
- value?: string;
-}
-
-const AutoGenerateAvatar = memo<AutoGenerateAvatarProps>(
- ({ loading, background, value, onChange, onGenerate, canAutoGenerate, disabled }) => {
- const { t } = useTranslation('common');
- const locale = useGlobalStore(globalGeneralSelectors.currentLanguage);
-
- return (
- <Flexbox
- horizontal
- align={'center'}
- flex={'none'}
- gap={2}
- padding={2}
- style={{
- background: cssVar.colorBgContainer,
- border: `1px solid ${cssVar.colorBorderSecondary}`,
- borderRadius: 32,
- paddingRight: 8,
- width: 'fit-content',
- }}
- >
- <EmojiPicker
- background={background || cssVar.colorFillTertiary}
- loading={loading}
- locale={locale}
- size={48}
- value={value}
- style={{
- background: cssVar.colorFillTertiary,
- opacity: disabled ? 0.5 : 1,
- }}
- onChange={(next) => {
- if (disabled) return;
-
- onChange?.(next);
- }}
- />
- <ActionIcon
- disabled={disabled || !canAutoGenerate}
- icon={Wand2}
- loading={loading}
- size="small"
- title={!canAutoGenerate ? t('autoGenerateTooltipDisabled') : t('autoGenerate')}
- onClick={onGenerate}
- />
- </Flexbox>
- );
- },
-);
-
-export default AutoGenerateAvatar;
diff --git a/src/features/AgentSetting/AgentMeta/AutoGenerateInput.tsx b/src/features/AgentSetting/AgentMeta/AutoGenerateInput.tsx
deleted file mode 100644
index fff5921b150..00000000000
--- a/src/features/AgentSetting/AgentMeta/AutoGenerateInput.tsx
+++ /dev/null
@@ -1,76 +0,0 @@
-import { type InputProps } from '@lobehub/ui';
-import { ActionIcon, Input } from '@lobehub/ui';
-import { Wand2 } from 'lucide-react';
-import { memo, useCallback, useEffect, useRef, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { useIMECompositionEvent } from '@/hooks/useIMECompositionEvent';
-
-export interface AutoGenerateInputProps extends Omit<InputProps, 'onChange'> {
- canAutoGenerate?: boolean;
- loading?: boolean;
- onChange?: (value: string) => void;
- onGenerate?: () => void;
- value?: string | any;
-}
-
-const AutoGenerateInput = memo<AutoGenerateInputProps>(
- ({ loading, value, onChange, onGenerate, canAutoGenerate, ...props }) => {
- const { t } = useTranslation('common');
-
- const [input, setInput] = useState<string>(value || '');
-
- const { compositionProps, isComposingRef } = useIMECompositionEvent();
- const isFocusing = useRef(false);
-
- const updateValue = useCallback(() => {
- onChange?.(input);
- }, [input]);
-
- useEffect(() => {
- if (value !== undefined) setInput(value);
- }, [value]);
-
- return (
- <Input
- suffix={
- onGenerate && (
- <ActionIcon
- disabled={!canAutoGenerate}
- icon={Wand2}
- loading={loading}
- size="small"
- title={!canAutoGenerate ? t('autoGenerateTooltipDisabled') : t('autoGenerate')}
- style={{
- marginRight: -4,
- }}
- onClick={onGenerate}
- />
- )
- }
- {...props}
- value={input}
- onBlur={() => {
- updateValue();
- isFocusing.current = false;
- }}
- onChange={(e) => {
- setInput(e.target.value);
- }}
- {...compositionProps}
- onFocus={() => {
- isFocusing.current = true;
- }}
- onPressEnter={(e) => {
- if (!e.shiftKey && !isComposingRef.current) {
- e.preventDefault();
- updateValue();
- isFocusing.current = false;
- }
- }}
- />
- );
- },
-);
-
-export default AutoGenerateInput;
diff --git a/src/features/AgentSetting/AgentMeta/AutoGenerateSelect.tsx b/src/features/AgentSetting/AgentMeta/AutoGenerateSelect.tsx
deleted file mode 100644
index 40ae21f709b..00000000000
--- a/src/features/AgentSetting/AgentMeta/AutoGenerateSelect.tsx
+++ /dev/null
@@ -1,49 +0,0 @@
-import { ActionIcon } from '@lobehub/ui';
-import { Select, type SelectProps } from '@lobehub/ui/base-ui';
-import { isString } from 'es-toolkit/compat';
-import { Wand2 } from 'lucide-react';
-import { memo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-export interface AutoGenerateInputProps extends SelectProps {
- canAutoGenerate?: boolean;
- loading?: boolean;
- onGenerate?: () => void;
-}
-
-const AutoGenerateSelect = memo<AutoGenerateInputProps>(
- ({ loading, onGenerate, value, canAutoGenerate, onChange, ...props }) => {
- const { t } = useTranslation('common');
-
- return (
- <Select
- mode="tags"
- open={false}
- style={{ width: '100%' }}
- tokenSeparators={[',', ',', ' ']}
- value={isString(value) ? value.split(',') : value}
- suffixIcon={
- onGenerate && (
- <ActionIcon
- disabled={!canAutoGenerate}
- icon={Wand2}
- loading={loading}
- size={'small'}
- title={!canAutoGenerate ? t('autoGenerateTooltipDisabled') : t('autoGenerate')}
- style={{
- marginRight: -4,
- }}
- onClick={onGenerate}
- />
- )
- }
- onChange={(v) => {
- onChange?.(isString(v) ? v.split(',') : v);
- }}
- {...props}
- />
- );
- },
-);
-
-export default AutoGenerateSelect;
diff --git a/src/features/AgentSetting/AgentPlugin/AddPluginButton.tsx b/src/features/AgentSetting/AgentPlugin/AddPluginButton.tsx
deleted file mode 100644
index 684fee81fe9..00000000000
--- a/src/features/AgentSetting/AgentPlugin/AddPluginButton.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import { Button, type ButtonProps } from '@lobehub/ui/base-ui';
-import { Grid2x2Plus } from 'lucide-react';
-import { type Ref } from 'react';
-import { useState } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import DevModal from '@/features/PluginDevModal';
-import { useAgentStore } from '@/store/agent';
-import { useToolStore } from '@/store/tool';
-
-import { useStore } from '../store';
-
-const AddPluginButton = ({ ref, ...props }: ButtonProps & { ref?: Ref<HTMLButtonElement> }) => {
- const { t } = useTranslation('setting');
- const disabled = useStore((s) => s.disabled);
- const [showModal, setModal] = useState(false);
- const toggleAgentPlugin = useAgentStore((s) => s.toggleAgentPlugin);
- const [installCustomPlugin, updateNewDevPlugin] = useToolStore((s) => [
- s.installCustomPlugin,
- s.updateNewCustomPlugin,
- ]);
-
- return (
- <div
- onClick={(e) => {
- e.stopPropagation();
- }}
- >
- <DevModal
- open={!disabled && showModal}
- onValueChange={updateNewDevPlugin}
- onOpenChange={(next) => {
- if (disabled) return;
-
- setModal(next);
- }}
- onSave={async (devPlugin) => {
- if (disabled) return;
-
- await installCustomPlugin(devPlugin);
- toggleAgentPlugin(devPlugin.identifier);
- }}
- />
- <Button
- {...props}
- disabled={disabled}
- icon={Grid2x2Plus}
- ref={ref}
- size={'small'}
- onClick={() => {
- if (disabled) return;
-
- setModal(true);
- }}
- >
- {t('plugin.addTooltip')}
- </Button>
- </div>
- );
-};
-
-export default AddPluginButton;
diff --git a/src/features/AgentSetting/AgentPlugin/LoadingList.tsx b/src/features/AgentSetting/AgentPlugin/LoadingList.tsx
deleted file mode 100644
index 941f4e43983..00000000000
--- a/src/features/AgentSetting/AgentPlugin/LoadingList.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-import { Flexbox, Skeleton } from '@lobehub/ui';
-
-const LoadingList = () => {
- const loadingItem = {
- avatar: <Skeleton.Avatar active shape="square" size={40} style={{ flex: 'none' }} />,
- label: (
- <Flexbox flex={1} gap={6} style={{ overflow: 'hidden' }}>
- <Skeleton.Button
- active
- size={'small'}
- style={{
- height: 16,
- width: '70%',
- }}
- />
- <Skeleton.Button
- active
- size={'small'}
- style={{
- height: 12,
- width: '50%',
- }}
- />
- </Flexbox>
- ),
- };
-
- return [loadingItem, loadingItem, loadingItem];
-};
-
-export default LoadingList;
diff --git a/src/features/AgentSetting/AgentPlugin/LocalPluginItem.tsx b/src/features/AgentSetting/AgentPlugin/LocalPluginItem.tsx
deleted file mode 100644
index 38dd2470209..00000000000
--- a/src/features/AgentSetting/AgentPlugin/LocalPluginItem.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-import { getActivePluginIds } from '@lobechat/types';
-import { Flexbox } from '@lobehub/ui';
-import { Switch } from '@lobehub/ui/base-ui';
-import { memo } from 'react';
-
-import { useStore } from '../store';
-
-const MarketList = memo<{ id: string }>(({ id }) => {
- const [toggleAgentPlugin, hasPlugin, disabled] = useStore((s) => [
- s.toggleAgentPlugin,
- !!s.config.plugins,
- s.disabled,
- ]);
- const plugins = useStore((s) => getActivePluginIds(s.config.plugins));
-
- return (
- <Flexbox horizontal align={'center'} gap={8}>
- <Switch
- checked={!hasPlugin ? false : plugins.includes(id)}
- disabled={disabled}
- onChange={() => {
- if (disabled) return;
-
- toggleAgentPlugin(id);
- }}
- />
- </Flexbox>
- );
-});
-
-export default MarketList;
diff --git a/src/features/AgentSetting/AgentPlugin/PluginAction/index.tsx b/src/features/AgentSetting/AgentPlugin/PluginAction/index.tsx
deleted file mode 100644
index 92e69c97262..00000000000
--- a/src/features/AgentSetting/AgentPlugin/PluginAction/index.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import { getActivePluginIds } from '@lobechat/types';
-import { Flexbox } from '@lobehub/ui';
-import { Switch } from '@lobehub/ui/base-ui';
-import isEqual from 'fast-deep-equal';
-import { memo } from 'react';
-
-import { useToolStore } from '@/store/tool';
-
-import { useStore } from '../../store';
-
-const PluginSwitch = memo<{ identifier: string }>(({ identifier }) => {
- const pluginManifestLoading = useToolStore((s) => s.pluginInstallLoading, isEqual);
- const [userEnabledPlugins, hasPlugin, disabled, toggleAgentPlugin] = useStore((s) => [
- getActivePluginIds(s.config.plugins),
- !!s.config.plugins,
- s.disabled,
- s.toggleAgentPlugin,
- ]);
-
- return (
- <Flexbox horizontal align={'center'} gap={8}>
- <Switch
- disabled={disabled}
- loading={pluginManifestLoading[identifier]}
- checked={
- // If loading, it means it's activated
- pluginManifestLoading[identifier] || !hasPlugin
- ? false
- : userEnabledPlugins.includes(identifier)
- }
- onChange={() => {
- if (disabled) return;
-
- toggleAgentPlugin(identifier);
- }}
- />
- </Flexbox>
- );
-});
-
-export default PluginSwitch;
diff --git a/src/features/AgentSetting/AgentPrompt/TokenTag.tsx b/src/features/AgentSetting/AgentPrompt/TokenTag.tsx
deleted file mode 100644
index 15b37bf2501..00000000000
--- a/src/features/AgentSetting/AgentPrompt/TokenTag.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-import { Tag } from '@lobehub/ui';
-import React, { memo } from 'react';
-
-import { useTokenCount } from '@/hooks/useTokenCount';
-
-const Tokens = memo<{ style?: React.CSSProperties; value: string }>(({ value, style }) => {
- const systemTokenCount = useTokenCount(value);
- if (!value || !systemTokenCount) return;
-
- return (
- <Tag
- style={{
- marginTop: 24,
- width: 'fit-content',
- ...style,
- }}
- >
- Token: {systemTokenCount}
- </Tag>
- );
-});
-
-export default Tokens;
diff --git a/src/features/AgentTaskList/index.tsx b/src/features/AgentTaskList/index.tsx
deleted file mode 100644
index b4acefb0eaa..00000000000
--- a/src/features/AgentTaskList/index.tsx
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from '@/features/AgentTasks/features/AgentTaskCardList';
diff --git a/src/features/AgentTasks/features/AgentTaskCardList.tsx b/src/features/AgentTasks/features/AgentTaskCardList.tsx
deleted file mode 100644
index 075dd6b9eef..00000000000
--- a/src/features/AgentTasks/features/AgentTaskCardList.tsx
+++ /dev/null
@@ -1,48 +0,0 @@
-import { Block, Flexbox } from '@lobehub/ui';
-import { Divider } from 'antd';
-import { Fragment, memo, useCallback, useMemo } from 'react';
-
-import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
-import { useAgentStore } from '@/store/agent';
-import { useTaskStore } from '@/store/task';
-import { taskListSelectors } from '@/store/task/selectors';
-
-import AgentTaskItem from './AgentTaskItem';
-import { getDisplayTaskCardTasks, getVisibleTaskCardTasks } from './taskCardListDisplay';
-import TaskListHeader from './TaskListHeader';
-
-const AgentTaskCardList = memo(() => {
- const agentId = useAgentStore((s) => s.activeAgentId);
- const navigate = useWorkspaceAwareNavigate();
- const useFetchTaskList = useTaskStore((s) => s.useFetchTaskList);
- useFetchTaskList({ agentId });
-
- const tasks = useTaskStore(taskListSelectors.taskList);
- const isInit = useTaskStore(taskListSelectors.isTaskListInit);
-
- const handleViewAll = useCallback(() => {
- navigate('/tasks');
- }, [navigate]);
-
- const visibleTasks = useMemo(() => getVisibleTaskCardTasks(tasks), [tasks]);
- const displayTasks = useMemo(() => getDisplayTaskCardTasks(tasks), [tasks]);
-
- if (!isInit || visibleTasks.length === 0) return null;
-
- return (
- <Block shadow variant={'outlined'}>
- <TaskListHeader count={visibleTasks.length} onViewAll={handleViewAll} />
- <Divider style={{ margin: 0 }} />
- <Flexbox gap={2} padding={2}>
- {displayTasks.map((task, index) => (
- <Fragment key={task.identifier}>
- <AgentTaskItem task={task} />
- {index !== displayTasks.length - 1 && <Divider dashed style={{ margin: 0 }} />}
- </Fragment>
- ))}
- </Flexbox>
- </Block>
- );
-});
-
-export default AgentTaskCardList;
diff --git a/src/features/AgentTasks/features/TaskListHeader.tsx b/src/features/AgentTasks/features/TaskListHeader.tsx
deleted file mode 100644
index eacbe2ac5c5..00000000000
--- a/src/features/AgentTasks/features/TaskListHeader.tsx
+++ /dev/null
@@ -1,51 +0,0 @@
-import { ActionIcon, Flexbox, Text } from '@lobehub/ui';
-import { Button } from '@lobehub/ui/base-ui';
-import { cssVar } from 'antd-style';
-import { ClipboardList } from 'lucide-react';
-import { memo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-interface TaskListHeaderProps {
- count?: number;
- onViewAll?: () => void;
-}
-
-const TaskListHeader = memo<TaskListHeaderProps>(({ onViewAll, count }) => {
- const { t } = useTranslation('chat');
-
- return (
- <Flexbox
- horizontal
- align={'center'}
- justify={'space-between'}
- paddingBlock={8}
- paddingInline={8}
- >
- <Flexbox horizontal align="center" gap={8}>
- <ActionIcon
- shadow
- icon={ClipboardList}
- size={16}
- variant={'outlined'}
- onClick={onViewAll}
- />
- <Text weight={500}>{t('taskList.title')}</Text>
- <Text color={cssVar.colorTextQuaternary} fontSize={12}>
- {count}
- </Text>
- </Flexbox>
- <Button
- size={'small'}
- type={'text'}
- style={{
- color: cssVar.colorTextDescription,
- }}
- onClick={onViewAll}
- >
- {t('taskList.viewAll')}
- </Button>
- </Flexbox>
- );
-});
-
-export default TaskListHeader;
diff --git a/src/features/ChangelogModal/index.tsx b/src/features/ChangelogModal/index.tsx
deleted file mode 100644
index 00118043c72..00000000000
--- a/src/features/ChangelogModal/index.tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-'use client';
-
-import { memo, useEffect, useState } from 'react';
-
-import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
-import { lambdaClient } from '@/libs/trpc/client';
-import { useGlobalStore } from '@/store/global';
-
-const ChangelogModal = memo<{ currentId?: string }>(({ currentId: propCurrentId }) => {
- const [latestChangelogId, updateSystemStatus] = useGlobalStore((s) => [
- s.status.latestChangelogId,
- s.updateSystemStatus,
- ]);
- const navigate = useWorkspaceAwareNavigate();
- const [currentId, setCurrentId] = useState(propCurrentId);
-
- useEffect(() => {
- if (propCurrentId) return;
- lambdaClient.changelog.getIndex
- .query()
- .then((index) => {
- if (index[0]?.id) setCurrentId(index[0].id);
- })
- .catch(() => {});
- }, [propCurrentId]);
-
- useEffect(() => {
- if (!currentId) return;
- const timer = setTimeout(() => {
- if (!latestChangelogId) {
- updateSystemStatus({ latestChangelogId: currentId });
- } else if (latestChangelogId !== currentId) {
- navigate('/changelog/modal');
- }
- }, 1000);
- return () => clearTimeout(timer);
- }, [currentId, latestChangelogId, updateSystemStatus, navigate]);
-
- return null;
-});
-
-export default ChangelogModal;
diff --git a/src/features/ChatInput/Desktop/FilePreview/FileList.tsx b/src/features/ChatInput/Desktop/FilePreview/FileList.tsx
deleted file mode 100644
index 829a2060aa8..00000000000
--- a/src/features/ChatInput/Desktop/FilePreview/FileList.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import { Flexbox, ScrollShadow } from '@lobehub/ui';
-import { createStaticStyles } from 'antd-style';
-import { memo } from 'react';
-
-import { useChatInputStore } from '@/features/ChatInput/store';
-import { fileChatSelectors, useFileStore } from '@/store/file';
-
-import FileItem from './FileItem';
-
-const styles = createStaticStyles(({ css }) => ({
- container: css`
- overflow-x: scroll;
-
- /* A swipe past the strip's edge must not fire the browser back gesture. */
- overscroll-behavior-x: none;
- width: 100%;
- `,
-}));
-
-const FileList = memo(() => {
- const expand = useChatInputStore((s) => s.expand);
-
- const inputFilesList = useFileStore(fileChatSelectors.chatUploadFileList);
- const showFileList = useFileStore(fileChatSelectors.chatUploadFileListHasItem);
-
- if (!inputFilesList.length || !showFileList) return null;
-
- return (
- <ScrollShadow
- hideScrollBar
- horizontal
- className={styles.container}
- orientation={'horizontal'}
- size={8}
- >
- <Flexbox horizontal gap={6} paddingBlock={8} paddingInline={expand ? 0 : 12}>
- {inputFilesList.map((item) => (
- <FileItem key={item.id} {...item} />
- ))}
- </Flexbox>
- </ScrollShadow>
- );
-});
-
-export default FileList;
diff --git a/src/features/ChatInput/Desktop/MentionedUsers/MentionedUserItem.tsx b/src/features/ChatInput/Desktop/MentionedUsers/MentionedUserItem.tsx
deleted file mode 100644
index b0d2b2120f7..00000000000
--- a/src/features/ChatInput/Desktop/MentionedUsers/MentionedUserItem.tsx
+++ /dev/null
@@ -1,86 +0,0 @@
-import { Avatar, Center, Flexbox, Text } from '@lobehub/ui';
-import { createStaticStyles, cssVar } from 'antd-style';
-import { X } from 'lucide-react';
-import { memo } from 'react';
-
-import { useMentionStore } from '@/store/mention';
-
-const styles = createStaticStyles(({ css }) => ({
- container: css`
- position: relative;
-
- width: 180px;
- height: 64px;
- border-radius: 8px;
-
- background: ${cssVar.colorBgContainer};
-
- :hover {
- background: ${cssVar.colorBgElevated};
- }
- `,
- removeButton: css`
- cursor: pointer;
-
- position: absolute;
- z-index: 10;
- inset-block-start: -4px;
- inset-inline-end: -4px;
-
- display: flex;
- align-items: center;
- justify-content: center;
-
- width: 20px;
- height: 20px;
- border-radius: 5px;
-
- background: ${cssVar.colorBgElevated};
- box-shadow:
- 0 0 0 0.5px ${cssVar.colorFillSecondary} inset,
- ${cssVar.boxShadowTertiary};
-
- :hover {
- color: ${cssVar.colorError};
- background: ${cssVar.colorErrorBg};
- }
- `,
-}));
-
-interface MentionedUserItemProps {
- agent: any; // The actual agent data from the group
-}
-
-const MentionedUserItem = memo<MentionedUserItemProps>(({ agent }) => {
- const removeMentionedUser = useMentionStore((s) => s.removeMentionedUser);
-
- const handleRemove = () => {
- removeMentionedUser(agent.id);
- };
-
- return (
- <Flexbox horizontal align={'center'} className={styles.container}>
- <Center flex={1} height={64} padding={4} style={{ maxWidth: 64 }}>
- <Avatar
- avatar={agent.avatar}
- background={agent.backgroundColor}
- shape={'square'}
- size={48}
- />
- </Center>
- <Flexbox flex={1} gap={4} style={{ paddingBottom: 4, paddingInline: 4 }}>
- <Text ellipsis={{ tooltip: true }} style={{ fontSize: 12, maxWidth: 100 }}>
- {agent.title || agent.id}
- </Text>
- <Text style={{ fontSize: 10 }} type="secondary">
- @{agent.id}
- </Text>
- </Flexbox>
- <div className={styles.removeButton} onClick={handleRemove}>
- <X size={12} />
- </div>
- </Flexbox>
- );
-});
-
-export default MentionedUserItem;
diff --git a/src/features/ChatInput/InputEditor/useAgentMentionItems.tsx b/src/features/ChatInput/InputEditor/useAgentMentionItems.tsx
deleted file mode 100644
index 7df229c738c..00000000000
--- a/src/features/ChatInput/InputEditor/useAgentMentionItems.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-import { Avatar } from '@lobehub/ui';
-import { useMemo } from 'react';
-
-import { useHomeStore } from '@/store/home';
-import { homeAgentListSelectors } from '@/store/home/selectors';
-
-import { useAgentId } from '../hooks/useAgentId';
-
-const MAX_AGENT_ITEMS = 20;
-
-export const useAgentMentionItems = () => {
- const allAgents = useHomeStore(homeAgentListSelectors.allAgents);
- const currentAgentId = useAgentId();
-
- return useMemo(() => {
- const otherAgents = allAgents.filter((a) => a.type === 'agent' && a.id !== currentAgentId);
-
- if (otherAgents.length === 0) return [];
-
- return otherAgents.slice(0, MAX_AGENT_ITEMS).map((agent) => ({
- icon: (
- <Avatar
- avatar={typeof agent.avatar === 'string' ? agent.avatar : undefined}
- background={agent.backgroundColor ?? undefined}
- size={24}
- />
- ),
- key: `agent-${agent.id}`,
- label: agent.title || 'Untitled Agent',
- metadata: { id: agent.id, type: 'agent' },
- }));
- }, [allAgents, currentAgentId]);
-};
diff --git a/src/features/ChatInput/InputEditor/useTopicMentionItems.tsx b/src/features/ChatInput/InputEditor/useTopicMentionItems.tsx
deleted file mode 100644
index d51d8d0a79f..00000000000
--- a/src/features/ChatInput/InputEditor/useTopicMentionItems.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { Icon } from '@lobehub/ui';
-import { MessageSquareText } from 'lucide-react';
-import { useMemo } from 'react';
-
-import { useChatStore } from '@/store/chat';
-import { topicSelectors } from '@/store/chat/selectors';
-import { useGlobalStore } from '@/store/global';
-import { systemStatusSelectors } from '@/store/global/selectors';
-
-export const useTopicMentionItems = () => {
- const topicPageSize = useGlobalStore(systemStatusSelectors.topicPageSize);
-
- const topicsSelector = useMemo(
- () => topicSelectors.displayTopicsForSidebar(topicPageSize),
- [topicPageSize],
- );
- const topics = useChatStore(topicsSelector);
- const activeTopicId = useChatStore((s) => s.activeTopicId);
-
- return useMemo(() => {
- if (!topics || topics.length === 0) return [];
-
- const MAX_LABEL_LENGTH = 50;
-
- return topics
- .filter((t) => t.id !== activeTopicId)
- .map((topic) => {
- const title = topic.title || 'Untitled';
- const label =
- title.length > MAX_LABEL_LENGTH ? `${title.slice(0, MAX_LABEL_LENGTH)}...` : title;
-
- return {
- icon: <Icon icon={MessageSquareText} size={20} />,
- key: `topic-${topic.id}`,
- label,
- metadata: { topicId: topic.id, topicTitle: topic.title, type: 'topic' },
- };
- });
- }, [topics, activeTopicId]);
-};
diff --git a/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/PluginSettings.tsx b/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/PluginSettings.tsx
deleted file mode 100644
index e598e1fd160..00000000000
--- a/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/PluginSettings.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-import { type ChatPluginPayload } from '@lobechat/types';
-import { Avatar, Center, Flexbox } from '@lobehub/ui';
-import { Button } from '@lobehub/ui/base-ui';
-import { Divider } from 'antd';
-import { cssVar } from 'antd-style';
-import isEqual from 'fast-deep-equal';
-import { memo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import PluginSettingsConfig from '@/features/PluginSettings';
-import { pluginHelpers, useToolStore } from '@/store/tool';
-import { pluginSelectors } from '@/store/tool/selectors';
-
-import { ErrorActionContainer, styles as errorStyles } from '../../../../Error/style';
-import { useConversationStore } from '../../../../store';
-
-interface PluginSettingsProps {
- id: string;
- plugin?: ChatPluginPayload;
-}
-
-const PluginSettings = memo<PluginSettingsProps>(({ id, plugin }) => {
- const { t } = useTranslation('error');
- const [resend, deleteMessage] = useConversationStore((s) => [
- s.delAndRegenerateMessage,
- s.deleteMessage,
- ]);
- const pluginIdentifier = plugin?.identifier as string;
- const pluginMeta = useToolStore(pluginSelectors.getPluginMetaById(pluginIdentifier), isEqual);
- const manifest = useToolStore(pluginSelectors.getToolManifestById(pluginIdentifier), isEqual);
-
- return (
- !!manifest && (
- <ErrorActionContainer>
- <Center gap={16} style={{ maxWidth: 400 }}>
- <Avatar
- avatar={pluginHelpers.getPluginAvatar(pluginMeta) || '⚙️'}
- background={cssVar.colorFillContent}
- gap={12}
- shape={'square'}
- size={80}
- />
- <Flexbox style={{ fontSize: 20 }}>
- {t('pluginSettings.title', { name: pluginHelpers.getPluginTitle(pluginMeta) })}
- </Flexbox>
- <Flexbox className={errorStyles.desc}>{t('pluginSettings.desc')}</Flexbox>
- <Divider style={{ margin: '0 16px' }} />
- {manifest.settings && (
- <PluginSettingsConfig id={manifest.identifier} schema={manifest.settings} />
- )}
- <Button
- block
- style={{ marginTop: 8 }}
- type={'primary'}
- onClick={() => {
- resend(id);
- deleteMessage(id);
- }}
- >
- {t('unlock.confirm')}
- </Button>
- </Center>
- </ErrorActionContainer>
- )
- );
-});
-
-export default PluginSettings;
diff --git a/src/features/Conversation/Messages/Tool/ErrorBoundary/ErrorResult.tsx b/src/features/Conversation/Messages/Tool/ErrorBoundary/ErrorResult.tsx
deleted file mode 100644
index d0acedce45f..00000000000
--- a/src/features/Conversation/Messages/Tool/ErrorBoundary/ErrorResult.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-'use client';
-
-import { Alert, Highlighter } from '@lobehub/ui';
-import { type ErrorInfo } from 'react';
-import { memo } from 'react';
-
-interface ErrorDisplayProps {
- apiName?: string;
- error: Error | null;
- errorInfo: ErrorInfo | null;
- identifier?: string;
-}
-
-/**
- * Error display component using @lobehub/ui Alert
- */
-export const ErrorDisplay = memo<ErrorDisplayProps>(({ error, identifier, apiName }) => {
- const title = identifier ? `${identifier}${apiName ? ` / ${apiName}` : ''}` : 'Tool Render Error';
-
- return (
- <Alert
- showIcon
- extraIsolate={false}
- message={error?.message || 'An unknown error occurred'}
- title={title}
- type="secondary"
- extra={
- error?.stack ? (
- <Highlighter actionIconSize="small" language="plaintext" padding={8} variant="borderless">
- {error.stack}
- </Highlighter>
- ) : undefined
- }
- style={{
- overflow: 'hidden',
- position: 'relative',
- width: '100%',
- }}
- />
- );
-});
-
-ErrorDisplay.displayName = 'ToolErrorDisplay';
diff --git a/src/features/Conversation/Messages/components/IntentUnderstanding.tsx b/src/features/Conversation/Messages/components/IntentUnderstanding.tsx
deleted file mode 100644
index 4fd7dce24de..00000000000
--- a/src/features/Conversation/Messages/components/IntentUnderstanding.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import { Flexbox } from '@lobehub/ui';
-import { useTranslation } from 'react-i18next';
-
-import CircleLoader from '@/components/CircleLoader';
-import { shinyTextStyles } from '@/styles';
-
-const IntentUnderstanding = () => {
- const { t } = useTranslation('chat');
-
- return (
- <Flexbox horizontal align={'center'} gap={8}>
- <CircleLoader />
- <Flexbox horizontal className={shinyTextStyles.shinyText}>
- {t('intentUnderstanding.title')}
- </Flexbox>
- </Flexbox>
- );
-};
-export default IntentUnderstanding;
diff --git a/src/features/DevPanel/CacheViewer/DataTable/index.tsx b/src/features/DevPanel/CacheViewer/DataTable/index.tsx
deleted file mode 100644
index 885004a4424..00000000000
--- a/src/features/DevPanel/CacheViewer/DataTable/index.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-'use client';
-
-import { RefreshCw } from 'lucide-react';
-import { memo } from 'react';
-
-import Header from '../../features/Header';
-import Table from '../../features/Table';
-import { useCachePanelContext } from '../cacheProvider';
-
-const DataTable = memo(() => {
- const { entries, isLoading, refreshData } = useCachePanelContext();
- return (
- <>
- <Header
- title="Cache Entries"
- actions={[
- {
- icon: RefreshCw,
- onClick: () => refreshData(),
- title: 'Refresh',
- },
- ]}
- />
- <Table
- columns={['url', 'headers.content-type', 'body', 'kind', 'tags', 'revalidate', 'timestamp']}
- dataSource={entries}
- loading={isLoading}
- />
- </>
- );
-});
-
-export default DataTable;
diff --git a/src/features/DevPanel/CacheViewer/cacheProvider.tsx b/src/features/DevPanel/CacheViewer/cacheProvider.tsx
deleted file mode 100644
index 49f36c87ecb..00000000000
--- a/src/features/DevPanel/CacheViewer/cacheProvider.tsx
+++ /dev/null
@@ -1,59 +0,0 @@
-'use client';
-
-import { type PropsWithChildren } from 'react';
-import { createContext, use, useEffect, useState, useTransition } from 'react';
-
-import { usePathname } from '@/libs/router/navigation';
-
-import { getCacheFiles } from './getCacheEntries';
-import { type NextCacheFileData } from './schema';
-
-interface CachePanelContextProps {
- entries: NextCacheFileData[];
- isLoading: boolean;
- refreshData: () => void;
- setEntries: (value: NextCacheFileData[]) => void;
-}
-
-const CachePanelContext = createContext<CachePanelContextProps>({
- entries: [],
- isLoading: false,
- refreshData: () => {},
- setEntries: () => {},
-});
-
-export const useCachePanelContext = () => use(CachePanelContext);
-
-export const CachePanelContextProvider = (
- props: PropsWithChildren<{
- entries: NextCacheFileData[];
- }>,
-) => {
- const [isLoading, startTransition] = useTransition();
- const [entries, setEntries] = useState(props.entries);
- const pathname = usePathname();
-
- const refreshData = () => {
- startTransition(async () => {
- const files = await getCacheFiles();
- setEntries(files ?? []);
- });
- };
-
- useEffect(() => {
- refreshData();
- }, [pathname]);
-
- return (
- <CachePanelContext
- value={{
- entries,
- isLoading,
- refreshData,
- setEntries,
- }}
- >
- {props.children}
- </CachePanelContext>
- );
-};
diff --git a/src/features/DevPanel/CacheViewer/getCacheEntries.ts b/src/features/DevPanel/CacheViewer/getCacheEntries.ts
deleted file mode 100644
index 702e659a85b..00000000000
--- a/src/features/DevPanel/CacheViewer/getCacheEntries.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-'use server';
-
-import { existsSync, promises } from 'node:fs';
-
-import pMap from 'p-map';
-import { ZodError } from 'zod';
-
-import { type NextCacheFileData } from './schema';
-import { nextCacheFileSchema } from './schema';
-
-const cachePath = '.next/cache/fetch-cache';
-
-export const getCacheFiles = async (): Promise<NextCacheFileData[]> => {
- if (!existsSync(cachePath)) {
- return [];
- }
- const files = await promises.readdir(cachePath);
- let result: NextCacheFileData[] = (await pMap(files, async (file) => {
- // ignore tags-manifest file
- if (/manifest/.test(file)) return false;
- try {
- const fileContent = await promises.readFile(`${cachePath}/${file}`).catch((err) => {
- throw new Error(`Error reading file ${file}`, {
- cause: err,
- });
- });
-
- const fileStats = await promises.stat(`${cachePath}/${file}`).catch((err) => {
- throw new Error(`Error reading file ${file}`, {
- cause: err,
- });
- });
-
- const jsonData = JSON.parse(fileContent.toString());
-
- return nextCacheFileSchema.parse({
- ...jsonData,
- id: file,
- timestamp: new Date(fileStats.birthtime),
- });
- } catch (error) {
- if (error instanceof ZodError) {
- const issues = error.issues;
- console.error(`File ${file} do not match the schema`, issues);
- }
- console.error(`Error parsing ${file}`);
- return false;
- }
- })) as NextCacheFileData[];
-
- result = result.filter(Boolean) as NextCacheFileData[];
-
- return result.sort((a, b) => b.timestamp.getTime() - a.timestamp.getTime());
-};
diff --git a/src/features/DevPanel/CacheViewer/index.tsx b/src/features/DevPanel/CacheViewer/index.tsx
deleted file mode 100644
index d54b08bc83a..00000000000
--- a/src/features/DevPanel/CacheViewer/index.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-import { Center, Empty } from '@lobehub/ui';
-import { Database } from 'lucide-react';
-import { useTranslation } from 'react-i18next';
-
-import { CachePanelContextProvider } from './cacheProvider';
-import DataTable from './DataTable';
-import { getCacheFiles } from './getCacheEntries';
-
-const CacheViewer = async () => {
- // eslint-disable-next-line react-hooks/rules-of-hooks
- const { t } = useTranslation('components');
- const files = await getCacheFiles();
-
- if (!files || files.length === 0)
- return (
- <Center height={'80%'}>
- <Empty
- description={t('devTools.cache.empty')}
- descriptionProps={{ fontSize: 14 }}
- icon={Database}
- style={{ maxWidth: 400 }}
- />
- </Center>
- );
-
- return (
- <CachePanelContextProvider entries={files}>
- <DataTable />
- </CachePanelContextProvider>
- );
-};
-
-export default CacheViewer;
diff --git a/src/features/DevPanel/CacheViewer/schema.ts b/src/features/DevPanel/CacheViewer/schema.ts
deleted file mode 100644
index ee146d794d7..00000000000
--- a/src/features/DevPanel/CacheViewer/schema.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-import { Buffer } from 'buffer.js';
-import { z } from 'zod';
-
-const unstableCacheFileSchema = z.object({
- data: z.object({
- body: z.string(),
- headers: z.object({}).transform(() => null),
- status: z.number(),
- url: z.literal(''),
- }),
- kind: z.union([z.literal('FETCH'), z.unknown()]),
- revalidate: z.number().optional(),
- tags: z.array(z.string()).optional().default([]),
-});
-
-const fetchCacheFileSchema = z.object({
- data: z.object({
- body: z.string(),
- headers: z.record(z.string(), z.string()),
- status: z.number(),
- url: z.string().url(),
- }),
- id: z.string(),
- kind: z.union([z.literal('FETCH'), z.unknown()]),
- revalidate: z.number().optional(),
- tags: z.array(z.string()).optional().default([]),
-});
-
-const atou = (str: string, type: string) => {
- if (type.startsWith('image/')) return `data:${type};base64,${str}`;
- return Buffer.from(str, 'base64').toString();
-};
-export const nextCacheFileSchema = z
- .union([unstableCacheFileSchema, fetchCacheFileSchema])
- .transform((item) => {
- const { data, ...cacheEntry } = item;
- const body =
- data.url !== ''
- ? atou(data.body, data.headers ? data.headers['content-type'] : '')
- : data.body;
- return {
- ...cacheEntry,
- ...data,
- body,
- timestamp: data.headers?.date ? new Date(data.headers?.date) : new Date(),
- url: data.url === '' ? 'unstable_cache' : data.url,
- };
- });
-
-export type NextCacheFileData = z.infer<typeof nextCacheFileSchema>;
diff --git a/src/features/DevPanel/FeatureFlagViewer/Form.tsx b/src/features/DevPanel/FeatureFlagViewer/Form.tsx
deleted file mode 100644
index fd37784a24a..00000000000
--- a/src/features/DevPanel/FeatureFlagViewer/Form.tsx
+++ /dev/null
@@ -1,93 +0,0 @@
-'use client';
-
-import { Flexbox, Form, Highlighter } from '@lobehub/ui';
-import { Switch } from '@lobehub/ui/base-ui';
-import { createStaticStyles } from 'antd-style';
-import { snakeCase } from 'es-toolkit/compat';
-import { ListRestartIcon } from 'lucide-react';
-import { memo, useMemo, useState } from 'react';
-
-import { DEFAULT_FEATURE_FLAGS } from '@/config/featureFlags';
-
-import Header from '../features/Header';
-
-const prefixCls = 'ant';
-
-const styles = createStaticStyles(({ css, cssVar }) => ({
- container: css`
- * {
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- }
- .${prefixCls}-form-item {
- padding-block: 4px !important;
- }
- `,
-}));
-
-const FeatureFlagForm = memo<{ flags: any }>(({ flags }) => {
- const [data, setData] = useState(flags);
- const [form] = Form.useForm();
-
- const output = useMemo(
- () =>
- Object.entries(data).map(([key, value]) => {
- const flag = snakeCase(key);
- // @ts-ignore
- if (DEFAULT_FEATURE_FLAGS[flag] === value) return false;
- if (value === true) return `+${flag}`;
- return `-${flag}`;
- }),
- [data],
- );
-
- return (
- <>
- <Header
- title={'Feature Flag Env'}
- actions={[
- {
- icon: ListRestartIcon,
- onClick: () => {
- form.resetFields();
- setData(flags);
- },
- title: 'Reset',
- },
- ]}
- />
- <Flexbox
- className={styles.container}
- height={'100%'}
- paddingInline={16}
- style={{ overflow: 'auto', position: 'relative' }}
- width={'100%'}
- >
- <Form
- form={form}
- initialValues={flags}
- itemMinWidth={'max(75%,240px)'}
- itemsType={'flat'}
- variant={'borderless'}
- items={Object.keys(flags).map((key) => {
- return {
- children: <Switch size={'small'} />,
- label: snakeCase(key),
- minWidth: undefined,
- name: key,
- valuePropName: 'checked',
- };
- })}
- onValuesChange={(_, v) => setData(v)}
- />
- </Flexbox>
- <Highlighter
- wrap
- language={'env'}
- style={{ flex: 'none', fontSize: 12 }}
- >{`FEATURE_FLAGS="${output.filter(Boolean).join(',')}"`}</Highlighter>
- </>
- );
-});
-
-export default FeatureFlagForm;
diff --git a/src/features/DevPanel/FeatureFlagViewer/index.tsx b/src/features/DevPanel/FeatureFlagViewer/index.tsx
deleted file mode 100644
index 2797e4bfbfc..00000000000
--- a/src/features/DevPanel/FeatureFlagViewer/index.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import { getServerFeatureFlagsValue } from '@/config/featureFlags';
-
-import FeatureFlagForm from './Form';
-
-const FeatureFlagViewer = () => {
- const serverFeatureFlags = getServerFeatureFlagsValue();
-
- return <FeatureFlagForm flags={serverFeatureFlags} />;
-};
-
-export default FeatureFlagViewer;
diff --git a/src/features/DevPanel/MetadataViewer/Ld.tsx b/src/features/DevPanel/MetadataViewer/Ld.tsx
deleted file mode 100644
index fbd3da88988..00000000000
--- a/src/features/DevPanel/MetadataViewer/Ld.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-import { Center, Empty, Highlighter } from '@lobehub/ui';
-import { Code } from 'lucide-react';
-import { memo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { useLd } from './useHead';
-
-const Ld = memo(() => {
- const { t } = useTranslation('components');
- const ld = useLd();
-
- if (!ld)
- return (
- <Center height={'80%'}>
- <Empty
- description={t('devTools.metadata.empty')}
- descriptionProps={{ fontSize: 14 }}
- icon={Code}
- style={{ maxWidth: 400 }}
- />
- </Center>
- );
-
- return (
- <Highlighter language="json" variant={'borderless'}>
- {JSON.stringify(JSON.parse(ld), null, 2)}
- </Highlighter>
- );
-});
-
-export default Ld;
diff --git a/src/features/DevPanel/MetadataViewer/MetaData.tsx b/src/features/DevPanel/MetadataViewer/MetaData.tsx
deleted file mode 100644
index 8cf797b02d4..00000000000
--- a/src/features/DevPanel/MetadataViewer/MetaData.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-import { Form, Input, TextArea } from '@lobehub/ui';
-import { memo } from 'react';
-
-import { useHead, useTitle } from './useHead';
-
-const MetaData = memo(() => {
- const title = useTitle();
- const description = useHead('name', 'description');
-
- return (
- <Form
- itemMinWidth={'max(75%,240px)'}
- itemsType={'flat'}
- variant={'borderless'}
- items={[
- {
- children: <Input value={title} variant={'filled'} />,
- label: `Title (${title.length})`,
- },
- {
- children: <TextArea rows={2} value={description} variant={'filled'} />,
- label: `Description (${description.length})`,
- },
- ]}
- />
- );
-});
-
-export default MetaData;
diff --git a/src/features/DevPanel/MetadataViewer/Og.tsx b/src/features/DevPanel/MetadataViewer/Og.tsx
deleted file mode 100644
index 7265e436b84..00000000000
--- a/src/features/DevPanel/MetadataViewer/Og.tsx
+++ /dev/null
@@ -1,74 +0,0 @@
-import { Flexbox, Form, Input, TextArea } from '@lobehub/ui';
-import { memo } from 'react';
-
-import Image from '@/libs/next/Image';
-
-import { useHead } from './useHead';
-
-const MetaData = memo(() => {
- const ogTitle = useHead('property', 'og:title');
- const ogDescription = useHead('property', 'og:description');
- const ogImage = useHead('property', 'og:image');
-
- return (
- <Form
- itemMinWidth={'max(75%,240px)'}
- itemsType={'flat'}
- variant={'borderless'}
- items={[
- {
- children: <Input value={ogTitle} variant={'filled'} />,
- label: `OG Title (${ogTitle.length})`,
- },
- {
- children: <TextArea rows={2} value={ogDescription} variant={'filled'} />,
- label: `OG Description (${ogDescription.length})`,
- },
- {
- children: (
- <Flexbox
- height={186}
- width={358}
- style={{
- background: 'rgba(0, 0, 0, .5)',
- borderRadius: 14,
- overflow: 'hidden',
- position: 'relative',
- }}
- >
- <div
- style={{
- background: 'rgba(0, 0, 0, .5)',
- borderRadius: 4,
- bottom: 10,
- left: 10,
- lineHeight: 1.3,
- padding: '2px 6px',
- position: 'absolute',
- zIndex: 10,
- }}
- >
- lobehub.com
- </div>
- <Image
- fill
- alt={'og'}
- src={ogImage}
- style={{ objectFit: 'cover' }}
- unoptimized={true}
- />
- </Flexbox>
- ),
- label: 'Og Image',
- minWidth: undefined,
- },
- {
- children: <Input value={ogImage} variant={'filled'} />,
- label: 'Og Image Url',
- },
- ]}
- />
- );
-});
-
-export default MetaData;
diff --git a/src/features/DevPanel/MetadataViewer/index.tsx b/src/features/DevPanel/MetadataViewer/index.tsx
deleted file mode 100644
index 7b8a2c460fd..00000000000
--- a/src/features/DevPanel/MetadataViewer/index.tsx
+++ /dev/null
@@ -1,80 +0,0 @@
-'use client';
-
-import { Flexbox } from '@lobehub/ui';
-import { Tabs } from '@lobehub/ui/base-ui';
-import { createStaticStyles } from 'antd-style';
-import { memo, useState } from 'react';
-
-import Header from '../features/Header';
-import Ld from './Ld';
-import MetaData from './MetaData';
-import Og from './Og';
-
-const prefixCls = 'ant';
-
-const styles = createStaticStyles(({ css }) => ({
- container: css`
- * {
- font-size: 12px;
- }
- .${prefixCls}-form-item {
- padding-block: 8px;
- }
- `,
-}));
-
-enum Tab {
- Ld = 'ld',
- Meta = 'meta',
- Og = 'og',
-}
-
-const MetadataViewer = memo(() => {
- const [active, setActive] = useState<Tab>(Tab.Og);
- return (
- <Flexbox
- className={styles.container}
- height={'100%'}
- style={{ overflow: 'hidden', position: 'relative' }}
- width={'100%'}
- >
- <Header
- style={{ paddingInlineStart: 0 }}
- title={
- <Tabs
- activeKey={active}
- style={{ margin: 16 }}
- items={[
- {
- key: Tab.Og,
- label: 'OG',
- },
- {
- key: Tab.Meta,
- label: 'MetaData',
- },
- {
- key: Tab.Ld,
- label: 'StructuredData',
- },
- ]}
- onChange={(v) => setActive(v as Tab)}
- />
- }
- />
- <Flexbox
- flex={1}
- height={'100%'}
- paddingInline={16}
- style={{ overflow: 'auto', paddingBottom: 16, position: 'relative' }}
- width={'100%'}
- >
- {active === Tab.Og && <Og />}
- {active === Tab.Meta && <MetaData />}
- {active === Tab.Ld && <Ld />}
- </Flexbox>
- </Flexbox>
- );
-});
-
-export default MetadataViewer;
diff --git a/src/features/DevPanel/MetadataViewer/useHead.ts b/src/features/DevPanel/MetadataViewer/useHead.ts
deleted file mode 100644
index 9e34e923862..00000000000
--- a/src/features/DevPanel/MetadataViewer/useHead.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { isOnServerSide } from '@/utils/env';
-
-export const useHead = (prop: string, name: string) => {
- if (isOnServerSide) return '';
- return document.querySelector(`meta[${prop}='${name}']`)?.getAttribute('content') || '';
-};
-
-export const useTitle = () => {
- if (isOnServerSide) return '';
- return document.querySelector(`title`)?.innerHTML || '';
-};
-
-export const useLd = () => {
- if (isOnServerSide) return '';
- return document.querySelector(`script[type='application/ld+json']`)?.innerHTML || '';
-};
diff --git a/src/features/DevPanel/SystemInspector/AiProviderRuntimeConfig.tsx b/src/features/DevPanel/SystemInspector/AiProviderRuntimeConfig.tsx
deleted file mode 100644
index fb4d8aa44c3..00000000000
--- a/src/features/DevPanel/SystemInspector/AiProviderRuntimeConfig.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import { useAiInfraStore } from '@/store/aiInfra';
-
-import JsonViewer from './JsonViewer';
-
-const AiProviderRuntimeConfig = () => {
- const aiProviderRuntimeConfig = useAiInfraStore((s) => s.aiProviderRuntimeConfig);
-
- return <JsonViewer data={aiProviderRuntimeConfig} />;
-};
-
-export default AiProviderRuntimeConfig;
diff --git a/src/features/DevPanel/SystemInspector/JsonViewer.tsx b/src/features/DevPanel/SystemInspector/JsonViewer.tsx
deleted file mode 100644
index ab3591fb6e0..00000000000
--- a/src/features/DevPanel/SystemInspector/JsonViewer.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-import { Flexbox, Highlighter } from '@lobehub/ui';
-import { memo } from 'react';
-
-interface JsonViewerProps {
- data: object;
-}
-
-const JsonViewer = memo<JsonViewerProps>(({ data }) => {
- return (
- <Flexbox style={{ overflow: 'scroll' }}>
- <Highlighter language={'json'} style={{ overflow: 'scroll', whiteSpace: 'pre' }}>
- {JSON.stringify(data, null, 2)}
- </Highlighter>
- </Flexbox>
- );
-});
-
-export default JsonViewer;
diff --git a/src/features/DevPanel/SystemInspector/ServerConfig.tsx b/src/features/DevPanel/SystemInspector/ServerConfig.tsx
deleted file mode 100644
index 6a52889b461..00000000000
--- a/src/features/DevPanel/SystemInspector/ServerConfig.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import { useServerConfigStore } from '@/store/serverConfig';
-
-import JsonViewer from './JsonViewer';
-
-export const ServerConfig = () => {
- const serverConfig = useServerConfigStore((s) => s.serverConfig);
-
- return <JsonViewer data={serverConfig} />;
-};
-
-export const SystemAgent = () => {
- const serverConfig = useServerConfigStore((s) => s.serverConfig);
-
- return <JsonViewer data={serverConfig.systemAgent || {}} />;
-};
-
-export const DefaultAgentConfig = () => {
- const serverConfig = useServerConfigStore((s) => s.serverConfig);
-
- return <JsonViewer data={serverConfig.defaultAgent || {}} />;
-};
-
-export const AIProvider = () => {
- const serverConfig = useServerConfigStore((s) => s.serverConfig);
-
- return <JsonViewer data={serverConfig.aiProvider || {}} />;
-};
diff --git a/src/features/DevPanel/SystemInspector/index.tsx b/src/features/DevPanel/SystemInspector/index.tsx
deleted file mode 100644
index 896ece1da7f..00000000000
--- a/src/features/DevPanel/SystemInspector/index.tsx
+++ /dev/null
@@ -1,60 +0,0 @@
-'use client';
-
-import { Flexbox } from '@lobehub/ui';
-import { Tabs } from '@lobehub/ui/base-ui';
-import { useState } from 'react';
-
-import AiProviderRuntimeConfig from './AiProviderRuntimeConfig';
-import { AIProvider, DefaultAgentConfig, ServerConfig, SystemAgent } from './ServerConfig';
-
-enum TabKey {
- AIProvider = 'aiProvider',
- AiProviderRuntimeConfig = 'aiProviderRuntimeConfig',
- DefaultAgentConfig = 'defaultAgentConfig',
- ServerConfig = 'serverConfig',
- SystemAgent = 'systemAgent',
-}
-
-const SystemInspector = () => {
- const [activeTab, setActiveTab] = useState<TabKey>(TabKey.ServerConfig);
-
- return (
- <Flexbox gap={4} height={'100%'}>
- <Tabs
- activeKey={activeTab}
- items={[
- {
- key: TabKey.AiProviderRuntimeConfig,
- label: 'Ai Provider Runtime Config',
- },
- {
- key: TabKey.AIProvider,
- label: 'AI Provider Config',
- },
-
- {
- key: TabKey.DefaultAgentConfig,
- label: 'Default Agent Config',
- },
- {
- key: TabKey.SystemAgent,
- label: 'System Agent',
- },
- {
- key: TabKey.ServerConfig,
- label: 'Server Config',
- },
- ]}
- onChange={(activeTab) => setActiveTab(activeTab as TabKey)}
- />
-
- {activeTab === TabKey.AiProviderRuntimeConfig && <AiProviderRuntimeConfig />}
- {activeTab === TabKey.DefaultAgentConfig && <DefaultAgentConfig />}
- {activeTab === TabKey.SystemAgent && <SystemAgent />}
- {activeTab === TabKey.AIProvider && <AIProvider />}
- {activeTab === TabKey.ServerConfig && <ServerConfig />}
- </Flexbox>
- );
-};
-
-export default SystemInspector;
diff --git a/src/features/DevPanel/features/FloatPanel.tsx b/src/features/DevPanel/features/FloatPanel.tsx
deleted file mode 100644
index 1ae54a1fdf0..00000000000
--- a/src/features/DevPanel/features/FloatPanel.tsx
+++ /dev/null
@@ -1,215 +0,0 @@
-'use client';
-
-import { BRANDING_NAME } from '@lobechat/business-const';
-import { ActionIcon, Flexbox, FluentEmoji, SideNav } from '@lobehub/ui';
-import { createStaticStyles, cssVar, cx } from 'antd-style';
-import { XIcon } from 'lucide-react';
-import { memo, type ReactNode, useEffect, useState } from 'react';
-import { Rnd } from 'react-rnd';
-
-import { isDesktop } from '@/const/version';
-import { usePathname } from '@/libs/next/navigation';
-
-// Define styles
-const styles = createStaticStyles(({ css }) => {
- return {
- collapsed: css`
- pointer-events: none;
- transform: scale(0.8);
- opacity: 0;
- `,
- expanded: css`
- pointer-events: auto;
- transform: scale(1);
- opacity: 1;
- `,
- debugButton: css`
- cursor: default;
- user-select: none;
-
- position: fixed;
- inset-block-end: 9px;
- inset-inline-end: 9px;
-
- padding-block: 1px;
- padding-inline: 8px;
- border-radius: 12px;
-
- font-size: 8px;
- color: ${cssVar.colorBgContainer};
-
- background-color: ${cssVar.colorText};
- `,
- header: css`
- cursor: move;
- user-select: none;
-
- padding-block: 8px;
- padding-inline: 16px;
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
-
- color: ${cssVar.colorText};
-
- background: ${cssVar.colorFillAlter};
- `,
- panel: css`
- position: fixed;
- z-index: 1000;
-
- overflow: hidden;
- display: flex;
-
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: 12px;
-
- background: ${cssVar.colorBgContainer};
- box-shadow: ${cssVar.boxShadow};
-
- transition: opacity ${cssVar.motionDurationMid} ${cssVar.motionEaseInOut};
- `,
- };
-});
-
-const minWidth = 800;
-const minHeight = 600;
-
-interface CollapsibleFloatPanelProps {
- items: { children: ReactNode; icon: ReactNode; key: string }[];
-}
-
-const CollapsibleFloatPanel = memo<CollapsibleFloatPanelProps>(({ items }) => {
- const [tab, setTab] = useState<string>(items[0].key);
-
- const [isExpanded, setIsExpanded] = useState(false);
- const [position, setPosition] = useState({ x: 100, y: 100 });
- const [size, setSize] = useState({ height: minHeight, width: minWidth });
-
- const pathname = usePathname();
- useEffect(() => {
- try {
- const localStoragePosition = localStorage.getItem('debug-panel-position');
- if (localStoragePosition && JSON.parse(localStoragePosition)) {
- setPosition(JSON.parse(localStoragePosition));
- }
- } catch {
- /* empty */
- }
-
- try {
- const localStorageSize = localStorage.getItem('debug-panel-size');
- if (localStorageSize && JSON.parse(localStorageSize)) {
- setSize(JSON.parse(localStorageSize));
- }
- } catch {
- /* empty */
- }
- }, []);
-
- return (
- <>
- {
- // Hide under desktop devtools
- pathname !== '/desktop/devtools' && isDesktop && (
- <div
- className={styles.debugButton}
- onClick={async () => {
- if (isDesktop) {
- const { electronDevtoolsService } = await import('@/services/electron/devtools');
-
- await electronDevtoolsService.openDevtools();
-
- return;
- }
- setIsExpanded(!isExpanded);
- }}
- >
- DEV
- </div>
- )
- }
- {isExpanded && (
- <Rnd
- bounds="window"
- className={cx(styles.panel, isExpanded ? styles.expanded : styles.collapsed)}
- dragHandleClassName="panel-drag-handle"
- minHeight={minHeight}
- minWidth={minWidth}
- position={position}
- size={size}
- onDragStop={(e, d) => {
- setPosition({ x: d.x, y: d.y });
- }}
- onResizeStop={(e, direction, ref, delta, position) => {
- setSize({
- height: Number(ref.style.height),
- width: Number(ref.style.width),
- });
- setPosition(position);
- }}
- >
- <Flexbox
- horizontal
- height={'100%'}
- style={{ overflow: 'hidden', position: 'relative' }}
- width={'100%'}
- >
- <SideNav
- avatar={<FluentEmoji emoji={'🧰'} size={24} />}
- bottomActions={[]}
- style={{
- paddingBlock: 12,
- width: 48,
- }}
- topActions={items.map((item) => (
- <ActionIcon
- active={tab === item.key}
- icon={item.icon}
- key={item.key}
- title={item.key}
- tooltipProps={{
- placement: 'right',
- }}
- onClick={() => setTab(item.key)}
- />
- ))}
- />
- <Flexbox
- height={'100%'}
- style={{ overflow: 'hidden', position: 'relative' }}
- width={'100%'}
- >
- <Flexbox
- horizontal
- align={'center'}
- className={cx('panel-drag-handle', styles.header)}
- justify={'space-between'}
- >
- <Flexbox horizontal align={'baseline'} gap={6}>
- <b>{BRANDING_NAME} Dev Tools</b>
- <span style={{ color: cssVar.colorTextDescription }}>/</span>
- <span style={{ color: cssVar.colorTextDescription }}>{tab}</span>
- </Flexbox>
- <ActionIcon icon={XIcon} onClick={() => setIsExpanded(false)} />
- </Flexbox>
- {items.map((item) => (
- <Flexbox
- flex={1}
- height={'100%'}
- key={item.key}
- style={{
- display: tab === item.key ? 'flex' : 'none',
- overflow: 'hidden',
- }}
- >
- {item.children}
- </Flexbox>
- ))}
- </Flexbox>
- </Flexbox>
- </Rnd>
- )}
- </>
- );
-});
-
-export default CollapsibleFloatPanel;
diff --git a/src/features/DevPanel/features/Header.tsx b/src/features/DevPanel/features/Header.tsx
deleted file mode 100644
index 71eb5275857..00000000000
--- a/src/features/DevPanel/features/Header.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import { type ActionIconProps, type FlexboxProps } from '@lobehub/ui';
-import { ActionIcon, Flexbox } from '@lobehub/ui';
-import { createStaticStyles } from 'antd-style';
-import { type ReactNode } from 'react';
-import React from 'react';
-
-const styles = createStaticStyles(({ css, cssVar }) => ({
- header: css`
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
- `,
- title: css`
- font-weight: 550;
- `,
-}));
-
-interface HeaderProps extends Omit<FlexboxProps, 'title' | 'children'> {
- actions?: ActionIconProps[];
- extra?: ReactNode;
- title?: ReactNode;
-}
-
-const Header = ({ title, actions = [], extra, ...rest }: HeaderProps) => {
- return (
- <Flexbox
- horizontal
- align={'center'}
- className={styles.header}
- flex={'none'}
- height={46}
- justify={'space-between'}
- paddingInline={16}
- {...rest}
- >
- <div className={styles.title}>{title}</div>
- <Flexbox horizontal align={'center'} gap={4}>
- {extra}
- {actions.map((action, index) => (
- <ActionIcon {...action} key={index} size={{ blockSize: 28, size: 16 }} />
- ))}
- </Flexbox>
- </Flexbox>
- );
-};
-
-export default Header;
diff --git a/src/features/DevPanel/features/Table/TableCell.tsx b/src/features/DevPanel/features/Table/TableCell.tsx
deleted file mode 100644
index 8f89c5dccfa..00000000000
--- a/src/features/DevPanel/features/Table/TableCell.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import dayjs from 'dayjs';
-import { get, isDate } from 'es-toolkit/compat';
-import React, { useMemo } from 'react';
-
-interface TableCellProps {
- column: string;
- dataItem: any;
- rowIndex: number;
-}
-
-const TableCell = ({ dataItem, column }: TableCellProps) => {
- const data = get(dataItem, column);
- const content = useMemo(() => {
- if (isDate(data)) return dayjs(data).format('YYYY-MM-DD HH:mm:ss');
-
- switch (typeof data) {
- case 'object': {
- return JSON.stringify(data);
- }
-
- case 'boolean': {
- return data ? 'True' : 'False';
- }
-
- default: {
- return data;
- }
- }
- }, [data]);
-
- return (
- <td key={column}>
- {/* Cannot use antd's Text component — it causes excessive re-renders that make scrolling extremely sluggish */}
- {content}
- </td>
- );
-};
-
-export default TableCell;
diff --git a/src/features/DevPanel/features/Table/index.tsx b/src/features/DevPanel/features/Table/index.tsx
deleted file mode 100644
index b15e750c67c..00000000000
--- a/src/features/DevPanel/features/Table/index.tsx
+++ /dev/null
@@ -1,143 +0,0 @@
-import { Center, Icon } from '@lobehub/ui';
-import { createStaticStyles } from 'antd-style';
-import { Loader2Icon } from 'lucide-react';
-import React from 'react';
-import { TableVirtuoso } from 'react-virtuoso';
-
-import TableCell from './TableCell';
-
-const styles = createStaticStyles(({ css, cssVar }) => ({
- columnList: css`
- margin-inline-start: 32px;
- font-size: ${cssVar.fontSizeSM};
- color: ${cssVar.colorTextSecondary};
-
- > div {
- padding-block: ${cssVar.paddingXS};
- padding-inline: 0;
- }
- `,
- table: css`
- overflow: scroll hidden;
- flex: 1;
-
- table {
- border-collapse: collapse;
- width: 100%;
- margin-inline-end: 12px;
- font-family: ${cssVar.fontFamilyCode};
- }
-
- thead {
- tr {
- outline: 1px solid ${cssVar.colorBorderSecondary};
- }
- }
-
- th,
- td {
- overflow: hidden;
-
- max-width: 200px;
- padding-block: 8px;
- padding-inline: 12px;
- border-inline-end: 1px solid ${cssVar.colorBorderSecondary};
-
- font-size: 12px;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-
- th {
- position: sticky;
- z-index: 1;
- inset-block-start: 0;
-
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
-
- font-weight: ${cssVar.fontWeightStrong};
- text-align: start;
- text-wrap: nowrap;
-
- background: ${cssVar.colorBgElevated};
- }
-
- td {
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
- text-wrap: nowrap;
- }
-
- tbody {
- tr:hover {
- background: ${cssVar.colorFillTertiary};
- }
- }
- `,
- tableItem: css`
- cursor: pointer;
-
- display: flex;
- gap: ${cssVar.padding};
- align-items: center;
-
- padding: 12px;
- border-radius: ${cssVar.borderRadius};
-
- color: ${cssVar.colorText};
- `,
-}));
-
-interface TableProps {
- columns: string[];
- dataSource: any[];
- loading?: boolean;
-}
-
-const Table = ({ columns, dataSource, loading }: TableProps) => {
- if (loading)
- return (
- <Center height={'100%'}>
- <Icon spin icon={Loader2Icon} />
- </Center>
- );
-
- const header = (
- <tr>
- {columns.map((column) => (
- <th key={column}>{column}</th>
- ))}
- </tr>
- );
-
- return (
- <div className={styles.table}>
- {dataSource.length === 0 ? (
- <>
- <table>
- <thead>{header}</thead>
- </table>
- <Center height={400}>no rows</Center>
- </>
- ) : (
- <TableVirtuoso
- data={dataSource}
- fixedHeaderContent={() => header}
- itemContent={(index, row) => (
- <>
- {columns.map((column) => (
- <TableCell
- column={column}
- dataItem={row}
- key={`${column}_${index}`}
- rowIndex={index}
- />
- ))}
- </>
- )}
- />
- )}
- </div>
- );
-};
-
-export default Table;
diff --git a/src/features/Electron/connection/Option.tsx b/src/features/Electron/connection/Option.tsx
deleted file mode 100644
index 09c4c35484c..00000000000
--- a/src/features/Electron/connection/Option.tsx
+++ /dev/null
@@ -1,100 +0,0 @@
-import { CheckCircleFilled } from '@ant-design/icons';
-import { type StorageModeEnum } from '@lobechat/electron-client-ipc';
-import { Center, Flexbox } from '@lobehub/ui';
-import { createStaticStyles, cx } from 'antd-style';
-import { type ComponentType, type ReactNode } from 'react';
-
-const styles = createStaticStyles(({ css, cssVar }) => ({
- checked: css`
- position: relative;
- border: 1px solid ${cssVar.colorPrimary};
- `,
- description: css`
- margin-block-start: 4px; /* Adjust spacing */
- font-size: 13px; /* Slightly larger description */
- color: ${cssVar.colorTextSecondary};
- `,
- iconWrapper: css`
- margin-block-start: 2px;
- padding: 0;
- color: ${cssVar.colorTextSecondary};
-
- svg {
- display: block;
- font-size: 24px; /* Increased icon size */
- stroke-width: 2; /* Ensure lucide icons look bolder */
- }
- `,
- label: css`
- font-size: 16px;
- font-weight: 600; /* Bolder label */
- color: ${cssVar.colorText};
- `,
- optionCard: css`
- cursor: pointer;
-
- width: 100%;
- padding: 16px;
- border: 1px solid ${cssVar.colorBorderSecondary}; /* Use secondary border */
- border-radius: ${cssVar.borderRadiusLG};
-
- color: ${cssVar.colorText};
-
- background-color: ${cssVar.colorBgContainer};
-
- transition: all 0.2s ${cssVar.motionEaseInOut};
-
- :hover {
- border-color: ${cssVar.colorPrimary};
- }
- `,
- optionInner: css`
- display: flex;
- gap: 16px;
- align-items: flex-start;
- justify-content: space-between;
- `,
-}));
-
-export interface OptionProps {
- children?: ReactNode;
- description: string;
- icon: ComponentType<any>;
- isSelected: boolean;
- label: string;
- onClick: (value: StorageModeEnum) => void;
- value: StorageModeEnum; // For self-hosted input
-}
-
-export const Option = ({
- description,
- icon: PrefixIcon,
- label,
- value,
- isSelected,
- onClick,
- children,
-}: OptionProps) => {
- return (
- <Flexbox
- className={cx(styles.optionCard, isSelected && styles.checked)}
- direction="vertical"
- key={value}
- onClick={() => onClick(value)}
- >
- <div className={styles.optionInner}>
- <Flexbox horizontal gap={16}>
- <Center className={styles.iconWrapper}>
- <PrefixIcon />
- </Center>
- <Flexbox gap={8}>
- <div className={styles.label}>{label}</div>
- <div className={styles.description}>{description}</div>
- </Flexbox>
- </Flexbox>
- {isSelected && <CheckCircleFilled style={{ fontSize: 16 }} />}
- </div>
- {children}
- </Flexbox>
- );
-};
diff --git a/src/features/Electron/connection/WaitingAnim.tsx b/src/features/Electron/connection/WaitingAnim.tsx
deleted file mode 100644
index e8162a75dab..00000000000
--- a/src/features/Electron/connection/WaitingAnim.tsx
+++ /dev/null
@@ -1,124 +0,0 @@
-'use client';
-
-import { Icon } from '@lobehub/ui';
-import { createStaticStyles, cx, keyframes } from 'antd-style';
-import { WifiIcon } from 'lucide-react';
-import { memo } from 'react';
-
-const airdropPulse = keyframes`
- 0% {
- transform: translate(-50%, -50%) scale(0.8);
- opacity: 0.5;
- }
- 100% {
- transform: translate(-50%, -50%) scale(2.5);
- opacity: 0;
- }
-`;
-
-const styles = createStaticStyles(({ css, cssVar }) => ({
- container: css`
- position: relative;
-
- display: flex;
- align-items: center;
- justify-content: center;
-
- width: 160px;
- height: 160px;
- margin-block-end: ${cssVar.marginXL};
- `,
-
- pulse1: css`
- animation: ${airdropPulse} 3s ease-out infinite;
-
- @media (prefers-reduced-motion: reduce) {
- animation: none;
- }
- `,
-
- pulse2: css`
- animation: ${airdropPulse} 3s ease-out 1.2s infinite;
-
- @media (prefers-reduced-motion: reduce) {
- animation: none;
- }
- `,
-
- pulse3: css`
- animation: ${airdropPulse} 3s ease-out 1.8s infinite;
-
- @media (prefers-reduced-motion: reduce) {
- animation: none;
- }
- `,
- pulseBase: css`
- pointer-events: none;
- content: '';
-
- position: absolute;
- inset-block-start: 50%;
- inset-inline-start: 50%;
- transform: translate(-50%, -50%);
-
- width: 100px;
- height: 100px;
- border-radius: 50%;
-
- opacity: 0;
- background-color: ${cssVar.colorPrimaryBgHover};
- `,
-
- radarIcon: css`
- z-index: 1;
- color: ${cssVar.colorPrimary};
- `,
-
- ring1: css`
- width: 80px;
- height: 80px;
- border: 1px solid ${cssVar.colorText};
- `,
-
- ring2: css`
- width: 120px;
- height: 120px;
- border: 1px solid ${cssVar.colorTextQuaternary};
- `,
-
- ring3: css`
- width: 160px;
- height: 160px;
- border: 1px solid ${cssVar.colorFillSecondary};
- `,
-
- ringBase: css`
- pointer-events: none;
-
- position: absolute;
- inset-block-start: 50%;
- inset-inline-start: 50%;
- transform: translate(-50%, -50%);
-
- border-radius: 50%;
- `,
-}));
-
-const WaitingAnim = memo(() => {
- return (
- <div className={styles.container}>
- {/* Added: star rings */}
- <div className={cx(styles.ringBase, styles.ring1)} />
- <div className={cx(styles.ringBase, styles.ring2)} />
- <div className={cx(styles.ringBase, styles.ring3)} />
- {/* Pulses */}
- <div className={cx(styles.pulseBase, styles.pulse1)} />
- <div className={cx(styles.pulseBase, styles.pulse2)} />
- <div className={cx(styles.pulseBase, styles.pulse3)} />
-
- <Icon className={styles.radarIcon} icon={WifiIcon} size={40} />
- </div>
- );
-});
-
-export default WaitingAnim;
diff --git a/src/features/GroupInfo/index.tsx b/src/features/GroupInfo/index.tsx
deleted file mode 100644
index 7b02496d632..00000000000
--- a/src/features/GroupInfo/index.tsx
+++ /dev/null
@@ -1,59 +0,0 @@
-import { Avatar, Center, Tag } from '@lobehub/ui';
-import { createStaticStyles, cssVar } from 'antd-style';
-import { startCase } from 'es-toolkit/compat';
-import { type CSSProperties } from 'react';
-import { memo } from 'react';
-
-import { type MetaData } from '@/types/meta';
-
-const styles = createStaticStyles(({ css }) => ({
- avatar: css`
- flex: none;
- `,
- desc: css`
- color: ${cssVar.colorTextDescription};
- text-align: center;
- `,
- title: css`
- font-size: 20px;
- font-weight: 600;
- text-align: center;
- `,
-}));
-
-export interface GroupInfoProps {
- meta?: MetaData;
- onAvatarClick?: () => void;
- style?: CSSProperties;
-}
-
-const GroupInfo = memo<GroupInfoProps>(({ style, meta, onAvatarClick }) => {
- if (!meta) return;
-
- return (
- <Center gap={16} style={style}>
- <Avatar
- animation
- avatar="👥"
- background={cssVar.colorFillTertiary}
- className={styles.avatar}
- shape={'square'}
- size={100}
- onClick={onAvatarClick}
- />
- {meta.title && <div className={styles.title}>{meta.title}</div>}
- {(meta?.tags as string[])?.length > 0 && (
- <Center horizontal gap={6} style={{ flexWrap: 'wrap' }}>
- {(meta.tags as string[]).map((tag: string, index) => (
- <Tag key={index} style={{ margin: 0 }}>
- {startCase(tag).trim()}
- </Tag>
- ))}
- </Center>
- )}
- {meta.description && <div className={styles.desc}>{meta.description}</div>}
- </Center>
- );
-});
-
-export default GroupInfo;
diff --git a/src/features/MobileSwitchLoading/index.tsx b/src/features/MobileSwitchLoading/index.tsx
deleted file mode 100644
index dd34f3296b1..00000000000
--- a/src/features/MobileSwitchLoading/index.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import { Center, Flexbox, Icon } from '@lobehub/ui';
-import { Loader2 } from 'lucide-react';
-import { type DynamicOptions } from 'next/dist/shared/lib/dynamic';
-import { memo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { ProductLogo } from '@/components/Branding';
-
-const MobileSwitchLoading: DynamicOptions['loading'] = memo(() => {
- const { t } = useTranslation('common');
- return (
- <Flexbox height={'100%'} style={{ position: 'relative', userSelect: 'none' }} width={'100%'}>
- <Center flex={1} gap={16} width={'100%'}>
- <ProductLogo size={48} type={'combine'} />
- <Center horizontal gap={12} style={{ fontSize: 15, lineHeight: 1.5, opacity: 0.66 }}>
- <Icon spin icon={Loader2} size={16} />
- {t('layoutInitializing')}
- </Center>
- </Center>
- </Flexbox>
- );
-});
-
-export default MobileSwitchLoading;
diff --git a/src/features/ModelParamsControl/FrequencyPenalty.tsx b/src/features/ModelParamsControl/FrequencyPenalty.tsx
deleted file mode 100644
index 68a5866b2e8..00000000000
--- a/src/features/ModelParamsControl/FrequencyPenalty.tsx
+++ /dev/null
@@ -1,48 +0,0 @@
-import { Flexbox, Icon, SliderWithInput } from '@lobehub/ui';
-import { cssVar } from 'antd-style';
-import { BookOpenText, FileIcon } from 'lucide-react';
-import { memo } from 'react';
-
-interface FrequencyPenaltyProps {
- disabled?: boolean;
- onChange?: (value: number) => void;
- value?: number;
-}
-
-const FrequencyPenalty = memo<FrequencyPenaltyProps>(({ value, onChange, disabled }) => {
- return (
- <Flexbox style={{ width: '100%' }}>
- <SliderWithInput
- changeOnWheel
- controls={false}
- disabled={disabled}
- max={2}
- min={-2}
- size={'small'}
- step={0.1}
- style={{ height: 42 }}
- value={value}
- marks={{
- '-2': (
- <Icon icon={FileIcon} size={'small'} style={{ color: cssVar.colorTextQuaternary }} />
- ),
- 0: <div />,
- 2: (
- <Icon
- icon={BookOpenText}
- size={'small'}
- style={{ color: cssVar.colorTextQuaternary }}
- />
- ),
- }}
- styles={{
- input: {
- maxWidth: 43,
- },
- }}
- onChange={onChange}
- />
- </Flexbox>
- );
-});
-export default FrequencyPenalty;
diff --git a/src/features/ModelParamsControl/PresencePenalty.tsx b/src/features/ModelParamsControl/PresencePenalty.tsx
deleted file mode 100644
index fb089f8bf08..00000000000
--- a/src/features/ModelParamsControl/PresencePenalty.tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-import { Flexbox, Icon, SliderWithInput } from '@lobehub/ui';
-import { cssVar } from 'antd-style';
-import { AtomIcon, RepeatIcon } from 'lucide-react';
-import { memo } from 'react';
-
-interface PresencePenaltyProps {
- disabled?: boolean;
- onChange?: (value: number) => void;
- value?: number;
-}
-
-const PresencePenalty = memo<PresencePenaltyProps>(({ value, onChange, disabled }) => {
- return (
- <Flexbox style={{ width: '100%' }}>
- <SliderWithInput
- changeOnWheel
- controls={false}
- disabled={disabled}
- max={2}
- min={-2}
- size={'small'}
- step={0.1}
- style={{ height: 42 }}
- value={value}
- marks={{
- '-2': (
- <Icon icon={RepeatIcon} size={'small'} style={{ color: cssVar.colorTextQuaternary }} />
- ),
- 0: <div />,
- 2: <Icon icon={AtomIcon} size={'small'} style={{ color: cssVar.colorTextQuaternary }} />,
- }}
- styles={{
- input: {
- maxWidth: 43,
- },
- }}
- onChange={onChange}
- />
- </Flexbox>
- );
-});
-export default PresencePenalty;
diff --git a/src/features/ModelParamsControl/Temperature.tsx b/src/features/ModelParamsControl/Temperature.tsx
deleted file mode 100644
index adb64f79af7..00000000000
--- a/src/features/ModelParamsControl/Temperature.tsx
+++ /dev/null
@@ -1,77 +0,0 @@
-import { Alert, Flexbox, Icon, SliderWithInput } from '@lobehub/ui';
-import { css, cssVar, cx } from 'antd-style';
-import { Sparkle, Sparkles } from 'lucide-react';
-import { memo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { useAgentStore } from '@/store/agent';
-import { agentSelectors } from '@/store/agent/selectors';
-
-const alertCls = css`
- .ant-alert-message {
- font-size: 12px;
- line-height: 18px !important;
- }
-
- .ant-alert-icon {
- height: 18px !important;
- }
-`;
-
-const Warning = memo(() => {
- const { t } = useTranslation('setting');
- const [temperature] = useAgentStore((s) => {
- const config = agentSelectors.currentAgentConfig(s);
- return [config.params?.temperature];
- });
-
- return (
- typeof temperature === 'number' &&
- temperature >= 1.5 && (
- <Alert
- classNames={{ alert: cx(alertCls) }}
- style={{ fontSize: 12 }}
- title={t('settingModel.temperature.warning')}
- type={'warning'}
- variant={'borderless'}
- />
- )
- );
-});
-
-interface TemperatureProps {
- disabled?: boolean;
- onChange?: (value: number) => void;
- value?: number;
-}
-
-const Temperature = memo<TemperatureProps>(({ value, onChange, disabled }) => {
- return (
- <Flexbox gap={4} style={{ width: '100%' }}>
- <SliderWithInput
- changeOnWheel
- controls={false}
- disabled={disabled}
- max={2}
- size={'small'}
- step={0.1}
- style={{ height: 42 }}
- value={value}
- marks={{
- 0: <Icon icon={Sparkle} size={'small'} style={{ color: cssVar.colorTextQuaternary }} />,
- 1: <div />,
- 2: <Icon icon={Sparkles} size={'small'} style={{ color: cssVar.colorTextQuaternary }} />,
- }}
- styles={{
- input: {
- maxWidth: 43,
- },
- }}
- onChange={onChange}
- />
- {!disabled && <Warning />}
- </Flexbox>
- );
-});
-
-export default Temperature;
diff --git a/src/features/ModelParamsControl/TopP.tsx b/src/features/ModelParamsControl/TopP.tsx
deleted file mode 100644
index e634a8e623c..00000000000
--- a/src/features/ModelParamsControl/TopP.tsx
+++ /dev/null
@@ -1,48 +0,0 @@
-import { Flexbox, Icon, SliderWithInput } from '@lobehub/ui';
-import { cssVar } from 'antd-style';
-import { FlowerIcon, TrainFrontTunnel } from 'lucide-react';
-import { memo } from 'react';
-
-interface TopPProps {
- disabled?: boolean;
- onChange?: (value: number) => void;
- value?: number;
-}
-
-const TopP = memo<TopPProps>(({ value, onChange, disabled }) => {
- return (
- <Flexbox style={{ width: '100%' }}>
- <SliderWithInput
- changeOnWheel
- controls={false}
- disabled={disabled}
- max={1}
- min={0}
- size={'small'}
- step={0.1}
- style={{ height: 42 }}
- value={value}
- marks={{
- 0: (
- <Icon
- icon={TrainFrontTunnel}
- size={'small'}
- style={{ color: cssVar.colorTextQuaternary }}
- />
- ),
- 0.9: <div />,
- 1: (
- <Icon icon={FlowerIcon} size={'small'} style={{ color: cssVar.colorTextQuaternary }} />
- ),
- }}
- styles={{
- input: {
- maxWidth: 43,
- },
- }}
- onChange={onChange}
- />
- </Flexbox>
- );
-});
-export default TopP;
diff --git a/src/features/PWAInstall/Install.tsx b/src/features/PWAInstall/Install.tsx
deleted file mode 100644
index f853cc731f5..00000000000
--- a/src/features/PWAInstall/Install.tsx
+++ /dev/null
@@ -1,76 +0,0 @@
-'use client';
-
-import { BRANDING_NAME } from '@lobechat/business-const';
-import { memo, useEffect, useLayoutEffect } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { PWA_INSTALL_ID } from '@/const/layoutTokens';
-import { usePWAInstall } from '@/hooks/usePWAInstall';
-import dynamic from '@/libs/next/dynamic';
-import { useGlobalStore } from '@/store/global';
-import { systemStatusSelectors } from '@/store/global/selectors';
-import { useUserStore } from '@/store/user';
-
-// @ts-ignore
-const PWA: any = dynamic(() => import('@khmyznikov/pwa-install/dist/pwa-install.react.js'), {
- ssr: false,
-});
-
-const PWAInstall = memo(() => {
- const { t } = useTranslation('metadata');
-
- const { install, canInstall } = usePWAInstall();
-
- const isShowPWAGuide = useUserStore((s) => s.isShowPWAGuide);
- const [hidePWAInstaller, updateSystemStatus] = useGlobalStore((s) => [
- systemStatusSelectors.hidePWAInstaller(s),
- s.updateSystemStatus,
- ]);
-
- // we need to make the pwa installer hidden by default
- useLayoutEffect(() => {
- sessionStorage.setItem('pwa-hide-install', 'true');
- }, []);
-
- const pwaInstall =
- typeof window === 'undefined' ? undefined : document.getElementById(PWA_INSTALL_ID);
-
- // add an event listener to control the user close installer action
- useEffect(() => {
- if (!pwaInstall) return;
-
- const handler = (e: Event) => {
- const event = e as CustomEvent;
-
- // it means user hide installer
- if (event.detail.message === 'dismissed') {
- updateSystemStatus({ hidePWAInstaller: true });
- }
- };
-
- pwaInstall.addEventListener('pwa-user-choice-result-event', handler);
- return () => {
- pwaInstall.removeEventListener('pwa-user-choice-result-event', handler);
- };
- }, [pwaInstall]);
-
- // trigger the PWA guide on demand
- useEffect(() => {
- if (!canInstall || hidePWAInstaller) return;
-
- // trigger the pwa installer and register the service worker
- if (isShowPWAGuide) {
- install();
- }
- }, [canInstall, hidePWAInstaller, isShowPWAGuide]);
-
- return (
- <PWA
- description={t('chat.description', { appName: BRANDING_NAME })}
- id={PWA_INSTALL_ID}
- manifest-url={'/manifest.webmanifest'}
- />
- );
-});
-
-export default PWAInstall;
diff --git a/src/features/PageEditor/Copilot/AgentSelector/useDropdownMenu.tsx b/src/features/PageEditor/Copilot/AgentSelector/useDropdownMenu.tsx
deleted file mode 100644
index d18236fb4f6..00000000000
--- a/src/features/PageEditor/Copilot/AgentSelector/useDropdownMenu.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-import { type MenuProps } from '@lobehub/ui';
-import { Icon } from '@lobehub/ui';
-import { confirmModal } from '@lobehub/ui/base-ui';
-import { Trash2 } from 'lucide-react';
-import { useMemo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { usePermission } from '@/hooks/usePermission';
-import { useHomeStore } from '@/store/home';
-
-interface UseDropdownMenuProps {
- agentId: string;
- agentTitle: string;
- isBuiltinAgent: boolean;
- onClose: () => void;
-}
-
-export const useDropdownMenu = ({
- agentId,
- isBuiltinAgent,
- onClose,
-}: UseDropdownMenuProps): MenuProps['items'] => {
- const { t } = useTranslation(['common', 'chat']);
- const removeAgent = useHomeStore((s) => s.removeAgent);
- const { allowed: canEdit } = usePermission('edit_own_content');
-
- const handleDelete = () => {
- if (!canEdit) return;
-
- confirmModal({
- cancelText: t('cancel'),
- content: t('confirmRemoveSessionItemAlert', { ns: 'chat' }),
- okButtonProps: { danger: true },
- okText: t('delete'),
- onOk: async () => {
- await removeAgent(agentId);
- onClose();
- },
- title: t('delete'),
- });
- };
-
- return useMemo(() => {
- if (isBuiltinAgent) return [];
-
- return [
- {
- danger: true,
- disabled: !canEdit,
- icon: <Icon icon={Trash2} />,
- key: 'delete',
- label: t('delete'),
- onClick: handleDelete,
- },
- ].filter(Boolean) as MenuProps['items'];
- }, [canEdit, t, isBuiltinAgent, handleDelete]);
-};
diff --git a/src/features/SkillStore/SkillList/AgentSkillItem.tsx b/src/features/SkillStore/SkillList/AgentSkillItem.tsx
deleted file mode 100644
index f3307584aba..00000000000
--- a/src/features/SkillStore/SkillList/AgentSkillItem.tsx
+++ /dev/null
@@ -1,169 +0,0 @@
-'use client';
-
-import { ActionIcon, Block, DropdownMenu, Flexbox, Icon, Tag } from '@lobehub/ui';
-import { confirmModal } from '@lobehub/ui/base-ui';
-import { SkillsIcon } from '@lobehub/ui/icons';
-import { createStaticStyles, cssVar } from 'antd-style';
-import { DownloadIcon, MoreVerticalIcon, PackageSearch, Trash2 } from 'lucide-react';
-import { lazy, memo, Suspense, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import ImperativeModal from '@/components/ImperativeModal';
-import SkillAvatar from '@/components/SkillAvatar';
-import { usePermission } from '@/hooks/usePermission';
-import { agentSkillService } from '@/services/skill';
-import { useToolStore } from '@/store/tool';
-import { type SkillListItem } from '@/types/index';
-import { downloadFile } from '@/utils/client/downloadFile';
-
-import { itemStyles } from './style';
-
-const AgentSkillDetail = lazy(() => import('@/features/AgentSkillDetail'));
-const AgentSkillEdit = lazy(() => import('@/features/AgentSkillEdit'));
-
-const styles = createStaticStyles(({ css }) => ({
- title: css`
- cursor: pointer;
-
- overflow: hidden;
-
- font-size: 14px;
- font-weight: 500;
- color: ${cssVar.colorText};
- text-overflow: ellipsis;
- white-space: nowrap;
-
- &:hover {
- color: ${cssVar.colorPrimary};
- }
- `,
-}));
-
-interface AgentSkillItemProps {
- skill: SkillListItem;
-}
-
-const AgentSkillItem = memo<AgentSkillItemProps>(({ skill }) => {
- const { t } = useTranslation('plugin');
- const { t: tc } = useTranslation('common');
- const [detailOpen, setDetailOpen] = useState(false);
- const [editOpen, setEditOpen] = useState(false);
- const [loading, setLoading] = useState(false);
- const { allowed: canEdit } = usePermission('edit_own_content');
- const deleteAgentSkill = useToolStore((s) => s.deleteAgentSkill);
-
- const handleDownload = async () => {
- if (!skill.zipFileHash) return;
-
- setLoading(true);
- try {
- const result = await agentSkillService.getZipUrl(skill.id);
- if (result.url) {
- await downloadFile(result.url, `${result.name || skill.name}.zip`);
- }
- } finally {
- setLoading(false);
- }
- };
-
- const handleDelete = () => {
- if (!canEdit) return;
- confirmModal({
- cancelText: tc('cancel'),
- content: t('store.actions.confirmUninstall'),
- okButtonProps: { danger: true },
- okText: t('store.actions.uninstall'),
- onOk: async () => {
- await deleteAgentSkill(skill.id);
- },
- title: t('store.actions.uninstall'),
- });
- };
-
- return (
- <>
- <Flexbox className={itemStyles.container} gap={0}>
- <Block
- horizontal
- align={'center'}
- gap={12}
- paddingBlock={12}
- paddingInline={12}
- variant={'outlined'}
- >
- <SkillAvatar size={40} />
- <Flexbox flex={1} gap={4} style={{ minWidth: 0, overflow: 'hidden' }}>
- <Flexbox horizontal align="center" gap={8}>
- <span className={styles.title} onClick={() => setDetailOpen(true)}>
- {skill.name}
- </span>
- <Tag icon={<Icon icon={SkillsIcon} />} size={'small'} />
- </Flexbox>
- {skill.description && (
- <span className={itemStyles.description}>{skill.description}</span>
- )}
- </Flexbox>
- <Flexbox horizontal>
- {skill.source === 'user' && (
- <ActionIcon
- disabled={!canEdit}
- icon={PackageSearch}
- title={t('store.actions.manifest')}
- onClick={() => setEditOpen(true)}
- />
- )}
- <DropdownMenu
- nativeButton={false}
- placement="bottomRight"
- items={[
- ...(skill.zipFileHash
- ? [
- {
- icon: <Icon icon={DownloadIcon} />,
- key: 'download',
- label: tc('download'),
- onClick: handleDownload,
- },
- { type: 'divider' as const },
- ]
- : []),
- {
- danger: true,
- disabled: !canEdit,
- icon: <Icon icon={Trash2} />,
- key: 'uninstall',
- label: t('store.actions.uninstall'),
- onClick: handleDelete,
- },
- ]}
- >
- <ActionIcon disabled={!canEdit} icon={MoreVerticalIcon} loading={loading} />
- </DropdownMenu>
- </Flexbox>
- </Block>
- </Flexbox>
- <ImperativeModal
- destroyOnHidden
- footer={null}
- open={detailOpen}
- styles={{ body: { height: 'calc(100dvh - 200px)', overflow: 'hidden', padding: 0 } }}
- title={t('dev.title.skillDetails')}
- width={960}
- onCancel={() => setDetailOpen(false)}
- >
- <Suspense fallback={<div style={{ height: '100%' }} />}>
- <AgentSkillDetail skillId={skill.id} />
- </Suspense>
- </ImperativeModal>
- {skill.source === 'user' && (
- <Suspense>
- <AgentSkillEdit open={editOpen} skillId={skill.id} onClose={() => setEditOpen(false)} />
- </Suspense>
- )}
- </>
- );
-});
-
-AgentSkillItem.displayName = 'AgentSkillStoreItem';
-
-export default AgentSkillItem;
diff --git a/src/features/SkillStore/SkillList/Custom/Item.tsx b/src/features/SkillStore/SkillList/Custom/Item.tsx
deleted file mode 100644
index cf4791bde74..00000000000
--- a/src/features/SkillStore/SkillList/Custom/Item.tsx
+++ /dev/null
@@ -1,159 +0,0 @@
-'use client';
-
-import { ActionIcon, Block, DropdownMenu, Flexbox, Icon } from '@lobehub/ui';
-import { confirmModal } from '@lobehub/ui/base-ui';
-import { createStaticStyles, cssVar } from 'antd-style';
-import { MoreVerticalIcon, PackageSearch, Trash2 } from 'lucide-react';
-import { memo, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import MCPTag from '@/components/Plugins/MCPTag';
-import PluginAvatar from '@/components/Plugins/PluginAvatar';
-import { createPluginDetailModal } from '@/features/PluginDetailModal';
-import DevModal from '@/features/PluginDevModal';
-import { usePermission } from '@/hooks/usePermission';
-import { useAgentStore } from '@/store/agent';
-import { agentSelectors } from '@/store/agent/selectors';
-import { useToolStore } from '@/store/tool';
-import { pluginSelectors } from '@/store/tool/selectors';
-
-import { itemStyles } from '../style';
-
-const styles = createStaticStyles(({ css }) => ({
- title: css`
- cursor: pointer;
-
- overflow: hidden;
-
- font-size: 14px;
- font-weight: 500;
- color: ${cssVar.colorText};
- text-overflow: ellipsis;
- white-space: nowrap;
-
- &:hover {
- color: ${cssVar.colorPrimary};
- }
- `,
-}));
-
-interface ItemProps {
- avatar?: string;
- description?: string;
- identifier: string;
- title?: string;
-}
-
-const Item = memo<ItemProps>(({ identifier, title, description, avatar }) => {
- const { t } = useTranslation('plugin');
- const [configOpen, setConfigOpen] = useState(false);
- const { allowed: canEdit } = usePermission('edit_own_content');
-
- const [customPlugin, uninstallPlugin, updateCustomPlugin, pluginManifest] = useToolStore((s) => [
- pluginSelectors.getCustomPluginById(identifier)(s),
- s.uninstallCustomPlugin,
- s.updateCustomPlugin,
- pluginSelectors.getToolManifestById(identifier)(s),
- ]);
-
- const [togglePlugin, isPluginEnabledInAgent] = useAgentStore((s) => [
- s.togglePlugin,
- agentSelectors.currentAgentPlugins(s).includes(identifier),
- ]);
-
- const handleDelete = () => {
- if (!canEdit) return;
- confirmModal({
- okButtonProps: { danger: true },
- onOk: async () => {
- if (isPluginEnabledInAgent) {
- await togglePlugin(identifier, false);
- }
- await uninstallPlugin(identifier);
- },
- title: t('store.actions.confirmUninstall'),
- });
- };
-
- return (
- <>
- <Flexbox className={itemStyles.container} gap={0}>
- <Block
- horizontal
- align={'center'}
- gap={12}
- paddingBlock={12}
- paddingInline={12}
- variant={'outlined'}
- >
- <PluginAvatar avatar={avatar} size={40} />
- <Flexbox flex={1} gap={4} style={{ minWidth: 0, overflow: 'hidden' }}>
- <Flexbox horizontal align="center" gap={8}>
- <span
- className={styles.title}
- onClick={() => {
- createPluginDetailModal({
- id: identifier,
- schema: pluginManifest?.settings,
- tab: 'info',
- });
- }}
- >
- {title || identifier}
- </span>
- <MCPTag showText={false} />
- </Flexbox>
- {description && <span className={itemStyles.description}>{description}</span>}
- </Flexbox>
- <Flexbox horizontal>
- <ActionIcon
- disabled={!canEdit}
- icon={PackageSearch}
- title={t('store.actions.manifest')}
- onClick={() => setConfigOpen(true)}
- />
- <DropdownMenu
- nativeButton={false}
- placement="bottomRight"
- items={[
- {
- danger: true,
- disabled: !canEdit,
- icon: <Icon icon={Trash2} />,
- key: 'uninstall',
- label: t('store.actions.uninstall'),
- onClick: handleDelete,
- },
- ]}
- >
- <ActionIcon disabled={!canEdit} icon={MoreVerticalIcon} />
- </DropdownMenu>
- </Flexbox>
- </Block>
- </Flexbox>
- {customPlugin && (
- <DevModal
- mode="edit"
- open={configOpen}
- value={customPlugin}
- onOpenChange={setConfigOpen}
- onDelete={async () => {
- if (!canEdit) return;
- if (isPluginEnabledInAgent) {
- await togglePlugin(identifier, false);
- }
- await uninstallPlugin(identifier);
- }}
- onSave={async (value) => {
- if (!canEdit) return;
- await updateCustomPlugin(identifier, value);
- }}
- />
- )}
- </>
- );
-});
-
-Item.displayName = 'CustomListItem';
-
-export default Item;
diff --git a/src/libs/next/navigation.ts b/src/libs/next/navigation.ts
deleted file mode 100644
index 0b516bba71c..00000000000
--- a/src/libs/next/navigation.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Navigation utilities — re-exports from next/navigation.
- * In Vite/SPA mode, this file is replaced by navigation.vite.ts via the
- * viteModuleRedirect plugin (see vite.config.ts).
- */
-
-export {
- notFound,
- type ReadonlyURLSearchParams,
- redirect,
- useParams,
- usePathname,
- useRouter,
- useSearchParams,
-} from 'next/navigation';
-
-export type RedirectType = 'push' | 'replace';
diff --git a/src/libs/next/navigation.vite.ts b/src/libs/next/navigation.vite.ts
deleted file mode 100644
index e6260434b03..00000000000
--- a/src/libs/next/navigation.vite.ts
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * Navigation utilities - SPA implementation via react-router-dom.
- *
- * Provides the same API surface as the previous Next.js navigation wrapper
- * so that existing consumer code does not need to change.
- */
-
-import { useLocation, useNavigate, useParams, useSearchParams } from 'react-router';
-
-// ---------------------------------------------------------------------------
-// useRouter — compat wrapper around useNavigate
-// ---------------------------------------------------------------------------
-export function useRouter() {
- const navigate = useNavigate();
- return {
- back: () => navigate(-1),
- forward: () => navigate(1),
- push: (href: string) => navigate(href),
- refresh: () => navigate(0),
- replace: (href: string) => navigate(href, { replace: true }),
- };
-}
-
-// ---------------------------------------------------------------------------
-// usePathname
-// ---------------------------------------------------------------------------
-export function usePathname(): string {
- return useLocation().pathname;
-}
-
-// ---------------------------------------------------------------------------
-// Re-exports that have the same shape in react-router-dom
-// ---------------------------------------------------------------------------
-export { useParams, useSearchParams };
-
-// ---------------------------------------------------------------------------
-// redirect — imperative navigation (works only inside components / loaders)
-// For non-component contexts, callers should throw a Response or use navigate.
-// ---------------------------------------------------------------------------
-export function redirect(url: string): never {
- throw new RedirectError(url);
-}
-
-class RedirectError extends Error {
- url: string;
- constructor(url: string) {
- super(`Redirect to ${url}`);
- this.url = url;
- }
-}
-
-// ---------------------------------------------------------------------------
-// notFound — throw to be caught by an ErrorBoundary
-// ---------------------------------------------------------------------------
-export function notFound(): never {
- throw new NotFoundError();
-}
-
-class NotFoundError extends Error {
- digest = 'NEXT_NOT_FOUND';
- constructor() {
- super('Not Found');
- }
-}
-
-// ---------------------------------------------------------------------------
-// Types kept for backward compat
-// ---------------------------------------------------------------------------
-export type RedirectType = 'push' | 'replace';
-export type ReadonlyURLSearchParams = URLSearchParams;
diff --git a/src/routes/(main)/(create)/image/features/ConfigPanel/components/MultiImagesUpload/ImageManageModal.tsx b/src/routes/(main)/(create)/image/features/ConfigPanel/components/MultiImagesUpload/ImageManageModal.tsx
deleted file mode 100644
index b5ae1730a95..00000000000
--- a/src/routes/(main)/(create)/image/features/ConfigPanel/components/MultiImagesUpload/ImageManageModal.tsx
+++ /dev/null
@@ -1,432 +0,0 @@
-'use client';
-
-import { Button } from '@lobehub/ui/base-ui';
-import { createStaticStyles, cx } from 'antd-style';
-import { Upload, X } from 'lucide-react';
-import { type FC } from 'react';
-import React, { memo, useEffect, useRef, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import ImperativeModal from '@/components/ImperativeModal';
-import Image from '@/libs/next/Image';
-import { useUploadFilesValidation } from '@/routes/(main)/(create)/image/features/ConfigPanel/hooks/useUploadFilesValidation';
-
-// ======== Types ======== //
-
-/**
- * Unified image item data structure
- * - url: Remote URL of existing image
- * - file: Newly selected file that needs to be uploaded
- * - previewUrl: Preview URL for local file (blob URL)
- * Items with url are existing images, items with file are files to be uploaded
- */
-export interface ImageItem {
- // URL of existing image
- file?: File;
- id: string;
- // Newly selected file
- previewUrl?: string;
- url?: string; // Preview URL for local file, only used when file exists
-}
-
-interface ImageManageModalProps {
- images: string[];
- maxCount?: number;
- // Array of existing image URLs
- onClose: () => void;
- onComplete: (imageItems: ImageItem[]) => void;
- open: boolean; // Unified completion callback
-}
-
-// ======== Utils ======== //
-
-const getFileName = (url: string): string => {
- try {
- const urlObj = new URL(url);
- const pathname = urlObj.pathname;
- return pathname.split('/').pop() || 'image.jpg';
- } catch {
- return 'image.jpg';
- }
-};
-
-const generateId = () => `${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
-
-// ======== Styles ======== //
-
-const prefixCls = 'ant';
-
-const styles = createStaticStyles(({ css, cssVar }) => ({
- content: css`
- display: flex;
- height: 480px;
- background: ${cssVar.colorBgContainer};
- `,
- fileName: css`
- margin-block-start: 16px;
- padding-block: 8px;
- padding-inline: 12px;
- border-radius: ${cssVar.borderRadius};
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
-
- background: ${cssVar.colorFillSecondary};
- `,
- footer: css`
- display: flex;
- align-items: center;
- justify-content: space-between;
-
- padding-block: 16px;
- padding-inline: 24px;
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
-
- background: ${cssVar.colorBgContainer};
- `,
- modal: css`
- .${prefixCls}-modal-container {
- overflow: hidden;
- padding: 0;
- }
- `,
- newFileIndicator: css`
- position: absolute;
- z-index: 5;
- inset-block-start: 4px;
- inset-inline-start: 4px;
-
- padding-block: 2px;
- padding-inline: 6px;
- border-radius: ${cssVar.borderRadiusSM};
-
- font-size: 10px;
- font-weight: 500;
- color: ${cssVar.colorWhite};
-
- background: ${cssVar.colorSuccess};
- `,
- previewArea: css`
- position: relative;
-
- display: flex;
- flex: 1;
- flex-direction: column;
- align-items: center;
- justify-content: center;
-
- padding: 24px;
- `,
- previewEmpty: css`
- font-size: 16px;
- color: ${cssVar.colorTextSecondary};
- `,
- previewImage: css`
- max-width: 100%;
- max-height: 320px;
- border-radius: ${cssVar.borderRadiusLG};
- box-shadow: ${cssVar.boxShadowSecondary};
- `,
- sidebar: css`
- overflow-y: auto;
-
- width: 200px;
- padding: 16px;
- border-inline-end: 1px solid ${cssVar.colorBorderSecondary};
-
- background: ${cssVar.colorBgLayout};
- `,
- thumbnail: css`
- cursor: pointer;
-
- position: relative;
-
- overflow: hidden;
-
- width: 100%;
- height: 120px;
- border: 2px solid transparent;
- border-radius: ${cssVar.borderRadius};
-
- transition: border-color 0.2s ease;
-
- &:hover {
- border-color: ${cssVar.colorPrimary};
- }
-
- &:hover .thumbnail-delete {
- opacity: 1;
- }
-
- &.selected {
- border-color: ${cssVar.colorPrimary};
- }
- `,
- thumbnailDelete: css`
- cursor: pointer;
-
- position: absolute;
- z-index: 10;
- inset-block-start: 4px;
- inset-inline-end: 4px;
-
- display: flex;
- align-items: center;
- justify-content: center;
-
- width: 20px;
- height: 20px;
- border-radius: 50%;
-
- color: ${cssVar.colorTextLightSolid};
-
- opacity: 0;
- background: ${cssVar.colorBgMask};
-
- transition: opacity 0.2s ease;
-
- &:hover {
- color: ${cssVar.colorError};
- background: ${cssVar.colorErrorBg};
- }
- `,
- thumbnailList: css`
- display: flex;
- flex-direction: column;
- gap: 8px;
- `,
-}));
-
-// ======== Main Component ======== //
-
-const ImageManageModal: FC<ImageManageModalProps> = memo(
- ({ open, images, maxCount, onClose, onComplete }) => {
- const { t } = useTranslation('components');
- const inputRef = useRef<HTMLInputElement>(null);
- const { validateFiles } = useUploadFilesValidation(maxCount);
-
- // Use unified data structure to manage all images
- const [imageItems, setImageItems] = useState<ImageItem[]>([]);
- const [selectedIndex, setSelectedIndex] = useState<number>(0);
-
- // Initialize state when modal opens
- useEffect(() => {
- if (open) {
- // Convert existing URLs to ImageItem format
- const initialItems: ImageItem[] = images.map((url) => ({
- id: generateId(),
- url,
- }));
- setImageItems(initialItems);
- setSelectedIndex(0);
- }
- }, [open, images]);
-
- // Cleanup blob URLs to prevent memory leaks
- useEffect(() => {
- return () => {
- // Cleanup function: revoke all blob URLs when component unmounts or imageItems change
- imageItems.forEach((item) => {
- if (item.previewUrl) {
- URL.revokeObjectURL(item.previewUrl);
- }
- });
- };
- }, [imageItems]);
-
- // Additional cleanup when modal closes
- useEffect(() => {
- if (!open) {
- imageItems.forEach((item) => {
- if (item.previewUrl) {
- URL.revokeObjectURL(item.previewUrl);
- }
- });
- setImageItems([]); // Clear items when modal closes
- }
- }, [imageItems, open]);
-
- const selectedItem = imageItems[selectedIndex];
-
- const handleDelete = (index: number) => {
- const itemToDelete = imageItems[index];
-
- // Clean up blob URL for the deleted item
- if (itemToDelete?.previewUrl) {
- URL.revokeObjectURL(itemToDelete.previewUrl);
- }
-
- const newItems = imageItems.filter((_, i) => i !== index);
- setImageItems(newItems);
-
- // Adjust selected index
- if (selectedIndex >= newItems.length) {
- setSelectedIndex(Math.max(0, newItems.length - 1));
- }
- };
-
- const handleThumbnailDelete = (index: number, event: React.MouseEvent) => {
- event.stopPropagation();
- handleDelete(index);
- };
-
- const handleUpload = () => {
- inputRef.current?.click();
- };
-
- const handleFilesChange = (event: React.ChangeEvent<HTMLInputElement>) => {
- const files = event.target.files;
- if (!files || files.length === 0) return;
-
- // Validate files, pass current image count
- if (!validateFiles(Array.from(files), imageItems.length)) {
- return;
- }
-
- // Create new ImageItem, generate one-time preview URL for each file
- const newItems: ImageItem[] = Array.from(files).map((file) => ({
- file,
- id: generateId(),
- previewUrl: URL.createObjectURL(file), // Create only once
- }));
-
- setImageItems((prev) => [...prev, ...newItems]);
- };
-
- const handleComplete = () => {
- // Directly pass current complete state to parent component
- onComplete(imageItems);
- onClose();
- };
-
- const getDisplayUrl = (item: ImageItem): string => {
- if (item.url) {
- return item.url;
- } else if (item.previewUrl) {
- return item.previewUrl;
- }
- return '';
- };
-
- const getDisplayFileName = (item: ImageItem): string => {
- if (item.file) {
- return item.file.name;
- } else if (item.url) {
- return getFileName(item.url);
- }
- return '';
- };
-
- const renderThumbnail = (item: ImageItem, index: number) => {
- const displayUrl = getDisplayUrl(item);
- const isNewFile = Boolean(item.file);
-
- return (
- <div
- className={cx(styles.thumbnail, index === selectedIndex && 'selected')}
- key={item.id}
- onClick={() => setSelectedIndex(index)}
- >
- <Image
- fill
- unoptimized
- alt={`Image ${index + 1}`}
- src={displayUrl}
- style={{ objectFit: 'cover' }}
- />
-
- {/* New file indicator */}
- {isNewFile && (
- <div className={styles.newFileIndicator}>
- {t('MultiImagesUpload.modal.newFileIndicator')}
- </div>
- )}
-
- {/* Delete button */}
- <div
- className={cx(styles.thumbnailDelete, 'thumbnail-delete')}
- onClick={(e) => handleThumbnailDelete(index, e)}
- >
- <X size={12} />
- </div>
- </div>
- );
- };
-
- return (
- <ImperativeModal
- centered
- className={styles.modal}
- footer={null}
- open={open}
- title={t('MultiImagesUpload.modal.title', { count: imageItems.length })}
- width={720}
- onCancel={onClose}
- >
- {/* Hidden file input */}
- <input
- multiple
- accept="image/*"
- ref={inputRef}
- style={{ display: 'none' }}
- type="file"
- onChange={handleFilesChange}
- onClick={(e) => {
- e.currentTarget.value = '';
- }}
- />
-
- {/* Content */}
- <div className={styles.content}>
- {/* Sidebar - Thumbnail List */}
- <div className={styles.sidebar}>
- <div className={styles.thumbnailList}>{imageItems.map(renderThumbnail)}</div>
- </div>
-
- {/* Preview Area */}
- <div className={styles.previewArea}>
- {selectedItem ? (
- <>
- <Image
- unoptimized
- alt="Preview"
- className={styles.previewImage}
- height={320}
- src={getDisplayUrl(selectedItem)}
- style={{ objectFit: 'contain' }}
- width={400}
- />
- <div className={styles.fileName}>{getDisplayFileName(selectedItem)}</div>
- </>
- ) : (
- <div className={styles.previewEmpty}>
- {t('MultiImagesUpload.modal.selectImageToPreview')}
- </div>
- )}
- </div>
- </div>
-
- {/* Footer */}
- <div className={styles.footer}>
- <Button
- disabled={maxCount ? imageItems.length >= maxCount : false}
- icon={<Upload size={16} />}
- type="default"
- onClick={handleUpload}
- >
- {t('MultiImagesUpload.modal.upload')}
- </Button>
-
- <Button type="primary" onClick={handleComplete}>
- {t('MultiImagesUpload.modal.complete')}
- </Button>
- </div>
- </ImperativeModal>
- );
- },
-);
-
-ImageManageModal.displayName = 'ImageManageModal';
-
-export default ImageManageModal;
diff --git a/src/routes/(main)/(create)/image/features/ConfigPanel/components/MultiImagesUpload/index.tsx b/src/routes/(main)/(create)/image/features/ConfigPanel/components/MultiImagesUpload/index.tsx
deleted file mode 100644
index c5f6817f6be..00000000000
--- a/src/routes/(main)/(create)/image/features/ConfigPanel/components/MultiImagesUpload/index.tsx
+++ /dev/null
@@ -1,836 +0,0 @@
-'use client';
-
-// Removed Image import - using img tags instead
-import { Center } from '@lobehub/ui';
-import { createStaticStyles, cssVar, cx } from 'antd-style';
-import { Image as ImageIcon, X } from 'lucide-react';
-import { type FC } from 'react';
-import React, { memo, useEffect, useRef, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import Image from '@/libs/next/Image';
-import { CONFIG_PANEL_WIDTH } from '@/routes/(main)/(create)/image/features/ConfigPanel/constants';
-import { useDragAndDrop } from '@/routes/(main)/(create)/image/features/ConfigPanel/hooks/useDragAndDrop';
-import { useUploadFilesValidation } from '@/routes/(main)/(create)/image/features/ConfigPanel/hooks/useUploadFilesValidation';
-import { configPanelStyles } from '@/routes/(main)/(create)/image/features/ConfigPanel/style';
-import { useFileStore } from '@/store/file';
-import { type FileUploadStatus } from '@/types/files/upload';
-
-import { type ImageItem } from './ImageManageModal';
-import ImageManageModal from './ImageManageModal';
-
-// ======== Business Types ======== //
-
-/**
- * Internal type for managing upload state and display
- */
-interface DisplayItem {
- // Upload status - using the correct type from file upload system
- error?: string;
- // URL for display, can be a blob: URL for local previews or a remote URL
- file?: File;
- id: string;
- // Error message if upload failed
- progress?: number;
- // The raw File object, present only for new, not-yet-uploaded images
- status?: FileUploadStatus;
- // Unique identifier for the item
- url: string; // Upload progress (0-100)
-}
-
-export interface MultiImagesUploadProps {
- // Callback when URLs change - supports both old API (string[]) and new API (object with dimensions)
- className?: string; // Array of image URLs
- maxCount?: number;
- maxFileSize?: number;
- onChange?: (
- data:
- | string[] // Old API: just URLs
- | { dimensions?: { height: number; width: number }; urls: string[] }, // New API: URLs with first image dimensions
- ) => void;
- style?: React.CSSProperties;
- value?: string[];
-}
-
-// ======== Styles ======== //
-
-const styles = createStaticStyles(({ css }) => {
- // Calculate available width for thumbnails
- // Panel width - outer padding (16px * 2) - gaps (8px * 3 for 4 items)
- const availableWidth = CONFIG_PANEL_WIDTH - 32 - 24;
- const thumbnailSize = availableWidth / 4;
-
- return {
- deleteIcon: css`
- cursor: pointer;
-
- position: absolute;
- z-index: 10;
- inset-block-start: 4px;
- inset-inline-end: 4px;
-
- display: flex;
- align-items: center;
- justify-content: center;
-
- width: 20px;
- height: 20px;
- border-radius: 50%;
-
- color: ${cssVar.colorTextLightSolid};
-
- opacity: 0;
- background: ${cssVar.colorBgMask};
-
- transition: opacity 0.2s ease;
-
- &:hover {
- color: ${cssVar.colorError};
- background: ${cssVar.colorErrorBg};
- }
- `,
-
- imageItem: css`
- position: relative;
-
- overflow: hidden;
-
- width: ${thumbnailSize}px;
- height: ${thumbnailSize}px;
- border-radius: ${cssVar.borderRadius};
-
- background: ${cssVar.colorBgContainer};
-
- &:hover .delete-icon {
- opacity: 1;
- }
- `,
-
- // Image thumbnails styles
- imageThumbnails: css`
- cursor: pointer;
-
- display: flex;
- gap: 8px;
-
- width: 100%;
- height: ${thumbnailSize}px;
- padding: 0;
- border-radius: ${cssVar.borderRadiusLG};
-
- transition: all 0.2s ease;
-
- &.drag-over {
- transform: scale(1.02);
- background: ${cssVar.colorPrimaryBg};
- }
- `,
-
- moreOverlay: css`
- position: absolute;
- inset-block: 0;
- inset-inline: 0;
-
- display: flex;
- align-items: center;
- justify-content: center;
-
- font-size: 16px;
- font-weight: 600;
- color: ${cssVar.colorTextLightSolid};
-
- background: ${cssVar.colorBgMask};
- `,
-
- placeholder: css`
- cursor: pointer;
-
- width: 100%;
- height: 120px;
- border: 1px solid ${cssVar.colorBorder};
- border-radius: ${cssVar.borderRadiusLG};
-
- background: ${cssVar.colorFillTertiary};
-
- transition: all 0.2s ease;
-
- &:hover {
- background: ${cssVar.colorFillSecondary};
- }
-
- &.drag-over {
- transform: scale(1.02);
- border-color: ${cssVar.colorPrimary};
- background: ${cssVar.colorPrimaryBg};
- }
- `,
-
- placeholderIcon: css`
- color: ${cssVar.colorTextTertiary};
- `,
-
- placeholderText: css`
- font-size: 12px; /* Made smaller than default token.fontSize (14px) */
- line-height: 1.4;
- color: ${cssVar.colorTextSecondary};
- text-align: center;
- `,
-
- progress: css`
- cursor: pointer;
-
- position: relative;
-
- overflow: hidden;
-
- width: 100%;
- height: 120px;
- border: 2px solid ${cssVar.colorPrimary};
- border-radius: ${cssVar.borderRadiusLG};
-
- background: ${cssVar.colorFillSecondary};
-
- transition: all 0.2s ease;
-
- &.drag-over {
- transform: scale(1.02);
- background: ${cssVar.colorPrimaryBg};
- }
- `,
-
- progressPrimary: css`
- margin-block-end: 4px;
- font-size: 14px;
- font-weight: 600;
- color: ${cssVar.colorPrimary};
- `,
-
- progressText: css`
- font-size: 12px;
- font-weight: 500;
- line-height: 1.4;
- color: ${cssVar.colorText};
- text-align: center;
- `,
- // Single image display styles
- singleImageDisplay: css`
- cursor: pointer;
-
- position: relative;
-
- overflow: hidden;
-
- width: 100%;
- height: 160px;
- border-radius: ${cssVar.borderRadiusLG};
-
- background: ${cssVar.colorBgContainer};
-
- transition: all 0.2s ease;
-
- &:hover .upload-more-overlay {
- opacity: 1;
- }
-
- &:hover .delete-icon {
- opacity: 1;
- }
-
- &.drag-over {
- transform: scale(1.02);
- background: ${cssVar.colorPrimaryBg};
- }
- `,
- uploadMoreButton: css`
- cursor: pointer;
-
- padding-block: 8px;
- padding-inline: 16px;
- border: 1px solid ${cssVar.colorBorder};
- border-radius: ${cssVar.borderRadius};
-
- font-size: 12px;
- font-weight: 500;
- color: ${cssVar.colorText};
-
- background: ${cssVar.colorBgContainer};
- box-shadow: ${cssVar.boxShadowSecondary};
-
- &:hover {
- border-color: ${cssVar.colorPrimary};
- color: ${cssVar.colorPrimary};
- background: ${cssVar.colorBgElevated};
- }
- `,
- uploadMoreOverlay: css`
- position: absolute;
- z-index: 5;
- inset-block: 0;
- inset-inline: 0;
-
- display: flex;
- align-items: center;
- justify-content: center;
-
- opacity: 0;
- background: ${cssVar.colorBgMask};
-
- transition: opacity 0.2s ease;
- `,
- };
-});
-
-// ======== Utils ======== //
-
-/**
- * Check if a URL is a local blob URL
- * @param url - The URL to check
- * @returns true if the URL is a blob URL
- */
-const isLocalBlobUrl = (url: string): boolean => url.startsWith('blob:');
-
-// ======== Sub-Components ======== //
-
-interface ImageUploadPlaceholderProps {
- isDragOver?: boolean;
- onClick?: () => void;
-}
-
-const ImageUploadPlaceholder: FC<ImageUploadPlaceholderProps> = memo(({ isDragOver, onClick }) => {
- const { t } = useTranslation('components');
-
- return (
- <Center
- className={cx(styles.placeholder, isDragOver && 'drag-over')}
- gap={16}
- horizontal={false}
- onClick={onClick}
- >
- <ImageIcon className={styles.placeholderIcon} size={48} strokeWidth={1.5} />
- <div className={styles.placeholderText}>
- {t('MultiImagesUpload.placeholder.primary')}
- <br />
- {t('MultiImagesUpload.placeholder.secondary')}
- </div>
- </Center>
- );
-});
-
-ImageUploadPlaceholder.displayName = 'ImageUploadPlaceholder';
-
-// ======== Circular Progress Component ======== //
-
-interface CircularProgressProps {
- className?: string;
- showText?: boolean;
- // 0-100
- size?: number;
- strokeWidth?: number;
- value: number;
-}
-
-const CircularProgress: FC<CircularProgressProps> = memo(
- ({ value, size = 48, strokeWidth = 4, className, showText = true }) => {
- // Ensure value is between 0 and 100
- const progress = Math.min(100, Math.max(0, value));
-
- // Calculate circle properties
- const radius = (size - strokeWidth) / 2;
- const circumference = radius * 2 * Math.PI;
- const offset = circumference - (progress / 100) * circumference;
-
- return (
- <div
- className={className}
- style={{
- alignItems: 'center',
- display: 'flex',
- height: size,
- justifyContent: 'center',
- position: 'relative',
- width: size,
- }}
- >
- {/* Background circle */}
- <svg
- height={size}
- style={{ position: 'absolute', transform: 'rotate(-90deg)' }}
- width={size}
- >
- <circle
- cx={size / 2}
- cy={size / 2}
- fill="none"
- r={radius}
- stroke={cssVar.colorBorder}
- strokeWidth={strokeWidth}
- />
- </svg>
-
- {/* Progress circle */}
- <svg
- height={size}
- style={{ position: 'absolute', transform: 'rotate(-90deg)' }}
- width={size}
- >
- <circle
- cx={size / 2}
- cy={size / 2}
- fill="none"
- r={radius}
- stroke={cssVar.colorPrimary}
- strokeDasharray={circumference}
- strokeDashoffset={offset}
- strokeLinecap="round"
- strokeWidth={strokeWidth}
- style={{
- transition: 'stroke-dashoffset 0.2s ease-in-out',
- }}
- />
- </svg>
-
- {/* Progress text */}
- {showText && (
- <span
- style={{
- color: cssVar.colorPrimary,
- fontSize: '12px',
- fontWeight: 600,
- position: 'relative',
- zIndex: 1,
- }}
- >
- {Math.round(progress)}%
- </span>
- )}
- </div>
- );
- },
-);
-
-CircularProgress.displayName = 'CircularProgress';
-
-interface ImageUploadProgressProps {
- completedCount: number;
- currentProgress: number;
- showCount?: boolean;
- totalCount: number;
-}
-
-const ImageUploadProgress: FC<ImageUploadProgressProps> = memo(
- ({ completedCount, totalCount, currentProgress, showCount = true }) => {
- const { t } = useTranslation('components');
-
- return (
- <Center className={styles.progress} gap={16} horizontal={false}>
- {/* Circular progress bar */}
- <CircularProgress size={60} strokeWidth={6} value={currentProgress} />
-
- {/* Progress text */}
- <div className={styles.progressText}>
- {showCount ? (
- <div className={styles.progressPrimary}>
- {t('MultiImagesUpload.progress.uploadingWithCount', {
- completed: completedCount,
- total: totalCount,
- })}
- </div>
- ) : null}
- </div>
- </Center>
- );
- },
-);
-
-ImageUploadProgress.displayName = 'ImageUploadProgress';
-
-interface ImageThumbnailsProps {
- images: string[];
- isDragOver?: boolean;
- onClick?: () => void;
- onDelete?: (index: number) => void;
-}
-
-const ImageThumbnails: FC<ImageThumbnailsProps> = memo(
- ({ images, isDragOver, onClick, onDelete }) => {
- const configStyles = configPanelStyles;
-
- // Display max 4 images, with overflow indication
- const displayImages = images.slice(0, 4);
- const remainingCount = Math.max(0, images.length - 3); // Show +x for images beyond first 3
-
- const handleDelete = (index: number, event: React.MouseEvent) => {
- event.stopPropagation(); // Prevent triggering container click
- onDelete?.(index);
- };
-
- const renderImageItem = (imageUrl: string, index: number) => {
- const isLastItem = index === 3;
- const showOverlay = isLastItem && remainingCount > 1;
-
- return (
- <div className={styles.imageItem} key={`${imageUrl}-${index}`}>
- <Image
- fill
- unoptimized
- alt={`Uploaded image ${index + 1}`}
- src={imageUrl}
- style={{ objectFit: 'cover' }}
- />
- {!showOverlay && (
- <div
- className={cx(styles.deleteIcon, 'delete-icon')}
- onClick={(e) => handleDelete(index, e)}
- >
- <X size={12} />
- </div>
- )}
- {showOverlay && <div className={styles.moreOverlay}>+{remainingCount}</div>}
- </div>
- );
- };
-
- return (
- <div
- className={cx(
- styles.imageThumbnails,
- configStyles.dragTransition,
- isDragOver && configStyles.dragOver,
- )}
- onClick={onClick}
- >
- {displayImages.map(renderImageItem)}
- </div>
- );
- },
-);
-
-ImageThumbnails.displayName = 'ImageThumbnails';
-
-interface SingleImageDisplayProps {
- imageUrl: string;
- isDragOver?: boolean;
- onClick?: () => void;
- onDelete?: () => void;
-}
-
-const SingleImageDisplay: FC<SingleImageDisplayProps> = memo(
- ({ imageUrl, isDragOver, onClick, onDelete }) => {
- const configStyles = configPanelStyles;
- const { t } = useTranslation('components');
-
- const handleDelete = (event: React.MouseEvent) => {
- event.stopPropagation(); // Prevent triggering container click
- onDelete?.();
- };
-
- const handleOverlayClick = (event: React.MouseEvent) => {
- event.stopPropagation(); // Prevent triggering container click
- onClick?.();
- };
-
- return (
- <div
- className={cx(
- styles.singleImageDisplay,
- configStyles.dragTransition,
- isDragOver && configStyles.dragOver,
- )}
- >
- <Image
- fill
- unoptimized
- alt="Uploaded image"
- src={imageUrl}
- style={{ objectFit: 'contain' }}
- />
-
- {/* Delete button */}
- <div className={cx(styles.deleteIcon, 'delete-icon')} onClick={handleDelete}>
- <X size={12} />
- </div>
-
- {/* Upload more overlay */}
- <div
- className={cx(styles.uploadMoreOverlay, 'upload-more-overlay')}
- onClick={handleOverlayClick}
- >
- <button className={styles.uploadMoreButton} type="button">
- {t('MultiImagesUpload.actions.uploadMore')}
- </button>
- </div>
- </div>
- );
- },
-);
-
-SingleImageDisplay.displayName = 'SingleImageDisplay';
-
-// ======== Main Component ======== //
-
-const MultiImagesUpload: FC<MultiImagesUploadProps> = memo(
- ({ value, onChange, style, className, maxCount, maxFileSize }) => {
- const inputRef = useRef<HTMLInputElement>(null);
- const uploadWithProgress = useFileStore((s) => s.uploadWithProgress);
- const [displayItems, setDisplayItems] = useState<DisplayItem[]>([]);
- const [modalOpen, setModalOpen] = useState(false);
- const configStyles = configPanelStyles;
- const { validateFiles } = useUploadFilesValidation(maxCount, maxFileSize);
-
- // Cleanup blob URLs to prevent memory leaks
- useEffect(() => {
- return () => {
- // Cleanup function: revoke all blob URLs when component unmounts or displayItems change
- displayItems.forEach((item) => {
- if (item.file && isLocalBlobUrl(item.url)) {
- URL.revokeObjectURL(item.url);
- }
- });
- };
- }, [displayItems]);
-
- const handlePlaceholderClick = () => {
- inputRef.current?.click();
- };
-
- const handleOpenModal = () => {
- setModalOpen(true);
- };
-
- const handleCloseModal = () => {
- setModalOpen(false);
- };
-
- const handleDelete = (index: number) => {
- if (!value) return;
- const newUrls = value.filter((_, i) => i !== index);
- onChange?.(newUrls);
- };
-
- const handleFilesSelected = async (files: File[], baseUrls?: string[]) => {
- if (files.length === 0) return;
-
- const currentUrls = baseUrls !== undefined ? baseUrls : value || [];
-
- // Validate files, pass current image count
- if (!validateFiles(files, currentUrls.length)) {
- return;
- }
-
- // Create initial display items with blob URLs for immediate preview
- const newDisplayItems: DisplayItem[] = files.map((file) => ({
- file,
- id: `${Date.now()}-${file.name}`,
- progress: 0,
- status: 'pending' as FileUploadStatus,
- url: URL.createObjectURL(file),
- }));
-
- setDisplayItems((prev) => [...prev, ...newDisplayItems]);
-
- // Start uploading files
- const uploadPromises = newDisplayItems.map((item) =>
- uploadWithProgress({
- file: item.file!,
- // Skip file type check for images
- onStatusUpdate: (updateData) => {
- if (updateData.type === 'updateFile') {
- setDisplayItems((prev) =>
- prev.map((displayItem) =>
- displayItem.id === item.id
- ? {
- ...displayItem,
- error: updateData.value.status === 'error' ? 'Upload failed' : undefined,
- progress: updateData.value.uploadState?.progress || 0,
- status: updateData.value.status,
- }
- : displayItem,
- ),
- );
- } else if (updateData.type === 'removeFile') {
- setDisplayItems((prev) => prev.filter((displayItem) => displayItem.id !== item.id));
- }
- },
- skipCheckFileType: true,
- }),
- );
-
- // Wait for all uploads to complete and collect successful URLs and dimensions
- const uploadResults = await Promise.allSettled(uploadPromises);
- const successfulUrls: string[] = [];
- let firstImageDimensions: { height: number; width: number } | undefined;
-
- uploadResults.forEach((result, index) => {
- const displayItem = newDisplayItems[index];
-
- if (result.status === 'fulfilled' && result.value) {
- successfulUrls.push(result.value.url);
-
- // Collect the first image's dimensions for auto-setting parameters
- if (index === 0 && result.value.dimensions) {
- firstImageDimensions = result.value.dimensions;
- }
-
- // Update display item with final URL and success status
- setDisplayItems((prev) =>
- prev.map((item) =>
- item.id === displayItem.id
- ? {
- ...item,
- file: undefined,
- progress: 100,
- status: 'success',
- url: result.value!.url, // Clear file reference after successful upload
- }
- : item,
- ),
- );
- } else {
- // Handle upload failure
- setDisplayItems((prev) =>
- prev.map((item) =>
- item.id === displayItem.id
- ? {
- ...item,
- error: 'Upload failed',
- progress: 0,
- status: 'error',
- }
- : item,
- ),
- );
- }
-
- // Clean up blob URL regardless of success or failure
- if (isLocalBlobUrl(displayItem.url)) {
- URL.revokeObjectURL(displayItem.url);
- }
- });
-
- // Update parent component with new URLs and dimensions (if applicable)
- if (successfulUrls.length > 0) {
- const updatedUrls = [...currentUrls, ...successfulUrls];
-
- // Pass dimensions if this is the first upload (no existing images) and only one image uploaded
- const shouldPassDimensions = currentUrls.length === 0 && successfulUrls.length === 1;
-
- if (shouldPassDimensions && firstImageDimensions) {
- onChange?.({ dimensions: firstImageDimensions, urls: updatedUrls });
- } else {
- onChange?.(updatedUrls);
- }
- }
-
- // Clear display items after all uploads complete
- setTimeout(() => {
- setDisplayItems([]);
- }, 1000); // Show success state for 1 second before clearing
- };
-
- const handleFilesChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
- const files = event.target.files;
- if (!files || files.length === 0) return;
-
- await handleFilesSelected(Array.from(files));
- };
-
- // ======== Drag and Drop Handlers ======== //
-
- const handleDrop = async (files: File[]) => {
- // Add all image files to existing images
- await handleFilesSelected(files);
- };
-
- const { isDragOver, dragHandlers } = useDragAndDrop({
- accept: 'image/*',
- onDrop: handleDrop,
- });
-
- // Handle Modal completion callback
- const handleModalComplete = async (imageItems: ImageItem[]) => {
- // Separate existing URLs and new files
- const existingUrls = imageItems.filter((item) => item.url).map((item) => item.url!);
-
- const newFiles = imageItems.filter((item) => item.file).map((item) => item.file!);
-
- // Immediately update existing URLs (deleted images will be filtered out)
- onChange?.(existingUrls);
-
- // If there are new files to upload, start upload process based on existingUrls
- if (newFiles.length > 0) {
- await handleFilesSelected(newFiles, existingUrls);
- }
- };
-
- // Calculate progress data
- const totalFiles = displayItems.length;
- const completedFiles = displayItems.filter((item) => (item.progress || 0) >= 100).length;
- const overallProgress =
- totalFiles > 0
- ? displayItems.reduce((sum, item) => sum + (item.progress || 0), 0) / totalFiles
- : 0;
-
- const hasImages = value && value.length > 0;
- const isUploading = displayItems.length > 0;
- const isSingleImage = value && value.length === 1;
-
- return (
- <div className={className} {...dragHandlers} style={style}>
- {/* Hidden file input */}
- <input
- multiple
- accept="image/*"
- ref={inputRef}
- style={{ display: 'none' }}
- type="file"
- onChange={handleFilesChange}
- onClick={(e) => {
- // Reset value to allow re-selecting the same file
- e.currentTarget.value = '';
- }}
- />
-
- {/* Conditional rendering based on state */}
- {isUploading ? (
- <div className={cx(configStyles.dragTransition, isDragOver && configStyles.dragOver)}>
- <ImageUploadProgress
- completedCount={completedFiles}
- currentProgress={overallProgress}
- showCount={totalFiles > 1}
- totalCount={totalFiles}
- />
- </div>
- ) : isSingleImage ? (
- <SingleImageDisplay
- imageUrl={value[0]}
- isDragOver={isDragOver}
- onClick={handleOpenModal}
- onDelete={() => handleDelete(0)}
- />
- ) : hasImages ? (
- <ImageThumbnails
- images={value || []}
- isDragOver={isDragOver}
- onClick={handleOpenModal}
- onDelete={handleDelete}
- />
- ) : (
- <ImageUploadPlaceholder isDragOver={isDragOver} onClick={handlePlaceholderClick} />
- )}
-
- {/* Image Management Modal */}
- <ImageManageModal
- images={value || []}
- maxCount={maxCount}
- open={modalOpen}
- onClose={handleCloseModal}
- onComplete={handleModalComplete}
- />
- </div>
- );
- },
-);
-
-MultiImagesUpload.displayName = 'MultiImagesUpload';
-
-export default MultiImagesUpload;
diff --git a/src/routes/(main)/(create)/image/features/ConfigPanel/constants.ts b/src/routes/(main)/(create)/image/features/ConfigPanel/constants.ts
deleted file mode 100644
index 46e3cbbba91..00000000000
--- a/src/routes/(main)/(create)/image/features/ConfigPanel/constants.ts
+++ /dev/null
@@ -1 +0,0 @@
-export const CONFIG_PANEL_WIDTH = 260;
diff --git a/src/routes/(main)/(create)/video/features/ConfigPanel/components/FrameUpload.tsx b/src/routes/(main)/(create)/video/features/ConfigPanel/components/FrameUpload.tsx
deleted file mode 100644
index d016a2476fb..00000000000
--- a/src/routes/(main)/(create)/video/features/ConfigPanel/components/FrameUpload.tsx
+++ /dev/null
@@ -1,32 +0,0 @@
-import { memo } from 'react';
-
-import { ImageUpload } from '@/routes/(main)/(create)/image/features/ConfigPanel';
-import { useVideoGenerationConfigParam } from '@/store/video/slices/generationConfig/hooks';
-
-interface FrameUploadProps {
- paramName: 'endImageUrl' | 'imageUrl';
-}
-
-const FrameUpload = memo<FrameUploadProps>(({ paramName }) => {
- const { value, setValue, maxFileSize, imageConstraints } =
- useVideoGenerationConfigParam(paramName);
-
- const handleChange = (
- data?: string | { dimensions?: { height: number; width: number }; url: string },
- ) => {
- const url = typeof data === 'string' ? data : data?.url;
- setValue((url ?? null) as any);
- };
-
- return (
- <ImageUpload
- imageConstraints={imageConstraints}
- maxFileSize={maxFileSize}
- placeholderHeight={120}
- value={value}
- onChange={handleChange}
- />
- );
-});
-
-export default FrameUpload;
diff --git a/src/routes/(main)/agent/[topicId]/index.tsx b/src/routes/(main)/agent/[topicId]/index.tsx
deleted file mode 100644
index 111c05ccfb2..00000000000
--- a/src/routes/(main)/agent/[topicId]/index.tsx
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from '@/routes/(main)/agent';
diff --git a/src/routes/(main)/community/(detail)/error.tsx b/src/routes/(main)/community/(detail)/error.tsx
deleted file mode 100644
index fe8c9f8224f..00000000000
--- a/src/routes/(main)/community/(detail)/error.tsx
+++ /dev/null
@@ -1,3 +0,0 @@
-'use client';
-
-export { default } from '@/components/Error';
diff --git a/src/routes/(main)/community/(detail)/features/SidebarContainer.tsx b/src/routes/(main)/community/(detail)/features/SidebarContainer.tsx
deleted file mode 100644
index 1a1b71f31fc..00000000000
--- a/src/routes/(main)/community/(detail)/features/SidebarContainer.tsx
+++ /dev/null
@@ -1,20 +0,0 @@
-import { type FlexboxProps } from '@lobehub/ui';
-import { Flexbox } from '@lobehub/ui';
-import { type FC } from 'react';
-
-const SidebarContainer: FC<FlexboxProps> = ({ children, style, ...rest }) => {
- return (
- <Flexbox
- flex={'none'}
- gap={48}
- height={'100%'}
- style={{ position: 'relative', width: 320, ...style }}
- width={'100%'}
- {...rest}
- >
- {children}
- </Flexbox>
- );
-};
-
-export default SidebarContainer;
diff --git a/src/routes/(main)/community/(detail)/not-found.tsx b/src/routes/(main)/community/(detail)/not-found.tsx
deleted file mode 100644
index 49edd856a42..00000000000
--- a/src/routes/(main)/community/(detail)/not-found.tsx
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from '@/components/404';
diff --git a/src/routes/(main)/community/(list)/error.tsx b/src/routes/(main)/community/(list)/error.tsx
deleted file mode 100644
index fe8c9f8224f..00000000000
--- a/src/routes/(main)/community/(list)/error.tsx
+++ /dev/null
@@ -1,3 +0,0 @@
-'use client';
-
-export { default } from '@/components/Error';
diff --git a/src/routes/(main)/community/(list)/not-found.tsx b/src/routes/(main)/community/(list)/not-found.tsx
deleted file mode 100644
index 49edd856a42..00000000000
--- a/src/routes/(main)/community/(list)/not-found.tsx
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from '@/components/404';
diff --git a/src/routes/(main)/community/features/CreateButton/Inner.tsx b/src/routes/(main)/community/features/CreateButton/Inner.tsx
deleted file mode 100644
index 634e82ffc8a..00000000000
--- a/src/routes/(main)/community/features/CreateButton/Inner.tsx
+++ /dev/null
@@ -1,56 +0,0 @@
-import { Icon, Tag, Typography } from '@lobehub/ui';
-import { Button } from '@lobehub/ui/base-ui';
-import { GithubIcon } from '@lobehub/ui/icons';
-import { Divider } from 'antd';
-import { Settings, Share2 } from 'lucide-react';
-import { memo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { AGENTS_INDEX_GITHUB, imageUrl } from '@/const/url';
-import Image from '@/libs/next/Image';
-
-const Inner = memo(() => {
- const { t } = useTranslation('discover');
- return (
- <Typography fontSize={14} headerMultiple={0.5} marginMultiple={0.4}>
- <Image
- alt={'banner'}
- height={602}
- src={imageUrl('banner_market_modal.webp')}
- style={{ height: 'auto', marginBottom: 24, width: '100%' }}
- width={1602}
- />
- <h3>
- <Tag color={'cyan'}>{t('createGuide.func1.tag')}</Tag>
- <span>{t('createGuide.func1.title')}</span>
- </h3>
- <p>
- <kbd>
- <Icon icon={Settings} />
- </kbd>
- {t('createGuide.func1.desc1')}
- <br />
- <kbd>
- <Icon icon={Share2} />
- </kbd>
- {t('createGuide.func1.desc2')}
- </p>
- <Divider />
- <h3>
- <Tag color={'cyan'}>{t('createGuide.func2.tag')}</Tag>
- <span>{t('createGuide.func2.title')}</span>
- </h3>
- <p>{t('createGuide.func2.desc')}</p>
- <br />
- <Button
- icon={GithubIcon}
- type={'primary'}
- onClick={() => window.open(AGENTS_INDEX_GITHUB, '__blank')}
- >
- {t('createGuide.func2.button')}
- </Button>
- </Typography>
- );
-});
-
-export default Inner;
diff --git a/src/routes/(main)/community/features/CreateButton/index.tsx b/src/routes/(main)/community/features/CreateButton/index.tsx
deleted file mode 100644
index 47ffac21d4b..00000000000
--- a/src/routes/(main)/community/features/CreateButton/index.tsx
+++ /dev/null
@@ -1,51 +0,0 @@
-import { ActionIcon, Icon, Skeleton } from '@lobehub/ui';
-import { Button } from '@lobehub/ui/base-ui';
-import { useResponsive } from 'antd-style';
-import { Brush } from 'lucide-react';
-import { memo, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import ImperativeModal from '@/components/ImperativeModal';
-import { MOBILE_HEADER_ICON_SIZE } from '@/const/layoutTokens';
-import dynamic from '@/libs/next/dynamic';
-
-const Inner = dynamic(() => import('./Inner'), {
- loading: () => <Skeleton paragraph={{ rows: 8 }} title={false} />,
-});
-
-const CreateButton = memo<{ mobile?: boolean }>(({ mobile }) => {
- const { mobile: resMobile } = useResponsive();
- const { t } = useTranslation('discover');
- const [isModalOpen, setIsModalOpen] = useState(false);
-
- const buttonContent =
- mobile || resMobile ? (
- <ActionIcon
- icon={Brush}
- size={MOBILE_HEADER_ICON_SIZE}
- title={t('create')}
- onClick={() => setIsModalOpen(true)}
- />
- ) : (
- <Button icon={<Icon icon={Brush} />} onClick={() => setIsModalOpen(true)}>
- {t('create')}
- </Button>
- );
-
- return (
- <>
- {buttonContent}
- <ImperativeModal
- allowFullscreen
- footer={null}
- open={isModalOpen}
- title={t('create')}
- onCancel={() => setIsModalOpen(false)}
- >
- <Inner />
- </ImperativeModal>
- </>
- );
-});
-
-export default CreateButton;
diff --git a/src/routes/(main)/eval/bench/[benchmarkId]/features/RunCards/RunSummaryCard.tsx b/src/routes/(main)/eval/bench/[benchmarkId]/features/RunCards/RunSummaryCard.tsx
deleted file mode 100644
index 9e9d5ed202c..00000000000
--- a/src/routes/(main)/eval/bench/[benchmarkId]/features/RunCards/RunSummaryCard.tsx
+++ /dev/null
@@ -1,126 +0,0 @@
-'use client';
-
-import { Flexbox, Text } from '@lobehub/ui';
-import { createStaticStyles, cssVar } from 'antd-style';
-import { memo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
-import SegmentBar from '@/routes/(main)/eval/features/SegmentBar';
-import StatusBadge from '@/routes/(main)/eval/features/StatusBadge';
-
-const styles = createStaticStyles(({ css }) => ({
- card: css`
- padding-block: 12px;
- padding-inline: 12px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${cssVar.borderRadius};
-
- background: ${cssVar.colorBgContainer};
-
- transition:
- border-color 0.15s ease,
- background 0.15s ease;
-
- &:hover {
- border-color: ${cssVar.colorBorder};
- background: ${cssVar.colorFillTertiary};
- }
-
- @media (prefers-reduced-motion: reduce) {
- transition: none;
- }
- `,
- name: css`
- overflow: hidden;
-
- font-weight: 600;
- color: ${cssVar.colorText};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- passRate: css`
- font-family: ${cssVar.fontFamilyCode};
- font-size: ${cssVar.fontSizeHeading3};
- font-weight: 600;
- line-height: 1;
- color: ${cssVar.colorText};
- `,
- score: css`
- font-family: ${cssVar.fontFamilyCode};
- font-weight: 600;
- color: ${cssVar.colorText};
- `,
- unit: css`
- font-size: ${cssVar.fontSizeSM};
- color: ${cssVar.colorTextTertiary};
- `,
-}));
-
-interface RunSummaryCardProps {
- benchmarkId: string;
- id: string;
- metrics?: {
- averageScore?: number;
- passRate?: number;
- totalCases?: number;
- };
- name?: string;
- status: string;
-}
-
-const RunSummaryCard = memo<RunSummaryCardProps>(({ id, name, status, metrics, benchmarkId }) => {
- const { t } = useTranslation('eval');
- const isActive = status === 'running' || status === 'pending';
-
- const passRate = metrics?.passRate;
- const totalCases = metrics?.totalCases ?? 0;
- // Derive a pass/fail split from the headline rate so the breakdown bar matches
- // the number shown — the summary metrics shape carries no per-status counts.
- const passedCases =
- passRate !== undefined && totalCases > 0 ? Math.round(passRate * totalCases) : 0;
- const failedCases = totalCases > 0 ? Math.max(0, totalCases - passedCases) : 0;
- const showResults = !isActive && passRate !== undefined;
-
- return (
- <WorkspaceLink
- style={{ color: 'inherit', textDecoration: 'none' }}
- to={`/eval/bench/${benchmarkId}/runs/${id}`}
- >
- <Flexbox className={styles.card} gap={10}>
- <Flexbox horizontal align="center" gap={8} justify="space-between">
- <span className={styles.name}>{name || id.slice(0, 8)}</span>
- <StatusBadge status={status} />
- </Flexbox>
-
- {showResults && (
- <Flexbox gap={8}>
- {/* Pass-rate hero — the run's headline outcome */}
- <Flexbox horizontal align="baseline" gap={6}>
- <span className={styles.passRate}>{Math.round(passRate! * 100)}%</span>
- <span className={styles.unit}>{t('run.metrics.passRate')}</span>
- </Flexbox>
- {totalCases > 0 && (
- <SegmentBar
- segments={[
- { color: cssVar.colorSuccess, value: passedCases },
- { color: cssVar.colorError, value: failedCases },
- ]}
- />
- )}
- {metrics?.averageScore !== undefined && (
- <Flexbox horizontal align="center" gap={6}>
- <Text fontSize={12} type="secondary">
- {t('run.metrics.avgScore')}
- </Text>
- <span className={styles.score}>{metrics.averageScore.toFixed(2)}</span>
- </Flexbox>
- )}
- </Flexbox>
- )}
- </Flexbox>
- </WorkspaceLink>
- );
-});
-
-export default RunSummaryCard;
diff --git a/src/routes/(main)/eval/bench/[benchmarkId]/features/TestCasePreviewModal/Content.tsx b/src/routes/(main)/eval/bench/[benchmarkId]/features/TestCasePreviewModal/Content.tsx
deleted file mode 100644
index 1d9968f6d09..00000000000
--- a/src/routes/(main)/eval/bench/[benchmarkId]/features/TestCasePreviewModal/Content.tsx
+++ /dev/null
@@ -1,102 +0,0 @@
-'use client';
-
-import { Flexbox } from '@lobehub/ui';
-import { Badge } from 'antd';
-import { createStaticStyles, cssVar } from 'antd-style';
-import { type FC } from 'react';
-import { useTranslation } from 'react-i18next';
-
-const styles = createStaticStyles(({ css }) => ({
- previewBlock: css`
- padding: 12px;
- border-radius: ${cssVar.borderRadius};
-
- font-size: ${cssVar.fontSize};
- line-height: 1.6;
- color: ${cssVar.colorText};
-
- background: ${cssVar.colorFillSecondary};
- `,
- previewLabel: css`
- margin: 0;
-
- font-size: ${cssVar.fontSizeSM};
- font-weight: 600;
- color: ${cssVar.colorTextTertiary};
- letter-spacing: 0.02em;
- text-transform: uppercase;
- `,
-}));
-
-const getDifficultyBadge = (difficulty: string) => {
- const config: Record<string, { bg: string; color: string }> = {
- easy: {
- bg: cssVar.colorSuccessBg,
- color: cssVar.colorSuccess,
- },
- hard: {
- bg: cssVar.colorErrorBg,
- color: cssVar.colorError,
- },
- medium: {
- bg: cssVar.colorWarningBg,
- color: cssVar.colorWarning,
- },
- };
-
- const c = config[difficulty] || config.easy;
- return (
- <Badge
- style={{
- backgroundColor: c.bg,
- borderColor: c.color + '30',
- color: c.color,
- fontSize: 12,
- textTransform: 'capitalize',
- }}
- >
- {difficulty}
- </Badge>
- );
-};
-
-export interface TestCasePreviewContentProps {
- testCase: any;
-}
-
-const TestCasePreviewContent: FC<TestCasePreviewContentProps> = ({ testCase }) => {
- const { t } = useTranslation('eval');
-
- if (!testCase) return null;
-
- return (
- <Flexbox gap={16}>
- <Flexbox gap={4}>
- <p className={styles.previewLabel}>{t('testCase.preview.input')}</p>
- <div className={styles.previewBlock}>{testCase.content?.input}</div>
- </Flexbox>
- <Flexbox gap={4}>
- <p className={styles.previewLabel}>{t('testCase.preview.expected')}</p>
- <div className={styles.previewBlock}>{testCase.content?.expectedOutput || '-'}</div>
- </Flexbox>
- <Flexbox horizontal align="center" gap={8}>
- {testCase.metadata?.difficulty && getDifficultyBadge(testCase.metadata.difficulty)}
- {testCase.metadata?.tags?.map((tag: string) => (
- <Badge
- key={tag}
- style={{
- backgroundColor: 'transparent',
- borderColor: cssVar.colorBorder,
- color: cssVar.colorTextTertiary,
- fontSize: 12,
- }}
- >
- {tag}
- </Badge>
- ))}
- </Flexbox>
- </Flexbox>
- );
-};
-
-export default TestCasePreviewContent;
diff --git a/src/routes/(main)/eval/bench/[benchmarkId]/features/TestCasePreviewModal/index.tsx b/src/routes/(main)/eval/bench/[benchmarkId]/features/TestCasePreviewModal/index.tsx
deleted file mode 100644
index 1f7ae528553..00000000000
--- a/src/routes/(main)/eval/bench/[benchmarkId]/features/TestCasePreviewModal/index.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-'use client';
-
-import { createModal, type ModalInstance } from '@lobehub/ui/base-ui';
-import { t } from 'i18next';
-
-import TestCasePreviewContent, { type TestCasePreviewContentProps } from './Content';
-
-export const createTestCasePreviewModal = (props: TestCasePreviewContentProps): ModalInstance =>
- createModal({
- content: <TestCasePreviewContent {...props} />,
- footer: null,
- title: t('testCase.preview.title', { ns: 'eval' }),
- width: 600,
- });
diff --git a/src/routes/(main)/group/_layout/Sidebar/GroupConfig/Header/Avatar.tsx b/src/routes/(main)/group/_layout/Sidebar/GroupConfig/Header/Avatar.tsx
deleted file mode 100644
index b994f462953..00000000000
--- a/src/routes/(main)/group/_layout/Sidebar/GroupConfig/Header/Avatar.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-'use client';
-
-import { Block } from '@lobehub/ui';
-import { memo } from 'react';
-
-import { useOpenChatSettings } from '@/hooks/useInterceptingRoutes';
-import SupervisorAvatar from '@/routes/(main)/group/features/GroupAvatar';
-
-const HeaderAvatar = memo<{ size?: number }>(() => {
- const openChatSettings = useOpenChatSettings();
-
- return (
- <Block
- clickable
- flex={'none'}
- height={32}
- padding={2}
- variant={'borderless'}
- width={32}
- style={{
- overflow: 'hidden',
- }}
- onClick={(e) => {
- e.stopPropagation();
- openChatSettings();
- }}
- >
- <SupervisorAvatar size={28} />
- </Block>
- );
-});
-
-export default HeaderAvatar;
diff --git a/src/routes/(main)/group/_layout/Sidebar/Topic/TopicListContent/SearchResult/index.tsx b/src/routes/(main)/group/_layout/Sidebar/Topic/TopicListContent/SearchResult/index.tsx
deleted file mode 100644
index 9953f91c991..00000000000
--- a/src/routes/(main)/group/_layout/Sidebar/Topic/TopicListContent/SearchResult/index.tsx
+++ /dev/null
@@ -1,49 +0,0 @@
-'use client';
-
-import { Center, Text } from '@lobehub/ui';
-import isEqual from 'fast-deep-equal';
-import React, { memo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import SkeletonList from '@/features/NavPanel/components/SkeletonList';
-import { useChatStore } from '@/store/chat';
-import { topicSelectors } from '@/store/chat/selectors';
-
-import TopicItem from '../../List/Item';
-
-const SearchResult = memo(() => {
- const { t } = useTranslation('topic');
- const [activeTopicId, isSearchingTopic] = useChatStore((s) => [
- s.activeTopicId,
- topicSelectors.isSearchingTopic(s),
- ]);
- const topics = useChatStore(topicSelectors.searchTopics, isEqual);
-
- if (isSearchingTopic) return <SkeletonList />;
-
- if (topics.length === 0)
- return (
- <Center paddingBlock={12}>
- <Text type={'secondary'}>{t('searchResultEmpty')}</Text>
- </Center>
- );
-
- return (
- <>
- {topics.map((topic) => (
- <TopicItem
- active={activeTopicId === topic.id}
- fav={topic.favorite}
- id={topic.id}
- key={topic.id}
- status={topic.status}
- title={topic.title}
- />
- ))}
- </>
- );
-});
-
-SearchResult.displayName = 'SearchResult';
-
-export default SearchResult;
diff --git a/src/routes/(main)/group/features/Conversation/ChatItem/ThreadItem.tsx b/src/routes/(main)/group/features/Conversation/ChatItem/ThreadItem.tsx
deleted file mode 100644
index 0e9052e6342..00000000000
--- a/src/routes/(main)/group/features/Conversation/ChatItem/ThreadItem.tsx
+++ /dev/null
@@ -1,65 +0,0 @@
-import { Flexbox, Icon } from '@lobehub/ui';
-import { createStaticStyles, cx } from 'antd-style';
-import dayjs from 'dayjs';
-import { ChevronRight } from 'lucide-react';
-import { memo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { useIsMobile } from '@/hooks/useIsMobile';
-import { useChatStore } from '@/store/chat';
-import { chatSelectors } from '@/store/chat/selectors';
-import { type ThreadItem } from '@/types/topic';
-
-const styles = createStaticStyles(({ css, cssVar }) => ({
- active: css`
- background: ${cssVar.colorFillTertiary};
- `,
- container: css`
- cursor: pointer;
-
- padding-block: 4px;
- padding-inline: 6px;
- border-radius: 6px;
-
- font-size: 12px;
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
- `,
- extra: css`
- color: ${cssVar.colorTextSecondary};
- `,
-}));
-
-const Item = memo<ThreadItem>(({ id, title, lastActiveAt, sourceMessageId }) => {
- const { t } = useTranslation('chat');
- const openThreadInPortal = useChatStore((s) => s.openThreadInPortal);
- const [isActive, messageCount] = useChatStore((s) => [
- s.activeThreadId === id,
- chatSelectors.countMessagesByThreadId(id)(s),
- ]);
- const mobile = useIsMobile();
- return (
- <Flexbox
- horizontal
- align={'baseline'}
- className={cx(styles.container, isActive && styles.active)}
- gap={8}
- onClick={() => {
- if (isActive) return;
-
- openThreadInPortal(id, sourceMessageId);
- }}
- >
- {title}
- <Flexbox horizontal className={styles.extra}>
- {!!messageCount && t('thread.threadMessageCount', { messageCount })}
- {!mobile && ` · ${dayjs(lastActiveAt).format('YYYY-MM-DD')}`}
- <Icon icon={ChevronRight} />
- </Flexbox>
- </Flexbox>
- );
-});
-
-export default Item;
diff --git a/src/routes/(main)/group/features/Conversation/Header/Tags/MemberCountTag.tsx b/src/routes/(main)/group/features/Conversation/Header/Tags/MemberCountTag.tsx
deleted file mode 100644
index 68388f673fa..00000000000
--- a/src/routes/(main)/group/features/Conversation/Header/Tags/MemberCountTag.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import { Flexbox, Icon, Tag, Tooltip } from '@lobehub/ui';
-import { Users } from 'lucide-react';
-import { memo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { useConversationStore } from '@/features/Conversation';
-import { contextSelectors } from '@/features/Conversation/store';
-import { useAgentGroupStore } from '@/store/agentGroup';
-import { agentGroupSelectors } from '@/store/agentGroup/selectors';
-
-const MemberCountTag = memo(() => {
- const { t } = useTranslation('chat');
- const groupId = useConversationStore(contextSelectors.groupId);
- const currentGroupAgents = useAgentGroupStore((s) =>
- agentGroupSelectors.getGroupAgents(groupId ?? '')(s),
- );
-
- const memberCount = currentGroupAgents?.length ?? 0;
-
- if (memberCount <= 0) return null;
-
- return (
- <Tooltip title={t('group.memberTooltip', { count: memberCount })}>
- <Flexbox height={22}>
- <Tag>
- <Icon icon={Users} />
- <span>{memberCount}</span>
- </Tag>
- </Flexbox>
- </Tooltip>
- );
-});
-
-export default MemberCountTag;
diff --git a/src/routes/(main)/group/features/Portal/features/Body.tsx b/src/routes/(main)/group/features/Portal/features/Body.tsx
deleted file mode 100644
index a46080d035d..00000000000
--- a/src/routes/(main)/group/features/Portal/features/Body.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-'use client';
-
-import { Flexbox } from '@lobehub/ui';
-import { css, cx } from 'antd-style';
-import { type PropsWithChildren } from 'react';
-
-const body = css`
- :has(.portal-artifact) {
- overflow: hidden;
- padding-block-end: 12px;
- }
-`;
-
-const Body = ({ children }: PropsWithChildren) => {
- return (
- <Flexbox
- className={cx(body, 'portal-body')}
- height={'100%'}
- style={{ flex: 1, height: 0, position: 'relative' }}
- width={'100%'}
- >
- {children}
- </Flexbox>
- );
-};
-
-export default Body;
diff --git a/src/routes/(main)/group/profile/features/MemberProfile/MentionList/MentionDropdown.tsx b/src/routes/(main)/group/profile/features/MemberProfile/MentionList/MentionDropdown.tsx
deleted file mode 100644
index 2e2c1a91c85..00000000000
--- a/src/routes/(main)/group/profile/features/MemberProfile/MentionList/MentionDropdown.tsx
+++ /dev/null
@@ -1,122 +0,0 @@
-import { type MenuRenderProps } from '@lobehub/editor';
-import { Flexbox } from '@lobehub/ui';
-import { cssVar } from 'antd-style';
-import { type ReactNode } from 'react';
-import { memo, useEffect, useLayoutEffect, useRef, useState } from 'react';
-
-import { type MentionListOption } from './types';
-
-/**
- * Get cursor position from browser selection API
- */
-const getCursorPosition = (): { x: number; y: number } | null => {
- const selection = window.getSelection();
- if (!selection || selection.rangeCount === 0) return null;
-
- const range = selection.getRangeAt(0);
- const rect = range.getBoundingClientRect();
-
- return {
- x: rect.left,
- y: rect.bottom,
- };
-};
-
-const MentionDropdown = memo<MenuRenderProps>(
- ({ activeKey, onSelect, open, options, setActiveKey }) => {
- const activeItemRef = useRef<HTMLDivElement>(null);
- const [position, setPosition] = useState<{ x: number; y: number } | null>(null);
-
- // Capture cursor position when menu opens
- useLayoutEffect(() => {
- if (open) {
- const pos = getCursorPosition();
- if (pos) {
- setPosition(pos);
- }
- }
- }, [open]);
-
- useEffect(() => {
- if (activeItemRef.current) {
- activeItemRef.current.scrollIntoView({
- behavior: 'smooth',
- block: 'nearest',
- });
- }
- }, [activeKey]);
-
- if (!open || !options.length || !position) return null;
-
- return (
- <Flexbox
- style={{
- background: cssVar.colorBgElevated,
- border: `1px solid ${cssVar.colorBorderSecondary}`,
- borderRadius: 12,
- boxShadow: cssVar.boxShadowSecondary,
- left: position.x,
- maxHeight: 260,
- maxWidth: 400,
- minWidth: 150,
- overflow: 'hidden auto',
- position: 'fixed',
- top: position.y,
- zIndex: 9999,
- }}
- >
- {options.map((option) => {
- if ((option as any)?.type === 'divider') {
- return (
- <div
- key={`divider-${(option as any)?.key ?? 'divider'}`}
- style={{ borderTop: `1px solid ${cssVar.colorBorderSecondary}` }}
- />
- );
- }
-
- const item = option as MentionListOption;
- const isActive = activeKey === item.key;
-
- return (
- <Flexbox
- align="center"
- direction="horizontal"
- gap={8}
- key={String(item.key)}
- paddingBlock={8}
- paddingInline={12}
- ref={isActive ? activeItemRef : null}
- style={{
- background: isActive ? cssVar.colorFillSecondary : undefined,
- cursor: 'pointer',
- }}
- onMouseEnter={() => setActiveKey?.(String(item.key))}
- onMouseDown={(e) => {
- e.preventDefault();
- onSelect?.(item);
- }}
- >
- {item.icon && <Flexbox style={{ flex: 'none' }}>{item?.icon as ReactNode}</Flexbox>}
- <div
- style={{
- color: cssVar.colorText,
- fontSize: 14,
- overflow: 'hidden',
- textOverflow: 'ellipsis',
- whiteSpace: 'nowrap',
- }}
- >
- {item.label}
- </div>
- </Flexbox>
- );
- })}
- </Flexbox>
- );
- },
-);
-
-MentionDropdown.displayName = 'MentionDropdown';
-
-export default MentionDropdown;
diff --git a/src/routes/(main)/group/profile/features/MemberProfile/MentionList/index.tsx b/src/routes/(main)/group/profile/features/MemberProfile/MentionList/index.tsx
deleted file mode 100644
index 2749d93ebb1..00000000000
--- a/src/routes/(main)/group/profile/features/MemberProfile/MentionList/index.tsx
+++ /dev/null
@@ -1 +0,0 @@
-export { default as useMentionOptions } from './useMentionItems';
diff --git a/src/routes/(main)/group/profile/features/MemberProfile/MentionList/types.ts b/src/routes/(main)/group/profile/features/MemberProfile/MentionList/types.ts
deleted file mode 100644
index 2aa3f0cdc4c..00000000000
--- a/src/routes/(main)/group/profile/features/MemberProfile/MentionList/types.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { type API } from '@lobechat/prompts';
-import { type DropdownItem } from '@lobehub/ui';
-
-export type MentionEntityType = 'collection' | 'api';
-
-export interface MentionMetadata {
- apis?: API[];
- description?: string;
- identifier: string;
- instructions?: string;
- label?: string;
- pluginIdentifier?: string;
- pluginType?: string;
- type?: MentionEntityType;
-}
-
-type MentionMenuItem = Extract<DropdownItem, { type?: 'item' }>;
-
-export type MentionListOption = MentionMenuItem & {
- description?: string;
- metadata?: MentionMetadata;
-};
diff --git a/src/routes/(main)/group/profile/features/MemberProfile/MentionList/useMentionItems.tsx b/src/routes/(main)/group/profile/features/MemberProfile/MentionList/useMentionItems.tsx
deleted file mode 100644
index b68ffbe5906..00000000000
--- a/src/routes/(main)/group/profile/features/MemberProfile/MentionList/useMentionItems.tsx
+++ /dev/null
@@ -1,234 +0,0 @@
-import { type ComposioAppType } from '@lobechat/const';
-import { COMPOSIO_APP_TYPES } from '@lobechat/const';
-import { ToolNameResolver } from '@lobechat/context-engine';
-import { type API } from '@lobechat/prompts';
-import { apiPrompt, toolPrompt } from '@lobechat/prompts';
-import { type ToolManifest } from '@lobechat/types';
-import { type IEditor } from '@lobehub/editor';
-import { INSERT_MENTION_COMMAND } from '@lobehub/editor';
-import { Icon, Image } from '@lobehub/ui';
-import { cssVar } from 'antd-style';
-import isEqual from 'fast-deep-equal';
-import { memo, useCallback, useMemo } from 'react';
-
-import PluginAvatar from '@/components/Plugins/PluginAvatar';
-import { globalAgentContextManager } from '@/helpers/GlobalAgentContextManager';
-import { usePermission } from '@/hooks/usePermission';
-import { useAgentStore } from '@/store/agent';
-import { pluginHelpers, useToolStore } from '@/store/tool';
-import { toolSelectors } from '@/store/tool/selectors';
-import { hydrationPrompt } from '@/utils/promptTemplate';
-
-import MentionDropdown from './MentionDropdown';
-import { type MentionListOption, type MentionMetadata } from './types';
-
-// Get Composio server type config by identifier
-const getComposioAppType = (identifier: string) =>
- COMPOSIO_APP_TYPES.find((type) => type.identifier === identifier);
-
-/**
- * Composio server icon component
- * For string type icon, renders using Image component
- * For IconType type icon, renders using Icon component and sets fill color based on theme
- */
-const ComposioIcon = memo<Pick<ComposioAppType, 'icon' | 'label'>>(({ icon, label }) => {
- if (typeof icon === 'string') {
- return <Image alt={label} height={20} src={icon} style={{ flex: 'none' }} width={20} />;
- }
-
- // Fill with theme color, automatically adapts in dark mode
- return <Icon fill={cssVar.colorText} icon={icon} size={20} />;
-});
-
-const toolNameResolver = new ToolNameResolver();
-
-const buildApiList = (identifier: string, manifest?: ToolManifest): API[] => {
- if (!manifest?.api) return [];
-
- return manifest.api.map((api) => ({
- desc: api.description || '',
- name: toolNameResolver.generate(identifier, api.name, manifest.type),
- }));
-};
-
-const hydrateSystemRole = (systemRole?: string) => {
- if (!systemRole) return '';
-
- return hydrationPrompt(systemRole, globalAgentContextManager.getContext());
-};
-
-const resolveInstructions = (
- metadata: MentionMetadata,
- manifest?: ToolManifest,
- fallbackDesc?: string,
-) => {
- if (metadata.instructions) return metadata.instructions;
-
- if (manifest?.systemRole) return hydrateSystemRole(manifest.systemRole);
-
- return metadata.description || fallbackDesc || pluginHelpers.getPluginDesc(manifest?.meta) || '';
-};
-
-const resolveApiName = (
- metadata: MentionMetadata,
- manifest: ToolManifest | undefined,
- pluginId?: string,
- fallbackLabel?: string,
-) => {
- if (metadata.identifier) return metadata.identifier;
-
- const sourceId = pluginId || manifest?.identifier || '';
-
- if (metadata.label) {
- return toolNameResolver.generate(sourceId, metadata.label, manifest?.type);
- }
-
- const firstApi = manifest?.api?.[0]?.name;
-
- if (firstApi) {
- return toolNameResolver.generate(sourceId, firstApi, manifest?.type);
- }
-
- return fallbackLabel;
-};
-
-const resolveApiDescription = (
- metadata: MentionMetadata,
- manifest: ToolManifest | undefined,
- pluginId: string | undefined,
- apiName?: string,
-) => {
- if (metadata.description) return metadata.description;
-
- if (!manifest?.api?.length || !apiName) return '';
-
- const sourceId = pluginId || manifest.identifier;
- const matched = manifest.api.find((api) => {
- const fullName = toolNameResolver.generate(sourceId, api.name, manifest.type);
-
- return fullName === apiName || api.name === apiName;
- });
-
- return matched?.description || '';
-};
-
-const useMentionOptions = () => {
- const { allowed: canEdit } = usePermission('edit_own_content');
- const installedTools = useToolStore(toolSelectors.metaList, isEqual);
- const toggleAgentPlugin = useAgentStore((s) => s.toggleAgentPlugin);
-
- const baseItems = useMemo<MentionListOption[]>(() => {
- const state = useToolStore.getState();
-
- return installedTools.map((tool) => {
- const manifest = toolSelectors.getManifestById(tool.identifier)(state);
- const label = pluginHelpers.getPluginTitle(tool.meta) || tool.identifier;
- const description = pluginHelpers.getPluginDesc(tool.meta);
- const apis = buildApiList(manifest?.identifier || tool.identifier, manifest);
-
- const createMetadata = (): MentionMetadata => ({
- apis: apis.map((api) => ({ ...api })),
- description,
- identifier: tool.identifier,
- label,
- pluginType: manifest?.type,
- type: 'collection',
- });
-
- // Prefer Composio icon, fall back to PluginAvatar
- const composioServerType = getComposioAppType(tool.identifier);
- const icon = composioServerType ? (
- <ComposioIcon icon={composioServerType.icon} label={composioServerType.label} />
- ) : (
- <PluginAvatar alt={label} avatar={pluginHelpers.getPluginAvatar(tool.meta)} size={20} />
- );
-
- return {
- description,
- icon,
- key: tool.identifier,
- label,
- metadata: createMetadata(),
- onSelect: (editor: IEditor) => {
- if (!canEdit) return;
-
- toggleAgentPlugin(tool.identifier, true);
- editor.dispatchCommand(INSERT_MENTION_COMMAND, {
- label,
- metadata: createMetadata() as unknown as Record<string, unknown>,
- });
- },
- };
- });
- }, [canEdit, installedTools, toggleAgentPlugin]);
-
- const loadItems = useCallback(
- async (
- search: { leadOffset: number; matchingString: string; replaceableString: string } | null,
- ) => {
- const query = search?.matchingString?.toLowerCase() || '';
-
- if (!query) return baseItems;
-
- return baseItems.filter((item) => {
- const label = typeof item.label === 'string' ? item.label.toLowerCase() : '';
- const desc = item.description?.toLowerCase() || '';
- const key = typeof item.key === 'string' ? item.key.toLowerCase() : '';
-
- return label.includes(query) || desc.includes(query) || key.includes(query);
- });
- },
- [baseItems],
- );
-
- const mentionMarkdownWriter = useCallback((mention: any) => {
- const metadata = (mention?.metadata || {}) as MentionMetadata;
- const pluginId = metadata.pluginIdentifier || metadata.identifier;
- const state = useToolStore.getState();
- const manifest = pluginId ? toolSelectors.getManifestById(pluginId)(state) : undefined;
-
- if (metadata.type === 'api') {
- const apiName = resolveApiName(metadata, manifest, pluginId, mention?.label);
- const apiDescription = resolveApiDescription(metadata, manifest, pluginId, apiName);
-
- if (!apiName) return mention?.getTextContent?.() || '';
-
- return `\n${apiPrompt({ desc: apiDescription, name: apiName })}\n`;
- }
-
- const apis =
- metadata.apis?.length && metadata.apis.length > 0
- ? metadata.apis
- : buildApiList(pluginId || manifest?.identifier || '', manifest);
-
- const name =
- metadata.label ||
- pluginHelpers.getPluginTitle(manifest?.meta) ||
- pluginId ||
- mention?.label ||
- '';
-
- const instructions = resolveInstructions(metadata, manifest, metadata.description);
-
- const prompt = toolPrompt({
- apis: apis || [],
- identifier: pluginId || '',
- name,
- systemRole: instructions,
- });
-
- return `\n${prompt}\n`;
- }, []);
-
- return useMemo(
- () => ({
- fuseOptions: { keys: ['key', 'label', 'description'], threshold: 0.4 },
- items: loadItems,
- markdownWriter: mentionMarkdownWriter,
- renderComp: MentionDropdown,
- }),
- [loadItems, mentionMarkdownWriter],
- );
-};
-
-export default useMentionOptions;
diff --git a/src/routes/(main)/home/_layout/Body/Project/Actions.tsx b/src/routes/(main)/home/_layout/Body/Project/Actions.tsx
deleted file mode 100644
index 8a458e2e572..00000000000
--- a/src/routes/(main)/home/_layout/Body/Project/Actions.tsx
+++ /dev/null
@@ -1,13 +0,0 @@
-import { ActionIcon } from '@lobehub/ui';
-import { PlusIcon } from 'lucide-react';
-import { memo } from 'react';
-
-import { useProjectMenuItems } from '../../hooks';
-
-const Actions = memo(() => {
- const { createProject } = useProjectMenuItems();
-
- return <ActionIcon icon={PlusIcon} size={'small'} onClick={createProject} />;
-});
-
-export default Actions;
diff --git a/src/routes/(main)/home/_layout/Body/Project/List/Actions.tsx b/src/routes/(main)/home/_layout/Body/Project/List/Actions.tsx
deleted file mode 100644
index 95da4701f4d..00000000000
--- a/src/routes/(main)/home/_layout/Body/Project/List/Actions.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-import { type DropdownItem } from '@lobehub/ui';
-import { ActionIcon, DropdownMenu } from '@lobehub/ui';
-import { MoreHorizontalIcon } from 'lucide-react';
-import { memo } from 'react';
-
-interface ActionsProps {
- dropdownMenu: DropdownItem[] | (() => DropdownItem[]);
-}
-
-const Actions = memo<ActionsProps>(({ dropdownMenu }) => {
- return (
- <DropdownMenu items={dropdownMenu}>
- <ActionIcon icon={MoreHorizontalIcon} size={'small'} />
- </DropdownMenu>
- );
-});
-
-export default Actions;
diff --git a/src/routes/(main)/home/_layout/Body/Project/List/Editing.tsx b/src/routes/(main)/home/_layout/Body/Project/List/Editing.tsx
deleted file mode 100644
index f2abd086cb7..00000000000
--- a/src/routes/(main)/home/_layout/Body/Project/List/Editing.tsx
+++ /dev/null
@@ -1,63 +0,0 @@
-import { Input, Popover, stopPropagation } from '@lobehub/ui';
-import { memo, useCallback, useState } from 'react';
-
-import { useKnowledgeBaseStore } from '@/store/library';
-
-interface EditingProps {
- id: string;
- name: string;
- toggleEditing: (visible?: boolean) => void;
-}
-
-const Editing = memo<EditingProps>(({ id, name, toggleEditing }) => {
- const [newName, setNewName] = useState(name);
- const [editing, updateKnowledgeBase] = useKnowledgeBaseStore((s) => [
- s.knowledgeBaseRenamingId === id,
- s.updateKnowledgeBase,
- ]);
-
- const handleUpdate = useCallback(() => {
- if (newName && name !== newName) {
- updateKnowledgeBase(id, { name: newName });
- }
- toggleEditing(false);
- }, [newName, name, id, updateKnowledgeBase]);
-
- return (
- <Popover
- open={editing}
- placement="bottomLeft"
- trigger="click"
- content={
- <Input
- autoFocus
- defaultValue={name}
- onChange={(e) => setNewName(e.target.value)}
- onClick={stopPropagation}
- onBlur={() => {
- handleUpdate();
- toggleEditing(false);
- }}
- onPressEnter={() => {
- handleUpdate();
- toggleEditing(false);
- }}
- />
- }
- styles={{
- content: {
- padding: 4,
- width: 320,
- },
- }}
- onOpenChange={(open) => {
- if (!open) handleUpdate();
- toggleEditing(open);
- }}
- >
- <div />
- </Popover>
- );
-});
-
-export default Editing;
diff --git a/src/routes/(main)/home/_layout/Body/Project/List/Item.tsx b/src/routes/(main)/home/_layout/Body/Project/List/Item.tsx
deleted file mode 100644
index 409b7cdce0d..00000000000
--- a/src/routes/(main)/home/_layout/Body/Project/List/Item.tsx
+++ /dev/null
@@ -1,54 +0,0 @@
-import { BoxIcon } from 'lucide-react';
-import { memo, useCallback } from 'react';
-
-import NavItem from '@/features/NavPanel/components/NavItem';
-import { useKnowledgeBaseStore } from '@/store/library';
-
-import Actions from './Actions';
-import Editing from './Editing';
-import { useProjectItemDropdownMenu } from './useDropdownMenu';
-
-interface ProjectItemProps {
- id: string;
- name: string;
-}
-
-const ProjectItem = memo<ProjectItemProps>(({ id, name }) => {
- const [editing, isLoading, isUpdating] = useKnowledgeBaseStore((s) => [
- s.knowledgeBaseRenamingId === id,
- s.knowledgeBaseLoadingIds.includes(id),
- s.knowledgeBaseUpdatingId === id,
- ]);
-
- const toggleEditing = useCallback(
- (visible?: boolean) => {
- useKnowledgeBaseStore.setState(
- { knowledgeBaseRenamingId: visible ? id : null },
- false,
- 'toggleEditing',
- );
- },
- [id],
- );
-
- const dropdownMenu = useProjectItemDropdownMenu({
- id,
- toggleEditing,
- });
-
- return (
- <>
- <NavItem
- actions={<Actions dropdownMenu={dropdownMenu} />}
- contextMenuItems={dropdownMenu}
- disabled={editing || isUpdating}
- icon={BoxIcon}
- loading={isLoading || isUpdating}
- title={name}
- />
- <Editing id={id} name={name} toggleEditing={toggleEditing} />
- </>
- );
-});
-
-export default ProjectItem;
diff --git a/src/routes/(main)/home/_layout/Body/Project/List/index.tsx b/src/routes/(main)/home/_layout/Body/Project/List/index.tsx
deleted file mode 100644
index 13cacc83f51..00000000000
--- a/src/routes/(main)/home/_layout/Body/Project/List/index.tsx
+++ /dev/null
@@ -1,51 +0,0 @@
-'use client';
-
-import { Flexbox } from '@lobehub/ui';
-import { memo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { LIBRARY_URL } from '@/const/url';
-import EmptyNavItem from '@/features/NavPanel/components/EmptyNavItem';
-import SkeletonList from '@/features/NavPanel/components/SkeletonList';
-import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
-import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
-import { useKnowledgeBaseStore } from '@/store/library';
-
-import { useProjectMenuItems } from '../../../hooks';
-import Item from './Item';
-
-const ProjectList = memo(() => {
- const { t } = useTranslation('home');
- const navigate = useWorkspaceAwareNavigate();
- const useFetchKnowledgeBaseList = useKnowledgeBaseStore((s) => s.useFetchKnowledgeBaseList);
- const { data, isLoading } = useFetchKnowledgeBaseList();
- const { createProject } = useProjectMenuItems();
-
- if (!data || isLoading) return <SkeletonList />;
-
- const isEmpty = data.length === 0;
-
- if (isEmpty) {
- return <EmptyNavItem title={t('project.create')} onClick={createProject} />;
- }
-
- return (
- <Flexbox gap={1}>
- {data.map((item) => (
- <WorkspaceLink
- aria-label={item.id}
- key={item.id}
- to={LIBRARY_URL(item.id)}
- onClick={(e) => {
- e.preventDefault();
- navigate(LIBRARY_URL(item.id));
- }}
- >
- <Item {...item} key={item.id} />
- </WorkspaceLink>
- ))}
- </Flexbox>
- );
-});
-
-export default ProjectList;
diff --git a/src/routes/(main)/home/_layout/Body/Project/List/useDropdownMenu.tsx b/src/routes/(main)/home/_layout/Body/Project/List/useDropdownMenu.tsx
deleted file mode 100644
index 29e445bdff2..00000000000
--- a/src/routes/(main)/home/_layout/Body/Project/List/useDropdownMenu.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-import { type MenuProps } from '@lobehub/ui';
-import { Icon } from '@lobehub/ui';
-import { confirmModal } from '@lobehub/ui/base-ui';
-import { PencilLine, Trash } from 'lucide-react';
-import { useCallback } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { useKnowledgeBaseStore } from '@/store/library';
-
-interface ProjectItemDropdownMenuProps {
- id: string;
- toggleEditing: (visible?: boolean) => void;
-}
-
-export const useProjectItemDropdownMenu = ({
- id,
- toggleEditing,
-}: ProjectItemDropdownMenuProps): (() => MenuProps['items']) => {
- const { t } = useTranslation(['home', 'common']);
- const [removeKnowledgeBase] = useKnowledgeBaseStore((s) => [s.removeKnowledgeBase]);
-
- return useCallback(
- () => [
- {
- icon: <Icon icon={PencilLine} />,
- key: 'rename',
- label: t('rename', { ns: 'common' }),
- onClick: () => {
- toggleEditing(true);
- },
- },
- {
- type: 'divider',
- },
- {
- danger: true,
- icon: <Icon icon={Trash} />,
- key: 'delete',
- label: t('delete', { ns: 'common' }),
- onClick: () => {
- if (!id) return;
- confirmModal({
- cancelText: t('cancel', { ns: 'common' }),
- content: t('project.deleteConfirm'),
- okButtonProps: { danger: true },
- okText: t('delete', { ns: 'common' }),
- onOk: async () => {
- await removeKnowledgeBase(id);
- },
- title: t('delete', { ns: 'common' }),
- });
- },
- },
- ],
- [t, id, removeKnowledgeBase, toggleEditing],
- );
-};
diff --git a/src/routes/(main)/home/_layout/Body/Project/useDropdownMenu.tsx b/src/routes/(main)/home/_layout/Body/Project/useDropdownMenu.tsx
deleted file mode 100644
index 28984836a5a..00000000000
--- a/src/routes/(main)/home/_layout/Body/Project/useDropdownMenu.tsx
+++ /dev/null
@@ -1,12 +0,0 @@
-import { type MenuProps } from '@lobehub/ui';
-import { useMemo } from 'react';
-
-import { useProjectMenuItems } from '../../hooks';
-
-export const useProjectActionsDropdownMenu = (): MenuProps['items'] => {
- const { createProjectMenuItem } = useProjectMenuItems();
-
- return useMemo(() => {
- return [createProjectMenuItem()].filter(Boolean) as MenuProps['items'];
- }, [createProjectMenuItem]);
-};
diff --git a/src/routes/(main)/home/_layout/CreateGroupModal/AgentItem.tsx b/src/routes/(main)/home/_layout/CreateGroupModal/AgentItem.tsx
deleted file mode 100644
index 0318282cefb..00000000000
--- a/src/routes/(main)/home/_layout/CreateGroupModal/AgentItem.tsx
+++ /dev/null
@@ -1,123 +0,0 @@
-'use client';
-
-import { Avatar, Checkbox, Flexbox, stopPropagation, Text } from '@lobehub/ui';
-import { useHover } from 'ahooks';
-import { createStaticStyles } from 'antd-style';
-import { X } from 'lucide-react';
-import { memo, useRef } from 'react';
-
-import { DEFAULT_AVATAR } from '@/const/meta';
-
-import { useAgentSelectionStore } from './store';
-
-const styles = createStaticStyles(({ css, cssVar }) => ({
- item: css`
- cursor: pointer;
-
- margin-block: 1px;
- padding-block: 6px;
- padding-inline: 8px;
- border-radius: ${cssVar.borderRadius};
-
- transition: background 0.2s ease;
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
- `,
- removeButton: css`
- cursor: pointer;
-
- display: flex;
- align-items: center;
- justify-content: center;
-
- width: 20px;
- height: 20px;
- border-radius: 4px;
-
- color: ${cssVar.colorTextTertiary};
-
- transition: all 0.2s ease;
-
- &:hover {
- color: ${cssVar.colorText};
- background: ${cssVar.colorFillSecondary};
- }
- `,
- title: css`
- overflow: hidden;
- flex: 1;
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
-}));
-
-export interface AgentItemData {
- avatar: string | null;
- backgroundColor: string | null;
- description: string | null;
- id: string;
- title: string | null;
-}
-
-interface AgentItemProps {
- agent: AgentItemData;
- defaultTitle: string;
- showCheckbox?: boolean;
- showRemove?: boolean;
-}
-
-const AgentItem = memo<AgentItemProps>(({ agent, defaultTitle, showCheckbox, showRemove }) => {
- const ref = useRef(null);
- const isHovering = useHover(ref);
-
- const isSelected = useAgentSelectionStore((s) => s.selectedAgentIds.includes(agent.id));
- const toggleAgent = useAgentSelectionStore((s) => s.toggleAgent);
- const removeAgent = useAgentSelectionStore((s) => s.removeAgent);
-
- const title = agent.title || defaultTitle;
- const avatar = agent.avatar || DEFAULT_AVATAR;
- const avatarBackground = agent.backgroundColor ?? undefined;
-
- const handleClick = () => {
- toggleAgent(agent.id);
- };
-
- const handleRemove = (e: { stopPropagation: () => void }) => {
- e.stopPropagation();
- removeAgent(agent.id);
- };
-
- return (
- <div
- className={styles.item}
- ref={ref}
- style={{ cursor: showCheckbox ? 'pointer' : 'default' }}
- onClick={showCheckbox ? handleClick : undefined}
- >
- <Flexbox horizontal align="center" gap={8} width="100%">
- {showCheckbox && (
- <Checkbox checked={isSelected} onChange={handleClick} onClick={stopPropagation} />
- )}
- <Avatar
- emojiScaleWithBackground
- animation={isHovering}
- avatar={avatar}
- background={avatarBackground}
- size={28}
- />
- <Text ellipsis className={styles.title}>
- {title}
- </Text>
- {showRemove && (
- <div className={styles.removeButton} onClick={handleRemove}>
- <X size={14} />
- </div>
- )}
- </Flexbox>
- </div>
- );
-});
-
-export default AgentItem;
diff --git a/src/routes/(main)/home/_layout/CreateGroupModal/AvailableAgentList.tsx b/src/routes/(main)/home/_layout/CreateGroupModal/AvailableAgentList.tsx
deleted file mode 100644
index 041441d325a..00000000000
--- a/src/routes/(main)/home/_layout/CreateGroupModal/AvailableAgentList.tsx
+++ /dev/null
@@ -1,155 +0,0 @@
-'use client';
-
-import { Flexbox, SearchBar, Skeleton, Text } from '@lobehub/ui';
-import { createStaticStyles } from 'antd-style';
-import isEqual from 'fast-deep-equal';
-import { type ChangeEvent } from 'react';
-import { memo, useCallback, useMemo, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-import { Virtuoso } from 'react-virtuoso';
-
-import AgentSelectionEmpty from '@/features/AgentSelectionEmpty';
-import { useHomeStore } from '@/store/home';
-import { homeAgentListSelectors } from '@/store/home/selectors';
-
-import { type AgentItemData } from './AgentItem';
-import AgentItem from './AgentItem';
-
-type Row = { agent: AgentItemData; type: 'agent' } | { label: string; type: 'header' };
-
-const styles = createStaticStyles(({ css, cssVar }) => ({
- container: css`
- user-select: none;
-
- overflow: hidden;
- display: flex;
- flex: 1;
- flex-direction: column;
-
- padding-block: ${cssVar.paddingSM}px 0;
- padding-inline: ${cssVar.paddingSM}px;
- border-inline-end: 1px solid ${cssVar.colorBorderSecondary};
- `,
- sectionHeader: css`
- padding-block: 6px 4px;
- padding-inline: 8px;
- color: ${cssVar.colorTextSecondary};
- `,
-}));
-
-interface AvailableAgentListProps {
- agents: AgentItemData[];
- isLoading: boolean;
-}
-
-const AvailableAgentList = memo<AvailableAgentListProps>(({ agents, isLoading }) => {
- const { t } = useTranslation(['chat', 'common']);
- const [searchTerm, setSearchTerm] = useState('');
-
- const defaultTitle = useMemo(() => t('defaultSession', { ns: 'common' }), [t]);
-
- // Pull the home store's already-bucketed private agent lists. We can't
- // refetch with `visibility` from the modal's `queryAgents` payload without
- // changing the shared `AvailableAgentItem` contract, so derive a Set of
- // private agent ids client-side and use it to split the modal's list.
- const privateGroups = useHomeStore(homeAgentListSelectors.privateAgentGroups, isEqual);
- const privateUngrouped = useHomeStore(homeAgentListSelectors.privateUngroupedAgents, isEqual);
- const privateAgentIds = useMemo(() => {
- const ids = new Set<string>();
- for (const g of privateGroups) for (const a of g.items) ids.add(a.id);
- for (const a of privateUngrouped) ids.add(a.id);
- return ids;
- }, [privateGroups, privateUngrouped]);
-
- const handleSearchChange = useCallback((e: ChangeEvent<HTMLInputElement>) => {
- setSearchTerm(e.target.value);
- }, []);
-
- // Filter agents based on search term (matches title or description)
- const filteredAgents = useMemo(() => {
- if (!searchTerm.trim()) return agents;
-
- const searchLower = searchTerm.toLowerCase();
- return agents.filter((agent) => {
- const title = agent.title || '';
- const description = agent.description || '';
- return (
- title.toLowerCase().includes(searchLower) || description.toLowerCase().includes(searchLower)
- );
- });
- }, [agents, searchTerm]);
-
- const rows = useMemo<Row[]>(() => {
- const privateList: AgentItemData[] = [];
- const workspaceList: AgentItemData[] = [];
- for (const agent of filteredAgents) {
- (privateAgentIds.has(agent.id) ? privateList : workspaceList).push(agent);
- }
-
- // Only insert the bucket headers when both buckets are non-empty — a list
- // that's entirely workspace (or entirely private) should read as a flat
- // list without unnecessary visual chrome.
- if (privateList.length === 0 || workspaceList.length === 0) {
- return filteredAgents.map((agent) => ({ agent, type: 'agent' }));
- }
-
- return [
- { label: t('mention.category.privateAgents', { ns: 'chat' }), type: 'header' },
- ...privateList.map((agent) => ({ agent, type: 'agent' as const })),
- { label: t('mention.category.workspaceAgents', { ns: 'chat' }), type: 'header' },
- ...workspaceList.map((agent) => ({ agent, type: 'agent' as const })),
- ];
- }, [filteredAgents, privateAgentIds, t]);
-
- return (
- <Flexbox className={styles.container} gap={12}>
- <SearchBar
- allowClear
- placeholder={t('sessionGroup.searchAgents')}
- value={searchTerm}
- variant="filled"
- onChange={handleSearchChange}
- />
-
- <Flexbox flex={1} style={{ minHeight: 0 }}>
- {isLoading ? (
- <Flexbox gap={8} padding={8}>
- <Skeleton active paragraph={{ rows: 1 }} title={false} />
- <Skeleton active paragraph={{ rows: 1 }} title={false} />
- <Skeleton active paragraph={{ rows: 1 }} title={false} />
- </Flexbox>
- ) : filteredAgents.length === 0 ? (
- <AgentSelectionEmpty
- search={Boolean(searchTerm)}
- variant={searchTerm ? 'empty' : 'noAvailable'}
- />
- ) : (
- <Virtuoso
- style={{ flex: 1 }}
- totalCount={rows.length}
- itemContent={(index) => {
- const row = rows[index];
- if (row.type === 'header') {
- return (
- <Text className={styles.sectionHeader} fontSize={12} type="secondary">
- {row.label}
- </Text>
- );
- }
- return (
- <AgentItem
- showCheckbox
- agent={row.agent}
- defaultTitle={defaultTitle}
- key={row.agent.id}
- />
- );
- }}
- />
- )}
- </Flexbox>
- </Flexbox>
- );
-});
-
-export default AvailableAgentList;
diff --git a/src/routes/(main)/home/_layout/CreateGroupModal/SelectedAgentList.tsx b/src/routes/(main)/home/_layout/CreateGroupModal/SelectedAgentList.tsx
deleted file mode 100644
index 29e570a3129..00000000000
--- a/src/routes/(main)/home/_layout/CreateGroupModal/SelectedAgentList.tsx
+++ /dev/null
@@ -1,79 +0,0 @@
-'use client';
-
-import { Flexbox, Input } from '@lobehub/ui';
-import { createStaticStyles } from 'antd-style';
-import { memo, useMemo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import AgentSelectionEmpty from '@/features/AgentSelectionEmpty';
-
-import { type AgentItemData } from './AgentItem';
-import AgentItem from './AgentItem';
-import { useAgentSelectionStore } from './store';
-
-const styles = createStaticStyles(({ css, cssVar }) => ({
- container: css`
- overflow-y: auto;
- flex: 1;
- padding: ${cssVar.paddingSM}px;
- `,
- title: css`
- font-size: 12px;
- font-weight: 500;
- color: ${cssVar.colorTextSecondary};
- `,
-}));
-
-interface SelectedAgentListProps {
- agents: AgentItemData[];
- groupName: string;
- onGroupNameChange: (name: string) => void;
-}
-
-const SelectedAgentList = memo<SelectedAgentListProps>(
- ({ agents, groupName, onGroupNameChange }) => {
- const { t } = useTranslation(['chat', 'common']);
-
- const selectedAgentIds = useAgentSelectionStore((s) => s.selectedAgentIds);
-
- const defaultTitle = useMemo(() => t('defaultSession', { ns: 'common' }), [t]);
-
- // Get selected agents data
- const selectedAgents = useMemo(() => {
- return selectedAgentIds
- .map((id) => agents.find((a) => a.id === id))
- .filter((a): a is AgentItemData => a !== undefined);
- }, [agents, selectedAgentIds]);
-
- return (
- <Flexbox className={styles.container} gap={12}>
- <Flexbox gap={4}>
- <div className={styles.title}>{t('sessionGroup.groupName')}</div>
- <Input
- autoFocus
- placeholder={t('sessionGroup.inputPlaceholder')}
- value={groupName}
- onChange={(e) => onGroupNameChange(e.target.value)}
- />
- </Flexbox>
-
- <Flexbox flex={1} gap={4}>
- <div className={styles.title}>
- {t('sessionGroup.selectedAgents', { count: selectedAgents.length })}
- </div>
- {selectedAgents.length === 0 ? (
- <AgentSelectionEmpty variant="noSelected" />
- ) : (
- <Flexbox>
- {selectedAgents.map((agent) => (
- <AgentItem showRemove agent={agent} defaultTitle={defaultTitle} key={agent.id} />
- ))}
- </Flexbox>
- )}
- </Flexbox>
- </Flexbox>
- );
- },
-);
-
-export default SelectedAgentList;
diff --git a/src/routes/(main)/home/_layout/CreateGroupModal/store.ts b/src/routes/(main)/home/_layout/CreateGroupModal/store.ts
deleted file mode 100644
index 200bd807867..00000000000
--- a/src/routes/(main)/home/_layout/CreateGroupModal/store.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-import { create } from 'zustand';
-
-interface AgentSelectionState {
- // Actions
- clearSelection: () => void;
- isSelected: (agentId: string) => boolean;
- removeAgent: (agentId: string) => void;
- // State
- selectedAgentIds: string[];
- setSelectedAgents: (agentIds: string[]) => void;
- toggleAgent: (agentId: string) => void;
-}
-
-export const useAgentSelectionStore = create<AgentSelectionState>((set, get) => ({
- clearSelection: () => {
- set({ selectedAgentIds: [] });
- },
-
- isSelected: (agentId) => {
- return get().selectedAgentIds.includes(agentId);
- },
-
- removeAgent: (agentId) => {
- set((state) => ({
- selectedAgentIds: state.selectedAgentIds.filter((id) => id !== agentId),
- }));
- },
-
- selectedAgentIds: [],
-
- setSelectedAgents: (agentIds) => {
- set({ selectedAgentIds: agentIds });
- },
-
- toggleAgent: (agentId) => {
- set((state) => {
- const isCurrentlySelected = state.selectedAgentIds.includes(agentId);
- if (isCurrentlySelected) {
- return { selectedAgentIds: state.selectedAgentIds.filter((id) => id !== agentId) };
- } else {
- return { selectedAgentIds: [...state.selectedAgentIds, agentId] };
- }
- });
- },
-}));
diff --git a/src/routes/(main)/home/features/FeaturedPlugins/Item.tsx b/src/routes/(main)/home/features/FeaturedPlugins/Item.tsx
deleted file mode 100644
index a074f5c4134..00000000000
--- a/src/routes/(main)/home/features/FeaturedPlugins/Item.tsx
+++ /dev/null
@@ -1,58 +0,0 @@
-import { Avatar, Block, Flexbox, Text } from '@lobehub/ui';
-import { cssVar } from 'antd-style';
-import { memo } from 'react';
-
-import MetaInfo from '@/routes/(main)/community/(list)/mcp/features/List/MetaInfo';
-import { RECENT_BLOCK_SIZE } from '@/routes/(main)/home/features/const';
-import { type DiscoverMcpItem } from '@/types/discover';
-
-const FeaturedPluginItem = memo<DiscoverMcpItem>(({ name, icon, github, installCount }) => {
- return (
- <Block
- clickable
- horizontal
- flex={'none'}
- gap={12}
- height={RECENT_BLOCK_SIZE.PLUGIN.HEIGHT}
- padding={12}
- variant={'outlined'}
- style={{
- borderRadius: cssVar.borderRadiusLG,
- overflow: 'hidden',
- width: '100%',
- }}
- >
- {/* Left side - Icon */}
- <Avatar
- emojiScaleWithBackground
- avatar={icon}
- shape={'square'}
- size={40}
- style={{
- background: 'transparent',
- flex: 'none',
- }}
- />
-
- {/* Right side - Content */}
- <Flexbox flex={1} gap={2} style={{ minWidth: 0 }}>
- {/* Title and Tags */}
- <Flexbox horizontal align={'center'} gap={8}>
- <Text ellipsis fontSize={13} weight={500}>
- {name}
- </Text>
- </Flexbox>
- <MetaInfo
- installCount={installCount}
- stars={github?.stars}
- style={{
- color: cssVar.colorTextDescription,
- fontSize: 12,
- }}
- />
- </Flexbox>
- </Block>
- );
-});
-
-export default FeaturedPluginItem;
diff --git a/src/routes/(main)/home/features/FeaturedPlugins/List.tsx b/src/routes/(main)/home/features/FeaturedPlugins/List.tsx
deleted file mode 100644
index 5c77c288ab1..00000000000
--- a/src/routes/(main)/home/features/FeaturedPlugins/List.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-'use client';
-
-import { memo } from 'react';
-import { Link } from 'react-router';
-import urlJoin from 'url-join';
-
-import GroupSkeleton from '@/routes/(main)/home/features/components/GroupSkeleton';
-import { RECENT_BLOCK_SIZE } from '@/routes/(main)/home/features/const';
-import { useDiscoverStore } from '@/store/discover';
-
-import FeaturedPluginItem from './Item';
-
-const FeaturedPluginsList = memo(() => {
- const useMcpList = useDiscoverStore((s) => s.useFetchMcpList);
-
- const { data: mcpList, isLoading } = useMcpList({
- page: 1,
- pageSize: 8,
- });
-
- // Loading state
- if (isLoading) {
- return (
- <GroupSkeleton
- height={RECENT_BLOCK_SIZE.PLUGIN.HEIGHT}
- rows={8}
- width={RECENT_BLOCK_SIZE.PLUGIN.WIDTH}
- />
- );
- }
-
- if (!mcpList || mcpList.items.length === 0) {
- return null;
- }
-
- return mcpList.items.map((item, index) => (
- <Link
- key={index}
- to={urlJoin('/community/mcp', item.identifier)}
- style={{
- color: 'inherit',
- textDecoration: 'none',
- }}
- >
- <FeaturedPluginItem {...item} />
- </Link>
- ));
-});
-
-export default FeaturedPluginsList;
diff --git a/src/routes/(main)/home/features/components/GroupSkeleton.tsx b/src/routes/(main)/home/features/components/GroupSkeleton.tsx
deleted file mode 100644
index 477f90d69de..00000000000
--- a/src/routes/(main)/home/features/components/GroupSkeleton.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-'use client';
-
-import { Skeleton } from '@lobehub/ui';
-import { cssVar } from 'antd-style';
-import { memo } from 'react';
-
-export const GroupSkeleton = memo<{
- height?: number | string;
- rows?: number;
- width?: number | string;
-}>(({ rows = 12, width, height }) => {
- return Array.from({ length: rows }).map((_, i) => (
- <Skeleton.Button
- active
- key={i}
- size={'large'}
- style={{
- borderRadius: cssVar.borderRadiusLG,
- height,
- maxHeight: height,
- maxWidth: width,
- minWidth: width,
- opacity: 0.5,
- }}
- />
- ));
-});
-
-export default GroupSkeleton;
diff --git a/src/routes/(main)/home/features/const.ts b/src/routes/(main)/home/features/const.ts
deleted file mode 100644
index 0dca5656d1e..00000000000
--- a/src/routes/(main)/home/features/const.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-export const RECENT_BLOCK_SIZE = {
- AGENT: {
- HEIGHT: 160,
- WIDTH: 200,
- },
- PAGE: {
- HEIGHT: 200,
- WIDTH: 200,
- },
- PLUGIN: {
- HEIGHT: 68,
- WIDTH: '100%',
- },
- RESOURCE: {
- HEIGHT: 216,
- WIDTH: 240,
- },
- TOPIC: {
- HEIGHT: 144,
- WIDTH: 144,
- },
-} as const;
diff --git a/src/routes/(main)/resource/features/modal/FileDetail.tsx b/src/routes/(main)/resource/features/modal/FileDetail.tsx
deleted file mode 100644
index e80894b49af..00000000000
--- a/src/routes/(main)/resource/features/modal/FileDetail.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-'use client';
-
-import { memo } from 'react';
-
-import FileNotFound from '@/features/FileNotFound';
-import { fileManagerSelectors, useFileStore } from '@/store/file';
-
-import Detail from '../FileDetail';
-
-const FileDetail = memo<{ id: string }>(({ id }) => {
- const file = useFileStore(fileManagerSelectors.getFileById(id));
-
- // Absent from the scoped list = deleted or access revoked (e.g. switched
- // back to private) — show the terminal card instead of a blank pane.
- if (!file) return <FileNotFound />;
-
- return <Detail {...file} />;
-});
-export default FileDetail;
diff --git a/src/routes/(main)/resource/features/modal/FilePreview.tsx b/src/routes/(main)/resource/features/modal/FilePreview.tsx
deleted file mode 100644
index 62a87219dd6..00000000000
--- a/src/routes/(main)/resource/features/modal/FilePreview.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-'use client';
-
-import { memo } from 'react';
-
-import FileNotFound from '@/features/FileNotFound';
-import FileViewer from '@/features/FileViewer';
-import { fileManagerSelectors, useFileStore } from '@/store/file';
-
-const FilePreview = memo<{ id: string }>(({ id }) => {
- const file = useFileStore(fileManagerSelectors.getFileById(id));
-
- // Absent from the scoped list = deleted or access revoked (e.g. switched
- // back to private) — show the terminal card instead of a blank pane.
- if (!file) return <FileNotFound />;
-
- return <FileViewer {...file} />;
-});
-
-export default FilePreview;
diff --git a/src/routes/(main)/resource/features/modal/FullscreenModal.tsx b/src/routes/(main)/resource/features/modal/FullscreenModal.tsx
deleted file mode 100644
index 036ed9350ee..00000000000
--- a/src/routes/(main)/resource/features/modal/FullscreenModal.tsx
+++ /dev/null
@@ -1,86 +0,0 @@
-'use client';
-
-import { ConfigProvider } from 'antd';
-import { createStaticStyles, cx } from 'antd-style';
-import { type ReactNode } from 'react';
-import { useCallback, useState } from 'react';
-
-import ImperativeModal from '@/components/ImperativeModal';
-
-const styles = createStaticStyles(({ css, cssVar }) => ({
- body: css`
- height: 100%;
- max-height: calc(100dvh - 56px) !important;
- `,
- content: css`
- height: 100%;
- border: none !important;
- background: transparent !important;
- `,
- extra: css`
- position: fixed;
- z-index: ${cssVar.zIndexPopupBase + 10};
- inset-block: 0;
- inset-inline-end: 0;
-
- width: 0;
- border-inline-start: 1px solid ${cssVar.colorSplit};
-
- background: ${cssVar.colorBgLayout};
- `,
- header: css`
- background: transparent !important;
- `,
- modal: css`
- position: relative;
- inset-block-start: 0;
-
- width: 100vw !important;
- max-width: none;
- height: 100%;
- margin: 0;
- padding-block-end: 0;
-
- > div {
- height: 100%;
- }
- `,
- modal_withDetail: css`
- width: calc(100vw) !important;
- `,
-}));
-
-interface FullscreenModalProps {
- children: ReactNode;
- detail?: ReactNode;
- onClose?: () => void;
-}
-
-const FullscreenModal = ({ children, detail, onClose }: FullscreenModalProps) => {
- const [open, setOpen] = useState(true);
- const showDetail = !!detail;
-
- const handleCancel = useCallback(() => {
- setOpen(false);
- onClose?.();
- }, [onClose]);
-
- return (
- <>
- <ConfigProvider theme={{ token: { motion: false } }}>
- <ImperativeModal
- className={cx(styles.modal, showDetail && styles.modal_withDetail)}
- classNames={{ body: styles.body, header: styles.header, wrapper: styles.content }}
- footer={false}
- open={open}
- width={'auto'}
- onCancel={handleCancel}
- >
- {children}
- </ImperativeModal>
- </ConfigProvider>
- {!!detail && <div className={styles.extra}>{detail}</div>}
- </>
- );
-};
-export default FullscreenModal;
diff --git a/src/routes/(main)/settings/agent/features/SystemAgentForm.tsx b/src/routes/(main)/settings/agent/features/SystemAgentForm.tsx
deleted file mode 100644
index 30eb3b71cd6..00000000000
--- a/src/routes/(main)/settings/agent/features/SystemAgentForm.tsx
+++ /dev/null
@@ -1,129 +0,0 @@
-'use client';
-
-import { type FormGroupItemType, type FormItemProps } from '@lobehub/ui';
-import { Flexbox, Form, Icon, Skeleton } from '@lobehub/ui';
-import { Button, Switch } from '@lobehub/ui/base-ui';
-import { Form as AntForm } from 'antd';
-import isEqual from 'fast-deep-equal';
-import { Loader2Icon, PencilIcon } from 'lucide-react';
-import { memo, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import TextArea from '@/components/TextArea';
-import { FORM_STYLE } from '@/const/layoutTokens';
-import ModelSelect from '@/features/ModelSelect';
-import { useUserStore } from '@/store/user';
-import { settingsSelectors } from '@/store/user/selectors';
-import { type UserSystemAgentConfigKey } from '@/types/user/settings';
-
-interface SystemAgentFormProps {
- allowCustomPrompt?: boolean;
- allowDisable?: boolean;
- defaultPrompt?: string;
- systemAgentKey: UserSystemAgentConfigKey;
-}
-
-const SystemAgentForm = memo(
- ({ systemAgentKey, allowDisable, allowCustomPrompt, defaultPrompt }: SystemAgentFormProps) => {
- const { t } = useTranslation('setting');
- const [form] = AntForm.useForm();
- const settings = useUserStore(settingsSelectors.currentSystemAgent, isEqual);
- const [updateSystemAgent, isUserStateInit] = useUserStore((s) => [
- s.updateSystemAgent,
- s.isUserStateInit,
- ]);
- const [loading, setLoading] = useState(false);
-
- if (!isUserStateInit) return <Skeleton active paragraph={{ rows: 5 }} title={false} />;
-
- const value = settings[systemAgentKey];
-
- const systemAgentSettings: FormGroupItemType = {
- children: [
- {
- children: (
- <ModelSelect
- showAbility={false}
- // value={value}
- onChange={async (props) => {
- setLoading(true);
- await updateSystemAgent(systemAgentKey, props);
- setLoading(false);
- }}
- />
- ),
- desc: t(`systemAgent.${systemAgentKey}.modelDesc`),
- label: t(`systemAgent.${systemAgentKey}.label`),
- name: systemAgentKey,
- },
- (!!allowCustomPrompt && {
- children: !!value.customPrompt ? (
- <TextArea
- placeholder={t('systemAgent.customPrompt.placeholder')}
- style={{ minHeight: 160 }}
- value={value.customPrompt}
- onBlur={async (e) => {
- setLoading(true);
- await updateSystemAgent(systemAgentKey, { customPrompt: e.target.value });
- setLoading(false);
- }}
- />
- ) : (
- <Button
- block
- icon={PencilIcon}
- onClick={async () => {
- setLoading(true);
- await updateSystemAgent(systemAgentKey, { customPrompt: defaultPrompt });
- setLoading(false);
- }}
- >
- {t('systemAgent.customPrompt.addPrompt')}
- </Button>
- ),
- desc: t('systemAgent.customPrompt.desc'),
- label: t('systemAgent.customPrompt.title'),
- name: [systemAgentKey, 'customPrompt'],
- }) as FormItemProps,
- ].filter(Boolean),
- extra: (
- <Flexbox direction="horizontal" gap={8}>
- {loading && <Icon spin icon={Loader2Icon} size={16} style={{ opacity: 0.5 }} />}
- {allowDisable && (
- <Switch
- value={value.enabled}
- onChange={async (enabled) => {
- setLoading(true);
- await updateSystemAgent(systemAgentKey, { enabled });
- setLoading(false);
- }}
- />
- )}
- </Flexbox>
- ),
- title: (
- <span
- style={{
- opacity: typeof value.enabled === 'boolean' && !value.enabled ? 0.45 : 1,
- }}
- >
- {t(`systemAgent.${systemAgentKey}.title`)}
- </span>
- ),
- };
-
- return (
- <Form
- collapsible={false}
- form={form}
- initialValues={settings}
- items={[systemAgentSettings]}
- itemsType={'group'}
- variant={'filled'}
- {...FORM_STYLE}
- />
- );
- },
-);
-
-export default SystemAgentForm;
diff --git a/src/routes/(main)/settings/creds/features/CredDisplay.tsx b/src/routes/(main)/settings/creds/features/CredDisplay.tsx
deleted file mode 100644
index 154af04387c..00000000000
--- a/src/routes/(main)/settings/creds/features/CredDisplay.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-'use client';
-
-import { type UserCredSummary } from '@lobechat/types';
-import { Flexbox } from '@lobehub/ui';
-import { Typography } from 'antd';
-import { createStaticStyles } from 'antd-style';
-import { type FC } from 'react';
-
-const styles = createStaticStyles(({ css }) => ({
- container: css`
- display: inline-flex;
- gap: 4px;
- align-items: center;
- `,
- value: css`
- font-family: monospace;
- font-size: 12px;
- `,
-}));
-
-interface CredDisplayProps {
- cred: UserCredSummary;
-}
-
-const CredDisplay: FC<CredDisplayProps> = ({ cred }) => {
- // For OAuth type, show username
- if (cred.type === 'oauth') {
- return (
- <span className={styles.value}>
- {cred.oauthUsername ? `@${cred.oauthUsername}` : cred.oauthProvider || '-'}
- </span>
- );
- }
-
- // For file type, show filename
- if (cred.type === 'file') {
- return (
- <Flexbox className={styles.container}>
- <span className={styles.value}>{cred.fileName || '-'}</span>
- {cred.fileSize && (
- <Typography.Text type="secondary">
- ({(cred.fileSize / 1024).toFixed(1)} KB)
- </Typography.Text>
- )}
- </Flexbox>
- );
- }
-
- // For KV types, show masked preview
- return (
- <Flexbox className={styles.container}>
- <span className={styles.value}>{cred.maskedPreview || '-'}</span>
- </Flexbox>
- );
-};
-
-export default CredDisplay;
diff --git a/src/routes/(mobile)/chat/features/Topic/features/AgentConfig/Header/Avatar.tsx b/src/routes/(mobile)/chat/features/Topic/features/AgentConfig/Header/Avatar.tsx
deleted file mode 100644
index 87db67f379d..00000000000
--- a/src/routes/(mobile)/chat/features/Topic/features/AgentConfig/Header/Avatar.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-'use client';
-
-import { Avatar, Block } from '@lobehub/ui';
-import { memo } from 'react';
-
-import { useOpenChatSettings } from '@/hooks/useInterceptingRoutes';
-import { useAgentStore } from '@/store/agent';
-import { agentSelectors } from '@/store/agent/selectors';
-
-const HeaderAvatar = memo(() => {
- const [avatar, backgroundColor] = useAgentStore((s) => [
- agentSelectors.currentAgentAvatar(s),
- agentSelectors.currentAgentBackgroundColor(s),
- ]);
-
- const openChatSettings = useOpenChatSettings();
-
- return (
- <Block
- clickable
- flex={'none'}
- height={32}
- padding={2}
- variant={'borderless'}
- width={32}
- style={{
- overflow: 'hidden',
- }}
- onClick={(e) => {
- e.stopPropagation();
- openChatSettings();
- }}
- >
- <Avatar avatar={avatar} background={backgroundColor} size={28} />
- </Block>
- );
-});
-
-export default HeaderAvatar;
diff --git a/src/routes/(mobile)/chat/features/Topic/features/AgentConfig/Header/index.tsx b/src/routes/(mobile)/chat/features/Topic/features/AgentConfig/Header/index.tsx
deleted file mode 100644
index ea6f020325a..00000000000
--- a/src/routes/(mobile)/chat/features/Topic/features/AgentConfig/Header/index.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-'use client';
-
-import { Flexbox, Text } from '@lobehub/ui';
-import { memo } from 'react';
-
-import { useAgentStore } from '@/store/agent';
-import { agentSelectors, builtinAgentSelectors } from '@/store/agent/selectors';
-
-import Avatar from './Avatar';
-
-const HeaderInfo = memo(() => {
- const isInbox = useAgentStore(builtinAgentSelectors.isInboxAgent);
- const title = useAgentStore(agentSelectors.currentAgentTitle);
-
- const displayTitle = isInbox ? 'Lobe AI' : title;
-
- return (
- <Flexbox
- horizontal
- align={'center'}
- flex={1}
- gap={8}
- style={{
- overflow: 'hidden',
- }}
- >
- <Avatar />
- <Text ellipsis weight={500}>
- {displayTitle}
- </Text>
- </Flexbox>
- );
-});
-
-export default HeaderInfo;
diff --git a/src/routes/(mobile)/chat/features/Topic/features/AgentConfig/SystemRole.tsx b/src/routes/(mobile)/chat/features/Topic/features/AgentConfig/SystemRole.tsx
deleted file mode 100644
index b00e2cdb28a..00000000000
--- a/src/routes/(mobile)/chat/features/Topic/features/AgentConfig/SystemRole.tsx
+++ /dev/null
@@ -1,112 +0,0 @@
-'use client';
-
-import { Flexbox, Skeleton } from '@lobehub/ui';
-import { EditableMessage } from '@lobehub/ui/chat';
-import { createStaticStyles } from 'antd-style';
-import { type MouseEvent } from 'react';
-import { memo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import AgentInfo from '@/features/AgentInfo';
-import { useOpenChatSettings } from '@/hooks/useInterceptingRoutes';
-import { usePermission } from '@/hooks/usePermission';
-import { useAgentStore } from '@/store/agent';
-import { agentSelectors } from '@/store/agent/selectors';
-import { ChatSettingsTabs } from '@/store/global/initialState';
-
-export const styles = createStaticStyles(({ css, cssVar }) => ({
- prompt: css`
- opacity: 0.75;
- transition: opacity 200ms ${cssVar.motionEaseOut};
-
- &:hover {
- opacity: 1;
- }
- `,
-}));
-
-interface SystemRoleProps {
- editing: boolean;
- isLoading: boolean;
- open: boolean;
- setEditing: (value: boolean) => void;
- setOpen: (value: boolean) => void;
-}
-
-const SystemRole = memo(({ editing, setEditing, open, setOpen, isLoading }: SystemRoleProps) => {
- const openChatSettings = useOpenChatSettings(ChatSettingsTabs.Prompt);
- const { t } = useTranslation('common');
- const { allowed: canEdit } = usePermission('edit_own_content');
-
- const [systemRole, updateAgentConfig, meta] = useAgentStore((s) => [
- agentSelectors.currentAgentSystemRole(s),
- s.updateAgentConfig,
- agentSelectors.currentAgentMeta(s),
- ]);
-
- const handleOpenWithEdit = (e: MouseEvent) => {
- if (!canEdit || isLoading) return;
- e.stopPropagation();
- setEditing(true);
- setOpen(true);
- };
-
- const handleOpen = (e: MouseEvent) => {
- if (isLoading) return;
- if (canEdit && e.altKey) handleOpenWithEdit(e);
- setOpen(true);
- };
-
- if (isLoading)
- return (
- <Flexbox padding={8}>
- <Skeleton active avatar={false} title={false} />
- </Flexbox>
- );
-
- return (
- <Flexbox height={200} paddingInline={8} onClick={handleOpen}>
- <EditableMessage
- classNames={{ markdown: styles.prompt }}
- editing={editing}
- markdownProps={{ enableLatex: false, enableMermaid: false }}
- openModal={open}
- placeholder={`${t('settingAgent.prompt.placeholder', { ns: 'setting' })}...`}
- styles={{ markdown: { opacity: systemRole ? undefined : 0.5, overflow: 'visible' } }}
- value={systemRole}
- model={{
- extra: (
- <AgentInfo
- meta={meta}
- style={{ marginBottom: 16 }}
- onAvatarClick={() => {
- setOpen(false);
- setEditing(false);
- openChatSettings();
- }}
- />
- ),
- }}
- text={{
- cancel: t('cancel'),
- confirm: t('ok'),
- edit: canEdit ? t('edit') : '',
- title: t('settingAgent.prompt.title', { ns: 'setting' }),
- }}
- onOpenChange={setOpen}
- onChange={(e) => {
- if (!canEdit) return;
- updateAgentConfig({ systemRole: e });
- }}
- onEditingChange={(value) => {
- if (!canEdit && value) return;
- setEditing(value);
- }}
- />
- </Flexbox>
- );
-});
-
-SystemRole.displayName = 'SystemRole';
-
-export default SystemRole;
diff --git a/src/routes/(mobile)/chat/features/Topic/features/ConfigLayout.tsx b/src/routes/(mobile)/chat/features/Topic/features/ConfigLayout.tsx
deleted file mode 100644
index 522e72c08ac..00000000000
--- a/src/routes/(mobile)/chat/features/Topic/features/ConfigLayout.tsx
+++ /dev/null
@@ -1,115 +0,0 @@
-'use client';
-
-import { ActionIcon, Flexbox } from '@lobehub/ui';
-import { createStaticStyles, cx } from 'antd-style';
-import { ChevronRight } from 'lucide-react';
-import { type CSSProperties, type ReactNode } from 'react';
-import { memo } from 'react';
-
-import SidebarHeader from '@/components/SidebarHeader';
-import { useGlobalStore } from '@/store/global';
-import { systemStatusSelectors } from '@/store/global/selectors';
-
-export const styles = createStaticStyles(({ css, cssVar }) => ({
- chevron: css`
- transition: transform 0.2s ${cssVar.motionEaseInOut};
- `,
- chevronExpanded: css`
- transform: rotate(90deg);
- `,
- container: css`
- position: relative;
- overflow: hidden auto;
- transition: all 0.2s ${cssVar.motionEaseInOut};
- `,
-}));
-
-export interface ConfigLayoutProps {
- actions?: ReactNode;
- children?: ReactNode;
- className?: string;
- containerStyle?: CSSProperties;
- expandedHeight?: number | string;
- headerStyle?: CSSProperties;
- onHeaderClick?: () => void;
- sessionId: string;
- title: ReactNode;
-}
-
-const ConfigLayout = memo<ConfigLayoutProps>(
- ({
- title,
- actions,
- sessionId,
- className,
- headerStyle,
- containerStyle,
- expandedHeight,
- onHeaderClick,
- children,
- }) => {
- const [expanded, toggleAgentSystemRoleExpand] = useGlobalStore((s) => [
- systemStatusSelectors.getAgentSystemRoleExpanded(sessionId)(s),
- s.toggleAgentSystemRoleExpand,
- ]);
-
- const handleHeaderClick = () => {
- toggleAgentSystemRoleExpand(sessionId);
- onHeaderClick?.();
- };
-
- const computedStyle: CSSProperties = expanded
- ? {
- minHeight: 232,
- opacity: 1,
- ...(expandedHeight !== undefined ? { maxHeight: expandedHeight } : {}),
- }
- : {
- minHeight: 0,
- opacity: 0,
- ...(expandedHeight !== undefined ? { maxHeight: 0 } : {}),
- };
-
- const combinedActions = (
- <Flexbox horizontal align="center" gap={2}>
- {actions}
- <ActionIcon
- className={cx(styles.chevron, expanded && styles.chevronExpanded)}
- icon={ChevronRight}
- size="small"
- style={{
- pointerEvents: 'none',
- }}
- onClick={handleHeaderClick}
- />
- </Flexbox>
- );
-
- return (
- <Flexbox className={className} height={'fit-content'}>
- <SidebarHeader
- actions={combinedActions}
- title={title}
- style={{
- cursor: 'pointer',
- ...headerStyle,
- }}
- onClick={handleHeaderClick}
- />
- <Flexbox
- className={styles.container}
- style={{
- ...computedStyle,
- ...containerStyle,
- }}
- >
- {children}
- </Flexbox>
- </Flexbox>
- );
- },
-);
-
-ConfigLayout.displayName = 'ConfigLayout';
-
-export default ConfigLayout;