Skip to content

fix: allow list_files to work on home directory#12127

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/home-dir-list-files-12121
Draft

fix: allow list_files to work on home directory#12127
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/home-dir-list-files-12121

Conversation

@roomote-v0
Copy link
Copy Markdown
Contributor

@roomote-v0 roomote-v0 bot commented Apr 16, 2026

Related GitHub Issue

Closes: #12121

Description

This PR attempts to address Issue #12121 where list_files returns "No files found." when the workspace is the user's home directory.

Root cause: handleSpecialDirectories() in list-files.ts short-circuited home directory requests by returning only the directory path itself (a single-element array). When formatFilesList() converted this to a relative path, it produced an empty string, which triggered the "No files found." message.

Changes:

  1. src/services/glob/list-files.ts: Removed the home directory restriction from handleSpecialDirectories(). The root directory (/) check remains since that is genuinely dangerous. The existing limit parameter already protects against performance issues for large directories.

  2. src/core/environment/getEnvironmentDetails.ts: Added a home directory check (similar to the existing Desktop check) so environment details skip automatic listing for home-directory workspaces, keeping the initial system prompt lightweight. Explicit list_files tool calls still work correctly.

  3. src/core/environment/__tests__/getEnvironmentDetails.spec.ts: Added a test for the new home directory handling.

Also removed the now-unused os import from list-files.ts.

Test Procedure

  • Ran npx vitest run core/environment/__tests__/getEnvironmentDetails.spec.ts (20 tests pass)
  • Ran npx vitest run services/glob/__tests__/list-files.spec.ts core/prompts/__tests__/responses-rooignore.spec.ts (19 tests pass)
  • All lint and type checks pass via pre-push hooks

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue.
  • Scope: Changes are focused on the linked issue.
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New test added for home directory handling in getEnvironmentDetails.
  • Documentation Impact: No documentation updates required.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.

Additional Notes

Feedback and guidance are welcome.

Interactively review PR in Roo Code Cloud

Remove home directory restriction from handleSpecialDirectories() in
list-files.ts so that explicit list_files tool calls return actual file
listings instead of "No files found."

Add a home directory check in getEnvironmentDetails() to skip automatic
file listing for home directory workspaces (similar to the existing
Desktop check), keeping the initial system prompt lightweight while
still allowing list_files to work correctly.

Add test for the new home directory handling in getEnvironmentDetails.
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.

[BUG] Cannot get file list from current dir

1 participant