Skip to content

Windows cross-drive project-root traversal fix #518

Description

@Hakubisual

What happened?

On Windows, findProjectRoot() can enter a synchronous infinite loop when Senpi is launched from one drive and a rules lookup targets a path on another drive.

resolve("/") points to the current working drive, while dirname() of the target drive root returns the same path. The traversal therefore never progresses or reaches its existing root check. The session freezes without an error, potentially using 100% CPU.

This reproduced with senpi -ne, so it was not caused by a user-loaded extension.

Steps to reproduce

  1. On Windows, launch Senpi from the C: drive:

    senpi -ne

  2. Read, edit, or write a file on another drive, such as D:\senpi-repro\file.txt, where no project marker exists in its parent directories.

  3. Observe that the session hangs indefinitely during project-root discovery.

Expected behavior

Project-root traversal should stop when dirname(currentDirectory) === currentDirectory and return null if no marker was found:

const parentDirectory = dirname(currentDirectory);

if (
	currentDirectory === filesystemRoot ||
	parentDirectory === currentDirectory
) {
	return null;
}

### Version

2026.7.29-6

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions