Skip to content

A nameless project shows its full Windows path as its title #806

Closed

Description

What happens

frontend/workspace/src/pages/home-projects.ts derives a project's display name from its worktree path when no name is configured:

function folderName(worktree: string) {
  if (worktree === "/") return "/"
  const parts = worktree.split("/").filter(Boolean)
  return parts.at(-1) ?? worktree
}

export function projectName(project: ProjectRecord) {
  return readable(project.name) || readable(folderName(project.worktree)) || "Untitled project"
}

split("/") produces a single element for a backslash path, so .at(-1) is the entire path.

Why it is wrong

Measured:

/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

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

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

Repro

projectName({ id: "prj_1", worktree: String.raw`C:\work\pdebench`, time: { created: 1 } })
// "C:\work\pdebench", expected "pdebench"

Suggested fix

const parts = worktree.split(/[\\/]/).filter(Boolean)

Four other path helpers in the same codebase already do this, so the fallback label currently disagrees with its own siblings:

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

frontend/workspace/src/pages/home-projects.test.ts did not exist; this adds it, covering the Windows path, a UNC path, the POSIX path, a configured name winning, an unusable name falling back, and the root worktree keeping its slash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions