Repository navigation
Description
Description
On a large non-Git workspace, GET /api/fs/find silently indexes only 100,000 files. Refreshing the index can replace that set with different files, so existing files disappear from search without any filesystem changes. This causes intermittent missing @ autocomplete results across clients.
I reproduced the changing subset directly against OpenCode 2.0.27 with a synthetic fixture containing 200,000 empty generated files under build/ and env/, plus 65 source files under src/. All inventory requests used query=/, type=file, and limit=1000000:
- Every response contained exactly 100,000 paths and returned HTTP 200.
- After refresh, 26,216 paths from the first snapshot disappeared and 26,216 different paths appeared.
- A disappeared file still existed on disk. The fixture was unchanged during the capture.
- The first file/directory search pair took 2.26 seconds.
Earlier 2.0.25 captures on two real non-Git workspaces also lost source results. One workspace's returned src/ file count changed from 5103 to 0 and back to 5103 across refreshes. Scoping those searches to src/ kept the wanted targets stable and reduced warm backend latency to about 3 to 4 ms. Internal project names and raw captures are omitted.
Expected: existing source files remain searchable across refreshes, or the API explicitly reports an incomplete index. Increasing the result limit should not silently search only a changing subset.
The 2.0.27 ripgrep scan caps non-VCS locations at 100_000 and replaces the index after each scan. Refresh is eligible after 10 seconds. This matches the observed ceiling and changing membership. The responses contain no completeness/truncation marker.
Plugins
No third-party plugins configured in the reproduction. The server used fresh HOME and XDG directories, and the fixture had no OpenCode config or plugin directories in its ancestors.
OpenCode version
2.0.27, installed CLI. Earlier real-workspace measurements used 2.0.25.
Steps to reproduce
-
Create a non-Git fixture with more than 100,000 generated files and a small source tree:
from pathlib import Path from tempfile import mkdtemp root = Path(mkdtemp(prefix="opencode-search-")) for name in ("build", "env"): for group in range(100): directory = root / name / f"group-{group:03}" directory.mkdir(parents=True) for i in range(1000): (directory / f"artifact-{i:04}.txt").touch() source = root / "src" / "PackageAlpha" / "src" source.mkdir(parents=True) for i in range(64): (source / f"source-{i:03}.rs").touch() (source / "wanted.rs").touch() print(root)
-
Start
opencode serve --hostname 127.0.0.1 --port 4599with a fresh home/config/data environment. SetROOTto the printed fixture path. -
Request an inventory and save the JSON response:
curl -sS -G http://127.0.0.1:4599/api/fs/find \ --data-urlencode "location[directory]=$ROOT" \ --data-urlencode 'query=/' --data 'type=file' --data 'limit=1000000'
-
Wait at least 12 seconds and issue another request to trigger refresh. Wait for the background scan, then save another response. Repeat if the first refresh selects the same subset.
-
Compare the
data[].pathsets. Check that removed paths still exist underROOT. No fixture changes are needed.
Screenshot and/or share link
Discovered while investigating openchamber/openchamber#4645. The synthetic reproduction calls OpenCode directly and does not require OpenChamber.
Operating System
Amazon Linux 2023, Linux 6.12.110-135.202.amzn2023.aarch64, arm64.
Terminal
API reproduction, no TUI. Shell /bin/zsh; TERM=xterm-256color. Terminal application unavailable.
Activity
opencode-agent commentedon Oct 12, 2026
Thanks for the detailed report and fixture. I reproduced this on 2.0.27, and it still happens on the latest
dev(a22754f).Using your fixture (200,000 generated files under
build/andenv/, plus 65 files undersrc/), I ranopencode serveand calledGET /api/fs/findwithquery=/,type=file,limit=1000000:dev). The removed files were still on disk, and nothing in the fixture had changed.locationanddata, with nothing saying the index is incomplete.In my runs the 65
src/files stayed in the results each time, so I did not reproduce source files themselves disappearing, as you saw on real workspaces. The swapping subset is the same underlying behaviour.The script below reproduces it. It sets
OPENCODE_SERVER_PASSWORD, becauseserverequires auth, and uses Basic auth with the useropencode.Reproduction script (repro.py)
Run it:
python3 repro.pyDante-dan commentedon Oct 13, 2026
I’ll keep the bounded non-Git scan and expose when its search index is incomplete, so callers can distinguish missing matches from a truncated inventory.