From c6c4979c0644f9931235cbf7275bf46367a4789d Mon Sep 17 00:00:00 2001 From: AgentSeal Date: Wed, 15 Apr 2026 01:09:18 -0700 Subject: [PATCH] =?UTF-8?q?feat:=20readable=20project=20names=20=E2=80=94?= =?UTF-8?q?=20strip=20home=20dir=20prefix,=20show=20~=20for=20home=20sessi?= =?UTF-8?q?ons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dashboard.tsx | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/dashboard.tsx b/src/dashboard.tsx index 9e17550..2130c0f 100644 --- a/src/dashboard.tsx +++ b/src/dashboard.tsx @@ -1,3 +1,5 @@ +import { homedir } from 'os' + import React, { useState, useCallback, useEffect } from 'react' import { render, Box, Text, useInput, useApp, useWindowSize } from 'ink' import { CATEGORY_LABELS, type ProjectSummary, type TaskCategory } from './types.js' @@ -187,10 +189,27 @@ function DailyActivity({ projects, days = 14, pw, bw }: { projects: ProjectSumma ) } -function shortProject(project: string): string { - const parts = project.replace(/^-/, '').split('-').filter(Boolean) - if (parts.length <= 2) return parts.join('/') - return parts.slice(-2).join('/') +const _homeEncoded = homedir().replace(/\//g, '-') + +function shortProject(encoded: string): string { + let path = encoded.replace(/^-/, '') + + // Strip home dir prefix (e.g. "Users-torukmakto-" → "") + if (path.startsWith(_homeEncoded.replace(/^-/, ''))) { + path = path.slice(_homeEncoded.replace(/^-/, '').length).replace(/^-/, '') + } + + // Strip common system prefixes + path = path + .replace(/^private-tmp-[^-]+-[^-]+-/, '') // /private/tmp/// + .replace(/^private-tmp-/, '') + .replace(/^tmp-/, '') + + if (!path) return '~' + + const parts = path.split('-').filter(Boolean) + if (parts.length <= 3) return parts.join('/') + return parts.slice(-3).join('/') } function ProjectBreakdown({ projects, pw, bw }: { projects: ProjectSummary[]; pw: number; bw: number }) {