tui: @/ does not reliably offer the project root in the mention picker

オープン 初心者向け
#61,640 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@HoneyPaptan がすでに取り組んでいます。

2026年11月4日 から。

  • #61758 @HoneyPaptan による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
backend, search

調査の方向性

packages/core/src/filesystem/search.ts から始めて、ripgrep バックエンドが rg --files のエントリからディレクトリインデックスを構築する方法を調べてください。Git 以外での動作を fff バックエンドおよび #60450 の空ディレクトリに関する関連作業と比較してください。完了条件は、Git 管理外の場所に対する GET /api/fs/find?query=/ が {"path":"/","type":"directory"} を含み、既存の Git 管理下での動作が維持されることです。

索引モデルが issue の本文から書いたものです。

説明

reproduced

Summary

@/ does not reliably offer the location root in the TUI mention picker. There are two independent causes:

  1. In larger Git repos the root is indexed, but the TUI requests only 20 search results and the root is dropped before the client can sort/display it.
  2. In some locations the root is never indexed at all (non-Git locations, and Git locations whose root contains no files).

In both cases there is no / entry to select, so the project directory cannot be attached to a prompt.

Environment

  • opencode version: 2.2.5
  • OS: Linux 6.18.60-1-lts (x86_64)
  • Terminal: TUI, TERM=xterm-256color, COLORTERM=truecolor, TERM_PROGRAM unset
  • Shell: /usr/bin/bash
  • Install/channel: latest release (/usr/bin/opencode)
  • Active plugins: none found (no plugin entries in global config; no local .opencode/plugin or .opencode/plugins)

Reproduction

A. Large Git repo: the root is indexed but truncated by the 20-result limit

This is the reported case. The repo has files at its root, is a normal Git checkout, and @/ still has no / entry.

  1. In a Git repo with enough matching directories, compare the API result at the TUI's limit with a larger limit:

    opencode api --standalone GET '/api/fs/find?query=/&limit=20'
    

    No / entry is returned; the first results are ordinary directories:

    {"data":[{"path":"cv/","type":"directory"},{"path":"db/","type":"directory"}, ...]}
    
    opencode api --standalone GET '/api/fs/find?query=/&limit=50'
    

    With a larger limit the root is present and sorts first:

    {"data":[{"path":"/","type":"directory"},{"path":"cv/","type":"directory"}, ...]}
    

    In the repo I tested, the threshold was limit=41: 40 returned no /, 41 returned it first.

  2. In the TUI, type @/. The picker shows the same first results as the limit=20 response and has no / entry.

  3. Nothing changes after the file index refreshes; this is deterministic for a given repo size.

B. Root not indexed
  • A Git repo whose root contains only subdirectories returns no / even with limit=50.
  • A non-Git location returns no / at any limit, even when a file exists directly at the root.

Expected Behavior

The location root should always be available as a directory entry in the @ picker, regardless of repo size, backend, or whether the root contains files.

Actual Behavior

The root is missing from the picker in the cases above, so there is nothing to select that represents the project directory.

Additional Context

  • Cause A: packages/tui/src/component/prompt/autocomplete.tsx requests limit: 20. packages/core/src/filesystem/search.ts passes that limit to the fff backend as pageSize, then sorts only the returned page. fff can place / after the first 20 matches, so it is truncated before the client ever sees it; with a larger page it appears and sorts first.
  • Cause B: the root is not seeded explicitly in the directory index. The fff backend only includes / incidentally when a file exists directly at the root. The ripgrep backend (non-Git, home, Windows, workspace-backed, or when fff is unavailable) builds directories only from parent components of rg --files entries, so / is never added.
  • Related: #33751 (directory suggestions require direct files; closed for inactivity) and #60293 / #60450 (empty directories in the ripgrep index). #60450 starts its walk at the root with known=true and only publishes provably empty child directories, so it will not add /.
  • Suggested fixes: seed the location root in the directory index for both backends, and request enough candidates (or paginate) so the client's sort/filter runs before the result limit is applied. A root entry should not depend on repo size.
主要言語
TypeScript
スター
224k
フォーク
30k
平均マージ
6時間 16分
マージ済み PR(30日)
507

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

anomalyco/opencode のほかの issue

anomalyco/opencode の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。