bug(web): Intermediate directory nodes in buildFileTree receive child leaf paths instead of directory paths
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 88/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript
調査の方向性
packages/web/src/features/git/utils.ts の buildFileTree から始め、次に packages/web/src/app/(app)/browse/components/fileTreePanel.tsx と getTree エンドポイントを調べます。ネストされたパスの例を再現し、中間ディレクトリノードがそれぞれ自身のディレクトリパスを公開していることを、フォルダーの正しい展開と API 出力を含めて確認します。
索引モデルが issue の本文から書いたものです。
説明
Describe the Bug
In packages/web/src/features/git/utils.ts, buildFileTree constructs a nested FileTreeNode hierarchy from a flat list of { type, path } objects.
When creating intermediate directory nodes (lines 68-74), the new node's path property is assigned item.path (the full path of the current leaf file being processed), instead of the path of that directory:
// packages/web/src/features/git/utils.ts:67-75
if (!next) {
next = {
name: part,
path: item.path, // <--- Bug: assigns leaf file's path to intermediate directory node
type: nodeType,
children: [],
};
current.children.push(next);
}
Impact
- Broken Folder State & Expansion in UI: In
packages/web/src/app/(app)/browse/components/fileTreePanel.tsx, folder expand/collapse state is tracked viaopenPaths.has(node.path)and route sync viapathParts.slice(0, i + 1).join('/'). Because directory nodes receive the child file's path instead of their own directory path, clicking folders or deep-linking to nested paths causes folder state tracking and auto-expansion to fail. - Public API Corruption: The
getTreeendpoint (/api/git/tree) returnsFileTreeNodewith corrupted directory paths to API consumers.
Reproduction
const flatList = [
{ type: 'blob', path: 'src/components/buttons/PrimaryButton.tsx' }
];
const tree = buildFileTree(flatList);
const srcDir = tree.children[0];
console.log(srcDir.name); // "src"
console.log(srcDir.path); // Expected "src", but Got "src/components/buttons/PrimaryButton.tsx"
Proposed Fix
Reconstruct the directory node's path using parts.slice(0, i + 1).join('/'):
if (!next) {
next = {
name: part,
path: parts.slice(0, i + 1).join('/'),
type: nodeType,
children: [],
};
current.children.push(next);
}
For intermediate directory levels (i < parts.length - 1), this evaluates to the proper directory path (e.g. "src", "src/components"), and for leaf files (i === parts.length - 1), it matches item.path.
- 主要言語
- TypeScript
- スター
- 3.9k
- フォーク
- 374
- 平均マージ
- 17時間 15分
- マージ済み PR(30日)
- 38
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
sourcebot-dev/sourcebot のほかの issue
-
fix(web): multiline highlight ranges are broken / omitted in LightweightCodeHighlighter対応中かも @riteshvish02 が 7 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
sourcebot-dev/sourcebot#1698 ·
メンテナーはふだん 1 日以内に返信
-
[bug] Search result hydration performs duplicate repository lookups within the same chunk対応中かも @dipeshbabu が 13 日前に担当しました。 オープンbug triage needed
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
sourcebot-dev/sourcebot#1681 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Linux ctags build instructions in CONTRIBUTING.md are missing build dependencies対応中かも @The-AarushiSingh が 20 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
sourcebot-dev/sourcebot#1633 ·
メンテナーはふだん 1 日以内に返信
-
Generic Git URL configs keep percent-encoded repo names対応中かも @Tyagiquamar が 20 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
sourcebot-dev/sourcebot#1384 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
MCP ask_codebase rejects explicit languageModel: getLanguageModelKey includes displayName which the MCP schema doesn't expose対応中かも @pranav718 が 37 日前に担当しました。 オープンask_sb bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
sourcebot-dev/sourcebot#1137 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
sourcebot-dev/sourcebot の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
kind/chore priority/must
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
sidereal-io/sidereal#380 ·
メンテナーはふだん 1 日以内に返信
-
Mend: dependency security vulnerability
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
opfab/operatorfabric-core#10653 ·
メンテナーはふだん 1 日以内に返信
-
backend bug size:sm
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
chrisbenincasa/tunarr#2237 ·
メンテナーはふだん 1 日以内に返信
-
documentation
難易度 2/5 半日 初心者へのやさしさ 69/100
Lam30ne/regulate-app#39 ·