Summary
The logic that converts a full filesystem path into a short two-segment display label (e.g., /home/user/projects/myapp becomes projects/myapp) exists in two different places with the same implementation:
In app/frontend/src/App.tsx (lines 84-89):
functiontabNameFromCwd(cwd: string): string{constparts=cwd.replace(/\/g,'/').replace(/\/$/,'').split('/').filter(Boolean)if(parts.length===0)return'~'if(parts.length===1)returnparts[0]returnparts.slice(-2).join('/')}In app/frontend/src/components/Terminal.tsx (lines 857-861):
constcwdLabel=React.useMemo(()=>{constparts=cwd.replace(/\/g,'/').split('/').filter(Boolean)if(parts.length===0)return'~'returnparts.length<=2 ? parts.join('/') : parts.slice(-2).join('/')},[cwd])There are also subtle differences between the two (the App.tsx version strips trailing slashes; the Terminal.tsx version does not and handles 2-part paths differently). This means they can show different labels for the same path.
How to fix
Move the canonical implementation to app/frontend/src/lib/pathUtils.ts (create if it does not exist) and import it in both files:
exportfunctionshortCwd(cwd: string): string{constparts=cwd.replace(/\/g,'/').replace(/\/$/,'').split('/').filter(Boolean)if(parts.length===0)return'~'if(parts.length===1)returnparts[0]returnparts.slice(-2).join('/')}Files
app/frontend/src/App.tsx (lines 84-89, tabNameFromCwd)app/frontend/src/components/Terminal.tsx (lines 857-861, cwdLabel useMemo)- New file:
app/frontend/src/lib/pathUtils.ts
Summary
The logic that converts a full filesystem path into a short two-segment display label (e.g.,
/home/user/projects/myappbecomesprojects/myapp) exists in two different places with the same implementation:In
app/frontend/src/App.tsx(lines 84-89):In
app/frontend/src/components/Terminal.tsx(lines 857-861):There are also subtle differences between the two (the App.tsx version strips trailing slashes; the Terminal.tsx version does not and handles 2-part paths differently). This means they can show different labels for the same path.
How to fix
Move the canonical implementation to
app/frontend/src/lib/pathUtils.ts(create if it does not exist) and import it in both files:Files
app/frontend/src/App.tsx(lines 84-89,tabNameFromCwd)app/frontend/src/components/Terminal.tsx(lines 857-861,cwdLabeluseMemo)app/frontend/src/lib/pathUtils.ts