type Props = { workDir?: string | null repoName?: string | null branch?: string | null sourceWorkDir?: string | null isWorktree?: boolean worktreeSlug?: string | null worktreePath?: string | null compact?: boolean } function basename(path: string | null | undefined): string { return path?.split('/').filter(Boolean).pop() || '' } export function ProjectContextChip({ workDir, repoName, branch, sourceWorkDir, isWorktree = false, worktreeSlug, worktreePath, compact = false, }: Props) { const labelRoot = isWorktree ? (sourceWorkDir || workDir) : workDir const label = branch ? (repoName || basename(labelRoot)) : (basename(labelRoot) || repoName || '') const worktreeName = worktreeSlug || basename(worktreePath) || 'isolated' const title = [ label, branch ? `branch: ${branch}` : null, isWorktree ? `worktree: ${worktreeName}` : null, worktreePath ? `worktree cwd: ${worktreePath}` : null, workDir ? `cwd: ${workDir}` : null, ].filter(Boolean).join('\n') if (!label) return null return (
{branch ? ( ) : ( folder )} {label} {branch ? ( <> | {branch} ) : null} {isWorktree ? ( <> | worktree {worktreeName} ) : null}
) }