mirror of
https://github.com/colbymchenry/codegraph.git
synced 2026-10-17 05:07:37 +08:00
fix(ui-map): count depth in folders that fork, so a Maven project opens on its packages (#2102)
A Maven / Gradle project keeps every line of Java under src/main/java/org/<company>/<app>/, and those folders hold nothing but the next one. The Map cut one folder per level, so petclinic drew the whole program as one `src/main/java/org` box, and the deepest grouping option (4) stopped at `src/main/java/org/springframework` — no setting reached the packages seven levels down. A folder with exactly one subfolder and no file of its own (read from every indexed file, tests included, so ids don't move when tests are toggled) now joins the level below it. moduleIdFor takes the set as an optional fourth argument — without it nothing changes — and pickDefaultDepth counts the same levels. Collapsing never splits a group at the same depth (a pass-through folder has one child), so repos without such chains keep their grouping; a lone chain like koel's `app/Console` → `app/Console/Commands` is renamed to the folder that holds the files. The box label (the wire `label`, which nothing read) now elides a chain of three or more folders — `src/main/java/…/petclinic/owner` — and ModuleNode and the width calculation use it; the tooltip and side panel keep the full path. Everywhere else the label equals the id, so other maps look the same. petclinic's default map: 8 boxes (owner, vet, model, system, the package's root files, resources) instead of one; realworld opens on io/spring's api, application, core, graphql, infrastructure. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -60,7 +60,8 @@
|
||||
layout.generated ? '. Every file in it is tool-generated.' : ''
|
||||
}`}
|
||||
>
|
||||
<span class="name">{module.id}</span>
|
||||
<!-- The label elides a folder chain nothing forks in; the title keeps the full path. -->
|
||||
<span class="name">{module.label || module.id}</span>
|
||||
<!-- The same string nodeWidth() sized the box for; they must not drift. -->
|
||||
<span class="count" class:island={layout.island}
|
||||
>{moduleMetaLabel(module, layout.island)}</span
|
||||
|
||||
@@ -414,7 +414,7 @@ export function buildMapLayout(
|
||||
const widths = new Map(
|
||||
modules.map((m) => {
|
||||
const island = islands.has(m.id);
|
||||
const lines = options.sizing?.(m, island) ?? { label: m.id, meta: moduleMetaLabel(m, island) };
|
||||
const lines = options.sizing?.(m, island) ?? { label: m.label || m.id, meta: moduleMetaLabel(m, island) };
|
||||
const count = portCount.get(m.id) ?? { top: 0, bottom: 0 };
|
||||
const forPorts = (Math.max(count.top, count.bottom) + 1) * portPitch;
|
||||
return [m.id, Math.max(nodeWidth(lines.label, lines.meta), forPorts)];
|
||||
|
||||
@@ -596,6 +596,7 @@ export interface WireFlowPayload {
|
||||
export interface WireMapModule {
|
||||
/** Directory path, the `(root files)` bucket, or a façade file's own path. */
|
||||
id: string;
|
||||
/** What the box says: the id, a folder chain nothing forks in written `first/…/last`. */
|
||||
label: string;
|
||||
files: number;
|
||||
symbols: number;
|
||||
|
||||
Reference in New Issue
Block a user