You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support Windows paths and directory separators in path tab completion
Summary
• In cli/src/hooks/use-path-tab-completion.ts, fix path tab completion and automatic directory navigation on Windows.
• Previously, usePathTabCompletion checked searchQuery.startsWith('/') || searchQuery.startsWith('~') for absolute paths. On Windows, drive paths (C:\...) and UNC paths were not matched, causing them to fall through to the relative path branch (path.join(currentPath, searchQuery)).
• Furthermore, completed.endsWith('/') was used to detect full directory completions. On Windows, path-completion.ts appends path.sep (\), so completed.endsWith('/') was always false, breaking automatic directory navigation when pressing Tab.
• Exports pure helpers isAbsolutePath, isCompleteDirectory, and toRelativePath from use-path-tab-completion.ts to handle both POSIX and Windows path styles.
• In cli/src/hooks/__tests__/use-path-tab-completion.test.ts, uses the exported implementations and adds test cases for Windows drive paths and backslash directory completions.
Test plan
[✓] bun test --config=/dev/null src/hooks/__tests__/use-path-tab-completion.test.ts — 35 pass, 0 fail
[✓] bun run --cwd cli typecheck — 0 errors
[✓] PR hygiene check passed
Good catch and a clean fix. The core bug is real: usePathTabCompletion only recognized POSIX-style absolute paths (/, ~), so Windows drive paths (C:\...) fell into the relative-path branch and got mangled via path.join(currentPath, searchQuery). Likewise, checking only completed.endsWith('/') broke auto-navigation on Windows since path-completion.ts appends path.sep (\) there.
Extracting isAbsolutePath, isCompleteDirectory, and toRelativePath as exported pure functions is the right move — it lets the test file exercise the actual implementation instead of a hand-duplicated copy (the previous tests were testing dead code, not the hook). That's a meaningful improvement on its own.
A couple of things worth double-checking before porting:
isCompleteDirectory now treats a trailing \ as a directory marker unconditionally, even on POSIX, where a filename literally ending in \ is legal (rare, but possible). Probably fine, just flag it.
isAbsolutePath calls both path.isAbsolute and path.win32.isAbsolute regardless of platform — intentional per the PR description, and reasonable since you want Windows-style paths recognized even if the CLI happens to run under WSL/POSIX, but worth a comment noting this is deliberate cross-platform detection, not a mistake.
Small, in-scope, tested, addresses a real cross-platform bug. This is the kind of PR worth porting by hand.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Support Windows paths and directory separators in path tab completion
Summary
• In
cli/src/hooks/use-path-tab-completion.ts, fix path tab completion and automatic directory navigation on Windows.• Previously,
usePathTabCompletioncheckedsearchQuery.startsWith('/') || searchQuery.startsWith('~')for absolute paths. On Windows, drive paths (C:\...) and UNC paths were not matched, causing them to fall through to the relative path branch (path.join(currentPath, searchQuery)).• Furthermore,
completed.endsWith('/')was used to detect full directory completions. On Windows,path-completion.tsappendspath.sep(\), socompleted.endsWith('/')was always false, breaking automatic directory navigation when pressing Tab.• Exports pure helpers
isAbsolutePath,isCompleteDirectory, andtoRelativePathfromuse-path-tab-completion.tsto handle both POSIX and Windows path styles.• In
cli/src/hooks/__tests__/use-path-tab-completion.test.ts, uses the exported implementations and adds test cases for Windows drive paths and backslash directory completions.Test plan
[✓]
bun test --config=/dev/null src/hooks/__tests__/use-path-tab-completion.test.ts— 35 pass, 0 fail[✓]
bun run --cwd cli typecheck— 0 errors[✓] PR hygiene check passed