Skip to content

fix(opencode): include linked directories in file search index#18291

Open
t7r0n wants to merge 2 commits intoanomalyco:devfrom
t7r0n:fix/file-search-follow-linked-dirs-18182
Open

fix(opencode): include linked directories in file search index#18291
t7r0n wants to merge 2 commits intoanomalyco:devfrom
t7r0n:fix/file-search-follow-linked-dirs-18182

Conversation

@t7r0n
Copy link

@t7r0n t7r0n commented Mar 19, 2026

Issue for this PR

Closes #18182

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

@ file autocomplete and find.files rely on File.search(), which uses a cache built in File.scan().
That scan used Ripgrep.files({ cwd }) without following links, so files under junction/symlink directories were not indexed.

This PR updates the scan to use follow: true and adds a regression test that creates a linked docs directory and verifies docs/linked/entry.ts is returned by File.search().

How did you verify your code works?

  • bunx prettier --check src/file/index.ts test/file/index.test.ts
  • bun test --timeout 30000 test/file/index.test.ts -t "File.search()"
  • bun test --timeout 30000 test/file/ripgrep.test.ts

Screenshots / recordings

N/A (non-UI change)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Contributor

Hey! Your PR title Fix @ file indexing for junction/symlink directories on Windows doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 19, 2026
@t7r0n t7r0n changed the title Fix @ file indexing for junction/symlink directories on Windows fix(opencode): include linked directories in file search index Mar 19, 2026
@github-actions github-actions bot removed needs:compliance This means the issue will auto-close after 2 hours. needs:title labels Mar 19, 2026
@github-actions
Copy link
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@t7r0n
Copy link
Author

t7r0n commented Mar 20, 2026

Added a follow-up fix for the Windows unit timeout seen on this PR.

What changed:

  • Replaced unconditional follow: true in File.scan() with a safer approach:
    • keep the normal non-follow Ripgrep.files({ cwd }) scan for the workspace
    • separately index root linked directories (symlink/junction) by scanning each link path directly
  • Added dedupe guards for files/dirs and linked targets to avoid repeated traversal/cycle amplification.

Why:

  • CI showed unit (windows) hanging in Run unit tests until job timeout.
  • Global recursive follow over links can explode traversal on Windows junction-heavy trees.

Local validation:

  • bun test --timeout 30000 test/file/index.test.ts -t "File.search()" (from packages/opencode)
  • bun test --timeout 30000 test/file/ripgrep.test.ts (from packages/opencode)
  • bun turbo test (repo root)
  • pre-push hook bun turbo typecheck

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.

File reference (@) fails to index files/folders created via Junction or SymbolicLink on Windows

1 participant