Skip to content

fix(windows): git path resolution for modified files across Git Bash, MSYS2, and Cygwin#16422

Merged
Hona merged 8 commits intoanomalyco:devfrom
Hona:fix/windows-modified-files-tracking
Mar 7, 2026
Merged

fix(windows): git path resolution for modified files across Git Bash, MSYS2, and Cygwin#16422
Hona merged 8 commits intoanomalyco:devfrom
Hona:fix/windows-modified-files-tracking

Conversation

@Hona
Copy link
Copy Markdown
Member

@Hona Hona commented Mar 7, 2026

  • normalize Windows shell paths at the OpenCode boundary so Git Bash, MSYS2, Cygwin, and WSL-style paths resolve to the real repo path
  • honor Path and PathExt casing when resolving git in Windows worker environments so git-backed project detection and snapshot tracking stay enabled
  • add focused Windows regression tests for shell-style path translation, exact drive-root paths, and project config lookup

Copilot AI review requested due to automatic review settings March 7, 2026 03:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores reliable Windows modified-file tracking by normalizing Windows shell-style directory paths (Git Bash/MSYS2/Cygwin/WSL mounts) and making git resolution robust to Windows environment variable casing, with added regression tests to prevent future regressions.

Changes:

  • Add Filesystem.resolve() to convert shell-style Windows paths into real, normalized repo paths and use it in Server/Instance/TUI path handling.
  • Update util.which() to honor Path/PathExt casing (and fall back to process env) on Windows.
  • Add focused Windows regression tests for path resolution, config lookup, and which() behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/opencode/src/util/which.ts Make PATH/PATHEXT resolution tolerant of Windows casing variants.
packages/opencode/src/util/filesystem.ts Introduce Filesystem.resolve() and expand Windows path normalization.
packages/opencode/src/server/server.ts Normalize inbound directory (query/header) before workspace/instance resolution.
packages/opencode/src/project/instance.ts Key instances by normalized directory paths to avoid duplicate instances on Windows.
packages/opencode/src/cli/cmd/tui/thread.ts Normalize PWD/project paths to ensure correct repo resolution under Windows shells.
packages/opencode/test/util/which.test.ts Add regression test for Path/PathExt casing fallback on Windows.
packages/opencode/test/util/filesystem.test.ts Add Windows-only coverage for resolving Git Bash/MSYS2/Cygwin/WSL-style paths.
packages/opencode/test/config/config.test.ts Add Windows-only config lookup tests using shell-style paths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

fn: async () => {
const cfg = await Config.get()
expect(cfg.snapshot).toBe(true)
expect(Instance.directory).toBe(tmp.path)
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instance.directory is now set via Filesystem.resolve(), which may return a realpath-canonicalized string on Windows (drive-letter / directory casing can differ from tmp.path). This strict equality check can become flaky; consider comparing against Filesystem.normalizePath(tmp.path) (or Filesystem.resolve(tmp.path)) instead.

Suggested change
expect(Instance.directory).toBe(tmp.path)
expect(Instance.directory).toBe(Filesystem.normalizePath(tmp.path))

Copilot uses AI. Check for mistakes.
@Hona Hona changed the title fix(opencode): restore Windows modified file tracking fix(windows): git path resolution for modified files across Git Bash, MSYS2, and Cygwin Mar 7, 2026
@Hona Hona requested a review from adamdotdevin as a code owner March 7, 2026 04:06
@Hona Hona merged commit 8a95be4 into anomalyco:dev Mar 7, 2026
9 checks passed
manno23 pushed a commit to manno23/opencode that referenced this pull request Mar 12, 2026
demostanis pushed a commit to demostanis/opencode that referenced this pull request Mar 19, 2026
demostanis pushed a commit to demostanis/opencode that referenced this pull request Mar 20, 2026
balcsida pushed a commit to balcsida/opencode that referenced this pull request Mar 24, 2026
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.

2 participants