Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

♻️ refactor(projects): count folder cards by tasks, star before the name (#22922)

Arvin Xu6b2bca7b5275
diff --git a/locales/en-US/project.json b/locales/en-US/project.json
index edcd60be968..108e6f4230c 100644
--- a/locales/en-US/project.json
+++ b/locales/en-US/project.json
@@ -173,14 +173,12 @@
"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.noTasks": "No tasks",
+ "list.folder.noTasksHint": "No tasks yet. Create the first one in this project and it shows up here.",
+ "list.folder.overviewError": "Couldn't load the tasks shown on the cards.",
+ "list.folder.recentTask": "Latest task",
"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",
diff --git a/locales/zh-CN/project.json b/locales/zh-CN/project.json
index ad81265a3a9..848a673d953 100644
--- a/locales/zh-CN/project.json
+++ b/locales/zh-CN/project.json
@@ -173,14 +173,12 @@
"list.emptyDescription": "创建第一个项目,集中组织目标、任务和资源。",
"list.folder.coordinatedBy": "由 {{name}} 协调",
"list.folder.intro": "项目简介",
- "list.folder.noTopics": "暂无对话",
- "list.folder.noTopicsHint": "还没有对话。在项目里发起第一个对话,它会出现在这里。",
- "list.folder.overviewError": "卡片上的对话和任务没能加载出来。",
- "list.folder.recentTopic": "最近对话",
+ "list.folder.noTasks": "暂无任务",
+ "list.folder.noTasksHint": "还没有任务。在项目里创建第一个任务,它会出现在这里。",
+ "list.folder.overviewError": "卡片上的任务没能加载出来。",
+ "list.folder.recentTask": "最近任务",
"list.folder.running": "进行中",
"list.folder.taskProgress": "{{done}}/{{total}} 任务",
- "list.folder.topicCount_one": "{{count}} 个对话",
- "list.folder.topicCount_other": "{{count}} 个对话",
"list.moreActions": "更多项目操作",
"list.searchEmpty": "没有匹配的项目。",
"list.searchPlaceholder": "搜索项目",
diff --git a/packages/database/src/repositories/projectOverview/__tests__/index.test.ts b/packages/database/src/repositories/projectOverview/__tests__/index.test.ts
index 2aff9967400..788e87fe474 100644
--- a/packages/database/src/repositories/projectOverview/__tests__/index.test.ts
+++ b/packages/database/src/repositories/projectOverview/__tests__/index.test.ts
@@ -5,8 +5,7 @@ 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 { tasks, users } from '../../../schemas';
import { ProjectRepository } from '../../project';
import { ProjectOverviewRepository } from '../index';
@@ -21,18 +20,22 @@ let identifierSequence = 0;
const createProject = (name: string, owner = projectRepo) =>
owner.create({ identifier: `O${String(++identifierSequence).padStart(5, '0')}`, name });
-const createTopic = async (
+const createTask = async (
projectId: string,
- title: string,
+ name: string,
updatedAt: Date,
- extra: { description?: string; historySummary?: string } = {},
+ extra: { description?: string; status?: string } = {},
) => {
- const topic = await new TopicModel(serverDB, userId).create({ projectId, title });
+ const task = await new TaskModel(serverDB, userId).create({
+ instruction: name,
+ name,
+ projectId,
+ });
await serverDB
- .update(topics)
+ .update(tasks)
.set({ ...extra, updatedAt })
- .where(eq(topics.id, topic.id));
- return topic;
+ .where(eq(tasks.id, task.id));
+ return task;
};
describe('ProjectOverviewRepository.list', () => {
@@ -49,26 +52,19 @@ describe('ProjectOverviewRepository.list', () => {
expect(await repo.list()).toEqual([]);
});
- it('batches topics, tasks and members per project', async () => {
+ it('batches 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',
+ await createTask(project.id, 'Oldest', new Date('2026-01-01'), { status: 'completed' });
+ await createTask(project.id, 'Second', new Date('2026-01-02'));
+ await createTask(project.id, 'Third', new Date('2026-01-03'));
+ await createTask(project.id, 'Fourth', new Date('2026-01-04'), { description: 'not shown' });
+ await createTask(project.id, 'Latest', new Date('2026-01-05'), {
+ description: 'Latest brief',
+ status: 'running',
});
- 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));
+ await createTask(project.id, 'Dropped', new Date('2026-01-06'), { status: 'canceled' });
const agentModel = new AgentModel(serverDB, userId);
for (const [index, title] of ['Writer', 'Reviewer', 'Tester'].entries()) {
@@ -79,21 +75,23 @@ describe('ProjectOverviewRepository.list', () => {
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([
+ // Canceled tasks leave both the rows and the total.
+ expect(overview).toMatchObject({ taskCount: 5, taskDoneCount: 1 });
+ expect(overview.recentTasks.map((task) => task.name)).toEqual([
'Latest',
'Fourth',
'Third',
'Second',
]);
- expect(overview.recentTopics.map((topic) => topic.summary)).toEqual([
- 'Summarized history',
+ expect(overview.recentTasks.map((task) => task.summary)).toEqual([
+ 'Latest brief',
null,
null,
null,
]);
- expect(overview.recentTopics[0].updatedAt).toBeInstanceOf(Date);
- expect(overview).toMatchObject({ taskCount: 2, taskDoneCount: 1 });
+ expect(overview.recentTasks[0]).toMatchObject({ status: 'running' });
+ expect(overview.recentTasks[0].identifier).toBeTruthy();
+ expect(overview.recentTasks[0].updatedAt).toBeInstanceOf(Date);
// The main agent leads, then the project order, capped at three.
expect(overview.agentCount).toBe(4);
@@ -106,22 +104,18 @@ describe('ProjectOverviewRepository.list', () => {
// A project with only its main agent still gets a card overview.
expect(overviews.find((item) => item.projectId === empty.id)).toMatchObject({
agentCount: 1,
- recentTopics: [],
+ recentTasks: [],
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',
- });
+ it('leaves the summary empty when the latest task has no description', async () => {
+ const project = await createProject('Undescribed');
+ await createTask(project.id, 'Only', new Date('2026-02-01'), { description: '' });
const [overview] = await repo.list();
- expect(overview.recentTopics[0].summary).toBe('Short description');
+ expect(overview.recentTasks[0].summary).toBeNull();
});
it('leaves out projects the caller cannot see', async () => {
diff --git a/packages/database/src/repositories/projectOverview/index.ts b/packages/database/src/repositories/projectOverview/index.ts
index 4651fedf4e3..d61532a0d01 100644
--- a/packages/database/src/repositories/projectOverview/index.ts
+++ b/packages/database/src/repositories/projectOverview/index.ts
@@ -1,24 +1,23 @@
-import { and, asc, eq, inArray, isNull, ne, sql } from 'drizzle-orm';
+import { and, asc, eq, inArray, 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;
+/** Tasks a folder card lists: the latest one as its headline, the rest as rows. */
+export const PROJECT_OVERVIEW_TASK_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 {
+export interface ProjectOverviewTask {
id: string;
- /** Only the latest topic carries one; the card shows it under the headline. */
+ identifier: string;
+ name: string | null;
+ status: string;
+ /** Only the latest task carries one; the card shows it under the headline. */
summary: string | null;
- title: string | null;
updatedAt: Date;
}
@@ -35,21 +34,19 @@ export interface ProjectOverview {
/** 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[];
+ /** Last updated first, at most {@link PROJECT_OVERVIEW_TASK_LIMIT}. */
+ recentTasks: ProjectOverviewTask[];
taskCount: number;
taskDoneCount: number;
- topicCount: number;
}
const emptyOverview = (projectId: string): ProjectOverview => ({
agentCount: 0,
agents: [],
projectId,
- recentTopics: [],
+ recentTasks: [],
taskCount: 0,
taskDoneCount: 0,
- topicCount: 0,
});
/**
@@ -75,20 +72,24 @@ export class ProjectOverviewRepository {
.where(buildWorkspaceWhere(this.scope, projects));
}
- /** The same topics the project page lists (`ProjectModel.listTopics`). */
- private topicWhere() {
+ /** The same tasks the project page lists (`ProjectModel.listTasks`), without canceled ones. */
+ private taskWhere() {
return and(
- inArray(topics.projectId, this.readableProjectIds()),
- buildWorkspaceWhere(this.scope, topics),
- isNull(topics.deletedAt),
+ inArray(tasks.projectId, this.readableProjectIds()),
+ ne(tasks.status, 'canceled'),
+ buildWorkspaceWhere(this.scope, {
+ isDeleted: tasks.isDeleted,
+ userId: tasks.createdByUserId,
+ visibility: tasks.visibility,
+ workspaceId: tasks.workspaceId,
+ }),
);
}
async list(): Promise<ProjectOverview[]> {
- const [topicCounts, recentTopics, taskCounts, agentCounts, members] = await Promise.all([
- this.countTopics(),
- this.listRecentTopics(),
+ const [taskCounts, recentTasks, agentCounts, members] = await Promise.all([
this.countTasks(),
+ this.listRecentTasks(),
this.countAgents(),
this.listMembers(),
]);
@@ -103,87 +104,60 @@ export class ProjectOverviewRepository {
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 { projectId, ...task } of recentTasks) overviewOf(projectId).recentTasks.push(task);
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() {
+ private async countTasks() {
return this.db
- .select({ count: sql<number>`count(*)`, projectId: sql<string>`${topics.projectId}` })
- .from(topics)
- .where(this.topicWhere())
- .groupBy(topics.projectId);
+ .select({
+ done: sql<number>`count(*) filter (where ${tasks.status} = 'completed')`,
+ projectId: sql<string>`${tasks.projectId}`,
+ total: sql<number>`count(*)`,
+ })
+ .from(tasks)
+ .where(this.taskWhere())
+ .groupBy(tasks.projectId);
}
- private async listRecentTopics() {
+ private async listRecentTasks() {
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(
+ description: tasks.description,
+ id: tasks.id,
+ identifier: tasks.identifier,
+ name: tasks.name,
+ projectId: sql<string>`${tasks.projectId}`.as('project_id'),
+ rank: sql<number>`row_number() over (partition by ${tasks.projectId} order by ${tasks.updatedAt} desc, ${tasks.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,
+ status: tasks.status,
+ updatedAt: tasks.updatedAt,
})
- .from(topics)
- .where(this.topicWhere())
- .as('ranked_project_topics');
+ .from(tasks)
+ .where(this.taskWhere())
+ .as('ranked_project_tasks');
const rows = await this.db
.select()
.from(ranked)
- .where(sql`${ranked.rank} <= ${PROJECT_OVERVIEW_TOPIC_LIMIT}`)
+ .where(sql`${ranked.rank} <= ${PROJECT_OVERVIEW_TASK_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,
+ return rows.map(({ description, rank, ...task }) => ({
+ ...task,
+ summary: Number(rank) === 1 ? description || null : null,
}));
}
- /** 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()),
diff --git a/packages/locales/src/default/project.ts b/packages/locales/src/default/project.ts
index 7b22422ebe7..4d4f8d70bd2 100644
--- a/packages/locales/src/default/project.ts
+++ b/packages/locales/src/default/project.ts
@@ -262,15 +262,13 @@ export default {
'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.noTasks': 'No tasks',
+ 'list.folder.noTasksHint':
+ 'No tasks yet. Create the first one in this project and it shows up here.',
+ 'list.folder.overviewError': "Couldn't load the tasks shown on the cards.",
+ 'list.folder.recentTask': 'Latest task',
'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.',
diff --git a/src/features/Projects/List/FolderCard/FolderPaper.tsx b/src/features/Projects/List/FolderCard/FolderPaper.tsx
index 9395c252871..a0402bd90d6 100644
--- a/src/features/Projects/List/FolderCard/FolderPaper.tsx
+++ b/src/features/Projects/List/FolderCard/FolderPaper.tsx
@@ -1,9 +1,12 @@
+import type { TaskStatus } from '@lobechat/types';
import { agentDisplayName } from '@lobechat/types';
+import { Icon } from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
import dayjs from 'dayjs';
import { useTranslation } from 'react-i18next';
+import { TASK_STATUS_VISUALS } from '@/components/ExecutionStatus';
import type { ProjectListItem } from '@/store/project';
import { sx } from '@/styles/sx';
@@ -63,12 +66,10 @@ const styles = stylex.create({
lineHeight: 1,
paddingBlock: 5,
},
- rowBullet: {
- backgroundColor: cssVar.colorTextQuaternary,
- borderRadius: '50%',
- flexShrink: 0,
- height: 4,
- width: 4,
+ headlineStatus: {
+ alignItems: 'center',
+ display: 'inline-flex',
+ gap: 4,
},
rowTime: {
color: cssVar.colorTextQuaternary,
@@ -100,7 +101,7 @@ const styles = stylex.create({
},
});
-/** Faint lines where a project's conversations will appear. */
+/** Faint lines where a project's tasks will appear. */
const PLACEHOLDER_WIDTHS = ['84%', '66%', '74%'];
interface FolderPaperProps {
@@ -108,36 +109,45 @@ interface FolderPaperProps {
sheet: FolderSheet;
}
-/** The front paper: the project's latest conversations, or its brief before it has any. */
+const statusVisual = (status: string) =>
+ TASK_STATUS_VISUALS[status as TaskStatus] ?? TASK_STATUS_VISUALS.backlog;
+
+/** The front paper: the project's latest tasks, or its brief before it has any. */
export const FolderPaper = ({ project, sheet }: FolderPaperProps) => {
const { t } = useTranslation('project');
+ const { t: tChat } = useTranslation('chat');
- if (sheet.kind === 'topics') {
+ if (sheet.kind === 'tasks') {
const { latest, others } = sheet;
+ const latestVisual = statusVisual(latest.status);
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' })}
+ <span>{t('list.folder.recentTask')}</span>
+ <span {...stylex.props(styles.headlineStatus)}>
+ <Icon color={latestVisual.color} icon={latestVisual.icon} size={10} />
+ {tChat(`taskDetail.status.${latest.status}` as 'taskDetail.status.backlog', {
+ defaultValue: latest.status,
+ })}
+ </span>
</div>
+ <div {...stylex.props(styles.headline)}>{latest.name || latest.identifier}</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>
- ))}
+ {others.map((task) => {
+ const visual = statusVisual(task.status);
+ return (
+ <div key={task.id} {...stylex.props(styles.row)}>
+ <Icon color={visual.color} icon={visual.icon} size={12} />
+ <span {...stylex.props(styles.rowTitle)}>{task.name || task.identifier}</span>
+ <span {...stylex.props(styles.rowTime)}>
+ {dayjs(task.updatedAt).fromNow(true)}
+ </span>
+ </div>
+ );
+ })}
</>
)}
</div>
@@ -157,7 +167,7 @@ export const FolderPaper = ({ project, sheet }: FolderPaperProps) => {
</div>
<div {...stylex.props(styles.headline)}>{lead}</div>
{sheet.kind === 'intro' && (
- <p {...stylex.props(styles.hint)}>{t('list.folder.noTopicsHint')}</p>
+ <p {...stylex.props(styles.hint)}>{t('list.folder.noTasksHint')}</p>
)}
{sheet.kind !== 'unavailable' && (
<div aria-hidden {...stylex.props(styles.placeholders)}>
diff --git a/src/features/Projects/List/FolderCard/folderSheet.test.ts b/src/features/Projects/List/FolderCard/folderSheet.test.ts
index 786b4bf171e..6beeafcae60 100644
--- a/src/features/Projects/List/FolderCard/folderSheet.test.ts
+++ b/src/features/Projects/List/FolderCard/folderSheet.test.ts
@@ -4,10 +4,12 @@ import type { ProjectOverview } from '@/store/project';
import { isRichFolder, resolveFolderSheet, resolveOverviewStatus } from './folderSheet';
-const topic = (title: string, day: number) => ({
- id: `tpc_${title}`,
+const task = (name: string, day: number) => ({
+ id: `task_${name}`,
+ identifier: `T-${day}`,
+ name,
+ status: 'backlog',
summary: null,
- title,
updatedAt: new Date(2026, 0, day),
});
@@ -15,15 +17,14 @@ const overview = (patch: Partial<ProjectOverview> = {}): ProjectOverview => ({
agentCount: 1,
agents: [],
projectId: 'prj_1',
- recentTopics: [],
+ recentTasks: [],
taskCount: 0,
taskDoneCount: 0,
- topicCount: 0,
...patch,
});
describe('resolveFolderSheet', () => {
- it('waits for the overview batch before claiming there are no conversations', () => {
+ it('waits for the overview batch before claiming there are no tasks', () => {
expect(resolveFolderSheet(undefined, 'loading')).toEqual({ kind: 'pending' });
});
@@ -31,27 +32,25 @@ describe('resolveFolderSheet', () => {
expect(resolveFolderSheet(undefined, 'loaded')).toEqual({ kind: 'intro' });
});
- it('shows the brief when the project has no conversations', () => {
+ it('shows the brief when the project has no tasks', () => {
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');
+ it('heads the paper with the latest task and lists up to three others', () => {
+ const tasks = [task('e', 5), task('d', 4), task('c', 3), task('b', 2), task('a', 1)];
+ const sheet = resolveFolderSheet(overview({ recentTasks: tasks, taskCount: 5 }), 'loaded');
- expect(sheet).toEqual({ kind: 'topics', latest: topics[0], others: topics.slice(1, 4) });
+ expect(sheet).toEqual({ kind: 'tasks', latest: tasks[0], others: tasks.slice(1, 4) });
});
- it('lists no rows when the project has a single conversation', () => {
- const only = topic('only', 1);
+ it('lists no rows when the project has a single task', () => {
+ const only = task('only', 1);
- expect(resolveFolderSheet(overview({ recentTopics: [only], topicCount: 1 }), 'loaded')).toEqual(
- {
- kind: 'topics',
- latest: only,
- others: [],
- },
- );
+ expect(resolveFolderSheet(overview({ recentTasks: [only], taskCount: 1 }), 'loaded')).toEqual({
+ kind: 'tasks',
+ latest: only,
+ others: [],
+ });
});
});
@@ -75,11 +74,13 @@ describe('resolveFolderSheet after a failed overview', () => {
});
it('still shows a project row that is already loaded', () => {
- const only = topic('only', 1);
+ const only = task('only', 1);
- expect(resolveFolderSheet(overview({ recentTopics: [only], topicCount: 1 }), 'failed')).toEqual(
- { kind: 'topics', latest: only, others: [] },
- );
+ expect(resolveFolderSheet(overview({ recentTasks: [only], taskCount: 1 }), 'failed')).toEqual({
+ kind: 'tasks',
+ latest: only,
+ others: [],
+ });
});
});
@@ -88,15 +89,11 @@ describe('isRichFolder', () => {
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 plain while the front paper lists every task', () => {
+ expect(isRichFolder(overview({ taskCount: 4 }))).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);
+ it('is rich past what the front paper lists', () => {
+ expect(isRichFolder(overview({ taskCount: 5 }))).toBe(true);
});
});
diff --git a/src/features/Projects/List/FolderCard/folderSheet.ts b/src/features/Projects/List/FolderCard/folderSheet.ts
index 21acdcdf01c..a339eab17f9 100644
--- a/src/features/Projects/List/FolderCard/folderSheet.ts
+++ b/src/features/Projects/List/FolderCard/folderSheet.ts
@@ -1,12 +1,12 @@
import type { ProjectOverview } from '@/store/project';
-type OverviewTopic = ProjectOverview['recentTopics'][number];
+type OverviewTask = ProjectOverview['recentTasks'][number];
-/** Other topics listed under the headline; the paper has room for three rows. */
-export const FOLDER_TOPIC_ROWS = 3;
+/** Other tasks listed under the headline; the paper has room for three rows. */
+export const FOLDER_TASK_ROWS = 3;
-/** More conversations than the front paper lists, or tasks, earn a second sheet edge. */
-const RICH_TOPIC_COUNT = 3;
+/** More tasks than the front paper lists earn a second sheet edge. */
+const RICH_TASK_COUNT = FOLDER_TASK_ROWS + 1;
/**
* Where the overview batch stands. A cached batch counts as `loaded` even when
@@ -24,10 +24,10 @@ export const resolveOverviewStatus = ({
/**
* 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;
+ * - `tasks`: the latest updated task as its headline, the next few as rows;
+ * - `intro`: the project brief, with a "no tasks yet" hint;
* - `pending`: the brief alone while the overview loads, so a project with
- * conversations never flashes the empty hint first;
+ * tasks 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.
*/
@@ -35,7 +35,7 @@ export type FolderSheet =
| { kind: 'intro' }
| { kind: 'pending' }
| { kind: 'unavailable' }
- | { kind: 'topics'; latest: OverviewTopic; others: OverviewTopic[] };
+ | { kind: 'tasks'; latest: OverviewTask; others: OverviewTask[] };
/**
* @param overview the project's overview row, `undefined` when it has none
@@ -48,12 +48,12 @@ export const resolveFolderSheet = (
if (!overview && status === 'loading') return { kind: 'pending' };
if (!overview && status === 'failed') return { kind: 'unavailable' };
- const [latest, ...others] = overview?.recentTopics ?? [];
+ const [latest, ...others] = overview?.recentTasks ?? [];
if (!latest) return { kind: 'intro' };
- return { kind: 'topics', latest, others: others.slice(0, FOLDER_TOPIC_ROWS) };
+ return { kind: 'tasks', latest, others: others.slice(0, FOLDER_TASK_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);
+ !!overview && overview.taskCount > RICH_TASK_COUNT;
diff --git a/src/features/Projects/List/FolderCard/index.tsx b/src/features/Projects/List/FolderCard/index.tsx
index 88163156d73..03996ccffe0 100644
--- a/src/features/Projects/List/FolderCard/index.tsx
+++ b/src/features/Projects/List/FolderCard/index.tsx
@@ -5,7 +5,7 @@ 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 { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { useFavoriteToggle } from '@/features/Favorites';
@@ -168,16 +168,11 @@ const styles = stylex.create({
height: 300,
position: 'relative',
},
- sep: {
- backgroundColor: cssVar.colorTextQuaternary,
- borderRadius: '50%',
- flexShrink: 0,
- height: 2,
- width: 2,
- },
star: {
+ alignSelf: 'center',
+ display: 'inline-flex',
flexShrink: 0,
- marginInlineStart: 'auto',
+ marginInlineEnd: -4,
},
tab: {
backgroundColor: FOLDER_COLOR,
@@ -216,18 +211,12 @@ export const FolderCard = memo<FolderCardProps>(({ overviewStatus, project }) =>
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);
+ const taskSummary = showCounts
+ ? taskCount > 0
+ ? t('list.folder.taskProgress', { done: overview?.taskDoneCount ?? 0, total: taskCount })
+ : t('list.folder.noTasks')
+ : undefined;
return (
<ContextMenuTrigger items={menuItems}>
@@ -254,8 +243,6 @@ export const FolderCard = memo<FolderCardProps>(({ overviewStatus, project }) =>
>
<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
@@ -266,6 +253,8 @@ export const FolderCard = memo<FolderCardProps>(({ overviewStatus, project }) =>
/>
</span>
)}
+ <span {...stylex.props(styles.name)}>{project.name}</span>
+ <span {...stylex.props(styles.identifier)}>{project.identifier}</span>
</div>
<div {...stylex.props(styles.meta)}>
{running && (
@@ -273,12 +262,7 @@ export const FolderCard = memo<FolderCardProps>(({ overviewStatus, project }) =>
<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>
- ))}
+ {taskSummary && <span>{taskSummary}</span>}
<span {...stylex.props(styles.metaFill)} />
<AgentStack agents={overview?.agents} project={project} />
<span title={dayjs(project.updatedAt).format('YYYY-MM-DD HH:mm')}>
diff --git a/src/features/Projects/List/index.tsx b/src/features/Projects/List/index.tsx
index 847c4359a2b..b813e504b7c 100644
--- a/src/features/Projects/List/index.tsx
+++ b/src/features/Projects/List/index.tsx
@@ -276,7 +276,7 @@ const ProjectListPage = memo(() => {
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.
+ // Cards draw recent tasks and members, which the light list row never needs.
const overviewSync = useProjectStore((s) => s.useFetchProjectOverviews)(
enabled && viewMode === 'folder',
);