Skip to content

fix(app): show directories in web project picker on open - #39758

Closed
mdatla wants to merge 2 commits into
anomalyco:devfrom
mdatla:fix/web-project-picker-browse
Closed

fix(app): show directories in web project picker on open#39758
mdatla wants to merge 2 commits into
anomalyco:devfrom
mdatla:fix/web-project-picker-browse

Conversation

@mdatla

@mdatla mdatla commented Jul 30, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #39434
Closes #37961
Closes #37611

Type of change

  • Bug fix

What does this PR do?

The web directory picker ("Open project") always shows "No folders found" on a fresh browser profile, so there is no way to add a first project in opencode web / opencode serve. Two independent causes in createDirectorySearch:

  1. An empty filter is sent to fuzzy find (/find/file). Fuzzy find returns nothing for an empty query, and fff additionally refuses to index $HOME / filesystem roots — which is where the picker bases itself (sync.data.path.home) on headless servers. Result: the picker always opens empty.
  2. The browse call file.list({ location: { directory } }) omits the path query param, which the server requires (FileListData.query.path: string). The server answers HTTP 400 "Missing key at [\"path\"]" and the .catch(() => []) swallows it. This also breaks the commonly suggested workaround of typing a path into the picker on current versions.

Fix: pass path: "" to file.list, and route empty filters to directory browse (match(directory, "", 50)) instead of fuzzy find. Typed non-empty filters still use /find/file — unchanged.

How did you verify your code works?

  • Reproduced against a live opencode serve 1.18.9 instance: GET /file?directory=<dir> → HTTP 400; the same request with path= → 200 with the full directory listing.
  • Added unit tests: empty filter browses via file.list (asserts path: "" is sent and file.find is not called); a typed filter still uses fuzzy find.
  • bun run test:unit (packages/app): 694 pass / 1 fail — the failure is i18n parity, which also fails on pristine dev (pre-existing, unrelated).
  • bun run typecheck: clean.

Screenshots / recordings

None attached — verified at the API level (curl repro above) and with unit tests. Happy to record the picker if a maintainer wants one.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
    Two notes:
  • I deliberately kept "What does this PR do?" tight and technical — the template warns that large AI-looking descriptions get ignored, and this is exactly the level of detail a maintainer needs.
  • The Closes #... lines will auto-close all three issues on merge; the commit message carries the same references as backup.

The web directory picker always rendered "No folders found" on a fresh
browser profile, making it impossible to add a first project:

1. An empty filter was sent to fuzzy find (/find/file), which returns no
   results for an empty query and additionally refuses to index $HOME or
   filesystem roots, where the picker bases itself on headless servers.
2. The browse call (file.list) omitted the required path query param,
   so the server answered HTTP 400 and the error was swallowed.

Browse directories via file.list (with path: "") when the filter is
empty, and keep fuzzy find for typed non-empty filters.

Fixes anomalyco#39434
Fixes anomalyco#37961
Fixes anomalyco#37611
@mdatla
mdatla requested review from Brendonovich and Hona as code owners July 30, 2026 21:35
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Found potential duplicates:

Why these are potentially related: These PRs all address issues with the web project picker not showing directories/folders on initial open or when the project is empty. PR #37612 is particularly relevant since it targets the same symptom (empty folder listing in picker). Your PR #39758 explicitly closes issues #39434, #37961, and #37611 — one of which (#37611) may be connected to #37612.

@EricZhou05

Copy link
Copy Markdown

Fixed in #41158.

@mdatla mdatla closed this Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants