Add consolidateTeamHierarchy: collapse single-branch chains into one heading - #185
Add consolidateTeamHierarchy: collapse single-branch chains into one heading#185shouze wants to merge 2 commits into
Conversation
|
Coverage after merging feat/team-hierarchy-consolidate into feat/team-hierarchy-model will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Pull request overview
Adds a pure hierarchy transformation that collapses single-child team chains into consolidated headings for future CLI integration.
Changes:
- Implements
consolidateTeamHierarchy. - Recomputes levels without mutating input.
- Adds tests for collapse, branching, nested
other, leaves, and purity.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Summary |
|---|---|
src/group.ts |
Implements consolidation; an unresolved moderate issue may drop groups from parent and intermediate nodes during collapse. |
src/group.test.ts |
Adds focused consolidation and edge-case tests. |
Suppressed comments (1)
src/group.ts:240
onlyis added to the suffix before its own child count is inspected. For a treeA -> B -> {C, D}, this producesA (including B)withC/Ddirectly underneath, so the fork nodeBdisappears instead of remaining a separate heading as required. Stop before addingonlywhen it has 2+ children, and cover this parent-with-fork case in a regression test.
while (current.children && current.children.length === 1) {
const only = current.children[0];
collapsedLabels.push(only.label === "other" ? "unset" : only.label);
current = only;
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
a99a066 to
9f08d84
Compare
|
Coverage after merging feat/team-hierarchy-consolidate into feat/team-hierarchy-model will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 similar comment
|
Coverage after merging feat/team-hierarchy-consolidate into feat/team-hierarchy-model will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/group.ts:242
TeamSection.leveldefines a top-level section as level 0, but this seeds the recomputation from the incoming root's level. If the input tree has a stale/nonzero root level, the consolidated result keeps that offset (and its descendants), solevelwas not actually recomputed. Start every top-level result at 0 instead.
return sections.map((s) => assignLevels(consolidateNode(s), s.level ?? 0));
9f08d84 to
c73d6c5
Compare
|
Coverage after merging feat/team-hierarchy-consolidate into feat/team-hierarchy-model will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Addresses Copilot review on PR #185: - consolidateNode no longer merges a child into the collapsed suffix when that child itself forks into 2+ children — the fork point now stays its own heading instead of disappearing. - groups from every merged node (root + intermediates) are now accumulated instead of only keeping the deepest node's groups, since overlap-nested parents can own repos directly.
c73d6c5 to
ad819ca
Compare
|
Coverage after merging feat/team-hierarchy-consolidate into feat/team-hierarchy-model will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 similar comment
|
Coverage after merging feat/team-hierarchy-consolidate into feat/team-hierarchy-model will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Summary
Adds the "advanced consolidated rendering" mechanism from #125 on top of the
tree built in #177: collapses chains of single-child nesting into one heading
with an "(including ...)" suffix, instead of one heading per level.
consolidateTeamHierarchy(sections): walks agroupByTeamHierarchytreeand, for any run of nodes each having exactly one child, merges them into a
single node whose label lists the collapsed labels
(
"gamme-client (including squad-dashboard)").0 (leaf) or 2+ children (a genuine fork) stop the collapse at that point,
per the issue's requirement that ambiguous branches stay separate headings.
"other"bucket reads as"unset"inside the suffix for readability(the underlying section's
labelis untouched).levelis recomputed on the resulting (shallower) tree.Activation (a CLI flag / heuristic to turn this on) is deliberately left to
the CLI-wiring issue (#182) — this PR only ships the isolated, tested
transform, consistent with how #177 shipped the base algorithm without CLI
wiring.
Closes #178
How to test
bun test src/group.test.ts6 new tests cover: single-branch collapse (2-level and 3-level chains), the
nested-"other"-as-"unset" suffix, no-collapse when a level forks into 2+
children, no-op on a leaf section, and purity (no input mutation).
Validation
bun test(888 pass)bun run lintbun run format:checkbun run knipbun run build.ts