mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-17 04:17:11 +00:00
fix: display correct project names in session stats
Replace session.projectPath.split('/').pop() with getProjectDisplayName()
to ensure the actual leaf folder name is shown instead of incorrect fragments.
Example fixes:
- /home/user/projects/my-app now shows "my-app" instead of "app"
- /home/user/workspaces/repo-name/worktrees/feature-branch now shows "feature-branch" instead of "branch"
Addresses potential issues with project name display in analytics dashboard.
Related to: #348 (quota display), #103 (context display)
This commit is contained in:
@@ -131,7 +131,7 @@ export function SessionStatsCard({ data, isLoading, className }: SessionStatsCar
|
||||
>
|
||||
<div className="flex flex-col min-w-0 flex-1">
|
||||
<span className="font-medium truncate" title={session.projectPath}>
|
||||
{session.projectPath.split('/').pop()}
|
||||
{getProjectDisplayName(session.projectPath)}
|
||||
</span>
|
||||
<span className="text-[10px] text-muted-foreground">
|
||||
{formatDistanceToNow(new Date(session.lastActivity), { addSuffix: true })}
|
||||
@@ -152,6 +152,17 @@ export function SessionStatsCard({ data, isLoading, className }: SessionStatsCar
|
||||
);
|
||||
}
|
||||
|
||||
function getProjectDisplayName(path: string): string {
|
||||
if (!path) return '';
|
||||
|
||||
// Remove leading/trailing slashes and split into segments
|
||||
const cleanPath = path.replace(/^\/|\/$/g, '');
|
||||
const segments = cleanPath.split('/').filter(segment => segment.length > 0);
|
||||
|
||||
// Return the last segment (leaf folder name)
|
||||
return segments[segments.length - 1] || '';
|
||||
}
|
||||
|
||||
function formatCompact(num: number): string {
|
||||
if (num >= 1_000_000_000) return `${(num / 1_000_000_000).toFixed(1)}B`;
|
||||
if (num >= 1_000_000) return `${(num / 1_000_000).toFixed(1)}M`;
|
||||
|
||||
Reference in New Issue
Block a user