feat: add directory/file path completion for terminal input#74
Open
BingqingLyu wants to merge 8 commits into
Open
feat: add directory/file path completion for terminal input#74BingqingLyu wants to merge 8 commits into
BingqingLyu wants to merge 8 commits into
Conversation
Implement path auto-completion inspired by Claude Code's directoryCompletion.ts. When user types a path-like token (/, ./, ../, ~/), trigger file/directory completion with LRU-cached directory scanning and .gitignore filtering. - New module: utils/directoryCompletion.ts with SimpleLRUCache, path parsing, directory scanning, and completion generation - New hook: usePathCompletion.ts with 100ms debounce and abort controller - Modified: useCommandCompletion.tsx to add PATH completion mode with SLASH/PATH disambiguation for absolute paths - 21 unit tests covering all path completion scenarios Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Use os.homedir() instead of process.env for home directory expansion - Extract magic number 100 to named constant MAX_SCAN_RESULTS - Remove redundant 'enabled' field from UsePathCompletionReturn - Add comment explaining cursorRow === 0 restriction for PATH mode Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Preserve ./ prefix in completion values (was incorrectly stripped) - Remove bare ~, ., .. from path-like token detection (produced wrong results) - Fix bare / falling into PATH mode instead of SLASH mode when commands exist - Include symlinks in scanDirectoryForPaths results - Simplify usePathCompletion to return void (align with useAtCompletion pattern) - Strengthen tests to verify actual mode selection via mock call assertions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Verify that path completion does not add trailing space after autocomplete (unlike AT/SLASH mode), which allows users to continue navigating deeper into directories. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add Windows backslash path support to isPathLikeToken (~\, .\, ..\) - Clear suggestions/loading state when usePathCompletion is disabled to prevent stale UI state Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Resolve symlink target type via stat() so symlinks to directories show as directories with trailing / and allow continued navigation - Use toCodePoints() instead of [...str].length for consistency with existing ASCII fast path - Fix test: use vi.spyOn(process, 'cwd') instead of direct assignment - Add tests for symlink-to-directory and broken symlink handling Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Map.set() on an existing key preserves its original insertion position, which would cause frequently-updated entries to be evicted prematurely. Delete-then-reinsert to maintain correct LRU ordering. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add completionMode to UseCommandCompletionReturn so consumers (e.g., InputPrompt) can distinguish PATH vs SLASH mode for correct SuggestionsDisplay layout - Fix Windows path regex to accept both C:\ and C:/ separators Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Apr 28, 2026
Owner
Author
Conflict Group 1This PR shares modified functions with 2 other PR(s): #62, #9. These PRs should be reviewed as a batch — merging one may affect the others.
graph LR
PR74["PR #74"]
FuseCommandCompletion_8197["useCommandCompletion<br>useCommandCompletion.tsx"]
PR74 -->|modifies| FuseCommandCompletion_8197
PR62["PR #62"]
PR62 -->|modifies| FuseCommandCompletion_8197
PR9["PR #9"]
PR9 -->|modifies| FuseCommandCompletion_8197
Posted by codegraph-ai conflict detection. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Background
Users frequently need to reference file paths in prompts (e.g.
src/components/auth/LoginForm.tsx). Currently they must type full paths manually, which is error-prone and slow in large projects with deep directory structures.Related: Item-18: Directory/File Path Completion
Before / After
@prefix triggers file completion/,./,../,~/as path prefixes/home/user/...misidentified as a slash command — no suggestions shownImplementation
.gitignore-aware filteringCompletionMode.PATH; resolves SLASH/PATH conflict so/homeis no longer treated as a slash commandChanges
utils/directoryCompletion.ts(+348)hooks/usePathCompletion.ts(+167)hooks/useCommandCompletion.tsx(+57/-8)Tests
Manual verification: Launch the CLI, type
./sr— you should see suggestions likesrc/. Press Tab to accept and continue completing the next directory level.