Skip to content

fix(workspace): read a Windows worktree folder name - #807

Merged
Ishaan Gangwani (ishaan1124) merged 1 commit into
synthetic-sciences:mainfrom
aniruddhaadak80:fix/project-folder-name-windows
Sep 29, 2026
Merged

Ishaan Gangwani (ishaan1124) merged 1 commit into
synthetic-sciences:mainfrom
aniruddhaadak80:fix/project-folder-name-windows

Conversation

@aniruddhaadak80

Copy link
Copy Markdown
Contributor

What

folderName — the fallback used when a project has no configured name — split only on /:

const parts = worktree.split("/").filter(Boolean)
return parts.at(-1) ?? worktree

A backslash path is one element, so .at(-1) is the whole path.

Why it matters

The server reports native separators: backend/cli/src/project/project.ts returns worktree straight from path.resolve() / the opened directory, with no POSIX normalisation anywhere in the tree.

/Users/me/Research/pdebench  ->  "pdebench"                 correct
C:\work\pdebench             ->  "C:\work\pdebench"        the whole path
\\server\share\pdebench      ->  "\\server\share\pdebench" the whole path
C:/work/pdebench             ->  "pdebench"                the same path, works

projectName is the title for the project list, the workbench header, and the command palette entry. On a Windows server, a project with no name — or one whose name readable() rejects for containing control characters or U+FFFD — showed its full path where every other surface shows the folder name. The same string also goes into each row's accessible label and the palette's search keys.

Verification

New file — pages/home-projects.test.ts did not exist. Three of six fail before the fix:

Expected: "pdebench"
Received: "C:\work\pdebench"
(fail) projectName > falls back to the last folder of a Windows worktree

Expected: "pdebench"
Received: "\\server\share\pdebench"
(fail) projectName > falls back to the last folder of a UNC worktree
(pass) falls back to the last folder of a Windows worktree
(pass) falls back to the last folder of a UNC worktree
(pass) still finds the last folder of a POSIX worktree
(pass) a configured name wins over the folder
(pass) falls back when the name is only whitespace or control characters
(pass) a nameless root worktree keeps its slash
 6 pass
 0 fail

The whole src/pages/ suite is green: 64 pass, 0 fail across 17 files.

The change

 function folderName(worktree: string) {
   if (worktree === "/") return "/"
-  const parts = worktree.split("/").filter(Boolean)
+  // The server reports native separators, so a Windows worktree arrives with
+  // backslashes and a forward-slash split would return the whole path.
+  const parts = worktree.split(/[\\/]/).filter(Boolean)
   return parts.at(-1) ?? worktree
 }

Four other path helpers in this codebase already split on both separators, so the fallback was disagreeing with its own siblings:

  • atlas/command-palette-scope.ts:4
  • context/permission.tsx:156
  • atlas/FilesPane.tsx:386
  • pages/session-undo.ts:19

Frontend typecheck clean; touched files are Prettier-clean (checked on LF-normalized copies — this checkout has core.autocrlf=true, which makes Prettier flag every file in the repo).

Fixes #806

@vercel

vercel Bot commented Sep 28, 2026

Copy link
Copy Markdown

ANIRUDDHA ADAK (@aniruddhaadak80) is attempting to deploy a commit to the InkVell Team on Vercel.

A member of the Team first needs to authorize it.

The fallback split only on /, so a worktree the server reported with native separators produced one segment and the whole path became the project title. Four other path helpers in the tree already split on both separators.
@ishaan1124
Ishaan Gangwani (ishaan1124) merged commit 7de7274 into synthetic-sciences:main Sep 29, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A nameless project shows its full Windows path as its title

2 participants