Skip to content

fix(tui): resolve cross-platform root detection and fallback paths in pickers#3795

Open
Piyush0049 wants to merge 1 commit into
docker:mainfrom
Piyush0049:fix/tui-windows-picker-paths
Open

fix(tui): resolve cross-platform root detection and fallback paths in pickers#3795
Piyush0049 wants to merge 1 commit into
docker:mainfrom
Piyush0049:fix/tui-windows-picker-paths

Conversation

@Piyush0049

Copy link
Copy Markdown
Contributor

Summary

This PR addresses two cross-platform path handling issues in the TUI file and directory picker components to ensure reliable behavior on Windows and POSIX systems.

1. Cross-Platform Root Directory Boundary Detection

  • Previous behavior: The TUI checked d.currentDir != "/" to decide whether to append the .. (parent directory) option.
  • Issue: On Windows, root directories start with drive letters (such as C:\). Since C:\ does not equal /, the TUI treated C:\ as a non-root folder and appended a .. entry pointing back to C:\, causing an infinite navigation loop.
  • Fix: Replaced hardcoded POSIX root checks with filepath.Dir(d.currentDir) != d.currentDir. This leverages the standard library to verify if a directory is its own parent, which works reliably on Windows, Linux, and macOS.

2. Cross-Platform Directory Fallback (/ to .)

  • Previous behavior: When os.Getwd() returned an error or empty string, the TUI fell back to workingDir = "/".
  • Issue: Hardcoding / as a fallback causes invalid path resolutions on Windows systems when execution context is lost.
  • Fix: Updated the fallback path from / to .. This aligns with the existing fallback pattern used in file_picker.go and ensures safe resolution relative to the process execution directory across all platforms.

Verification

  • Verified with golangci-lint run (0 issues).
  • Verified unit test suite with go test ./pkg/tui/dialog.

@Piyush0049
Piyush0049 requested a review from a team as a code owner July 23, 2026 08:29
@aheritier aheritier added area/tui For features/issues/fixes related to the TUI kind/fix PR fixes a bug (maps to fix:). Use on PRs only. labels Jul 23, 2026
@Piyush0049 Piyush0049 added area/tui For features/issues/fixes related to the TUI kind/fix PR fixes a bug (maps to fix:). Use on PRs only. labels Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/tui For features/issues/fixes related to the TUI kind/fix PR fixes a bug (maps to fix:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants