Files
orca/mobile/src/session/worktree-label.ts
T

13 lines
544 B
TypeScript

// Why: worktree ids encode `repo::path`; screens that only receive the id
// (deep links, route params without a name) still need a human label.
export function getWorktreeLabel(name: string | undefined, worktreeId: string): string {
if (name?.trim()) {
return name.trim()
}
const pathPart = worktreeId.includes('::')
? worktreeId.slice(worktreeId.indexOf('::') + 2)
: worktreeId
const normalized = pathPart.replace(/\\/g, '/').replace(/\/+$/, '')
return normalized.slice(normalized.lastIndexOf('/') + 1) || 'Worktree'
}