Skip to content

Close four Windows path gaps: UNC host case, drive-relative paths, directive drive paths, PATH case - #443

Merged
jbearak merged 2 commits into
mainfrom
win-path-gaps
Nov 20, 2026
Merged

jbearak merged 2 commits into
mainfrom
win-path-gaps

Conversation

@jbearak

@jbearak jbearak commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Four small Windows path gaps left open after #440.

  • UNC host case. A workspace opened as \\Server\share\proj held its files as \\server\share\proj\… once a path had been through a URI, which lower-cases the host. The root check compared them exactly, so the files fell outside the root. The canonical path form now lower-cases the UNC host. The share and directory names keep their case.
  • Drive-relative paths. do C:foo.do and cd C:sub mean "in drive C's current directory". Sight joined them as C:\wd\C:foo.do and reported the file missing. When the working directory is on that drive they now resolve there. A path on another drive is left as before: its current directory is unknown.
  • Directive drive paths. DirectiveParser.resolve_path gave C:/x/parent.do on Windows where every other path is C:\x\parent.do, and collapsed a UNC directive path //server/share/x to \server\share\x. On Windows it now returns the canonical form. Other platforms are unchanged.
  • Installer PATH check. is_path_in_env compared PATH entries exactly, so c:\users\me\bin did not match C:\Users\Me\bin and the installer said the directory was not on PATH. It ignores case on Windows.

Proof

  • New tests in tests/unit/utils/fs-path.test.ts pass the platform explicitly, so they run on every host. Seven of them fail without the source change.
  • The installer test runs with the host's rules, so the Windows job covers the Windows side.
  • check:line-endings, typecheck, lint pass; bun test ./tests: 10,485 pass, 15 skip, 0 fail.

Summary by CodeRabbit

  • Bug Fixes
    • PATH detection on Windows now recognizes entries that differ from the target only by letter case.
    • Improved resolution of Windows drive-relative paths when resolving file references and directory changes.
    • Windows path comparisons now normalize UNC host-name casing, while preserving casing elsewhere in the path.
    • Path resolution now applies platform-specific normalization to absolute and relative paths.

…rective drive paths, PATH case

- A UNC host name is lower-cased in the canonical path form, so a path
  that came through a URI is found inside a root typed with another
  case.
- 'do C:foo.do' and 'cd C:sub' resolve in the working directory when it
  is on that drive.
- A directive path is returned in canonical form on Windows
  (C:\x\parent.do); a UNC directive path keeps both leading
  separators there.
- The installer's PATH check ignores case on Windows.
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changes update Windows path comparison and resolution. They canonicalize UNC host names, handle matching drive-relative paths during path resolution, and make PATH entry matching case-insensitive on Windows.

Changes: Project path resolution

Layer / File(s) Summary
Canonical paths and drive-relative helper
src/utils/fs-path.ts, tests/unit/utils/fs-path.test.ts
Windows canonical paths now use lowercase UNC host names. A new helper strips the drive prefix from a drive-relative path when its drive matches the base directory. Tests cover canonicalization, containment, and helper behavior.
Directive and working-directory resolution
src/directive-parser/index.ts, src/utils/file-path-utils.ts, tests/unit/utils/fs-path.test.ts
DirectiveParser.resolve_path accepts an optional platform and canonicalizes its results. Forward-call and relative cd resolution use the drive-relative helper. Tests cover Windows and POSIX path results.

PATH environment matching

Layer / File(s) Summary
Platform-aware PATH comparison
scripts/install.ts, tests/property/path-detection.prop.test.ts
The target path and expanded PATH entries use case-insensitive comparison on Windows and case-sensitive comparison on other platforms. A property test checks this behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

  • jbearak/sight#441: Both PRs change the DirectiveParser.resolve_path contract, including its Windows path output.
  • jbearak/sight#440: Both PRs update canonical Windows filesystem paths, including UNC host-name handling.
Merge Risk: Minimal · up to dd2df

This change fixes Windows path handling for UNC host case, drive-relative paths, directive drive paths, and PATH matching. Other platforms are unaffected, and no actionable merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names four specific Windows path changes: UNC host case, drive-relative paths, directive drive paths, and PATH case. Each maps to a change in the raw summary: the install.ts PATH case-insens…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names four specific Windows path changes: UNC host case, drive-relative paths, directive drive paths, and PATH case. Each maps to a change in the raw summary: the install.ts PATH case-insensitive comparison, the fs-path.ts UNC host lowercasing and drive_relative_rest helper, the file-path-utils.ts drive-relative candidates, and the directive-parser resolve_path changes. The title is long (99 characters) but it accurately covers the main change.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Team
  • Run ID: ceb5ebdc-8076-4794-96ff-08969d13a30a
Commits

Reviewing files that changed from the base of the PR and between 5ec70e1 and dd2dfa4.

Files selected for processing: 4

  • src/directive-parser/index.ts
  • src/utils/file-path-utils.ts
  • src/utils/fs-path.ts
  • tests/unit/utils/fs-path.test.ts

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour.

… paths in directives and at the workspace root

- The path-case walk compared a source path's UNC host exactly against
  a root whose host was already lower-cased, skipped the walk and
  called a case-only file name exact.
- An extended UNC path (\\?\UNC\host) has its host folded as well.
- 'sight: done-by C:parent.do' resolves beside the file, and
  'do C:foo.do' is tried at the workspace root as other relative paths
  are.
@jbearak

jbearak commented Nov 20, 2026

Copy link
Copy Markdown
Owner Author

Note

🤖 Claude Fable 5.2 responding on behalf of jbearak

An independent review of the first commit found four defects. All are fixed in the next commit, each with a test that passes the Windows platform explicitly.

  • A case-only file name under a UNC root was reported as exact. The root's host was lower-cased but the source path's was compared as typed, so the case walk was skipped. The comparison form now folds the host too. Test: "still reports a case-only file name under a UNC root" (fails without the change).
  • sight: done-by "C:parent.do" resolved to C:\ws\C:parent.do. Directive paths now treat a drive-relative path on the file's drive as relative.
  • do C:foo.do was joined literally at the workspace root. The root fallback now resolves it as it does other relative paths.
  • \\?\UNC\Server\Share kept its host case. The extended form is folded as well; \\.\ and \\?\C:\ are left alone.

The module header now says the UNC host is folded.

@jbearak
jbearak merged commit f7ab199 into main Nov 20, 2026
17 checks passed
@jbearak
jbearak deleted the win-path-gaps branch November 20, 2026 16:36
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.

1 participant