Skip to content

Add consolidateTeamHierarchy: collapse single-branch chains into one heading - #185

Open
shouze wants to merge 2 commits into
feat/team-hierarchy-modelfrom
feat/team-hierarchy-consolidate
Open

Add consolidateTeamHierarchy: collapse single-branch chains into one heading#185
shouze wants to merge 2 commits into
feat/team-hierarchy-modelfrom
feat/team-hierarchy-consolidate

Conversation

@shouze

@shouze shouze commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

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 a groupByTeamHierarchy tree
    and, 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)").
  • A node is only collapsed when its next level has exactly one child —
    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.
  • The "other" bucket reads as "unset" inside the suffix for readability
    (the underlying section's label is untouched).
  • level is recomputed on the resulting (shallower) tree.
  • Pure function, no mutation of the input.

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.ts

6 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 lint
  • bun run format:check
  • bun run knip
  • bun run build.ts

@shouze
shouze marked this pull request as ready for review August 23, 2026 20:29
@github-actions

Copy link
Copy Markdown

Coverage after merging feat/team-hierarchy-consolidate into feat/team-hierarchy-model will be

96.34%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.74%100%100%94.07%340–344, 405, 422, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.68%100%98.33%100%
   output.ts99.29%100%95.65%99.61%80
   regex.ts99.39%100%100%99.34%329
   render.ts89.82%100%88.24%89.89%172, 196–201, 203–205, 207–208, 229, 417–418, 442–444, 510–514, 526–527, 532–539, 541–549, 551–552
   scroll-cooldown.ts100%100%100%100%
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   layout-constants.ts100%100%100%100%
   mouse-hit.ts100%100%100%100%
   mouse.ts100%100%100%100%
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%
   terminal.ts100%100%100%100%

Copilot AI lite review requested due to automatic review settings August 23, 2026 20:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  • only is added to the suffix before its own child count is inspected. For a tree A -> B -> {C, D}, this produces A (including B) with C/D directly underneath, so the fork node B disappears instead of remaining a separate heading as required. Stop before adding only when 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.

Comment thread src/group.ts
@shouze
shouze force-pushed the feat/team-hierarchy-consolidate branch from a99a066 to 9f08d84 Compare August 23, 2026 20:42
@github-actions

Copy link
Copy Markdown

Coverage after merging feat/team-hierarchy-consolidate into feat/team-hierarchy-model will be

96.35%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.74%100%100%94.07%340–344, 405, 422, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.69%100%98.36%100%
   output.ts99.29%100%95.65%99.61%80
   regex.ts99.39%100%100%99.34%329
   render.ts89.82%100%88.24%89.89%172, 196–201, 203–205, 207–208, 229, 417–418, 442–444, 510–514, 526–527, 532–539, 541–549, 551–552
   scroll-cooldown.ts100%100%100%100%
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   layout-constants.ts100%100%100%100%
   mouse-hit.ts100%100%100%100%
   mouse.ts100%100%100%100%
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%
   terminal.ts100%100%100%100%

1 similar comment
@github-actions

Copy link
Copy Markdown

Coverage after merging feat/team-hierarchy-consolidate into feat/team-hierarchy-model will be

96.35%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.74%100%100%94.07%340–344, 405, 422, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.69%100%98.36%100%
   output.ts99.29%100%95.65%99.61%80
   regex.ts99.39%100%100%99.34%329
   render.ts89.82%100%88.24%89.89%172, 196–201, 203–205, 207–208, 229, 417–418, 442–444, 510–514, 526–527, 532–539, 541–549, 551–552
   scroll-cooldown.ts100%100%100%100%
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   layout-constants.ts100%100%100%100%
   mouse-hit.ts100%100%100%100%
   mouse.ts100%100%100%100%
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%
   terminal.ts100%100%100%100%

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.level defines 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), so level was not actually recomputed. Start every top-level result at 0 instead.
  return sections.map((s) => assignLevels(consolidateNode(s), s.level ?? 0));

@shouze
shouze force-pushed the feat/team-hierarchy-consolidate branch from 9f08d84 to c73d6c5 Compare August 24, 2026 00:10
@github-actions

Copy link
Copy Markdown

Coverage after merging feat/team-hierarchy-consolidate into feat/team-hierarchy-model will be

96.32%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.74%100%100%94.07%340–344, 405, 422, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.69%100%98.36%100%
   output.ts99.29%100%95.65%99.61%80
   regex.ts99.39%100%100%99.34%329
   render.ts89.70%100%88.24%89.76%176, 200–205, 207–209, 211–212, 233, 421–422, 446–448, 516–520, 532–533, 538–545, 547–555, 557–560
   scroll-cooldown.ts100%100%100%100%
   style.ts100%100%100%100%
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   layout-constants.ts100%100%100%100%
   mouse-hit.ts100%100%100%100%
   mouse.ts100%100%100%100%
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%
   terminal.ts100%100%100%100%

shouze added 2 commits August 24, 2026 02:10
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.
@shouze
shouze force-pushed the feat/team-hierarchy-consolidate branch from c73d6c5 to ad819ca Compare August 24, 2026 00:14
@github-actions

Copy link
Copy Markdown

Coverage after merging feat/team-hierarchy-consolidate into feat/team-hierarchy-model will be

96.32%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.74%100%100%94.07%340–344, 405, 422, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.69%100%98.36%100%
   output.ts99.29%100%95.65%99.61%80
   regex.ts99.39%100%100%99.34%329
   render.ts89.70%100%88.24%89.76%176, 200–205, 207–209, 211–212, 233, 421–422, 446–448, 516–520, 532–533, 538–545, 547–555, 557–560
   scroll-cooldown.ts100%100%100%100%
   style.ts100%100%100%100%
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   layout-constants.ts100%100%100%100%
   mouse-hit.ts100%100%100%100%
   mouse.ts100%100%100%100%
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%
   terminal.ts100%100%100%100%

1 similar comment
@github-actions

Copy link
Copy Markdown

Coverage after merging feat/team-hierarchy-consolidate into feat/team-hierarchy-model will be

96.32%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.74%100%100%94.07%340–344, 405, 422, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.69%100%98.36%100%
   output.ts99.29%100%95.65%99.61%80
   regex.ts99.39%100%100%99.34%329
   render.ts89.70%100%88.24%89.76%176, 200–205, 207–209, 211–212, 233, 421–422, 446–448, 516–520, 532–533, 538–545, 547–555, 557–560
   scroll-cooldown.ts100%100%100%100%
   style.ts100%100%100%100%
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   layout-constants.ts100%100%100%100%
   mouse-hit.ts100%100%100%100%
   mouse.ts100%100%100%100%
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%
   terminal.ts100%100%100%100%

@shouze shouze self-assigned this Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[2/7] Advanced consolidated rendering

2 participants