Skip to content

Conversation

stevenwjy
Copy link

@stevenwjy stevenwjy commented Sep 15, 2025

Fixes #6093

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue with grouped tables where leaf rows were not correctly identified, leading to incorrect or missing aggregated values.
    • Ensures summary rows (totals, averages, custom aggregations) display accurate data when groups are expanded or collapsed.
    • Improves stability when working with deeply nested groups, preventing occasional errors and inconsistent displays.
    • Enhances reliability of downstream features that depend on leaf rows in grouped views, resulting in more predictable and correct table behavior.

Copy link

coderabbitai bot commented Sep 15, 2025

Walkthrough

Updated getGroupedRowModel to compute leafRows by flattening groupedRows when any row has subRows, including at depth 0; otherwise, leafRows remains groupedRows. No public API or type signatures changed.

Changes

Cohort / File(s) Summary of Changes
Leaf row flattening logic in grouping
packages/table-core/src/utils/getGroupedRowModel.ts
Adjusted leafRows computation to use flattenBy on groupedRows when any grouped row contains subRows; otherwise, use groupedRows directly. Ensures correct leaf extraction at depth 0. No exported/public signatures changed.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Caller as Caller
  participant Table as Table Core
  participant GRM as getGroupedRowModel
  participant FB as flattenBy

  Caller->>Table: build grouped row model
  Table->>GRM: compute grouped rows
  Note over GRM: Determine leafRows
  alt Any grouped row has subRows
    GRM->>FB: flattenBy(groupedRows, r => r.subRows)
    FB-->>GRM: leafRows (flattened)
  else No subRows present
    GRM-->>GRM: leafRows = groupedRows
  end
  GRM-->>Table: grouped rows with leafRows
  Table-->>Caller: result
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I hopped through rows, both tall and low,
Found leaves at depth where none would show.
A gentle flatten—now they gleam,
SubRows stitched into a stream.
With tidy paws and subtle cheer,
The grouping’s fixed—all leaves appear! 🌿🐇

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "Fix calculation of leafRows in getGroupedRowModel" is concise, directly names the affected function, and clearly communicates the primary intent to correct the leafRows calculation. It avoids noise and is specific enough for a reviewer scanning history to understand the main change. The title aligns with the changes summarized in the PR.
Linked Issues Check ✅ Passed The change in packages/table-core/src/utils/getGroupedRowModel.ts adjusts leafRows to be the flattened collection when groupedRows contain subRows, replacing the prior depth-based condition and directly addressing the bug described in issue [#6093]. This implementation meets the objective to compute leafRows correctly at depth === 0 and preserves public signatures per the PR summary. Based on the provided information, the PR satisfies the linked issue's coding requirement.
Out of Scope Changes Check ✅ Passed The raw_summary shows a single focused edit confined to getGroupedRowModel.ts that changes only how leafRows are computed, with no exported signature changes and no other files modified. There is no evidence in the provided summary of unrelated or out-of-scope modifications. Therefore the PR appears limited to in-scope changes related to the linked issue.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9c62cf2 and 3d535f2.

📒 Files selected for processing (1)
  • packages/table-core/src/utils/getGroupedRowModel.ts (1 hunks)

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.

getGroupedRowModel doesn't calculate leafRows correctly at depth 0
1 participant