Repository navigation
Description
Summary
In a Git project using the fff file search backend, directories created after the project has been indexed are missing from @ completion when they contain no direct files. Empty directories never appear. A directory that contains only subdirectories also stays missing even when a file is created deeper inside it: only the file's immediate parent directory is added.
A fresh server, or a location the server has not indexed before, returns all of these directories correctly. Restarting the server makes them appear. The TUI @ picker reads /api/fs/find directly, so it has no entry for these directories.
Environment
- opencode version: 2.4.3 (latest; also reproduced on 2.4.2)
- Client: TUI; verified against
opencode serveand the running background service - Model and provider: Not relevant
- OS: Linux 6.18.65-1-lts (x64)
- Terminal: alacritty,
TERM=alacritty,COLORTERM=truecolor - Shell: /usr/bin/bash
- Install/channel: latest release (
/usr/bin/opencode, v2.4.2; v2.4.3 release binary used for the latest verification) - Active plugins: None found
Reproduction
-
Create a Git repository and start OpenCode with
fffavailable:mkdir -p /tmp/oc-fff-repro && cd /tmp/oc-fff-repro git init mkdir -p deep/sub && touch deep/sub/file.txt opencode serve --port 4099
opencode serveprints a local URL and password. Export the password before using the API commands below:export OPENCODE_PASSWORD=<password printed by opencode serve>
-
Query the API once to initialize the location's
fffpicker:opencode api --server http://127.0.0.1:4099 GET '/api/fs/find?query=deep&limit=20'The result includes
deep/,deep/sub/, anddeep/sub/file.txt. -
While the server is still running, create a new empty directory and a new directory that contains only a subdirectory with a file:
mkdir -p newempty newdeep/sub touch newdeep/sub/file.txt
-
Query the new directories:
opencode api --server http://127.0.0.1:4099 GET '/api/fs/find?query=newempty&limit=20' opencode api --server http://127.0.0.1:4099 GET '/api/fs/find?query=newdeep&limit=20'
Actual results:
{"data":[]} {"data":[{"path":"newdeep/sub/file.txt","type":"file"},{"path":"newdeep/sub/","type":"directory"}]}newempty/is absent, andnewdeep/is absent even though its child directories and file were indexed. -
Stop and restart
opencode serveon the same repository, then repeat the queries from step 4. Bothnewempty/andnewdeep/are returned, the same way the initialdeep/query returneddeep/. -
In the TUI, typing
@newemptyor@newdeepshows no matching directory, so neither directory can be selected.
Creating a file directly inside newempty/ makes newempty/ appear on the next query, and it stays indexed after that file is removed:
touch newempty/file.txt # query now returns newempty/ and newempty/file.txt
rm newempty/file.txt # newempty/ remainsExpected Behavior
Every directory that exists in the location should be available in @ completion, regardless of whether it contains files or only subdirectories. Creating a directory while the server is running should make it mentionable without restarting the server.
Actual Behavior
- A newly created empty directory is never added to the live
fffindex. - A newly created directory that contains only subdirectories is not added; only the immediate parent of a newly indexed file is added (
newdeep/sub/), not all of its ancestors (newdeep/). - The TUI
@picker consumes/api/fs/finddirectly, so these directories cannot be mentioned. - Restarting the server, or using a fresh location, returns the missing directories, which shows the initial scan handles them correctly and the incremental update is the failing part.
Additional Context
- Reproduced on the latest v2.4.3 release binary with
opencode serve, and on v2.4.2 with the running background service. - The
fffbackend inpackages/core/src/filesystem/search.tscreates one picker per location and relies onfff's watcher for changes after the initial scan. The observed behavior is consistent with the watcher adding only the immediate parent directory of each new file and not handling directory-creation events for empty directories. - The same symptom was reported for v1 in @ autocomplete no longer suggests ancestor directories without direct files after fff integration #33751, which was closed for inactivity after
fffintegration. - Related but distinct: fs: ripgrep directory search omits empty directories #60293 covers empty directories in the fresh ripgrep index (and the open PR fix: find empty directories in filesystem search #60450 adds them to the ripgrep scan), and tui: @/ does not reliably offer the project root in the mention picker #61640 covers the project root when it contains only subdirectories.
- Workaround: create a file directly inside the missing directory, or restart the server so it rescans the location.
- Frequency: always, for directories created after the location's
fffpicker has been initialized.
Activity
opencodejr commentedon Nov 30, 2026
Thanks for the detailed report. I reproduced this on the released 2.4.3 CLI through
opencode serve, following your steps:deep/sub/file.txt, I queried/api/fs/find?query=deep, which returneddeep/,deep/sub/and the file.mkdir -p newempty newdeep/sub && touch newdeep/sub/file.txt.newemptydid not returnnewempty/. Queryingnewdeepreturned onlynewdeep/sub/andnewdeep/sub/file.txt, withoutnewdeep/.It still happens on the latest
dev(88b03b9), run from source. The script below reproduces it against the API.Related: #60293 (empty directories missing from the ripgrep backend, open PR #60450) and #61640 (the project root missing from
@/, open PR #61758).Reproduction script (repro.sh)
Run it:
sh repro.sharchit15singh commentedon Nov 30, 2026
I reproduced this on macOS arm64 with OpenCode v2.4.3 and narrowed it to the fff dependency. In a standalone Git fixture,
FileFinder.directorySearch()on fff 0.10.5 (OpenCode’s pin) and 0.11.0 included the immediate parent of a new file, but omitted both its ancestor and a new empty directory after 7 seconds. A fresh picker found both directories.Would you prefer an upstream fff fix followed by an OpenCode dependency update, or an OpenCode-side workaround? I can help with whichever route fits. Codex assisted with the reproductions and this comment.
pewpil commentedon Nov 30, 2026
Source-level follow-up on current
dev(20c6a0a) with the pinned fff 0.10.5.The gap is in fff's live directory table, not in OpenCode's
/api/fs/findcall path:crates/fff-core/src/watcher/background_watcher.rs:478-481).index_new_directorythen indexes files (:709-783) and returns early when the new subtree has no files (:764-766), without inserting the directory or its walked subdirectories intosync_data.dirs.FilePicker::add_new_file, which registers the new file's immediate parent (crates/fff-core/src/file_picker.rs:1693-1701), not its ancestors.file_picker.rs:2180-2242), including empty subtrees and pure ancestors. That is why a restart or a fresh picker returns the missing directories.I reproduced this directly against clean fff v0.10.5:
[]sub/file.txt->["sub/"](the parentnewdeep/is absent)A minimal upstream patch that registers the new directory and its walked subdirectories/ancestors in
index_new_directorymakes both cases pass, and the existing 7 directory-index tests still pass in a temporary clone. An optional hardening is to haveadd_new_fileregister all ancestors, so a file event alone repairs a missed directory event. The fix then needs an fff release and a bump of both@ff-labs/fff-bunand@ff-labs/fff-nodein OpenCode; the existing fff patch only changes ESM import specifiers and cannot carry the native fix.v0.10.6 and v0.11.0 retain the same watcher path, and
mainstill has the early return. None of the related OpenCode PRs cover it: #60450 adds empty directories to the ripgrep layer, #61758 adds the root for the literal/query, #67279 changes fff selection for ignored locations, #65571 adds an exact-path probe, #62065 normalizes separators, and #65623 bounds cold ripgrep indexing. #33751 is the same symptom from v1 and was closed for inactivity, not fixed.Workaround remains: create a file directly in the missing directory, or restart the server so the initial scan rebuilds the directory table.
I have not opened an upstream fff issue for this yet; the reproduction and patch above are from a temporary v0.10.5 clone and have not been reviewed by the fff maintainers.
dkovalenko-oai commentedon Dec 1, 2026
looking