Add fast project display names option

This commit is contained in:
Simos Mikelatos
2026-06-07 08:46:31 +00:00
parent 3b4d6885aa
commit 371ff034e4
2 changed files with 17 additions and 1 deletions

View File

@@ -54,6 +54,7 @@ type ProgressUpdate = {
type GetProjectsWithSessionsOptions = {
skipSynchronization?: boolean;
fastDisplayNames?: boolean;
sessionsLimit?: number;
sessionsOffset?: number;
};
@@ -116,6 +117,15 @@ export async function generateDisplayName(projectName: string, actualProjectDir:
return projectPath;
}
function generateFastDisplayName(projectPath: string): string {
if (projectPath.startsWith('/')) {
const parts = projectPath.split('/').filter(Boolean);
return parts[parts.length - 1] || projectPath;
}
return projectPath.replace(/-/g, '/');
}
function normalizeSessionPagination(options: SessionPaginationOptions = {}): { limit: number; offset: number } {
const rawLimit = Number.isFinite(options.limit) ? Math.floor(Number(options.limit)) : DEFAULT_PROJECT_SESSIONS_PAGE_SIZE;
const rawOffset = Number.isFinite(options.offset) ? Math.floor(Number(options.offset)) : 0;
@@ -239,7 +249,9 @@ export async function getProjectsWithSessions(
const displayName =
row.custom_project_name && row.custom_project_name.trim().length > 0
? row.custom_project_name
: await generateDisplayName(path.basename(projectPath) || projectPath, projectPath);
: options.fastDisplayNames
? generateFastDisplayName(projectPath)
: await generateDisplayName(path.basename(projectPath) || projectPath, projectPath);
const sessionsPage = readProjectSessionsPageByPath(projectPath, {
limit: options.sessionsLimit,