Skip to content

Commit e4a6c3b

Browse files
committed
remoev inheritance
1 parent f4c92ba commit e4a6c3b

3 files changed

Lines changed: 14 additions & 23 deletions

File tree

apps/probe-viewer/src/grouping/README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,10 @@ dependency. The config is `{ hierarchy }`, a tree of nodes. Each node has a
1818
`label` and either `children` (more nodes) or `probes` (model ids, in display
1919
order) at the leaves.
2020

21-
`collapsible` is a per-node property that **propagates to descendants**: a node
22-
uses its own `collapsible` when set, otherwise it inherits the resolved value of
23-
its parent, and the top-level default is `true`. So only the exceptions need
24-
stating: the length bands set `collapsible: false` (a static, always-open
25-
divider) and that flows down to their probes, while everything else omits it and
26-
inherits the default. `true` is a foldable header with a caret; `false` is a
27-
static divider.
21+
`collapsible` is a per-node property that **defaults to `true`**, so only the
22+
exceptions need stating: the length bands set `collapsible: false`, while every
23+
other node omits it. `true` is a foldable header with a caret; `false` is a
24+
static, always-open divider.
2825

2926
The walker (`groupEntries.ts`) attaches each manifest entry to the node listing
3027
its model, prunes empty branches, and collects anything not placed into a

apps/probe-viewer/src/grouping/groupEntries.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@ import type { GroupNode, HierarchyConfig, HierarchyNode } from "./types";
66
// probe needs a home in the config.
77
const UNGROUPED_LABEL = "Ungrouped";
88

9-
// Top-level default when a node does not set `collapsible` and has no parent.
10-
const ROOT_COLLAPSIBLE = true;
11-
129
// Resolves the explicit hierarchy against the given (already search-filtered)
1310
// entries: attaches each entry to the node that lists its model id, prunes
1411
// empty branches, and gathers anything unplaced into a trailing "Ungrouped"
15-
// group. `collapsible` is resolved per node, inheriting the parent's value when
16-
// the node does not set its own.
12+
// group. `collapsible` is per node and defaults to true.
1713
export function groupEntries(
1814
entries: ManifestEntry[],
1915
config: HierarchyConfig,
@@ -22,12 +18,12 @@ export function groupEntries(
2218
for (const entry of entries) byModel.set(entry.model, entry);
2319
const placed = new Set<string>();
2420

25-
const walk = (node: HierarchyNode, inherited: boolean): GroupNode | null => {
26-
const collapsible = node.collapsible ?? inherited;
21+
const walk = (node: HierarchyNode): GroupNode | null => {
22+
const collapsible = node.collapsible ?? true;
2723

2824
if (node.children) {
2925
const children = node.children
30-
.map((child) => walk(child, collapsible))
26+
.map((child) => walk(child))
3127
.filter((child): child is GroupNode => child !== null);
3228
if (children.length === 0) return null;
3329
const count = children.reduce((sum, child) => sum + child.count, 0);
@@ -47,7 +43,7 @@ export function groupEntries(
4743
};
4844

4945
const groups = config.hierarchy
50-
.map((node) => walk(node, ROOT_COLLAPSIBLE))
46+
.map((node) => walk(node))
5147
.filter((group): group is GroupNode => group !== null);
5248

5349
const leftovers = entries.filter((entry) => !placed.has(entry.model));

apps/probe-viewer/src/grouping/types.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ import type { ManifestEntry } from "../types/probe";
55
// model ids at the leaves. A manufacturer with no config renders as a flat list
66
// (see ./index.ts).
77
//
8-
// Collapsibility is a per-node property that propagates to descendants: a node
9-
// uses its own `collapsible` when set, otherwise it inherits the resolved value
10-
// of its parent, and the top-level default is `true`. So only the exceptions
11-
// need stating: the length bands set `collapsible: false`, which flows down to
12-
// their probes, while everything else inherits the default and stays foldable.
8+
// Collapsibility is per node and defaults to `true`, so only the exceptions
9+
// need stating: the length bands set `collapsible: false` to render as static
10+
// dividers, and every other node omits it and stays a foldable header.
1311

1412
export interface HierarchyNode {
1513
label: string;
16-
// true => a collapsible group header; false => a static, always-open divider.
17-
// Omitted => inherit the parent's resolved value (root default: true).
14+
// true (default) => a collapsible group header; false => a static, always-open
15+
// divider.
1816
collapsible?: boolean;
1917
children?: HierarchyNode[];
2018
probes?: string[]; // model ids, in display order

0 commit comments

Comments
 (0)