Skip to content

fix(ui): use path.Join for git tree paths on Windows#903

Open
syf2211 wants to merge 1 commit into
charmbracelet:mainfrom
syf2211:fix/681-windows-git-tree-paths
Open

fix(ui): use path.Join for git tree paths on Windows#903
syf2211 wants to merge 1 commit into
charmbracelet:mainfrom
syf2211:fix/681-windows-git-tree-paths

Conversation

@syf2211

@syf2211 syf2211 commented Jun 25, 2026

Copy link
Copy Markdown

Summary

Fix file browser navigation failing on Windows hosts when browsing repository subdirectories. Git always uses forward slashes (/) for paths; filepath.Join/Dir/Clean on Windows converts them to backslashes (\), which git does not recognize.

Motivation

Fixes #681 — users on Windows (and clients connecting to Windows-hosted servers) could only navigate one directory level deep in the Files tab. Entering a subdirectory either showed no change or duplicated path segments like \bat.

Changes

  • pkg/ui/pages/repo/files.go — use path.Join/path.Dir for browser navigation state
  • pkg/ui/pages/repo/readme.go — use path.Dir for readme path display
  • git/utils.go — use path.Join/path.Dir in LatestFile pattern matching
  • git/repo.go — use path.Clean(filepath.ToSlash(...)) in TreePath
  • git/tree.go — use path.Join for TreeEntry logical paths
  • git/repo_test.go — regression tests for forward-slash invariant

OS filesystem paths (data directory, hooks, LFS storage) are unchanged and still correctly use filepath.

Tests

go test ./git/... -count=1
go test ./... -count=1

All tests pass, including testscript integration suite (~67s).

Notes

Related to closed PR #815 (same root cause; redirected to fork workflow). This version also fixes TreePath and git/tree.go entry path construction, which were not covered in #815.

Git always uses forward slashes for repository paths. Using filepath.Join,
filepath.Dir, or filepath.Clean on Windows converts separators to backslashes,
which breaks file browser navigation into subdirectories.

Replace filepath with path for git logical paths in the UI and git package.
Add regression tests for the forward-slash invariant.

Fixes charmbracelet#681
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.

soft serve 0.8.4 on windows host not navigating folders in repo correctly

2 participants