Skip to content

feat(table): hide empty columns in display renderers#83

Merged
moshloop merged 1 commit intomainfrom
feat/hide-empty-table-columns
Mar 1, 2026
Merged

feat(table): hide empty columns in display renderers#83
moshloop merged 1 commit intomainfrom
feat/hide-empty-table-columns

Conversation

@moshloop
Copy link
Copy Markdown
Member

@moshloop moshloop commented Mar 1, 2026

Add WithoutEmptyColumns() to filter out columns where every row is empty. Applied to ANSI, HTML, StaticHTML, and CompactHTML renderers. CSV, Excel, JSON, and YAML output preserves all columns.

Description

Brief description of the changes in this PR.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring

Testing

  • Tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested the CLI with example data

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

Breaking Changes

If this is a breaking change, please describe the impact and migration path for existing users:

Additional Notes

Add any additional notes, screenshots, or context about the changes here.

Summary by CodeRabbit

  • New Features

    • Tables now automatically remove empty columns (where all values are empty across all rows) when rendering, resulting in cleaner and more compact output. This applies to all table rendering formats including HTML variants and Lipgloss output.
  • Tests

    • Added comprehensive test coverage for the empty column filtering feature, ensuring columns are correctly removed or retained based on their content.

Add WithoutEmptyColumns() to filter out columns where every row is
empty. Applied to ANSI, HTML, StaticHTML, and CompactHTML renderers.
CSV, Excel, JSON, and YAML output preserves all columns.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 1, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 15b1c8a and ee30607.

📒 Files selected for processing (2)
  • api/table.go
  • api/table_test.go

Walkthrough

Added a new TextTable.WithoutEmptyColumns() method that removes columns where all rows have empty values. Updated rendering methods to apply this filtering before generating HTML or text output, resulting in cleaner table displays without unnecessary empty columns.

Changes

Cohort / File(s) Summary
New WithoutEmptyColumns Method
api/table.go
Added WithoutEmptyColumns() method that returns a table copy with fully-empty columns removed. Updated four rendering paths (CompactHTML, StaticHTML, html/PrintableHTML, renderLipgloss) to call this method before rendering.
Test Coverage for WithoutEmptyColumns
api/table_test.go
New test suite verifying column filtering behavior: removes columns when all rows are empty, retains columns with at least one non-empty value, treats whitespace-only values as empty, and preserves original behavior on empty tables.
✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/hide-empty-table-columns

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.

@moshloop moshloop enabled auto-merge (rebase) March 1, 2026 14:16
@moshloop moshloop merged commit 1049de5 into main Mar 1, 2026
12 of 13 checks passed
@moshloop moshloop deleted the feat/hide-empty-table-columns branch March 1, 2026 14:18
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.

1 participant