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(projects): folder card view for the projects page (#22860)

Arvin Xu922b9e2c9c2b
diff --git a/apps/server/src/routers/lambda/project.ts b/apps/server/src/routers/lambda/project.ts
index 3935fd44ef4..98eef15e0b8 100644
--- a/apps/server/src/routers/lambda/project.ts
+++ b/apps/server/src/routers/lambda/project.ts
@@ -21,6 +21,7 @@ import {
} from '@/database/models/project';
import { ProjectRepository } from '@/database/repositories/project';
import { ProjectCoordinatorRepository } from '@/database/repositories/projectCoordinator';
+import { ProjectOverviewRepository } from '@/database/repositories/projectOverview';
import type { LobeChatDatabase } from '@/database/type';
import { router } from '@/libs/trpc/lambda';
import { serverDatabase } from '@/libs/trpc/lambda/middleware';
@@ -57,6 +58,7 @@ const projectProcedure = wsCompatProcedure.use(serverDatabase).use(async (opts)
options,
),
projectModel: new ProjectModel(ctx.serverDB, ctx.userId, workspaceId, options),
+ projectOverviewRepo: new ProjectOverviewRepository(ctx.serverDB, ctx.userId, workspaceId),
projectRepo: new ProjectRepository(ctx.serverDB, ctx.userId, workspaceId),
},
});
@@ -344,6 +346,15 @@ export const projectRouter = router({
// Re-enabling them must also move the task's acceptances (and those of its
// run topics): `acceptances.project_id` is copied from the task when filed,
// unless the publisher named another project explicitly.
+ /** Folder-card content for every visible project, in one batch. */
+ listOverviews: projectProcedure.query(async ({ ctx }) => {
+ try {
+ return { data: await ctx.projectOverviewRepo.list(), success: true };
+ } catch (error) {
+ mapProjectError(error, 'listOverviews');
+ }
+ }),
+
moveTask: projectWriteProcedure
.input(idInput.extend({ taskId: z.string() }))
.mutation(async () => {
diff --git a/locales/en-US/project.json b/locales/en-US/project.json
index da956f4fec3..edcd60be968 100644
--- a/locales/en-US/project.json
+++ b/locales/en-US/project.json
@@ -171,10 +171,23 @@
"list.deleteError": "Could not delete the project.",
"list.deleteSuccess": "“{{name}}” deleted",
"list.emptyDescription": "Create your first project to organize goals, tasks, and resources.",
+ "list.folder.coordinatedBy": "Coordinated by {{name}}",
+ "list.folder.intro": "About",
+ "list.folder.noTopics": "No conversations",
+ "list.folder.noTopicsHint": "No conversations yet. Start the first one in this project and it shows up here.",
+ "list.folder.overviewError": "Couldn't load the conversations and tasks shown on the cards.",
+ "list.folder.recentTopic": "Latest conversation",
+ "list.folder.running": "In progress",
+ "list.folder.taskProgress": "{{done}}/{{total}} tasks",
+ "list.folder.topicCount_one": "{{count}} conversation",
+ "list.folder.topicCount_other": "{{count}} conversations",
"list.moreActions": "More project actions",
"list.searchEmpty": "No projects match your search.",
"list.searchPlaceholder": "Search projects",
"list.title": "Projects",
+ "list.view.folder": "Folders",
+ "list.view.list": "List",
+ "list.view.title": "View",
"list.viewAll": "View all projects",
"members.coordinatorResponsibility": "Leads topics and tasks in this project",
"members.description": "Invite agents to work on this project and note what each one owns.",
diff --git a/locales/zh-CN/project.json b/locales/zh-CN/project.json
index 4b53bbc8d4a..ad81265a3a9 100644
--- a/locales/zh-CN/project.json
+++ b/locales/zh-CN/project.json
@@ -171,10 +171,23 @@
"list.deleteError": "无法删除项目。",
"list.deleteSuccess": "已删除“{{name}}”",
"list.emptyDescription": "创建第一个项目,集中组织目标、任务和资源。",
+ "list.folder.coordinatedBy": "由 {{name}} 协调",
+ "list.folder.intro": "项目简介",
+ "list.folder.noTopics": "暂无对话",
+ "list.folder.noTopicsHint": "还没有对话。在项目里发起第一个对话,它会出现在这里。",
+ "list.folder.overviewError": "卡片上的对话和任务没能加载出来。",
+ "list.folder.recentTopic": "最近对话",
+ "list.folder.running": "进行中",
+ "list.folder.taskProgress": "{{done}}/{{total}} 任务",
+ "list.folder.topicCount_one": "{{count}} 个对话",
+ "list.folder.topicCount_other": "{{count}} 个对话",
"list.moreActions": "更多项目操作",
"list.searchEmpty": "没有匹配的项目。",
"list.searchPlaceholder": "搜索项目",
"list.title": "项目",
+ "list.view.folder": "文件夹",
+ "list.view.list": "列表",
+ "list.view.title": "视图",
"list.viewAll": "查看所有项目",
"members.coordinatorResponsibility": "负责项目中的话题和任务",
"members.description": "邀请 Agent 参与这个项目,并记下各自负责什么。",
diff --git a/packages/database/src/repositories/projectOverview/__tests__/index.test.ts b/packages/database/src/repositories/projectOverview/__tests__/index.test.ts
new file mode 100644
index 00000000000..2aff9967400
--- /dev/null
+++ b/packages/database/src/repositories/projectOverview/__tests__/index.test.ts
@@ -0,0 +1,132 @@
+import { eq } from 'drizzle-orm';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+
+import { getTestDB } from '../../../core/getTestDB';
+import { AgentModel } from '../../../models/agent';
+import { ProjectModel } from '../../../models/project';
+import { TaskModel } from '../../../models/task';
+import { TopicModel } from '../../../models/topic';
+import { tasks, topics, users } from '../../../schemas';
+import { ProjectRepository } from '../../project';
+import { ProjectOverviewRepository } from '../index';
+
+const serverDB = await getTestDB();
+const userId = 'project-overview-user';
+const otherUserId = 'project-overview-other-user';
+const projectRepo = new ProjectRepository(serverDB, userId);
+const model = new ProjectModel(serverDB, userId);
+const repo = new ProjectOverviewRepository(serverDB, userId);
+let identifierSequence = 0;
+
+const createProject = (name: string, owner = projectRepo) =>
+ owner.create({ identifier: `O${String(++identifierSequence).padStart(5, '0')}`, name });
+
+const createTopic = async (
+ projectId: string,
+ title: string,
+ updatedAt: Date,
+ extra: { description?: string; historySummary?: string } = {},
+) => {
+ const topic = await new TopicModel(serverDB, userId).create({ projectId, title });
+ await serverDB
+ .update(topics)
+ .set({ ...extra, updatedAt })
+ .where(eq(topics.id, topic.id));
+ return topic;
+};
+
+describe('ProjectOverviewRepository.list', () => {
+ beforeEach(async () => {
+ await serverDB.delete(users);
+ await serverDB.insert(users).values([{ id: userId }, { id: otherUserId }]);
+ });
+
+ afterEach(async () => {
+ await serverDB.delete(users);
+ });
+
+ it('returns nothing when the caller has no projects', async () => {
+ expect(await repo.list()).toEqual([]);
+ });
+
+ it('batches topics, tasks and members per project', async () => {
+ const project = await createProject('Folder');
+ const empty = await createProject('Empty');
+
+ await createTopic(project.id, 'Oldest', new Date('2026-01-01'));
+ await createTopic(project.id, 'Second', new Date('2026-01-02'));
+ await createTopic(project.id, 'Third', new Date('2026-01-03'));
+ await createTopic(project.id, 'Fourth', new Date('2026-01-04'), { description: 'not shown' });
+ await createTopic(project.id, 'Latest', new Date('2026-01-05'), {
+ historySummary: 'Summarized history',
+ });
+ const deleted = await createTopic(project.id, 'Deleted', new Date('2026-01-06'));
+ await serverDB.update(topics).set({ deletedAt: new Date() }).where(eq(topics.id, deleted.id));
+
+ const taskModel = new TaskModel(serverDB, userId);
+ const done = await taskModel.create({ instruction: 'Done', projectId: project.id });
+ await taskModel.create({ instruction: 'Open', projectId: project.id });
+ const canceled = await taskModel.create({ instruction: 'Dropped', projectId: project.id });
+ await serverDB.update(tasks).set({ status: 'completed' }).where(eq(tasks.id, done.id));
+ await serverDB.update(tasks).set({ status: 'canceled' }).where(eq(tasks.id, canceled.id));
+
+ const agentModel = new AgentModel(serverDB, userId);
+ for (const [index, title] of ['Writer', 'Reviewer', 'Tester'].entries()) {
+ const agent = await agentModel.create({ title });
+ await model.addAgent(project.id, { agentId: agent.id, sortOrder: index + 1 });
+ }
+
+ const overviews = await repo.list();
+ const overview = overviews.find((item) => item.projectId === project.id)!;
+
+ expect(overview.topicCount).toBe(5);
+ expect(overview.recentTopics.map((topic) => topic.title)).toEqual([
+ 'Latest',
+ 'Fourth',
+ 'Third',
+ 'Second',
+ ]);
+ expect(overview.recentTopics.map((topic) => topic.summary)).toEqual([
+ 'Summarized history',
+ null,
+ null,
+ null,
+ ]);
+ expect(overview.recentTopics[0].updatedAt).toBeInstanceOf(Date);
+ expect(overview).toMatchObject({ taskCount: 2, taskDoneCount: 1 });
+
+ // The main agent leads, then the project order, capped at three.
+ expect(overview.agentCount).toBe(4);
+ expect(overview.agents.map((agent) => agent.id)).toEqual([
+ project.coordinatorAgentId,
+ ...(await model.listAgents(project.id))!.slice(1, 3).map(({ agent }) => agent.id),
+ ]);
+ expect(overview.agents[1].title).toBe('Writer');
+
+ // A project with only its main agent still gets a card overview.
+ expect(overviews.find((item) => item.projectId === empty.id)).toMatchObject({
+ agentCount: 1,
+ recentTopics: [],
+ taskCount: 0,
+ topicCount: 0,
+ });
+ });
+
+ it('prefers a topic description over its history summary', async () => {
+ const project = await createProject('Described');
+ await createTopic(project.id, 'Only', new Date('2026-02-01'), {
+ description: 'Short description',
+ historySummary: 'Long summary',
+ });
+
+ const [overview] = await repo.list();
+
+ expect(overview.recentTopics[0].summary).toBe('Short description');
+ });
+
+ it('leaves out projects the caller cannot see', async () => {
+ await createProject('Foreign', new ProjectRepository(serverDB, otherUserId));
+
+ expect(await repo.list()).toEqual([]);
+ });
+});
diff --git a/packages/database/src/repositories/projectOverview/index.ts b/packages/database/src/repositories/projectOverview/index.ts
new file mode 100644
index 00000000000..4651fedf4e3
--- /dev/null
+++ b/packages/database/src/repositories/projectOverview/index.ts
@@ -0,0 +1,231 @@
+import { and, asc, eq, inArray, isNull, ne, sql } from 'drizzle-orm';
+
+import { agents } from '../../schemas/agent';
+import { projectAgents, projects } from '../../schemas/project';
+import { tasks } from '../../schemas/task';
+import { topics } from '../../schemas/topic';
+import type { LobeChatDatabase } from '../../type';
+import { buildWorkspaceWhere } from '../../utils/workspace';
+
+/** Topics a folder card lists: the latest one as its headline, the rest as rows. */
+export const PROJECT_OVERVIEW_TOPIC_LIMIT = 4;
+/** Agents a folder card stacks. */
+export const PROJECT_OVERVIEW_AGENT_LIMIT = 3;
+/** The headline summary is a few lines on a card; the rest never renders. */
+const SUMMARY_MAX_CHARS = 240;
+
+export interface ProjectOverviewTopic {
+ id: string;
+ /** Only the latest topic carries one; the card shows it under the headline. */
+ summary: string | null;
+ title: string | null;
+ updatedAt: Date;
+}
+
+export interface ProjectOverviewAgent {
+ avatar: string | null;
+ backgroundColor: string | null;
+ id: string;
+ name: string | null;
+ title: string | null;
+}
+
+export interface ProjectOverview {
+ agentCount: number;
+ /** Members, the main agent first, at most {@link PROJECT_OVERVIEW_AGENT_LIMIT}. */
+ agents: ProjectOverviewAgent[];
+ projectId: string;
+ /** Newest first, at most {@link PROJECT_OVERVIEW_TOPIC_LIMIT}. */
+ recentTopics: ProjectOverviewTopic[];
+ taskCount: number;
+ taskDoneCount: number;
+ topicCount: number;
+}
+
+const emptyOverview = (projectId: string): ProjectOverview => ({
+ agentCount: 0,
+ agents: [],
+ projectId,
+ recentTopics: [],
+ taskCount: 0,
+ taskDoneCount: 0,
+ topicCount: 0,
+});
+
+/**
+ * What the projects page draws on each folder card, for every project the
+ * caller can see, in one batch: a fixed number of queries whatever the number
+ * of projects, so the grid never asks per card.
+ */
+export class ProjectOverviewRepository {
+ constructor(
+ private readonly db: LobeChatDatabase,
+ private readonly userId: string,
+ private readonly workspaceId?: string,
+ ) {}
+
+ private get scope() {
+ return { userId: this.userId, workspaceId: this.workspaceId };
+ }
+
+ private readableProjectIds() {
+ return this.db
+ .select({ id: projects.id })
+ .from(projects)
+ .where(buildWorkspaceWhere(this.scope, projects));
+ }
+
+ /** The same topics the project page lists (`ProjectModel.listTopics`). */
+ private topicWhere() {
+ return and(
+ inArray(topics.projectId, this.readableProjectIds()),
+ buildWorkspaceWhere(this.scope, topics),
+ isNull(topics.deletedAt),
+ );
+ }
+
+ async list(): Promise<ProjectOverview[]> {
+ const [topicCounts, recentTopics, taskCounts, agentCounts, members] = await Promise.all([
+ this.countTopics(),
+ this.listRecentTopics(),
+ this.countTasks(),
+ this.countAgents(),
+ this.listMembers(),
+ ]);
+
+ const overviews = new Map<string, ProjectOverview>();
+ const overviewOf = (projectId: string) => {
+ let overview = overviews.get(projectId);
+ if (!overview) {
+ overview = emptyOverview(projectId);
+ overviews.set(projectId, overview);
+ }
+ return overview;
+ };
+
+ for (const row of topicCounts) overviewOf(row.projectId).topicCount = Number(row.count);
+ for (const { projectId, ...topic } of recentTopics)
+ overviewOf(projectId).recentTopics.push(topic);
+ for (const row of taskCounts) {
+ const overview = overviewOf(row.projectId);
+ overview.taskCount = Number(row.total);
+ overview.taskDoneCount = Number(row.done);
+ }
+ for (const row of agentCounts) overviewOf(row.projectId).agentCount = Number(row.count);
+ for (const { projectId, ...agent } of members) overviewOf(projectId).agents.push(agent);
+
+ return [...overviews.values()];
+ }
+
+ private async countTopics() {
+ return this.db
+ .select({ count: sql<number>`count(*)`, projectId: sql<string>`${topics.projectId}` })
+ .from(topics)
+ .where(this.topicWhere())
+ .groupBy(topics.projectId);
+ }
+
+ private async listRecentTopics() {
+ const ranked = this.db
+ .select({
+ id: topics.id,
+ projectId: sql<string>`${topics.projectId}`.as('project_id'),
+ rank: sql<number>`row_number() over (partition by ${topics.projectId} order by ${topics.updatedAt} desc, ${topics.id} desc)`.as(
+ 'rank',
+ ),
+ summary: sql<
+ string | null
+ >`coalesce(nullif(${topics.description}, ''), left(${topics.historySummary}, ${SUMMARY_MAX_CHARS}))`.as(
+ 'summary',
+ ),
+ title: topics.title,
+ updatedAt: topics.updatedAt,
+ })
+ .from(topics)
+ .where(this.topicWhere())
+ .as('ranked_project_topics');
+
+ const rows = await this.db
+ .select()
+ .from(ranked)
+ .where(sql`${ranked.rank} <= ${PROJECT_OVERVIEW_TOPIC_LIMIT}`)
+ .orderBy(asc(ranked.projectId), asc(ranked.rank));
+
+ return rows.map(({ id, projectId, rank, summary, title, updatedAt }) => ({
+ id,
+ projectId,
+ summary: Number(rank) === 1 ? summary : null,
+ title,
+ updatedAt,
+ }));
+ }
+
+ /** The same tasks the project page lists (`ProjectModel.listTasks`); canceled ones leave the total. */
+ private async countTasks() {
+ return this.db
+ .select({
+ done: sql<number>`count(*) filter (where ${tasks.status} = 'completed')`,
+ projectId: sql<string>`${tasks.projectId}`,
+ total: sql<number>`count(*)`,
+ })
+ .from(tasks)
+ .where(
+ and(
+ inArray(tasks.projectId, this.readableProjectIds()),
+ ne(tasks.status, 'canceled'),
+ buildWorkspaceWhere(this.scope, {
+ isDeleted: tasks.isDeleted,
+ userId: tasks.createdByUserId,
+ visibility: tasks.visibility,
+ workspaceId: tasks.workspaceId,
+ }),
+ ),
+ )
+ .groupBy(tasks.projectId);
+ }
+
+ private memberWhere() {
+ return and(
+ inArray(projectAgents.projectId, this.readableProjectIds()),
+ buildWorkspaceWhere(this.scope, agents),
+ );
+ }
+
+ private async countAgents() {
+ return this.db
+ .select({ count: sql<number>`count(*)`, projectId: projectAgents.projectId })
+ .from(projectAgents)
+ .innerJoin(agents, eq(projectAgents.agentId, agents.id))
+ .where(this.memberWhere())
+ .groupBy(projectAgents.projectId);
+ }
+
+ /** Member order of `ProjectModel.listAgents`: the main agent, then the project order. */
+ private async listMembers() {
+ const ranked = this.db
+ .select({
+ avatar: agents.avatar,
+ backgroundColor: agents.backgroundColor,
+ id: agents.id,
+ name: agents.name,
+ projectId: sql<string>`${projectAgents.projectId}`.as('project_id'),
+ rank: sql<number>`row_number() over (partition by ${projectAgents.projectId} order by case when ${projectAgents.agentId} = ${projects.coordinatorAgentId} then 0 else 1 end, ${projectAgents.sortOrder}, ${projectAgents.createdAt})`.as(
+ 'rank',
+ ),
+ title: agents.title,
+ })
+ .from(projectAgents)
+ .innerJoin(agents, eq(projectAgents.agentId, agents.id))
+ .innerJoin(projects, eq(projectAgents.projectId, projects.id))
+ .where(this.memberWhere())
+ .as('ranked_project_agents');
+
+ const rows = await this.db
+ .select()
+ .from(ranked)
+ .where(sql`${ranked.rank} <= ${PROJECT_OVERVIEW_AGENT_LIMIT}`)
+ .orderBy(asc(ranked.projectId), asc(ranked.rank));
+
+ return rows.map(({ rank: _rank, ...agent }) => agent);
+ }
+}
diff --git a/packages/locales/src/default/project.ts b/packages/locales/src/default/project.ts
index 3d617331157..7b22422ebe7 100644
--- a/packages/locales/src/default/project.ts
+++ b/packages/locales/src/default/project.ts
@@ -260,6 +260,17 @@ export default {
'goals.status.running': 'Pursuing',
'goals.status.scheduled': 'Scheduled',
'goals.title': 'Goals',
+ 'list.folder.coordinatedBy': 'Coordinated by {{name}}',
+ 'list.folder.intro': 'About',
+ 'list.folder.noTopics': 'No conversations',
+ 'list.folder.noTopicsHint':
+ 'No conversations yet. Start the first one in this project and it shows up here.',
+ 'list.folder.overviewError': "Couldn't load the conversations and tasks shown on the cards.",
+ 'list.folder.recentTopic': 'Latest conversation',
+ 'list.folder.running': 'In progress',
+ 'list.folder.taskProgress': '{{done}}/{{total}} tasks',
+ 'list.folder.topicCount_one': '{{count}} conversation',
+ 'list.folder.topicCount_other': '{{count}} conversations',
'list.emptyDescription': 'Create your first project to organize goals, tasks, and resources.',
'list.deleteAction': 'Delete project',
'list.deleteError': 'Could not delete the project.',
@@ -269,6 +280,9 @@ export default {
'list.searchPlaceholder': 'Search projects',
'list.title': 'Projects',
'list.viewAll': 'View all projects',
+ 'list.view.folder': 'Folders',
+ 'list.view.list': 'List',
+ 'list.view.title': 'View',
'overview.noDescription': 'A dedicated workspace for this long-running goal.',
'overview.activeTasks': 'In progress',
'overview.agentSelect': 'Choose an agent',
diff --git a/src/features/Projects/List/FolderCard/Actions.test.tsx b/src/features/Projects/List/FolderCard/Actions.test.tsx
new file mode 100644
index 00000000000..edd025f6c92
--- /dev/null
+++ b/src/features/Projects/List/FolderCard/Actions.test.tsx
@@ -0,0 +1,29 @@
+/**
+ * @vitest-environment happy-dom
+ */
+import { render, screen } from '@testing-library/react';
+import { describe, expect, it, vi } from 'vitest';
+
+import { RowMouseSensor, RowTouchSensor } from '@/features/HomeSidebar/Body/sortableRow';
+
+import { FolderCardActions } from './Actions';
+
+vi.mock('react-i18next', async (importOriginal) => ({
+ ...(await importOriginal<object>()),
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
+describe('FolderCardActions', () => {
+ it('does not arm the card drag sensors when the ⋯ button is pressed', () => {
+ render(<FolderCardActions menuItems={[]} />);
+ const button = screen.getByRole('button', { name: 'list.moreActions' });
+
+ const mouse = new MouseEvent('mousedown', { bubbles: true, button: 0 });
+ Object.defineProperty(mouse, 'target', { value: button });
+ const touch = new Event('touchstart', { bubbles: true });
+ Object.defineProperty(touch, 'target', { value: button });
+
+ expect(RowMouseSensor.activators[0].handler({ nativeEvent: mouse })).toBe(false);
+ expect(RowTouchSensor.activators[0].handler({ nativeEvent: touch as TouchEvent })).toBe(false);
+ });
+});
diff --git a/src/features/Projects/List/FolderCard/Actions.tsx b/src/features/Projects/List/FolderCard/Actions.tsx
new file mode 100644
index 00000000000..3a9de4baf5a
--- /dev/null
+++ b/src/features/Projects/List/FolderCard/Actions.tsx
@@ -0,0 +1,54 @@
+'use client';
+
+import { ActionIcon, type DropdownItem, DropdownMenu } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
+import { MoreHorizontalIcon } from 'lucide-react';
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { folderCardMarker } from './markers.stylex';
+
+const styles = stylex.create({
+ actions: {
+ // Over the pocket's top-right corner, beside the project name.
+ insetBlockStart: 207,
+ insetInlineEnd: 12,
+ opacity: {
+ 'default': 0,
+ '@media (hover: none)': 1,
+ [stylex.when.ancestor(':hover', folderCardMarker)]: 1,
+ [stylex.when.ancestor(':focus-within', folderCardMarker)]: 1,
+ },
+ position: 'absolute',
+ transitionDuration: cssVar.motionDurationFast,
+ transitionProperty: 'opacity',
+ zIndex: 2,
+ },
+});
+
+interface FolderCardActionsProps {
+ deleting?: boolean;
+ menuItems: DropdownItem[];
+}
+
+// `data-row-action` keeps a press on the ⋯ button from picking the card up
+// for a manual-sort drag (see RowMouseSensor / RowTouchSensor).
+export const FolderCardActions = memo<FolderCardActionsProps>(({ deleting, menuItems }) => {
+ const { t } = useTranslation('project');
+
+ return (
+ <span data-row-action {...stylex.props(styles.actions)}>
+ <DropdownMenu items={menuItems} placement={'bottomRight'}>
+ <ActionIcon
+ icon={MoreHorizontalIcon}
+ loading={deleting}
+ size={'small'}
+ title={t('list.moreActions')}
+ />
+ </DropdownMenu>
+ </span>
+ );
+});
+
+FolderCardActions.displayName = 'FolderCardActions';
diff --git a/src/features/Projects/List/FolderCard/AgentStack.tsx b/src/features/Projects/List/FolderCard/AgentStack.tsx
new file mode 100644
index 00000000000..1d4deb0fe5a
--- /dev/null
+++ b/src/features/Projects/List/FolderCard/AgentStack.tsx
@@ -0,0 +1,80 @@
+import { agentDisplayName } from '@lobechat/types';
+import { Tooltip } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
+
+import AgentAvatar from '@/components/AgentAvatar';
+import AssigneeAvatar from '@/features/AgentTasks/features/AssigneeAvatar';
+import type { ProjectListItem, ProjectOverview } from '@/store/project';
+
+const AVATAR_SIZE = 18;
+
+const styles = stylex.create({
+ item: {
+ borderRadius: '50%',
+ // Separates overlapping avatars against the pocket glass.
+ boxShadow: `0 0 0 1.5px ${cssVar.colorBgLayout}`,
+ display: 'inline-flex',
+ marginInlineStart: { ':first-child': 0, 'default': -6 },
+ },
+ root: {
+ display: 'flex',
+ flexShrink: 0,
+ },
+});
+
+interface AgentStackProps {
+ /** Members from the overview; until it loads, the main agent stands in. */
+ agents?: ProjectOverview['agents'];
+ project: ProjectListItem;
+}
+
+/** The project's agents, overlapped, the main agent first. */
+export const AgentStack = ({ agents, project }: AgentStackProps) => {
+ if (!agents?.length) {
+ const { coordinatorAgent } = project;
+ const label = coordinatorAgent ? agentDisplayName(coordinatorAgent) : undefined;
+ return (
+ <span {...stylex.props(styles.root)}>
+ {coordinatorAgent && label ? (
+ <Tooltip title={label}>
+ <span {...stylex.props(styles.item)}>
+ <AgentAvatar
+ agentId={project.coordinatorAgentId}
+ avatar={coordinatorAgent.avatar}
+ background={coordinatorAgent.backgroundColor || cssVar.colorBgContainer}
+ name={label}
+ shape={'circle'}
+ size={AVATAR_SIZE}
+ />
+ </span>
+ </Tooltip>
+ ) : (
+ <AssigneeAvatar tooltip agentId={project.coordinatorAgentId} size={AVATAR_SIZE} />
+ )}
+ </span>
+ );
+ }
+
+ return (
+ <span {...stylex.props(styles.root)}>
+ {agents.map((agent) => {
+ const label = agentDisplayName(agent);
+ return (
+ <Tooltip key={agent.id} title={label}>
+ <span {...stylex.props(styles.item)}>
+ <AgentAvatar
+ agentId={agent.id}
+ avatar={agent.avatar}
+ background={agent.backgroundColor || cssVar.colorBgContainer}
+ name={label}
+ shape={'circle'}
+ size={AVATAR_SIZE}
+ />
+ </span>
+ </Tooltip>
+ );
+ })}
+ </span>
+ );
+};
diff --git a/src/features/Projects/List/FolderCard/FolderPaper.tsx b/src/features/Projects/List/FolderCard/FolderPaper.tsx
new file mode 100644
index 00000000000..9395c252871
--- /dev/null
+++ b/src/features/Projects/List/FolderCard/FolderPaper.tsx
@@ -0,0 +1,171 @@
+import { agentDisplayName } from '@lobechat/types';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
+import dayjs from 'dayjs';
+import { useTranslation } from 'react-i18next';
+
+import type { ProjectListItem } from '@/store/project';
+import { sx } from '@/styles/sx';
+
+import type { FolderSheet } from './folderSheet';
+
+const styles = stylex.create({
+ eyebrow: {
+ color: cssVar.colorTextQuaternary,
+ display: 'flex',
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: 10,
+ gap: 8,
+ justifyContent: 'space-between',
+ lineHeight: 1,
+ },
+ headline: {
+ WebkitBoxOrient: 'vertical',
+ WebkitLineClamp: 2,
+ color: cssVar.colorText,
+ display: '-webkit-box',
+ fontSize: 15,
+ fontWeight: 600,
+ letterSpacing: '-0.01em',
+ lineHeight: 1.35,
+ marginBlockEnd: 6,
+ marginBlockStart: 10,
+ overflow: 'hidden',
+ overflowWrap: 'anywhere',
+ },
+ hint: {
+ color: cssVar.colorTextQuaternary,
+ fontSize: 11,
+ lineHeight: 1.6,
+ margin: 0,
+ },
+ placeholder: {
+ backgroundColor: cssVar.colorFillTertiary,
+ borderRadius: 3,
+ display: 'block',
+ height: 5,
+ },
+ placeholders: {
+ display: 'grid',
+ gap: 6,
+ marginBlockStart: 12,
+ },
+ root: {
+ paddingBlock: 16,
+ paddingInline: 18,
+ },
+ row: {
+ alignItems: 'center',
+ color: cssVar.colorTextSecondary,
+ display: 'flex',
+ fontSize: 11,
+ gap: 8,
+ lineHeight: 1,
+ paddingBlock: 5,
+ },
+ rowBullet: {
+ backgroundColor: cssVar.colorTextQuaternary,
+ borderRadius: '50%',
+ flexShrink: 0,
+ height: 4,
+ width: 4,
+ },
+ rowTime: {
+ color: cssVar.colorTextQuaternary,
+ flexShrink: 0,
+ fontSize: 10,
+ },
+ rowTitle: {
+ flex: '1',
+ minWidth: 0,
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ rule: {
+ backgroundColor: cssVar.colorBorderSecondary,
+ height: 1,
+ marginBlockEnd: 6,
+ marginBlockStart: 10,
+ },
+ summary: {
+ WebkitBoxOrient: 'vertical',
+ WebkitLineClamp: 2,
+ color: cssVar.colorTextSecondary,
+ display: '-webkit-box',
+ fontSize: 11,
+ lineHeight: 1.6,
+ margin: 0,
+ overflow: 'hidden',
+ },
+});
+
+/** Faint lines where a project's conversations will appear. */
+const PLACEHOLDER_WIDTHS = ['84%', '66%', '74%'];
+
+interface FolderPaperProps {
+ project: ProjectListItem;
+ sheet: FolderSheet;
+}
+
+/** The front paper: the project's latest conversations, or its brief before it has any. */
+export const FolderPaper = ({ project, sheet }: FolderPaperProps) => {
+ const { t } = useTranslation('project');
+
+ if (sheet.kind === 'topics') {
+ const { latest, others } = sheet;
+ return (
+ <div {...stylex.props(styles.root)}>
+ <div {...stylex.props(styles.eyebrow)}>
+ <span>{t('list.folder.recentTopic')}</span>
+ <span>{dayjs(latest.updatedAt).fromNow()}</span>
+ </div>
+ <div {...stylex.props(styles.headline)}>
+ {latest.title || t('defaultTitle', { ns: 'topic' })}
+ </div>
+ {latest.summary && <p {...stylex.props(styles.summary)}>{latest.summary}</p>}
+ {others.length > 0 && (
+ <>
+ <div {...stylex.props(styles.rule)} />
+ {others.map((topic) => (
+ <div key={topic.id} {...stylex.props(styles.row)}>
+ <i {...stylex.props(styles.rowBullet)} />
+ <span {...stylex.props(styles.rowTitle)}>
+ {topic.title || t('defaultTitle', { ns: 'topic' })}
+ </span>
+ <span {...stylex.props(styles.rowTime)}>
+ {dayjs(topic.updatedAt).fromNow(true)}
+ </span>
+ </div>
+ ))}
+ </>
+ )}
+ </div>
+ );
+ }
+
+ const coordinator = project.coordinatorAgent ? agentDisplayName(project.coordinatorAgent) : '';
+ const lead =
+ project.description ||
+ (coordinator ? t('list.folder.coordinatedBy', { name: coordinator }) : project.name);
+
+ return (
+ <div {...stylex.props(styles.root)}>
+ <div {...stylex.props(styles.eyebrow)}>
+ <span>{t('list.folder.intro')}</span>
+ <span>{dayjs(project.createdAt).format('YYYY.MM')}</span>
+ </div>
+ <div {...stylex.props(styles.headline)}>{lead}</div>
+ {sheet.kind === 'intro' && (
+ <p {...stylex.props(styles.hint)}>{t('list.folder.noTopicsHint')}</p>
+ )}
+ {sheet.kind !== 'unavailable' && (
+ <div aria-hidden {...stylex.props(styles.placeholders)}>
+ {PLACEHOLDER_WIDTHS.map((width) => (
+ <span key={width} {...sx(styles.placeholder, { width })} />
+ ))}
+ </div>
+ )}
+ </div>
+ );
+};
diff --git a/src/features/Projects/List/FolderCard/folderSheet.test.ts b/src/features/Projects/List/FolderCard/folderSheet.test.ts
new file mode 100644
index 00000000000..786b4bf171e
--- /dev/null
+++ b/src/features/Projects/List/FolderCard/folderSheet.test.ts
@@ -0,0 +1,102 @@
+import { describe, expect, it } from 'vitest';
+
+import type { ProjectOverview } from '@/store/project';
+
+import { isRichFolder, resolveFolderSheet, resolveOverviewStatus } from './folderSheet';
+
+const topic = (title: string, day: number) => ({
+ id: `tpc_${title}`,
+ summary: null,
+ title,
+ updatedAt: new Date(2026, 0, day),
+});
+
+const overview = (patch: Partial<ProjectOverview> = {}): ProjectOverview => ({
+ agentCount: 1,
+ agents: [],
+ projectId: 'prj_1',
+ recentTopics: [],
+ taskCount: 0,
+ taskDoneCount: 0,
+ topicCount: 0,
+ ...patch,
+});
+
+describe('resolveFolderSheet', () => {
+ it('waits for the overview batch before claiming there are no conversations', () => {
+ expect(resolveFolderSheet(undefined, 'loading')).toEqual({ kind: 'pending' });
+ });
+
+ it('shows the brief when the loaded batch has no row for the project', () => {
+ expect(resolveFolderSheet(undefined, 'loaded')).toEqual({ kind: 'intro' });
+ });
+
+ it('shows the brief when the project has no conversations', () => {
+ expect(resolveFolderSheet(overview(), 'loaded')).toEqual({ kind: 'intro' });
+ });
+
+ it('heads the paper with the latest conversation and lists up to three others', () => {
+ const topics = [topic('e', 5), topic('d', 4), topic('c', 3), topic('b', 2), topic('a', 1)];
+ const sheet = resolveFolderSheet(overview({ recentTopics: topics, topicCount: 5 }), 'loaded');
+
+ expect(sheet).toEqual({ kind: 'topics', latest: topics[0], others: topics.slice(1, 4) });
+ });
+
+ it('lists no rows when the project has a single conversation', () => {
+ const only = topic('only', 1);
+
+ expect(resolveFolderSheet(overview({ recentTopics: [only], topicCount: 1 }), 'loaded')).toEqual(
+ {
+ kind: 'topics',
+ latest: only,
+ others: [],
+ },
+ );
+ });
+});
+
+describe('resolveOverviewStatus', () => {
+ it('is loading until the batch arrives', () => {
+ expect(resolveOverviewStatus({ error: undefined, loaded: false })).toBe('loading');
+ });
+
+ it('fails when the first fetch errors, instead of staying pending', () => {
+ expect(resolveOverviewStatus({ error: new Error('boom'), loaded: false })).toBe('failed');
+ });
+
+ it('keeps a cached batch when a later revalidation fails', () => {
+ expect(resolveOverviewStatus({ error: new Error('boom'), loaded: true })).toBe('loaded');
+ });
+});
+
+describe('resolveFolderSheet after a failed overview', () => {
+ it('shows the brief without the loading placeholders', () => {
+ expect(resolveFolderSheet(undefined, 'failed')).toEqual({ kind: 'unavailable' });
+ });
+
+ it('still shows a project row that is already loaded', () => {
+ const only = topic('only', 1);
+
+ expect(resolveFolderSheet(overview({ recentTopics: [only], topicCount: 1 }), 'failed')).toEqual(
+ { kind: 'topics', latest: only, others: [] },
+ );
+ });
+});
+
+describe('isRichFolder', () => {
+ it('is plain without an overview', () => {
+ expect(isRichFolder(undefined)).toBe(false);
+ });
+
+ it('is plain with up to three conversations and no tasks', () => {
+ expect(isRichFolder(overview({ topicCount: 3 }))).toBe(false);
+ });
+
+ it('is rich past three conversations', () => {
+ expect(isRichFolder(overview({ topicCount: 4 }))).toBe(true);
+ });
+
+ it('is rich with any task', () => {
+ expect(isRichFolder(overview({ taskCount: 1 }))).toBe(true);
+ });
+});
diff --git a/src/features/Projects/List/FolderCard/folderSheet.ts b/src/features/Projects/List/FolderCard/folderSheet.ts
new file mode 100644
index 00000000000..21acdcdf01c
--- /dev/null
+++ b/src/features/Projects/List/FolderCard/folderSheet.ts
@@ -0,0 +1,59 @@
+import type { ProjectOverview } from '@/store/project';
+
+type OverviewTopic = ProjectOverview['recentTopics'][number];
+
+/** Other topics listed under the headline; the paper has room for three rows. */
+export const FOLDER_TOPIC_ROWS = 3;
+
+/** More conversations than the front paper lists, or tasks, earn a second sheet edge. */
+const RICH_TOPIC_COUNT = 3;
+
+/**
+ * Where the overview batch stands. A cached batch counts as `loaded` even when
+ * its revalidation failed: the cards keep showing it.
+ */
+export type OverviewStatus = 'failed' | 'loaded' | 'loading';
+
+export const resolveOverviewStatus = ({
+ error,
+ loaded,
+}: {
+ error: unknown;
+ loaded: boolean;
+}): OverviewStatus => (loaded ? 'loaded' : error ? 'failed' : 'loading');
+
+/**
+ * What the front paper of a folder card shows:
+ * - `topics`: the latest conversation as its headline, the next few as rows;
+ * - `intro`: the project brief, with a "no conversations yet" hint;
+ * - `pending`: the brief alone while the overview loads, so a project with
+ * conversations never flashes the empty hint first;
+ * - `unavailable`: the brief alone after the overview failed to load, without
+ * the loading placeholders, so a failed card does not look pending forever.
+ */
+export type FolderSheet =
+ | { kind: 'intro' }
+ | { kind: 'pending' }
+ | { kind: 'unavailable' }
+ | { kind: 'topics'; latest: OverviewTopic; others: OverviewTopic[] };
+
+/**
+ * @param overview the project's overview row, `undefined` when it has none
+ * @param status where the overview batch stands
+ */
+export const resolveFolderSheet = (
+ overview: ProjectOverview | undefined,
+ status: OverviewStatus,
+): FolderSheet => {
+ if (!overview && status === 'loading') return { kind: 'pending' };
+ if (!overview && status === 'failed') return { kind: 'unavailable' };
+
+ const [latest, ...others] = overview?.recentTopics ?? [];
+ if (!latest) return { kind: 'intro' };
+
+ return { kind: 'topics', latest, others: others.slice(0, FOLDER_TOPIC_ROWS) };
+};
+
+/** A second paper edge peeks out behind the front one when the project holds more than it shows. */
+export const isRichFolder = (overview: ProjectOverview | undefined): boolean =>
+ !!overview && (overview.topicCount > RICH_TOPIC_COUNT || overview.taskCount > 0);
diff --git a/src/features/Projects/List/FolderCard/index.tsx b/src/features/Projects/List/FolderCard/index.tsx
new file mode 100644
index 00000000000..88163156d73
--- /dev/null
+++ b/src/features/Projects/List/FolderCard/index.tsx
@@ -0,0 +1,296 @@
+'use client';
+
+import { ContextMenuTrigger, Icon, Tooltip } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
+import dayjs from 'dayjs';
+import { StarIcon } from 'lucide-react';
+import { Fragment, memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useFavoriteToggle } from '@/features/Favorites';
+import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
+import { useIsDark } from '@/hooks/useIsDark';
+import type { ProjectListItem } from '@/store/project';
+import { useProjectOverview } from '@/store/project';
+
+import { projectFavoriteTarget } from '../../projectFavorite';
+import { useProjectMenuItems } from '../useProjectMenuItems';
+import { FolderCardActions } from './Actions';
+import { AgentStack } from './AgentStack';
+import { FolderPaper } from './FolderPaper';
+import { isRichFolder, type OverviewStatus, resolveFolderSheet } from './folderSheet';
+import { folderCardMarker } from './markers.stylex';
+
+const PAPER_EASE = 'cubic-bezier(.2,.8,.2,1)';
+const REDUCED_MOTION = '@media (prefers-reduced-motion: reduce)';
+// Opaque, so the tab laid over the back panel joins it without a darker overlap.
+const FOLDER_COLOR = `color-mix(in srgb, ${cssVar.colorText} 6%, ${cssVar.colorBgContainer})`;
+// Dark mode keeps the light layering: a recessed folder, the paper as the
+// brightest surface, and a pocket close to the page.
+const FOLDER_COLOR_DARK = `color-mix(in srgb, ${cssVar.colorBgLayout} 50%, ${cssVar.colorBgContainer})`;
+
+const styles = stylex.create({
+ back: {
+ backgroundColor: FOLDER_COLOR,
+ borderColor: cssVar.colorBorderSecondary,
+ borderStyle: 'solid',
+ borderWidth: 1,
+ borderEndEndRadius: 16,
+ borderEndStartRadius: 16,
+ borderStartEndRadius: 16,
+ borderStartStartRadius: 4,
+ insetBlockEnd: 0,
+ insetBlockStart: 8,
+ insetInline: 0,
+ position: 'absolute',
+ },
+ backDark: {
+ backgroundColor: FOLDER_COLOR_DARK,
+ },
+ dot: {
+ backgroundColor: cssVar.colorInfo,
+ borderRadius: '50%',
+ display: 'inline-block',
+ flexShrink: 0,
+ height: 7,
+ width: 7,
+ },
+ link: {
+ borderRadius: 16,
+ color: 'inherit',
+ display: 'block',
+ insetBlock: 0,
+ insetInline: 0,
+ outline: {
+ 'default': 'none',
+ ':focus-visible': `2px solid ${cssVar.colorPrimaryBorder}`,
+ },
+ outlineOffset: 4,
+ position: 'absolute',
+ },
+ meta: {
+ alignItems: 'center',
+ color: cssVar.colorTextSecondary,
+ display: 'flex',
+ fontSize: 12,
+ gap: 8,
+ minWidth: 0,
+ whiteSpace: 'nowrap',
+ },
+ metaFill: {
+ flex: '1',
+ },
+ name: {
+ color: cssVar.colorText,
+ fontSize: 16,
+ fontWeight: 600,
+ letterSpacing: '-0.01em',
+ minWidth: 0,
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ identifier: {
+ color: cssVar.colorTextQuaternary,
+ flexShrink: 0,
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: 11,
+ },
+ nameRow: {
+ alignItems: 'baseline',
+ display: 'flex',
+ gap: 8,
+ minWidth: 0,
+ // Leaves room for the more-actions button over the pocket's corner.
+ paddingInlineEnd: 28,
+ },
+ paper: {
+ backgroundColor: cssVar.colorBgElevated,
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: 10,
+ borderStyle: 'solid',
+ borderWidth: 1,
+ boxShadow: cssVar.boxShadowTertiary,
+ height: 212,
+ insetBlockStart: 22,
+ insetInline: 16,
+ overflow: 'hidden',
+ position: 'absolute',
+ transform: {
+ default: null,
+ [stylex.when.ancestor(':hover', folderCardMarker)]: 'translateY(-6px)',
+ [stylex.when.ancestor(':focus-within', folderCardMarker)]: 'translateY(-6px)',
+ },
+ transitionDuration: { default: cssVar.motionDurationMid, [REDUCED_MOTION]: '0s' },
+ transitionProperty: 'transform',
+ transitionTimingFunction: PAPER_EASE,
+ },
+ paperBehind: {
+ backgroundColor: cssVar.colorBgContainer,
+ boxShadow: 'none',
+ insetBlockStart: 14,
+ insetInline: 28,
+ transform: {
+ default: null,
+ [stylex.when.ancestor(':hover', folderCardMarker)]: 'translateY(-9px)',
+ [stylex.when.ancestor(':focus-within', folderCardMarker)]: 'translateY(-9px)',
+ },
+ },
+ paperBehindDark: {
+ backgroundColor: cssVar.colorBgElevated,
+ },
+ paperDark: {
+ backgroundColor: `color-mix(in srgb, ${cssVar.colorText} 8%, ${cssVar.colorBgElevated})`,
+ },
+ pocket: {
+ backdropFilter: 'blur(16px) saturate(1.2)',
+ backgroundColor: `color-mix(in srgb, ${cssVar.colorBgLayout} 78%, transparent)`,
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: 16,
+ borderStyle: 'solid',
+ borderWidth: 1,
+ display: 'flex',
+ flexDirection: 'column',
+ height: 104,
+ insetBlockEnd: 0,
+ insetInline: 0,
+ justifyContent: 'space-between',
+ paddingBlockEnd: 14,
+ paddingBlockStart: 16,
+ paddingInline: 18,
+ position: 'absolute',
+ },
+ pocketDark: {
+ backgroundColor: `color-mix(in srgb, ${cssVar.colorBgContainer} 78%, transparent)`,
+ },
+ root: {
+ height: 300,
+ position: 'relative',
+ },
+ sep: {
+ backgroundColor: cssVar.colorTextQuaternary,
+ borderRadius: '50%',
+ flexShrink: 0,
+ height: 2,
+ width: 2,
+ },
+ star: {
+ flexShrink: 0,
+ marginInlineStart: 'auto',
+ },
+ tab: {
+ backgroundColor: FOLDER_COLOR,
+ borderBlockEndWidth: 0,
+ borderColor: cssVar.colorBorderSecondary,
+ borderStartEndRadius: 12,
+ borderStartStartRadius: 12,
+ borderStyle: 'solid',
+ borderWidth: 1,
+ height: 20,
+ insetBlockStart: 0,
+ insetInlineStart: 0,
+ position: 'absolute',
+ width: '40%',
+ },
+});
+
+interface FolderCardProps {
+ /** Where the page's overview batch stands; the page owns the fetch and its error. */
+ overviewStatus: OverviewStatus;
+ project: ProjectListItem;
+}
+
+/**
+ * A project as a folder: a back panel with a tab, the project's latest content
+ * on a paper inside, and a frosted pocket in front with its name and numbers.
+ */
+export const FolderCard = memo<FolderCardProps>(({ overviewStatus, project }) => {
+ const { t } = useTranslation('project');
+ const overview = useProjectOverview(project.id);
+ const { deleting, menuItems } = useProjectMenuItems(project);
+ const { isFavorite } = useFavoriteToggle(projectFavoriteTarget(project));
+ const isDark = useIsDark();
+
+ const sheet = resolveFolderSheet(overview, overviewStatus);
+ const rich = isRichFolder(overview);
+ const running = project.status === 'active';
+ const showCounts = overviewStatus === 'loaded';
+ const topicCount = overview?.topicCount ?? 0;
+ const taskCount = overview?.taskCount ?? 0;
+
+ const metaItems = [
+ showCounts &&
+ (topicCount > 0
+ ? t('list.folder.topicCount', { count: topicCount })
+ : t('list.folder.noTopics')),
+ showCounts &&
+ taskCount > 0 &&
+ t('list.folder.taskProgress', { done: overview?.taskDoneCount ?? 0, total: taskCount }),
+ ].filter((item): item is string => !!item);
+
+ return (
+ <ContextMenuTrigger items={menuItems}>
+ <div {...stylex.props(styles.root, folderCardMarker)}>
+ <div {...stylex.props(styles.back, isDark && styles.backDark)} />
+ <div {...stylex.props(styles.tab, isDark && styles.backDark)} />
+ {rich && (
+ <div
+ {...stylex.props(
+ styles.paper,
+ isDark && styles.paperDark,
+ styles.paperBehind,
+ isDark && styles.paperBehindDark,
+ )}
+ />
+ )}
+ <div {...stylex.props(styles.paper, isDark && styles.paperDark)}>
+ <FolderPaper project={project} sheet={sheet} />
+ </div>
+ <WorkspaceLink
+ aria-label={project.name}
+ to={`/project/${project.slug ?? project.id}`}
+ {...stylex.props(styles.link)}
+ >
+ <div {...stylex.props(styles.pocket, isDark && styles.pocketDark)}>
+ <div {...stylex.props(styles.nameRow)}>
+ <span {...stylex.props(styles.name)}>{project.name}</span>
+ <span {...stylex.props(styles.identifier)}>{project.identifier}</span>
+ {isFavorite && (
+ <span {...stylex.props(styles.star)}>
+ <Icon
+ color={cssVar.colorWarning}
+ fill={cssVar.colorWarning}
+ icon={StarIcon}
+ size={13}
+ />
+ </span>
+ )}
+ </div>
+ <div {...stylex.props(styles.meta)}>
+ {running && (
+ <Tooltip title={t('list.folder.running')}>
+ <span aria-label={t('list.folder.running')} {...stylex.props(styles.dot)} />
+ </Tooltip>
+ )}
+ {metaItems.map((item, index) => (
+ <Fragment key={index}>
+ {index > 0 && <span {...stylex.props(styles.sep)} />}
+ <span>{item}</span>
+ </Fragment>
+ ))}
+ <span {...stylex.props(styles.metaFill)} />
+ <AgentStack agents={overview?.agents} project={project} />
+ <span title={dayjs(project.updatedAt).format('YYYY-MM-DD HH:mm')}>
+ {dayjs(project.updatedAt).fromNow()}
+ </span>
+ </div>
+ </div>
+ </WorkspaceLink>
+ <FolderCardActions deleting={deleting} menuItems={menuItems} />
+ </div>
+ </ContextMenuTrigger>
+ );
+});
+
+FolderCard.displayName = 'FolderCard';
diff --git a/src/features/Projects/List/FolderCard/markers.stylex.ts b/src/features/Projects/List/FolderCard/markers.stylex.ts
new file mode 100644
index 00000000000..ceab5b2f264
--- /dev/null
+++ b/src/features/Projects/List/FolderCard/markers.stylex.ts
@@ -0,0 +1,4 @@
+import * as stylex from '@stylexjs/stylex';
+
+/** The folder card: hovering or focusing it slides its papers up. */
+export const folderCardMarker = stylex.defineMarker();
diff --git a/src/features/Projects/List/FolderGrid.tsx b/src/features/Projects/List/FolderGrid.tsx
new file mode 100644
index 00000000000..ce7bee19a85
--- /dev/null
+++ b/src/features/Projects/List/FolderGrid.tsx
@@ -0,0 +1,115 @@
+'use client';
+
+import { type DropdownItem, DropdownMenu, Icon } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
+import { PlusIcon } from 'lucide-react';
+import { useTranslation } from 'react-i18next';
+
+import type { ProjectListItem } from '@/store/project';
+
+import { FolderCard } from './FolderCard';
+import type { OverviewStatus } from './FolderCard/folderSheet';
+import SortableProjectRows from './SortableProjectRows';
+
+const styles = stylex.create({
+ create: {
+ alignItems: 'center',
+ appearance: 'none',
+ backgroundColor: {
+ 'default': 'transparent',
+ ':hover': cssVar.colorFillQuaternary,
+ },
+ borderColor: cssVar.colorBorder,
+ borderRadius: 16,
+ borderStyle: 'dashed',
+ borderWidth: 1.5,
+ color: cssVar.colorTextTertiary,
+ cursor: 'pointer',
+ display: 'flex',
+ flexDirection: 'column',
+ font: 'inherit',
+ gap: 10,
+ height: 286,
+ justifyContent: 'center',
+ marginBlockStart: 14,
+ padding: 0,
+ transitionDuration: cssVar.motionDurationFast,
+ transitionProperty: 'background-color',
+ width: '100%',
+ },
+ createIcon: {
+ alignItems: 'center',
+ backgroundColor: cssVar.colorFillTertiary,
+ borderRadius: 12,
+ color: cssVar.colorTextSecondary,
+ display: 'flex',
+ height: 42,
+ justifyContent: 'center',
+ width: 42,
+ },
+ grid: {
+ display: 'grid',
+ columnGap: 28,
+ gridTemplateColumns: 'repeat(auto-fill, minmax(280px, 1fr))',
+ rowGap: 36,
+ },
+ skeleton: {
+ backgroundColor: cssVar.colorFillQuaternary,
+ borderRadius: 16,
+ height: 300,
+ },
+});
+
+const SKELETON_CARDS = 6;
+
+/** Placeholder folders while the project list first loads. */
+export const FolderGridSkeleton = () => (
+ <div aria-hidden {...stylex.props(styles.grid)}>
+ {Array.from({ length: SKELETON_CARDS }, (_, index) => (
+ <div key={index} {...stylex.props(styles.skeleton)} />
+ ))}
+ </div>
+);
+
+interface FolderGridProps {
+ createMenuItems: DropdownItem[];
+ /** Cards can be dragged into the shared custom order. */
+ draggable: boolean;
+ overviewStatus: OverviewStatus;
+ projects: ProjectListItem[];
+}
+
+/** Projects as folder cards, ending with a card that creates one. */
+export const FolderGrid = ({
+ createMenuItems,
+ draggable,
+ overviewStatus,
+ projects,
+}: FolderGridProps) => {
+ const { t } = useTranslation('project');
+
+ return (
+ <div {...stylex.props(styles.grid)}>
+ {draggable ? (
+ <SortableProjectRows
+ layout={'grid'}
+ projects={projects}
+ renderRow={(project) => <FolderCard overviewStatus={overviewStatus} project={project} />}
+ />
+ ) : (
+ projects.map((project) => (
+ <FolderCard key={project.id} overviewStatus={overviewStatus} project={project} />
+ ))
+ )}
+ <DropdownMenu items={createMenuItems} placement={'bottom'}>
+ <button type={'button'} {...stylex.props(styles.create)}>
+ <span {...stylex.props(styles.createIcon)}>
+ <Icon icon={PlusIcon} size={20} />
+ </span>
+ {t('create.action')}
+ </button>
+ </DropdownMenu>
+ </div>
+ );
+};
diff --git a/src/features/Projects/List/SortableProjectRows.tsx b/src/features/Projects/List/SortableProjectRows.tsx
index 3690b67a64b..e7c30f083a1 100644
--- a/src/features/Projects/List/SortableProjectRows.tsx
+++ b/src/features/Projects/List/SortableProjectRows.tsx
@@ -11,6 +11,7 @@ import {
} from '@dnd-kit/core';
import {
arrayMove,
+ rectSortingStrategy,
SortableContext,
sortableKeyboardCoordinates,
useSortable,
@@ -80,76 +81,83 @@ const SortableRow = memo<SortableRowProps>(({ children, id }) => {
SortableRow.displayName = 'SortableRow';
interface SortableProjectRowsProps {
+ /** `grid` lets items move across columns (folder cards); `list` keeps them in one column. */
+ layout?: 'grid' | 'list';
/** Rows in their current custom order — the whole list, never a search subset. */
projects: ProjectListItem[];
renderRow: (project: ProjectListItem) => ReactNode;
}
/** Drag to reorder the shared custom project order. */
-const SortableProjectRows = memo<SortableProjectRowsProps>(({ projects, renderRow }) => {
- const { t } = useTranslation('project');
- const moveProject = useProjectStore((s) => s.moveProject);
- const [activeId, setActiveId] = useState<string>();
- const ids = useMemo(() => projects.map((p) => p.id), [projects]);
-
- const sensors = useSensors(
- useSensor(RowMouseSensor, { activationConstraint: { distance: 5 } }),
- // A press-and-hold picks a row up on touch, so a vertical swipe still scrolls the page.
- useSensor(RowTouchSensor, { activationConstraint: { delay: 250, tolerance: 5 } }),
- useSensor(RowKeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }),
- );
-
- const activeProject = activeId ? projects.find((p) => p.id === activeId) : undefined;
-
- const handleDragStart = ({ active }: DragStartEvent) => setActiveId(String(active.id));
-
- const handleDragEnd = async ({ active, over }: DragEndEvent) => {
- setActiveId(undefined);
- suppressNextClick();
- if (!over || active.id === over.id) return;
-
- try {
- await moveProject(
- String(active.id),
- arrayMove(ids, ids.indexOf(String(active.id)), ids.indexOf(String(over.id))),
- );
- } catch (error) {
- console.error('Failed to save project order', error);
- toast.error(t('sidebar.reorderError'));
- }
- };
-
- return (
- <DndContext
- collisionDetection={closestCenter}
- sensors={sensors}
- onDragCancel={() => setActiveId(undefined)}
- onDragEnd={handleDragEnd}
- onDragStart={handleDragStart}
- >
- <SortableContext items={ids} strategy={verticalListSortingStrategy}>
- {projects.map((project) => (
- <SortableRow id={project.id} key={project.id}>
- {renderRow(project)}
- </SortableRow>
- ))}
- </SortableContext>
- {createPortal(
- <DragOverlay dropAnimation={sortableRowDropAnimation}>
- {activeProject ? (
- <Flexbox horizontal align={'center'} gap={8} {...stylex.props(styles.overlay)}>
- {projectIcon(activeProject)}
- <Text ellipsis weight={500}>
- {activeProject.name}
- </Text>
- </Flexbox>
- ) : null}
- </DragOverlay>,
- document.body,
- )}
- </DndContext>
- );
-});
+const SortableProjectRows = memo<SortableProjectRowsProps>(
+ ({ layout = 'list', projects, renderRow }) => {
+ const { t } = useTranslation('project');
+ const moveProject = useProjectStore((s) => s.moveProject);
+ const [activeId, setActiveId] = useState<string>();
+ const ids = useMemo(() => projects.map((p) => p.id), [projects]);
+
+ const sensors = useSensors(
+ useSensor(RowMouseSensor, { activationConstraint: { distance: 5 } }),
+ // A press-and-hold picks a row up on touch, so a vertical swipe still scrolls the page.
+ useSensor(RowTouchSensor, { activationConstraint: { delay: 250, tolerance: 5 } }),
+ useSensor(RowKeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }),
+ );
+
+ const activeProject = activeId ? projects.find((p) => p.id === activeId) : undefined;
+
+ const handleDragStart = ({ active }: DragStartEvent) => setActiveId(String(active.id));
+
+ const handleDragEnd = async ({ active, over }: DragEndEvent) => {
+ setActiveId(undefined);
+ suppressNextClick();
+ if (!over || active.id === over.id) return;
+
+ try {
+ await moveProject(
+ String(active.id),
+ arrayMove(ids, ids.indexOf(String(active.id)), ids.indexOf(String(over.id))),
+ );
+ } catch (error) {
+ console.error('Failed to save project order', error);
+ toast.error(t('sidebar.reorderError'));
+ }
+ };
+
+ return (
+ <DndContext
+ collisionDetection={closestCenter}
+ sensors={sensors}
+ onDragCancel={() => setActiveId(undefined)}
+ onDragEnd={handleDragEnd}
+ onDragStart={handleDragStart}
+ >
+ <SortableContext
+ items={ids}
+ strategy={layout === 'grid' ? rectSortingStrategy : verticalListSortingStrategy}
+ >
+ {projects.map((project) => (
+ <SortableRow id={project.id} key={project.id}>
+ {renderRow(project)}
+ </SortableRow>
+ ))}
+ </SortableContext>
+ {createPortal(
+ <DragOverlay dropAnimation={sortableRowDropAnimation}>
+ {activeProject ? (
+ <Flexbox horizontal align={'center'} gap={8} {...stylex.props(styles.overlay)}>
+ {projectIcon(activeProject)}
+ <Text ellipsis weight={500}>
+ {activeProject.name}
+ </Text>
+ </Flexbox>
+ ) : null}
+ </DragOverlay>,
+ document.body,
+ )}
+ </DndContext>
+ );
+ },
+);
SortableProjectRows.displayName = 'SortableProjectRows';
diff --git a/src/features/Projects/List/index.tsx b/src/features/Projects/List/index.tsx
index 248b991fefe..847c4359a2b 100644
--- a/src/features/Projects/List/index.tsx
+++ b/src/features/Projects/List/index.tsx
@@ -16,20 +16,20 @@ import {
Flexbox,
Icon,
SearchBar,
+ Segmented,
Text,
- toast,
Tooltip,
} from '@lobehub/ui';
import dayjs from 'dayjs';
import {
ArrowDownUpIcon,
FolderClosedIcon,
+ ListIcon,
+ type LucideIcon,
MoreHorizontalIcon,
- PencilIcon,
PlusIcon,
SearchXIcon,
StarIcon,
- TrashIcon,
} from 'lucide-react';
import { memo, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -39,33 +39,38 @@ import AgentAvatar from '@/components/AgentAvatar';
import AsyncError from '@/components/AsyncError';
import { PROJECT_STATUS_VISUALS, resolveProjectStatus } from '@/components/ExecutionStatus';
import AssigneeAvatar from '@/features/AgentTasks/features/AssigneeAvatar';
-import { useFavoriteMenuItem, useFavoriteToggle } from '@/features/Favorites';
+import { useFavoriteToggle } from '@/features/Favorites';
import NavHeader from '@/features/NavHeader';
import SkeletonList from '@/features/NavPanel/components/SkeletonList';
import { openCreateProjectFromGithubModal } from '@/features/Projects/CreateFromGithub';
import { openCreateProjectModal } from '@/features/Projects/CreateProjectModal';
-import { createDeleteProjectModal } from '@/features/Projects/DeleteProjectModal';
import ProjectDisabled from '@/features/Projects/ProjectDisabled';
-import { openRenameProjectModal } from '@/features/Projects/RenameProjectModal';
import { useCanManageProject } from '@/features/Projects/useCanManageProject';
import TopicCreatorAvatar from '@/features/TopicCreatorAvatar';
import UserAvatar from '@/features/User/UserAvatar';
import WideScreenContainer from '@/features/WideScreenContainer';
import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
import { useGlobalStore } from '@/store/global';
-import type { ProjectListSortBy } from '@/store/global/initialState';
+import type { ProjectListSortBy, ProjectListViewMode } from '@/store/global/initialState';
import { systemStatusSelectors } from '@/store/global/selectors';
-import { useLoadedProjectList, useProjectStore } from '@/store/project';
+import { useLoadedProjectList, useProjectOverviewsLoaded, useProjectStore } from '@/store/project';
import type { ProjectListItem } from '@/store/project/store';
import { useUserStore } from '@/store/user';
import { labPreferSelectors } from '@/store/user/selectors';
import { projectFavoriteTarget } from '../projectFavorite';
import { resolveProjectListState } from '../projectListState';
+import { resolveOverviewStatus } from './FolderCard/folderSheet';
+import { FolderGrid, FolderGridSkeleton } from './FolderGrid';
import SortableProjectRows from './SortableProjectRows';
import { sortProjects } from './sortProjects';
+import { useProjectMenuItems } from './useProjectMenuItems';
const SORT_BYS: ProjectListSortBy[] = ['manual', 'createdAt', 'updatedAt'];
+const VIEW_MODES: { icon: LucideIcon; mode: ProjectListViewMode }[] = [
+ { icon: FolderClosedIcon, mode: 'folder' },
+ { icon: ListIcon, mode: 'list' },
+];
const styles = createStaticStyles(({ css, cssVar }) => ({
actions: css`
@@ -211,54 +216,10 @@ ProjectFavoriteStar.displayName = 'ProjectFavoriteStar';
const ProjectRow = memo<{ project: ProjectListItem }>(({ project }) => {
const { t } = useTranslation(['project', 'common']);
- const [deleting, setDeleting] = useState(false);
- const deleteProject = useProjectStore((s) => s.deleteProject);
- const canManage = useCanManageProject();
- const favoriteMenuItem = useFavoriteMenuItem(projectFavoriteTarget(project), {
- showHotkey: false,
- });
+ const { deleting, menuItems } = useProjectMenuItems(project);
const status = resolveProjectStatus(project.status);
const statusVisual = PROJECT_STATUS_VISUALS[status];
- const handleDelete = async () => {
- setDeleting(true);
- try {
- await deleteProject(project.id);
- } catch (error) {
- // On success the row unmounts, so only a failure re-enables it.
- setDeleting(false);
- throw error;
- }
- toast.success(t('list.deleteSuccess', { name: project.name }));
- };
-
- const menuItems: DropdownItem[] = [
- ...(favoriteMenuItem ? [favoriteMenuItem] : []),
- ...(canManage
- ? ([
- { type: 'divider' },
- {
- icon: <Icon icon={PencilIcon} />,
- key: 'rename',
- label: t('rename.action'),
- onClick: () => openRenameProjectModal(project),
- },
- {
- danger: true,
- icon: <Icon icon={TrashIcon} />,
- key: 'delete',
- label: t('list.deleteAction'),
- onClick: () => {
- createDeleteProjectModal({
- onConfirm: handleDelete,
- project: { id: project.id, name: project.name },
- });
- },
- },
- ] satisfies DropdownItem[])
- : []),
- ];
-
const row = (
<Flexbox horizontal align={'center'} className={styles.row} gap={8}>
<WorkspaceLink className={styles.link} to={`/project/${project.slug ?? project.id}`}>
@@ -314,6 +275,16 @@ const ProjectListPage = memo(() => {
)(enabled);
const listState = resolveProjectListState({ error, isHydrated, isValidating, projects });
const sortBy = useGlobalStore(systemStatusSelectors.projectListSortBy);
+ const viewMode = useGlobalStore(systemStatusSelectors.projectListViewMode);
+ // Cards draw recent topics, tasks and members, which the light list row never needs.
+ const overviewSync = useProjectStore((s) => s.useFetchProjectOverviews)(
+ enabled && viewMode === 'folder',
+ );
+ const overviewsLoaded = useProjectOverviewsLoaded();
+ const overviewStatus = resolveOverviewStatus({
+ error: overviewSync.error,
+ loaded: overviewsLoaded,
+ });
const updateSystemStatus = useGlobalStore((s) => s.updateSystemStatus);
// The custom order is shared by the workspace, so only editors may change it.
const canManage = useCanManageProject();
@@ -339,6 +310,12 @@ const ProjectListPage = memo(() => {
type: 'checkbox' as const,
}));
+ const viewOptions = VIEW_MODES.map(({ icon, mode }) => ({
+ icon: <Icon icon={icon} />,
+ title: t(`list.view.${mode}`),
+ value: mode,
+ }));
+
const createMenuItems = useMemo<DropdownItem[]>(
() => [
{
@@ -391,6 +368,12 @@ const ProjectListPage = memo(() => {
onChange={(event) => setKeyword(event.target.value)}
/>
<Flexbox horizontal align={'center'} flex={'none'} gap={8}>
+ <Segmented<ProjectListViewMode>
+ aria-label={t('list.view.title')}
+ options={viewOptions}
+ value={viewMode}
+ onChange={(mode) => updateSystemStatus({ projectListViewMode: mode })}
+ />
<DropdownMenu items={sortMenuItems} placement={'bottomRight'}>
<Button icon={ArrowDownUpIcon} title={t('sidebar.sort.title')}>
{t(`sidebar.sort.${sortBy}`)}
@@ -404,7 +387,11 @@ const ProjectListPage = memo(() => {
{listState === 'error' ? (
<AsyncError error={error} onRetry={() => revalidate()} />
) : listState === 'loading' ? (
- <SkeletonList rows={8} />
+ viewMode === 'folder' ? (
+ <FolderGridSkeleton />
+ ) : (
+ <SkeletonList rows={8} />
+ )
) : filteredProjects.length === 0 ? (
<Center flex={1} padding={48}>
<Empty
@@ -412,6 +399,24 @@ const ProjectListPage = memo(() => {
icon={keyword.trim() ? SearchXIcon : FolderClosedIcon}
/>
</Center>
+ ) : viewMode === 'folder' ? (
+ <Flexbox gap={16}>
+ {overviewStatus === 'failed' && (
+ // The cards stay usable; only their conversations and tasks are missing.
+ <AsyncError
+ error={overviewSync.error}
+ title={t('list.folder.overviewError')}
+ variant={'inline'}
+ onRetry={() => overviewSync.revalidate()}
+ />
+ )}
+ <FolderGrid
+ createMenuItems={createMenuItems}
+ draggable={draggable}
+ overviewStatus={overviewStatus}
+ projects={filteredProjects}
+ />
+ </Flexbox>
) : (
<Flexbox gap={4}>
{draggable ? (
diff --git a/src/features/Projects/List/useProjectMenuItems.tsx b/src/features/Projects/List/useProjectMenuItems.tsx
new file mode 100644
index 00000000000..2b1cdf95257
--- /dev/null
+++ b/src/features/Projects/List/useProjectMenuItems.tsx
@@ -0,0 +1,65 @@
+import { type DropdownItem, Icon, toast } from '@lobehub/ui';
+import { PencilIcon, TrashIcon } from 'lucide-react';
+import { useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useFavoriteMenuItem } from '@/features/Favorites';
+import { createDeleteProjectModal } from '@/features/Projects/DeleteProjectModal';
+import { openRenameProjectModal } from '@/features/Projects/RenameProjectModal';
+import { useCanManageProject } from '@/features/Projects/useCanManageProject';
+import { useProjectStore } from '@/store/project';
+import type { ProjectListItem } from '@/store/project/store';
+
+import { projectFavoriteTarget } from '../projectFavorite';
+
+/** Favorite, rename and delete for one project, shared by its row and its folder card. */
+export const useProjectMenuItems = (project: ProjectListItem) => {
+ const { t } = useTranslation(['project', 'common']);
+ const [deleting, setDeleting] = useState(false);
+ const deleteProject = useProjectStore((s) => s.deleteProject);
+ const canManage = useCanManageProject();
+ const favoriteMenuItem = useFavoriteMenuItem(projectFavoriteTarget(project), {
+ showHotkey: false,
+ });
+
+ const handleDelete = async () => {
+ setDeleting(true);
+ try {
+ await deleteProject(project.id);
+ } catch (error) {
+ // On success the row unmounts, so only a failure re-enables it.
+ setDeleting(false);
+ throw error;
+ }
+ toast.success(t('list.deleteSuccess', { name: project.name }));
+ };
+
+ const menuItems: DropdownItem[] = [
+ ...(favoriteMenuItem ? [favoriteMenuItem] : []),
+ ...(canManage
+ ? ([
+ { type: 'divider' },
+ {
+ icon: <Icon icon={PencilIcon} />,
+ key: 'rename',
+ label: t('rename.action'),
+ onClick: () => openRenameProjectModal(project),
+ },
+ {
+ danger: true,
+ icon: <Icon icon={TrashIcon} />,
+ key: 'delete',
+ label: t('list.deleteAction'),
+ onClick: () => {
+ createDeleteProjectModal({
+ onConfirm: handleDelete,
+ project: { id: project.id, name: project.name },
+ });
+ },
+ },
+ ] satisfies DropdownItem[])
+ : []),
+ ];
+
+ return { deleting, menuItems };
+};
diff --git a/src/services/project.ts b/src/services/project.ts
index 02e7dd324f5..47ab83c4497 100644
--- a/src/services/project.ts
+++ b/src/services/project.ts
@@ -47,6 +47,9 @@ class ProjectService {
return { ...response, data: projects };
};
+ /** Folder-card content (recent topics, task progress, members) for every visible project. */
+ listOverviews = async () => lambdaClient.project.listOverviews.query();
+
detail = async (id: string) => lambdaClient.project.detail.query({ id });
delete = async (id: string) => lambdaClient.project.delete.mutate({ id });
diff --git a/src/store/global/initialState.ts b/src/store/global/initialState.ts
index 66c5fc05ba9..10793e6c2f6 100644
--- a/src/store/global/initialState.ts
+++ b/src/store/global/initialState.ts
@@ -197,6 +197,9 @@ export interface ChannelListSort {
/** How the sidebar project list is ordered; `manual` follows the shared drag order. */
export type ProjectListSortBy = 'manual' | 'createdAt' | 'updatedAt';
+/** How the projects page lays out projects: folder cards or compact rows. */
+export type ProjectListViewMode = 'folder' | 'list';
+
export interface SystemStatus {
/**
* Agent Builder panel width
@@ -384,6 +387,8 @@ export interface SystemStatus {
* order itself is shared and lives on `projects.sort_order`.
*/
projectListSortBy?: ProjectListSortBy;
+ /** Layout of the projects page. Device-local view setting. */
+ projectListViewMode?: ProjectListViewMode;
/**
* Per byProject group (keyed by the group id, e.g. `project-id:<id>`): how its
* topics are sectioned. Absent means `none`.
diff --git a/src/store/global/selectors/systemStatus.ts b/src/store/global/selectors/systemStatus.ts
index dbc704eb9c9..4187d83ac68 100644
--- a/src/store/global/selectors/systemStatus.ts
+++ b/src/store/global/selectors/systemStatus.ts
@@ -9,6 +9,7 @@ import type {
GlobalState,
ModelDetailPanelExpandedKey,
ProjectListSortBy,
+ ProjectListViewMode,
ProjectTopicSubGroupMode,
SystemStatus,
WorkspaceOverridableField,
@@ -515,6 +516,8 @@ const channelListSort = (s: GlobalState): ChannelListSort =>
s.status.channelListSort ?? DEFAULT_CHANNEL_LIST_SORT;
const projectListSortBy = (s: GlobalState): ProjectListSortBy =>
s.status.projectListSortBy ?? 'manual';
+const projectListViewMode = (s: GlobalState): ProjectListViewMode =>
+ s.status.projectListViewMode ?? 'folder';
const agentDocumentSort = (s: GlobalState): AgentDocumentSort =>
s.status.agentDocumentSort ?? DEFAULT_AGENT_DOCUMENT_SORT;
const agentListViewOptions = (s: GlobalState) => s.status.agentListViewOptions;
@@ -569,6 +572,7 @@ export const systemStatusSelectors = {
contactListSortBy,
channelListSort,
projectListSortBy,
+ projectListViewMode,
agentListExpandedGroupKeys,
agentListSidebarSectionCollapsed,
agentListViewMode,
diff --git a/src/store/project/index.ts b/src/store/project/index.ts
index 36aa308a0a2..a742591004e 100644
--- a/src/store/project/index.ts
+++ b/src/store/project/index.ts
@@ -1,4 +1,4 @@
-export type { ProjectDetail, ProjectListItem } from './store';
+export type { ProjectDetail, ProjectListItem, ProjectOverview } from './store';
export {
projectByRefSelector,
projectListItemSelector,
@@ -7,5 +7,7 @@ export {
useLoadedProjectList,
useProjectByRef,
useProjectIdByRef,
+ useProjectOverview,
+ useProjectOverviewsLoaded,
useProjectStore,
} from './store';
diff --git a/src/store/project/projection.ts b/src/store/project/projection.ts
index 59ad46618ff..c12ea62bc14 100644
--- a/src/store/project/projection.ts
+++ b/src/store/project/projection.ts
@@ -3,6 +3,7 @@ import type { projectService } from '@/services/project';
type ProjectListResponse = Awaited<ReturnType<typeof projectService.listAll>>;
type ProjectDetailResponse = Awaited<ReturnType<typeof projectService.detail>>;
+type ProjectOverviewResponse = Awaited<ReturnType<typeof projectService.listOverviews>>;
type ProjectListRow = ProjectListResponse['data'][number];
/**
* List and detail replicas share one project entity, and only `project.list`
@@ -11,6 +12,10 @@ type ProjectListRow = ProjectListResponse['data'][number];
export type ProjectListItem = Omit<ProjectListRow, 'coordinatorAgent'> &
Partial<Pick<ProjectListRow, 'coordinatorAgent'>>;
export type ProjectDetail = ProjectDetailResponse['data'];
+/** Folder-card content of one project; a project with no row has none of it yet. */
+export type ProjectOverview = ProjectOverviewResponse['data'][number];
+/** Overviews by project id. */
+export type ProjectOverviewMap = Record<string, ProjectOverview>;
/** The sidebar / list page reads every project, so the list has one entry. */
export const PROJECT_LIST_KEY = 'all';
@@ -34,3 +39,15 @@ export const projectDetailResource = defineReplica<string, ProjectDetail, Projec
storage: 'indexedDB',
version: 1,
});
+
+/** Folder-card content of every project in scope (`projectOverviewMap.all`), by project id. */
+export const projectOverviewResource = defineReplica<
+ Record<string, never>,
+ ProjectOverviewMap,
+ ProjectOverviewResponse
+>({
+ key: () => PROJECT_LIST_KEY,
+ name: 'projectOverview',
+ storage: 'indexedDB',
+ version: 1,
+});
diff --git a/src/store/project/store.ts b/src/store/project/store.ts
index 21bc4b06d86..ef3c935cdb8 100644
--- a/src/store/project/store.ts
+++ b/src/store/project/store.ts
@@ -28,9 +28,12 @@ import {
projectDetailResource,
type ProjectListItem,
projectListResource,
+ type ProjectOverview,
+ type ProjectOverviewMap,
+ projectOverviewResource,
} from './projection';
-export type { ProjectDetail, ProjectListItem } from './projection';
+export type { ProjectDetail, ProjectListItem, ProjectOverview } from './projection';
export interface ProjectStoreState {
/** Project pages by route param (id or slug). */
@@ -41,6 +44,10 @@ export interface ProjectStoreState {
projectListMap: Record<string, ProjectListItem[]>;
/** Replica bookkeeping for `projectListMap`. */
projectListReplica: ReplicaState<ProjectListItem[]>;
+ /** `projectOverviewMap.all`: folder-card content of every project, by project id. */
+ projectOverviewMap: Record<string, ProjectOverviewMap>;
+ /** Replica bookkeeping for `projectOverviewMap`. */
+ projectOverviewReplica: ReplicaState<ProjectOverviewMap>;
}
interface ProjectStore extends ProjectStoreState {
@@ -90,6 +97,8 @@ interface ProjectStore extends ProjectStoreState {
useFetchProjectDetail: (idOrSlug?: string) => ReplicaSyncResult;
/** Fetch orchestration only; read the rows with `useCurrentProjectList`. */
useFetchProjectList: (enabled?: boolean) => ReplicaSyncResult;
+ /** Fetch orchestration only; read a card's content with `useProjectOverview`. */
+ useFetchProjectOverviews: (enabled?: boolean) => ReplicaSyncResult;
}
export const initialProjectState: ProjectStoreState = {
@@ -97,6 +106,8 @@ export const initialProjectState: ProjectStoreState = {
projectDetailReplica: createReplicaState(),
projectListMap: {},
projectListReplica: createReplicaState(),
+ projectOverviewMap: {},
+ projectOverviewReplica: createReplicaState(),
};
const LIST_PARAMS = {} as Record<string, never>;
@@ -146,6 +157,16 @@ export const useProjectStore = createWithEqualityFn<ProjectStore>()(
stateKey: 'projectDetailReplica',
view: recordLens<ProjectStore, ProjectDetail>('projectDetailMap'),
});
+ const overviews = createReplicaSlice(projectOverviewResource, {
+ actionPrefix: 'project/overview',
+ fetcher: () => projectService.listOverviews(),
+ get,
+ merge: (response) =>
+ Object.fromEntries(response.data.map((overview) => [overview.projectId, overview])),
+ set,
+ stateKey: 'projectOverviewReplica',
+ view: recordLens<ProjectStore, ProjectOverviewMap>('projectOverviewMap'),
+ });
// The same project lives in the list and in every loaded project page.
const projectEntity = linkReplicaEntity<ProjectListItem>([list, detail]);
@@ -332,6 +353,7 @@ export const useProjectStore = createWithEqualityFn<ProjectStore>()(
},
useFetchProjectDetail: (idOrSlug) => detail.useSync(idOrSlug || null),
useFetchProjectList: (enabled = true) => list.useSync(LIST_PARAMS, { enabled }),
+ useFetchProjectOverviews: (enabled = true) => overviews.useSync(LIST_PARAMS, { enabled }),
};
}),
shallow,
@@ -351,6 +373,14 @@ export const useCurrentProjectList = () =>
export const useLoadedProjectList = () =>
useProjectStore((state): ProjectListItem[] | undefined => state.projectListMap[PROJECT_LIST_KEY]);
+/** A project's folder-card content; `undefined` until loaded or when it has none. */
+export const useProjectOverview = (projectId: string): ProjectOverview | undefined =>
+ useProjectStore((state) => state.projectOverviewMap[PROJECT_LIST_KEY]?.[projectId]);
+
+/** Whether the overview batch has arrived, so a card without a row really has no content. */
+export const useProjectOverviewsLoaded = () =>
+ useProjectStore((state) => state.projectOverviewMap[PROJECT_LIST_KEY] !== undefined);
+
/** One row of the cached project list; `undefined` when it is not (yet) in the list. */
export const projectListItemSelector =
(id: string | null | undefined) =>