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.

✨ feat: add full project list page (#18336)

Arvin Xu6f80b672dee2
diff --git a/locales/en-US/electron.json b/locales/en-US/electron.json
index 9dc5619f89e..d3ecad34963 100644
--- a/locales/en-US/electron.json
+++ b/locales/en-US/electron.json
@@ -36,6 +36,7 @@
"navigation.pin": "Pin",
"navigation.pinned": "Pinned",
"navigation.profile": "Agent Profile",
+ "navigation.projects": "Projects",
"navigation.provider": "Provider",
"navigation.recentView": "Recent pages",
"navigation.resourceAll": "All",
diff --git a/locales/en-US/project.json b/locales/en-US/project.json
index 8dc773d4604..778ea33a6e1 100644
--- a/locales/en-US/project.json
+++ b/locales/en-US/project.json
@@ -32,11 +32,12 @@
"acceptance.title": "Acceptance",
"create.action": "Create project",
"create.identifierDescription": "Used as the task prefix, for example LOBE-123.",
+ "create.identifierInvalid": "Use 3–6 uppercase letters or numbers, starting with a letter.",
"create.identifierLabel": "Identifier",
"create.identifierPlaceholder": "LOBE",
"create.nameLabel": "Project name",
"create.namePlaceholder": "What are you working on?",
- "create.slugDescription": "Used for the project URL. Leave blank to generate one automatically.",
+ "create.slugDescription": "Used for the project URL and generated from the project name.",
"create.slugInvalid": "Use lowercase letters, numbers, and single hyphens only.",
"create.slugLabel": "Slug (optional)",
"create.slugPlaceholder": "my-project",
@@ -57,6 +58,11 @@
"goals.status.running": "Pursuing",
"goals.status.scheduled": "Scheduled",
"goals.title": "Goals",
+ "list.emptyDescription": "Create your first project to organize goals, tasks, and resources.",
+ "list.searchEmpty": "No projects match your search.",
+ "list.searchPlaceholder": "Search projects",
+ "list.title": "Projects",
+ "list.viewAll": "View all projects",
"overview.activeTasks": "In progress",
"overview.composerPlaceholder": "Tell the project what to move forward next…",
"overview.contextEnabled": "Project context loaded",
diff --git a/locales/zh-CN/electron.json b/locales/zh-CN/electron.json
index 51d5f1b9910..51b3647407b 100644
--- a/locales/zh-CN/electron.json
+++ b/locales/zh-CN/electron.json
@@ -36,6 +36,7 @@
"navigation.pin": "固定",
"navigation.pinned": "已固定",
"navigation.profile": "助理档案",
+ "navigation.projects": "项目",
"navigation.provider": "模型服务商",
"navigation.recentView": "最近访问",
"navigation.resourceAll": "全部",
diff --git a/locales/zh-CN/project.json b/locales/zh-CN/project.json
index 2fa4f0b12bf..3c68f9af478 100644
--- a/locales/zh-CN/project.json
+++ b/locales/zh-CN/project.json
@@ -32,11 +32,12 @@
"acceptance.title": "验收",
"create.action": "创建项目",
"create.identifierDescription": "用于任务编号前缀,例如 LOBE-123。",
+ "create.identifierInvalid": "请输入 3–6 位大写字母或数字,并以字母开头。",
"create.identifierLabel": "项目标识",
"create.identifierPlaceholder": "LOBE",
"create.nameLabel": "项目名称",
"create.namePlaceholder": "你正在推进什么事情?",
- "create.slugDescription": "用于项目 URL,留空时会自动生成。",
+ "create.slugDescription": "用于项目 URL,将根据项目名称自动生成。",
"create.slugInvalid": "仅可使用小写字母、数字和单个连字符。",
"create.slugLabel": "Slug(可选)",
"create.slugPlaceholder": "my-project",
@@ -57,6 +58,11 @@
"goals.status.running": "推进中",
"goals.status.scheduled": "已计划",
"goals.title": "目标",
+ "list.emptyDescription": "创建第一个项目,集中组织目标、任务和资源。",
+ "list.searchEmpty": "没有匹配的项目。",
+ "list.searchPlaceholder": "搜索项目",
+ "list.title": "项目",
+ "list.viewAll": "查看所有项目",
"overview.activeTasks": "正在推进",
"overview.composerPlaceholder": "告诉项目接下来要推进什么…",
"overview.contextEnabled": "已载入项目上下文",
diff --git a/packages/locales/src/default/electron.ts b/packages/locales/src/default/electron.ts
index 85fd9dde9ce..54926d5a36a 100644
--- a/packages/locales/src/default/electron.ts
+++ b/packages/locales/src/default/electron.ts
@@ -29,6 +29,7 @@ export default {
'navigation.pin': 'Pin',
'navigation.pinned': 'Pinned',
'navigation.profile': 'Agent Profile',
+ 'navigation.projects': 'Projects',
'navigation.provider': 'Provider',
'navigation.recentView': 'Recent pages',
'navigation.resources': 'Resources',
diff --git a/packages/locales/src/default/project.ts b/packages/locales/src/default/project.ts
index 5fc20282516..a3b428c16c0 100644
--- a/packages/locales/src/default/project.ts
+++ b/packages/locales/src/default/project.ts
@@ -34,11 +34,12 @@ export default {
'acceptance.title': 'Acceptance',
'create.action': 'Create project',
'create.identifierDescription': 'Used as the task prefix, for example LOBE-123.',
+ 'create.identifierInvalid': 'Use 3–6 uppercase letters or numbers, starting with a letter.',
'create.identifierLabel': 'Identifier',
'create.identifierPlaceholder': 'LOBE',
'create.nameLabel': 'Project name',
'create.namePlaceholder': 'What are you working on?',
- 'create.slugDescription': 'Used for the project URL. Leave blank to generate one automatically.',
+ 'create.slugDescription': 'Used for the project URL and generated from the project name.',
'create.slugInvalid': 'Use lowercase letters, numbers, and single hyphens only.',
'create.slugLabel': 'Slug (optional)',
'create.slugPlaceholder': 'my-project',
@@ -59,6 +60,11 @@ export default {
'goals.status.running': 'Pursuing',
'goals.status.scheduled': 'Scheduled',
'goals.title': 'Goals',
+ 'list.emptyDescription': 'Create your first project to organize goals, tasks, and resources.',
+ 'list.searchEmpty': 'No projects match your search.',
+ 'list.searchPlaceholder': 'Search projects',
+ 'list.title': 'Projects',
+ 'list.viewAll': 'View all projects',
'overview.noDescription': 'A dedicated workspace for this long-running goal.',
'overview.activeTasks': 'In progress',
'overview.contextEnabled': 'Project context loaded',
diff --git a/src/components/ExecutionStatus.test.ts b/src/components/ExecutionStatus.test.ts
new file mode 100644
index 00000000000..5a740dc7906
--- /dev/null
+++ b/src/components/ExecutionStatus.test.ts
@@ -0,0 +1,16 @@
+import { describe, expect, it } from 'vitest';
+
+import { resolveProjectStatus } from './ExecutionStatus';
+
+describe('resolveProjectStatus', () => {
+ it('preserves supported project statuses', () => {
+ expect(resolveProjectStatus('active')).toBe('active');
+ expect(resolveProjectStatus('completed')).toBe('completed');
+ });
+
+ it('falls back to backlog for missing or unknown persisted values', () => {
+ expect(resolveProjectStatus(undefined)).toBe('backlog');
+ expect(resolveProjectStatus(null)).toBe('backlog');
+ expect(resolveProjectStatus('in_progress')).toBe('backlog');
+ });
+});
diff --git a/src/components/ExecutionStatus.ts b/src/components/ExecutionStatus.ts
index 04ba1ead37b..cbab8b1c6dc 100644
--- a/src/components/ExecutionStatus.ts
+++ b/src/components/ExecutionStatus.ts
@@ -1,4 +1,5 @@
-import type { ChatTopicStatus, TaskStatus } from '@lobechat/types';
+import type { ChatTopicStatus, ProjectStatus, TaskStatus } from '@lobechat/types';
+import { PROJECT_STATUSES } from '@lobechat/types';
import { cssVar } from 'antd-style';
import type { LucideIcon } from 'lucide-react';
import {
@@ -11,6 +12,7 @@ import {
CircleX,
Clock,
HandIcon,
+ PauseCircle,
StarIcon,
TriangleAlert,
} from 'lucide-react';
@@ -52,6 +54,22 @@ export const TASK_STATUS_VISUALS: Record<TaskStatus, ExecutionStatusVisual> = {
scheduled: VISUALS.scheduled,
};
+export const PROJECT_STATUS_VISUALS: Record<ProjectStatus, ExecutionStatusVisual> = {
+ active: VISUALS.running,
+ archived: VISUALS.archived,
+ backlog: VISUALS.backlog,
+ canceled: VISUALS.canceled,
+ completed: VISUALS.completed,
+ paused: { color: cssVar.colorTextSecondary, icon: PauseCircle },
+ reviewing: VISUALS.waitingForHuman,
+};
+
+const PROJECT_STATUS_SET = new Set<string>(PROJECT_STATUSES);
+
+/** Normalize untrusted persisted/API values before rendering a project status. */
+export const resolveProjectStatus = (status: null | string | undefined): ProjectStatus =>
+ status && PROJECT_STATUS_SET.has(status) ? (status as ProjectStatus) : 'backlog';
+
export const TOPIC_STATUS_VISUALS: Record<ChatTopicStatus, ExecutionStatusVisual> = {
active: VISUALS.idle,
archived: VISUALS.archived,
diff --git a/src/features/HomeSidebar/Body/Project/index.tsx b/src/features/HomeSidebar/Body/Project/index.tsx
index 7fa30a5f04b..451e25edaf0 100644
--- a/src/features/HomeSidebar/Body/Project/index.tsx
+++ b/src/features/HomeSidebar/Body/Project/index.tsx
@@ -1,7 +1,7 @@
'use client';
import { AccordionItem, ActionIcon, Flexbox, Text } from '@lobehub/ui';
-import { PlusIcon, SquareKanbanIcon } from 'lucide-react';
+import { ArrowRightIcon, PlusIcon, SquareKanbanIcon } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -34,10 +34,10 @@ const Project = memo<ProjectProps>(({ itemKey }) => {
paddingInline="8px 4px"
action={
<ActionIcon
- icon={PlusIcon}
+ icon={ArrowRightIcon}
size="small"
- title={t('create.title')}
- onClick={openCreateProjectModal}
+ title={t('list.viewAll')}
+ onClick={() => navigate('/projects')}
/>
}
title={
diff --git a/src/features/Projects/CreateProjectModal.tsx b/src/features/Projects/CreateProjectModal.tsx
index 077f2c2441b..abba052268a 100644
--- a/src/features/Projects/CreateProjectModal.tsx
+++ b/src/features/Projects/CreateProjectModal.tsx
@@ -7,13 +7,20 @@ import { useTranslation } from 'react-i18next';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useProjectStore } from '@/store/project';
-import { getCreateProjectInput, isProjectSlugValid } from './createProjectForm';
+import {
+ getCreateProjectInput,
+ getProjectFieldSuggestions,
+ isProjectIdentifierValid,
+ isProjectSlugValid,
+} from './createProjectForm';
interface CreateProjectFormState {
identifier: string;
+ identifierEdited: boolean;
loading: boolean;
name: string;
slug: string;
+ slugEdited: boolean;
}
const CreateProjectContent = memo(() => {
@@ -23,17 +30,32 @@ const CreateProjectContent = memo(() => {
const createProject = useProjectStore((s) => s.createProject);
const [form, setForm] = useState<CreateProjectFormState>({
identifier: '',
+ identifierEdited: false,
loading: false,
name: '',
slug: '',
+ slugEdited: false,
});
const createInput = getCreateProjectInput(form);
+ const identifierValid = isProjectIdentifierValid(form.identifier);
+ const identifierInvalid =
+ (form.identifierEdited || Boolean(form.name.trim())) && !identifierValid;
const slugValid = isProjectSlugValid(form.slug);
const updateForm = (patch: Partial<CreateProjectFormState>) => {
setForm((current) => ({ ...current, ...patch }));
};
+ const updateName = (name: string) => {
+ const suggestions = getProjectFieldSuggestions(name);
+ setForm((current) => ({
+ ...current,
+ identifier: current.identifierEdited ? current.identifier : suggestions.identifier,
+ name,
+ slug: current.slugEdited ? current.slug : suggestions.slug,
+ }));
+ };
+
const handleCreate = async () => {
if (!createInput || form.loading) return;
updateForm({ loading: true });
@@ -61,7 +83,7 @@ const CreateProjectContent = memo(() => {
maxLength={255}
placeholder={t('create.namePlaceholder')}
value={form.name}
- onChange={(event) => updateForm({ name: event.target.value })}
+ onChange={(event) => updateName(event.target.value)}
onPressEnter={handleCreate}
/>
</Flexbox>
@@ -72,12 +94,15 @@ const CreateProjectContent = memo(() => {
<Input
maxLength={6}
placeholder={t('create.identifierPlaceholder')}
+ status={identifierInvalid ? 'error' : undefined}
value={form.identifier}
- onChange={(event) => updateForm({ identifier: event.target.value.toUpperCase() })}
onPressEnter={handleCreate}
+ onChange={(event) =>
+ updateForm({ identifier: event.target.value.toUpperCase(), identifierEdited: true })
+ }
/>
- <Text fontSize={12} type="secondary">
- {t('create.identifierDescription')}
+ <Text fontSize={12} type={identifierInvalid ? 'danger' : 'secondary'}>
+ {t(identifierInvalid ? 'create.identifierInvalid' : 'create.identifierDescription')}
</Text>
</Flexbox>
<Flexbox gap={6}>
@@ -89,8 +114,10 @@ const CreateProjectContent = memo(() => {
placeholder={t('create.slugPlaceholder')}
status={slugValid ? undefined : 'error'}
value={form.slug}
- onChange={(event) => updateForm({ slug: event.target.value.toLowerCase() })}
onPressEnter={handleCreate}
+ onChange={(event) =>
+ updateForm({ slug: event.target.value.toLowerCase(), slugEdited: true })
+ }
/>
<Text fontSize={12} type={slugValid ? 'secondary' : 'danger'}>
{t(slugValid ? 'create.slugDescription' : 'create.slugInvalid')}
diff --git a/src/features/Projects/Layout/index.tsx b/src/features/Projects/Layout/index.tsx
index fe5a5a7c66a..0108019ae8c 100644
--- a/src/features/Projects/Layout/index.tsx
+++ b/src/features/Projects/Layout/index.tsx
@@ -1,36 +1,19 @@
'use client';
-import { Center, Flexbox, Icon, Text } from '@lobehub/ui';
-import { Button } from '@lobehub/ui/base-ui';
-import { FolderKanbanIcon } from 'lucide-react';
+import { Flexbox } from '@lobehub/ui';
import { memo } from 'react';
-import { useTranslation } from 'react-i18next';
import { Outlet } from 'react-router';
-import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
+import ProjectDisabled from '@/features/Projects/ProjectDisabled';
import { useUserStore } from '@/store/user';
import { labPreferSelectors } from '@/store/user/selectors';
import ProjectSidebar from './Sidebar';
const ProjectLayout = memo(() => {
- const { t } = useTranslation('project');
- const navigate = useWorkspaceAwareNavigate();
const enabled = useUserStore(labPreferSelectors.enableProjects);
- if (!enabled) {
- return (
- <Center height="100%" width="100%">
- <Flexbox align="center" gap={12}>
- <Icon icon={FolderKanbanIcon} size={40} />
- <Text fontSize={18} weight={600}>
- {t('disabled.title')}
- </Text>
- <Button onClick={() => navigate('/settings/labs')}>{t('disabled.action')}</Button>
- </Flexbox>
- </Center>
- );
- }
+ if (!enabled) return <ProjectDisabled />;
return (
<>
diff --git a/src/features/Projects/List/index.tsx b/src/features/Projects/List/index.tsx
new file mode 100644
index 00000000000..45d6495038f
--- /dev/null
+++ b/src/features/Projects/List/index.tsx
@@ -0,0 +1,175 @@
+'use client';
+
+import { Center, Empty, Flexbox, Icon, SearchBar, Text, Tooltip } from '@lobehub/ui';
+import { Button } from '@lobehub/ui/base-ui';
+import { createStaticStyles } from 'antd-style';
+import dayjs from 'dayjs';
+import { PlusIcon, SearchXIcon, SquareKanbanIcon } from 'lucide-react';
+import { memo, useMemo, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';
+import AsyncError from '@/components/AsyncError';
+import { PROJECT_STATUS_VISUALS, resolveProjectStatus } from '@/components/ExecutionStatus';
+import NavHeader from '@/features/NavHeader';
+import SkeletonList from '@/features/NavPanel/components/SkeletonList';
+import { openCreateProjectModal } from '@/features/Projects/CreateProjectModal';
+import ProjectDisabled from '@/features/Projects/ProjectDisabled';
+import TopicCreatorAvatar from '@/features/TopicCreatorAvatar';
+import UserAvatar from '@/features/User/UserAvatar';
+import WideScreenContainer from '@/features/WideScreenContainer';
+import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
+import { useCurrentProjectList, useProjectStore } from '@/store/project';
+import type { ProjectListItem } from '@/store/project/store';
+import { useUserStore } from '@/store/user';
+import { labPreferSelectors } from '@/store/user/selectors';
+
+const styles = createStaticStyles(({ css, cssVar }) => ({
+ identifier: css`
+ flex: none;
+ min-width: 72px;
+ color: ${cssVar.colorTextTertiary};
+ `,
+ owner: css`
+ flex: none;
+ width: 20px;
+ `,
+ row: css`
+ padding-block: 7px;
+ padding-inline: 4px 12px;
+ border-radius: ${cssVar.borderRadiusLG};
+ color: inherit;
+
+ &:hover {
+ background: ${cssVar.colorFillTertiary};
+ }
+ `,
+ updatedAt: css`
+ flex: none;
+
+ min-width: 88px;
+
+ color: ${cssVar.colorTextQuaternary};
+ text-align: end;
+ white-space: nowrap;
+ `,
+}));
+
+const ProjectOwnerAvatar = memo<{ userId: string }>(({ userId }) => {
+ const activeWorkspaceId = useActiveWorkspaceId();
+
+ return (
+ <span className={styles.owner}>
+ {activeWorkspaceId ? (
+ <TopicCreatorAvatar size={20} userId={userId} />
+ ) : (
+ <UserAvatar size={20} />
+ )}
+ </span>
+ );
+});
+
+ProjectOwnerAvatar.displayName = 'ProjectOwnerAvatar';
+
+const ProjectRow = memo<{ project: ProjectListItem }>(({ project }) => {
+ const { t } = useTranslation('project');
+ const status = resolveProjectStatus(project.status);
+ const statusVisual = PROJECT_STATUS_VISUALS[status];
+
+ return (
+ <WorkspaceLink to={`/project/${project.id}`}>
+ <Flexbox horizontal align={'center'} className={styles.row} gap={8}>
+ <Tooltip title={t(`acceptance.status.${status}`)}>
+ <Icon color={statusVisual.color} icon={statusVisual.icon} size={16} />
+ </Tooltip>
+ <Flexbox flex={1} style={{ minWidth: 0 }}>
+ <Text ellipsis weight={500}>
+ {project.name}
+ </Text>
+ </Flexbox>
+ <Text className={styles.identifier} fontSize={12}>
+ {project.identifier}
+ </Text>
+ <ProjectOwnerAvatar userId={project.userId} />
+ <Text
+ className={styles.updatedAt}
+ fontSize={12}
+ title={dayjs(project.updatedAt).format('YYYY-MM-DD HH:mm')}
+ >
+ {dayjs(project.updatedAt).fromNow()}
+ </Text>
+ </Flexbox>
+ </WorkspaceLink>
+ );
+});
+
+ProjectRow.displayName = 'ProjectRow';
+
+const ProjectListPage = memo(() => {
+ const { t } = useTranslation('project');
+ const [keyword, setKeyword] = useState('');
+ const enabled = useUserStore(labPreferSelectors.enableProjects);
+ const projects = useCurrentProjectList();
+ const { error, isLoading, mutate } = useProjectStore((s) => s.useFetchProjectList)(enabled);
+
+ const filteredProjects = useMemo(() => {
+ const normalizedKeyword = keyword.trim().toLocaleLowerCase();
+ return normalizedKeyword
+ ? projects.filter((project) =>
+ [project.name, project.identifier, project.description]
+ .filter(Boolean)
+ .some((value) => value!.toLocaleLowerCase().includes(normalizedKeyword)),
+ )
+ : projects;
+ }, [keyword, projects]);
+
+ if (!enabled) return <ProjectDisabled />;
+
+ return (
+ <Flexbox flex={1} height={'100%'}>
+ <NavHeader
+ left={
+ <Text style={{ paddingInlineStart: 4 }} weight={500}>
+ {t('list.title')}
+ </Text>
+ }
+ />
+ <WideScreenContainer gap={16} paddingBlock={16} wrapperStyle={{ flex: 1, overflowY: 'auto' }}>
+ <Flexbox horizontal align={'center'} gap={12} justify={'space-between'}>
+ <SearchBar
+ allowClear
+ placeholder={t('list.searchPlaceholder')}
+ style={{ maxWidth: 280 }}
+ value={keyword}
+ onChange={(event) => setKeyword(event.target.value)}
+ />
+ <Button icon={PlusIcon} onClick={openCreateProjectModal}>
+ {t('create.action')}
+ </Button>
+ </Flexbox>
+ {error ? (
+ <AsyncError error={error} onRetry={() => mutate()} />
+ ) : isLoading && projects.length === 0 ? (
+ <SkeletonList rows={8} />
+ ) : filteredProjects.length === 0 ? (
+ <Center flex={1} padding={48}>
+ <Empty
+ description={keyword.trim() ? t('list.searchEmpty') : t('list.emptyDescription')}
+ icon={keyword.trim() ? SearchXIcon : SquareKanbanIcon}
+ />
+ </Center>
+ ) : (
+ <Flexbox gap={4}>
+ {filteredProjects.map((project) => (
+ <ProjectRow key={project.id} project={project} />
+ ))}
+ </Flexbox>
+ )}
+ </WideScreenContainer>
+ </Flexbox>
+ );
+});
+
+ProjectListPage.displayName = 'ProjectListPage';
+
+export default ProjectListPage;
diff --git a/src/features/Projects/ProjectDisabled.tsx b/src/features/Projects/ProjectDisabled.tsx
new file mode 100644
index 00000000000..11e07ac5cee
--- /dev/null
+++ b/src/features/Projects/ProjectDisabled.tsx
@@ -0,0 +1,27 @@
+'use client';
+
+import { Center, Flexbox, Icon, Text } from '@lobehub/ui';
+import { Button } from '@lobehub/ui/base-ui';
+import { FolderKanbanIcon } from 'lucide-react';
+import { useTranslation } from 'react-i18next';
+
+import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
+
+const ProjectDisabled = () => {
+ const { t } = useTranslation('project');
+ const navigate = useWorkspaceAwareNavigate();
+
+ return (
+ <Center height={'100%'} width={'100%'}>
+ <Flexbox align={'center'} gap={12}>
+ <Icon icon={FolderKanbanIcon} size={40} />
+ <Text fontSize={18} weight={600}>
+ {t('disabled.title')}
+ </Text>
+ <Button onClick={() => navigate('/settings/labs')}>{t('disabled.action')}</Button>
+ </Flexbox>
+ </Center>
+ );
+};
+
+export default ProjectDisabled;
diff --git a/src/features/Projects/Workspace/index.tsx b/src/features/Projects/Workspace/index.tsx
index 2edfd16c136..983a33a8151 100644
--- a/src/features/Projects/Workspace/index.tsx
+++ b/src/features/Projects/Workspace/index.tsx
@@ -1,9 +1,9 @@
'use client';
-import { Center, Flexbox, Icon, Tag, Text, TextArea } from '@lobehub/ui';
+import { Center, Flexbox, Tag, Text, TextArea } from '@lobehub/ui';
import { Button } from '@lobehub/ui/base-ui';
import { createStaticStyles, cssVar } from 'antd-style';
-import { FolderKanbanIcon, SendHorizontalIcon, SparklesIcon } from 'lucide-react';
+import { SendHorizontalIcon, SparklesIcon } from 'lucide-react';
import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router';
@@ -11,6 +11,7 @@ import { useParams } from 'react-router';
import AsyncError from '@/components/AsyncError';
import NeuralNetworkLoading from '@/components/NeuralNetworkLoading';
import { getProjectConversationStartPath } from '@/features/Projects/Layout/navigation';
+import ProjectDisabled from '@/features/Projects/ProjectDisabled';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useCurrentProjectDetail, useProjectStore } from '@/store/project';
import { useUserStore } from '@/store/user';
@@ -94,19 +95,7 @@ const ProjectWorkspace = memo(() => {
const [message, setMessage] = useState('');
const { error, isLoading, mutate } = useProjectStore((s) => s.useFetchProjectDetail)(projectId);
- if (!enabled) {
- return (
- <Center height={'100%'}>
- <Flexbox align={'center'} gap={12}>
- <Icon icon={FolderKanbanIcon} size={40} />
- <Text fontSize={18} weight={600}>
- {t('disabled.title')}
- </Text>
- <Button onClick={() => navigate('/settings/labs')}>{t('disabled.action')}</Button>
- </Flexbox>
- </Center>
- );
- }
+ if (!enabled) return <ProjectDisabled />;
if (error) return <AsyncError error={error} variant={'page'} onRetry={() => mutate()} />;
if (isLoading || !detail)
return (
diff --git a/src/features/Projects/createProjectForm.test.ts b/src/features/Projects/createProjectForm.test.ts
index 2e69c849214..89d978fab1f 100644
--- a/src/features/Projects/createProjectForm.test.ts
+++ b/src/features/Projects/createProjectForm.test.ts
@@ -1,8 +1,38 @@
import { describe, expect, it } from 'vitest';
-import { getCreateProjectInput, isProjectSlugValid } from './createProjectForm';
+import {
+ getCreateProjectInput,
+ getProjectFieldSuggestions,
+ isProjectIdentifierValid,
+ isProjectSlugValid,
+} from './createProjectForm';
describe('createProjectForm', () => {
+ it('derives a valid identifier and slug from the project name', () => {
+ expect(getProjectFieldSuggestions('LobeHub')).toEqual({
+ identifier: 'LOBE',
+ slug: 'lobe-hub',
+ });
+ expect(getProjectFieldSuggestions('LobeHub Mobile')).toEqual({
+ identifier: 'LHM',
+ slug: 'lobe-hub-mobile',
+ });
+ expect(getProjectFieldSuggestions('用户记忆')).toEqual({
+ identifier: 'YHJY',
+ slug: 'yong-hu-ji-yi',
+ });
+ });
+
+ it('returns empty suggestions when the project name is empty', () => {
+ expect(getProjectFieldSuggestions(' ')).toEqual({ identifier: '', slug: '' });
+ });
+
+ it('validates the identifier format shown by the form', () => {
+ expect(isProjectIdentifierValid('LOBE')).toBe(true);
+ expect(isProjectIdentifierValid('LH')).toBe(false);
+ expect(isProjectIdentifierValid('1LOBE')).toBe(false);
+ });
+
it('normalizes and includes a user-provided slug', () => {
expect(
getCreateProjectInput({
diff --git a/src/features/Projects/createProjectForm.ts b/src/features/Projects/createProjectForm.ts
index 4c77e691381..ae3b926896a 100644
--- a/src/features/Projects/createProjectForm.ts
+++ b/src/features/Projects/createProjectForm.ts
@@ -1,6 +1,9 @@
import { PROJECT_IDENTIFIER_REGEX } from '@lobechat/types';
+import { kebabCase } from 'es-toolkit';
+import { pinyin } from 'pinyin-pro';
const PROJECT_SLUG_REGEX = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
+const PROJECT_IDENTIFIER_LENGTH = 4;
export interface CreateProjectDraft {
identifier: string;
@@ -8,6 +11,36 @@ export interface CreateProjectDraft {
slug: string;
}
+export interface ProjectFieldSuggestions {
+ identifier: string;
+ slug: string;
+}
+
+export const getProjectFieldSuggestions = (name: string): ProjectFieldSuggestions => {
+ const normalizedName = name.trim();
+ if (!normalizedName) return { identifier: '', slug: '' };
+
+ const transliteratedName = pinyin(normalizedName, {
+ nonZh: 'consecutive',
+ toneType: 'none',
+ type: 'array',
+ }).join(' ');
+ const slug = kebabCase(transliteratedName).replaceAll(/[^a-z0-9-]/g, '');
+ const parts = slug.split('-').filter(Boolean);
+ const initials = parts.map((part) => part[0]).join('');
+ const compactName = parts.join('');
+ const identifierSource = initials.length >= 3 ? initials : compactName;
+ const identifier = identifierSource
+ .slice(0, PROJECT_IDENTIFIER_LENGTH)
+ .padEnd(3, 'x')
+ .toUpperCase();
+
+ return { identifier, slug };
+};
+
+export const isProjectIdentifierValid = (identifier: string) =>
+ PROJECT_IDENTIFIER_REGEX.test(identifier.trim().toUpperCase());
+
export const isProjectSlugValid = (slug: string) => {
const normalizedSlug = slug.trim().toLowerCase();
return !normalizedSlug || PROJECT_SLUG_REGEX.test(normalizedSlug);
@@ -18,7 +51,7 @@ export const getCreateProjectInput = (draft: CreateProjectDraft) => {
const name = draft.name.trim();
const slug = draft.slug.trim().toLowerCase();
- if (!name || !PROJECT_IDENTIFIER_REGEX.test(identifier) || !isProjectSlugValid(slug)) {
+ if (!name || !isProjectIdentifierValid(identifier) || !isProjectSlugValid(slug)) {
return null;
}
diff --git a/src/features/Projects/routeMeta.ts b/src/features/Projects/routeMeta.ts
new file mode 100644
index 00000000000..22715268127
--- /dev/null
+++ b/src/features/Projects/routeMeta.ts
@@ -0,0 +1,8 @@
+import { SquareKanbanIcon } from 'lucide-react';
+
+import { routeMeta } from '@/spa/router/routeMeta';
+
+export const projectsRouteMeta = routeMeta({
+ icon: SquareKanbanIcon,
+ titleKey: 'navigation.projects',
+});
diff --git a/src/features/Workspace/__tests__/workspaceAwarePath.test.ts b/src/features/Workspace/__tests__/workspaceAwarePath.test.ts
index 75380917aed..0e80793f508 100644
--- a/src/features/Workspace/__tests__/workspaceAwarePath.test.ts
+++ b/src/features/Workspace/__tests__/workspaceAwarePath.test.ts
@@ -22,6 +22,7 @@ describe('buildWorkspaceAwarePath', () => {
);
expect(buildWorkspaceAwarePath('/group/group-1', 'acme')).toBe('/acme/group/group-1');
expect(buildWorkspaceAwarePath('/project/project-1', 'acme')).toBe('/acme/project/project-1');
+ expect(buildWorkspaceAwarePath('/projects', 'acme')).toBe('/acme/projects');
});
it('prefixes deep agent and evaluation paths used by cross-page navigation', () => {
diff --git a/src/features/Workspace/useWorkspaceUrlSync.desktop.test.ts b/src/features/Workspace/useWorkspaceUrlSync.desktop.test.ts
index ea180f10371..ea2c77d7364 100644
--- a/src/features/Workspace/useWorkspaceUrlSync.desktop.test.ts
+++ b/src/features/Workspace/useWorkspaceUrlSync.desktop.test.ts
@@ -119,4 +119,13 @@ describe('useWorkspaceUrlSync (desktop)', () => {
expect(switchToPersonal).toHaveBeenCalled();
});
+
+ it('treats the unqualified projects route as personal context', () => {
+ vi.spyOn(useActiveWorkspaceIdModule, 'useActiveWorkspaceId').mockReturnValue('ws-1');
+ setTabs([{ id: 'a', url: '/projects' }], 'a');
+
+ renderHook(() => useWorkspaceUrlSync(), { wrapper });
+
+ expect(switchToPersonal).toHaveBeenCalled();
+ });
});
diff --git a/src/features/Workspace/useWorkspaceUrlSync.ts b/src/features/Workspace/useWorkspaceUrlSync.ts
index 56a3a698b31..1fdbae48b5e 100644
--- a/src/features/Workspace/useWorkspaceUrlSync.ts
+++ b/src/features/Workspace/useWorkspaceUrlSync.ts
@@ -24,6 +24,7 @@ const RESERVED_FIRST_SEGMENTS = new Set([
'community',
'memory',
'page',
+ 'projects',
'resource',
'image',
'video',
diff --git a/src/features/Workspace/workspaceAwarePath.ts b/src/features/Workspace/workspaceAwarePath.ts
index af27682e473..3a6b9be306b 100644
--- a/src/features/Workspace/workspaceAwarePath.ts
+++ b/src/features/Workspace/workspaceAwarePath.ts
@@ -71,6 +71,7 @@ const WORKSPACE_MIRRORED_FIRST_SEGMENTS = new Set([
'memory',
'page',
'project',
+ 'projects',
'resource',
'settings',
'task',
diff --git a/src/layout/GlobalProvider/useUserStateRedirect.test.ts b/src/layout/GlobalProvider/useUserStateRedirect.test.ts
index 4589e8470c6..412d07c362a 100644
--- a/src/layout/GlobalProvider/useUserStateRedirect.test.ts
+++ b/src/layout/GlobalProvider/useUserStateRedirect.test.ts
@@ -16,6 +16,7 @@ describe('shouldDeferOnboardingRedirect', () => {
it('does not defer on personal app routes', () => {
expect(shouldDeferOnboardingRedirect('/')).toBe(false);
expect(shouldDeferOnboardingRedirect('/agent')).toBe(false);
+ expect(shouldDeferOnboardingRedirect('/projects')).toBe(false);
expect(shouldDeferOnboardingRedirect('/settings/profile')).toBe(false);
});
});
diff --git a/src/layout/GlobalProvider/useUserStateRedirect.ts b/src/layout/GlobalProvider/useUserStateRedirect.ts
index 92bd5b33d62..d1c83c140e8 100644
--- a/src/layout/GlobalProvider/useUserStateRedirect.ts
+++ b/src/layout/GlobalProvider/useUserStateRedirect.ts
@@ -22,6 +22,7 @@ const RESERVED_FIRST_SEGMENTS = new Set([
'next-auth',
'onboarding',
'page',
+ 'projects',
'resource',
'settings',
'share',
diff --git a/src/routes/(main)/projects/index.tsx b/src/routes/(main)/projects/index.tsx
new file mode 100644
index 00000000000..51941f2f0ad
--- /dev/null
+++ b/src/routes/(main)/projects/index.tsx
@@ -0,0 +1 @@
+export { default } from '@/features/Projects/List';
diff --git a/src/spa/router/desktopRouter.shared.tsx b/src/spa/router/desktopRouter.shared.tsx
index c5d8d065a3f..78075b006a4 100644
--- a/src/spa/router/desktopRouter.shared.tsx
+++ b/src/spa/router/desktopRouter.shared.tsx
@@ -33,6 +33,7 @@ import { goalsRouteMeta } from '@/features/AgentGoals/routeMeta';
import { taskRouteMeta, tasksRouteMeta } from '@/features/AgentTasks/routeMeta';
import { agentsRouteMeta } from '@/features/AgentViewAll/routeMeta';
import { pageRouteMeta } from '@/features/Pages/routeMeta';
+import { projectsRouteMeta } from '@/features/Projects/routeMeta';
import { settingsRouteMeta } from '@/features/Settings/features/routeMeta';
import { workspaceHomeRouteMeta } from '@/features/Workspace/routeMeta';
import {
@@ -818,6 +819,21 @@ export const sharedMainAreaChildren: RouteObject[] = [
path: 'agents',
},
+ // Projects view-all route
+ {
+ children: [
+ {
+ element: dynamicElement(() => import('@/routes/(main)/projects'), 'Desktop > Projects', {
+ preloadId: 'projects',
+ }),
+ handle: { meta: projectsRouteMeta },
+ index: true,
+ },
+ ],
+ errorElement: <ErrorBoundary resetPath=".." />,
+ path: 'projects',
+ },
+
// Task workspace routes (cross-agent)
{
children: [
diff --git a/src/spa/router/desktopRouter.sync.test.tsx b/src/spa/router/desktopRouter.sync.test.tsx
index 0b8a6c0abd1..1ada8e7c48d 100644
--- a/src/spa/router/desktopRouter.sync.test.tsx
+++ b/src/spa/router/desktopRouter.sync.test.tsx
@@ -145,6 +145,16 @@ describe('desktop router shared definition', () => {
},
);
+ it.each(mainAreaVariants)('%s exposes the projects view-all route', (_, factory) => {
+ const personalMatches = matchRoutes(createMainAreaRoutes(factory), '/projects');
+ const workspaceMatches = matchRoutes(createMainAreaRoutes(factory), '/acme/projects');
+
+ expect(personalMatches?.at(-1)?.route.index).toBe(true);
+ expect(personalMatches?.at(-1)?.route.handle).toMatchObject({ meta: expect.any(Object) });
+ expect(workspaceMatches?.at(-1)?.route.index).toBe(true);
+ expect(workspaceMatches?.at(-1)?.route.handle).toMatchObject({ meta: expect.any(Object) });
+ });
+
it.each(mainAreaVariants)(
'%s personal memory settings are not shadowed by workspace memory routes',
(_, factory) => {