From 3aace2f7a8f297a612d68bdfce9c090c8615667e Mon Sep 17 00:00:00 2001 From: Hrijul Dey <44521405+hr1juldey@users.noreply.github.com> Date: Wed, 18 Nov 2026 20:33:58 +0530 Subject: [PATCH] fix(graph): repo map language label covers the generic tree-sitter tier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sortedLanguages consulted only the depth-tier EXTENSIONS table, so languages indexed by the generic tier (rust, c, …) dropped out of the set: a Rust repo with a few website .js files was labeled javascript. Fall through to genericLangOf, the same fallback the build banner already applies. Fixes #762 --- src/graph/map.ts | 3 ++- test/graph-map.test.ts | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/graph/map.ts b/src/graph/map.ts index d5d2fc4f9..932831b52 100644 --- a/src/graph/map.ts +++ b/src/graph/map.ts @@ -20,6 +20,7 @@ */ import type { GraphV1, NodeV1 } from "./types.js"; import { languageLabelOf } from "./extract.js"; +import { genericLangOf } from "./generic.js"; import { WALK_RELATIONS } from "./relations.js"; import { scopeLabel, scopeOf, scopesOfGraph } from "./scopes.js"; import { withSavings, savingsFor, type Savings } from "../context/savings.js"; @@ -132,7 +133,7 @@ function topHubs(nodes: NodeV1[], inDegree: Map, cap: number): H function sortedLanguages(paths: string[]): string[] { const set = new Set(); for (const p of paths) { - const label = languageLabelOf(p); + const label = languageLabelOf(p) ?? genericLangOf(p)?.name ?? null; if (label) set.add(label); } return [...set].sort(); diff --git a/test/graph-map.test.ts b/test/graph-map.test.ts index be45d4c7c..494da4000 100644 --- a/test/graph-map.test.ts +++ b/test/graph-map.test.ts @@ -87,6 +87,21 @@ test("buildRepoMap: totals count files, symbols, edges, and languages across the assert.deepEqual(map.totals.languages, ["python", "typescript"]); }); +// Issue #762: generic-tree-sitter-tier languages (rust, c, …) are indexed but +// `sortedLanguages` consulted only the depth-tier EXTENSIONS table, so a Rust +// repo with a few website .js files was labeled "javascript". +test("buildRepoMap: generic-tier languages (rust) label the map too, not just depth-tier ones", () => { + const nodes = [ + fileNode("src/lib.rs"), + symNode("src/lib.rs", "fnRust"), + fileNode("static/app.js"), + symNode("static/app.js", "fnJs"), + ]; + const map = buildRepoMap(graphOf(nodes, [])); + assert.deepEqual(map.totals.languages, ["javascript", "rust"]); + assert.match(formatRepoMap(map), /\brust\b/); +}); + test("buildRepoMap: dirs are grouped by first path segment and sorted by symbol count desc", () => { const nodes = [ fileNode("alpha/a.ts"),