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:
Colby Mchenry
2026-09-29 17:03:34 +00:00
committed by GitHub
parent 0419a51636
commit dcd79ad3c5
6 changed files with 189 additions and 31 deletions
+2 -1
View File
@@ -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
+1 -1
View File
@@ -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)];
+1
View File
@@ -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;