[BUG] Desktop Code tab: @-mention autocomplete drops all files outside nested git repos when session root is not a git repo

Status Fixed / completed
Reported on v2.1.284
Maintainer reply None cached
Activity 0 comments · opened Sep 30, 2026 · closed Oct 1, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

In the Claude Desktop Code tab, @-mention file autocomplete only shows files from nested git repositories when the session's root folder is not a git repository but has one or more direct child folders that are git repositories. Every file/folder outside those nested repos is silently missing from the index.

Example layout (session cwd = project/):

project/                 <- NOT a git repo (session cwd)
├── annotation-toolkit/  <- git repo
├── paper/               <- plain folder (contains paper/latex/, a git repo two levels down)
├── proposal/            <- plain folder
└── research/            <- plain folder, ~2,300 files
  • Typing @ shows only annotation-toolkit (plus sessions and open app windows).
  • Typing @research, @proposal, @paper returns no file/folder results at all — only unrelated matches (e.g. a Slack channel named "research").
  • rg --files in the same folder lists ~2,300 files in ~20 ms, so this is not a size/permission/scan-time problem. ~/Projects is not a TCC-protected location.

Root cause (from reading the bundled file-index worker in app.asar):

  1. The index is built by running git ls-files --recurse-submodules in the session root and in each direct child directory that contains a .git.
  2. For the root, git ls-files fails with fatal: not a git repository. That specific error is intentionally not logged, and the root result is simply null.
  3. Results are combined: if any listing succeeded, only the successful listings are committed; a failed listing with an empty prefix (the root) is dropped.
  4. The directory-walk fallback (depth ≤ 4, ≤ 2,000 entries) runs only when every listing failed.

So a single nested repo is enough to suppress the fallback, and the whole non-git root is excluded from @-mention autocomplete with no warning in the UI or in main.log.

(Separately, nested-repo discovery only checks direct children, so paper/latex/ above is not found either — but that matters less than the root being dropped.)

What Should Happen?

When the session root is not a git repository, its files should still be indexed: e.g. run the directory-walk fallback for the root (excluding the nested-repo subtrees, which are covered by their own git ls-files) and merge it with the nested-repo listings. @research, @proposal, etc. should then autocomplete as they do in a folder without nested repos.

Error Messages/Logs

# No error is logged for this case. The root failure ("not a git repository") is deliberately
# suppressed, and ~/Library/Logs/Claude/main.log only shows:
[info] [file-index] worker forked
# with no subsequent file-index warnings for this session's cwd.

Steps to Reproduce

(The behaviour was observed on the real layout above; this minimal repro follows the same code path.)

  1. Create a folder layout like this:

``bash
mkdir -p /tmp/repro/{subrepo,plain/docs}
echo a > /tmp/repro/subrepo/a.txt
echo b > /tmp/repro/plain/docs/b.txt
echo c > /tmp/repro/root-file.txt
git -C /tmp/repro/subrepo init -q && git -C /tmp/repro/subrepo add -A
`
(
/tmp/repro` itself is not a git repo.)

  1. In Claude Desktop → Code tab, start a new local session with /tmp/repro as the folder.
  2. In the prompt box type @root-file, @plain, and @b.txt: no file results.
  3. Type @a.txt: subrepo/a.txt is found.
  4. Control: rm -rf /tmp/repro/subrepo/.git, start a new session in /tmp/repro: now @root-file, @plain, @b.txt are found (the directory-walk fallback runs because every listing failed).

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

Claude Desktop 2.16120.0 (bundled Claude Code 2.1.284); CLI claude --version: 2.1.285 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

  • Surface: Claude Desktop (macOS) → Code tab, local session. Not tested in the CLI's own @ autocomplete.
  • macOS 26.7 (25G229), git 2.54.0 (Apple Git-157).
  • Related but different: #81310 (file-index-worker git ls-files fails with EPERM for sessions under TCC-protected dirs and falls back to the depth-limited scan). In this report there is no EPERM and the fallback never runs at all.

View original on GitHub ↗