anomalyco / anomalyco/opencode

`@` file search returns nothing when cwd is the home directory — fff init failure leaves an empty stub, no ripgrep fallback

Open
#41,456 1 comment 0 reactions 1 assignee View on GitHub

@kitlangton is already working on this.

Since Aug 9, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

When the working directory is the user's home directory (or filesystem root), file search returns zero results for the entire session — the @ autocomplete shows no files/directories, and /api/fs/find returns [] for every query.

fff refuses to initialize there (log: failed to initialize fff: Can not run certain FFF features in a file system root or home directories). That's reasonable, but packages/core/src/filesystem/search.ts handles the failure by installing a permanently empty stub:

if (!result?.ok) {
  ...
  return Service.of({
    find: () => Effect.succeed([]),
    glob: () => Effect.succeed([]),
    grep: () => Effect.succeed([]),
  })
}

instead of falling back to ripgrepLayer. The layer is chosen by Flag.OPENCODE_DISABLE_FFF || !Fff.available(), and available()\) is true even when create()` will fail for this directory — so the failure is silent and unrecoverable without the env var.

OpenCode version

1.18.15

Steps to reproduce
  1. cd ~ && opencode serve --hostname 127.0.0.1 --port 4096 &
  2. curl 'http://127.0.0.1:4096/api/fs/find?query=projects&limit=20'{"data":[]} (also empty for query= and type=directory)
  3. Restart with OPENCODE_DISABLE_FFF=1 → the same query correctly returns matching files and directories.
Expected behavior

When Fff.create() fails, fall back to the ripgrep search layer (or select the layer based on whether the directory is indexable) instead of returning empty results forever.

Note on the ripgrep fallback

Once the fallback kicks in, empty queries still return [] because it uses fuzzysort 3.1.0, where go('', items) yields nothing (fff returns all entries for an empty query, so the two layers disagree). Worth normalizing too.

Operating System

Linux (WSL2)

Terminal

Windows Terminal / bash

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.