Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

bug(web): Intermediate directory nodes in buildFileTree receive child leaf paths instead of directory paths

Offen Anfängerfreundlich
#1,707 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@riteshvish02 arbeitet bereits daran.

Seit 03.10.2026.

  • #1708 von @riteshvish02 — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
88/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
typescript
Bereich
api, frontend

Rechercherichtung

Beginne in packages/web/src/features/git/utils.ts bei buildFileTree, untersuche anschließend packages/web/src/app/(app)/browse/components/fileTreePanel.tsx und den getTree-Endpunkt. Reproduziere das Beispiel mit dem verschachtelten Pfad und überprüfe, dass Knoten für Zwischenverzeichnisse ihre eigenen Verzeichnispfade bereitstellen, einschließlich der korrekten Ordneraufklappung und API-Ausgabe.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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
  1. Broken Folder State & Expansion in UI: In packages/web/src/app/(app)/browse/components/fileTreePanel.tsx, folder expand/collapse state is tracked via openPaths.has(node.path) and route sync via pathParts.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.
  2. Public API Corruption: The getTree endpoint (/api/git/tree) returns FileTreeNode with 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.

Vorherrschende Sprache
TypeScript
Sterne
3.9k
Forks
374
Ø Merge
17 Std. 15 Min.
Gemergte PRs (30 T.)
38

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus sourcebot-dev/sourcebot

Alle Issues in sourcebot-dev/sourcebot

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.