Skip to content

Conversation

Copy link
Contributor

CopilotAI commented Jan 19, 2026

Implementation Plan for Incremental Table Row Display

  • Analyze codebase structure and understand Table class implementation
  • Identify existing test infrastructure (PHPUnit tests)
  • Run existing tests to establish baseline
  • Add resetRows() method to clear only rows (not headers/footers)
  • Add displayRow() method to display single row without headers/borders
  • Add internal state tracking to manage whether table has been displayed
  • Create PHPUnit tests for new functionality
  • Validate changes with existing and new tests
  • Run full test suite (lint, phpcs, phpstan, phpunit)
  • Fix border cache issue in Ascii renderer
  • Update example to demonstrate proper usage
  • Remove duplicate bottom border for cleaner incremental display
  • Remove example file per review feedback
  • Address code review feedback (unused property, proper cleanup, assignment in args)
Original prompt

This section details on the original issue you should resolve

<issue_title>Add ability to add row in a loop to existing already-rendered table</issue_title>
<issue_description>## Feature Request

Describe your use case and the problem you are facing

I want to "register" an empty table, and then later in a loop using table reference ($table) add rows.

Right now if I register a table, call the display() method to render it, and then later call the

$table->addRow(); $table->display();

it will render the whole table again - with headers and previously added rows.

Describe the solution you'd like

I think separating resetTable() method into individual methods for header, rows, footer is needed.

So I should be able to either do this:

$table->setHeaders(); $table->display(); foreach ($rowsas$row){$table->resetRows(); $table->addRow($row); $table->display()}

or something like this:

$table->setHeaders(); $table->display(); foreach ($rowsas$row){$table->displayRow($row)}

Also, because header is a mandatory table data, displaying a new row should not render the top border but render the bottom row.</issue_description>

Comments on the Issue (you are @copilot in this section)

@danielbachhuber Seems fine to me, as long as there aren't any backcompat breaks. Feel free to submit a PR if you'd like.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@codecov

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

- Reset border cache when widths change in Ascii renderer - Update displayRow() to properly handle width updates - Improve example to better demonstrate incremental row display - All tests pass (lint, phpcs, phpstan, phpunit) Co-authored-by: swissspidy <[email protected]>

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

- Fix duplicate border issue when displaying table with headers but no rows - Update test to reflect correct behavior (single border after headers) - Improves visual consistency for incremental row display - All tests pass Co-authored-by: swissspidy <[email protected]>

This comment was marked as resolved.

@swissspidyswissspidy changed the title [WIP] Add ability to add row in a loop to existing tableAdd ability to add row in a loop to existing tableJan 19, 2026
Copy link
Contributor

CopilotAI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds the ability to incrementally display table rows in a loop, addressing the feature request to render rows without re-rendering the entire table including headers and previously added rows.

Changes:

  • Added resetRows() method to clear only row data while preserving headers and footers
  • Added displayRow() method to display individual rows without headers or top borders
  • Fixed border rendering issues in the Ascii renderer to prevent duplicate borders

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
FileDescription
lib/cli/Table.phpImplements core functionality with resetRows() and displayRow() methods, plus state tracking
lib/cli/table/Ascii.phpFixes border cache invalidation when column widths change
tests/Test_Table.phpAdds comprehensive test coverage for new methods
tests/Test_Table_Ascii.phpRemoves expected duplicate bottom border from test output
examples/incremental-table.phpDemonstrates usage patterns for incremental table row display

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

As requested in review feedback. Co-authored-by: swissspidy <[email protected]>
- Remove unused $_displayed property - Fix assignment in function argument (use false directly) - Add proper cleanup with try-finally blocks in tests - Ensure temp files are cleaned up even if assertions fail Co-authored-by: swissspidy <[email protected]>
@swissspidyswissspidy marked this pull request as ready for review January 19, 2026 17:15
@swissspidyswissspidy requested a review from a team as a code ownerJanuary 19, 2026 17:15
@swissspidyswissspidy added this to the 0.12.6 milestone Jan 20, 2026
@swissspidyswissspidy merged commit c95fbcf into mainJan 20, 2026
22 checks passed
@swissspidyswissspidy deleted the copilot/add-row-in-loop-to-table branch January 20, 2026 20:16
@swissspidyswissspidy modified the milestones: 0.12.6, 0.12.7Jan 20, 2026
@swissspidyswissspidy linked an issue Jan 20, 2026 that may be closed by this pull request
2 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability to add row in a loop to existing already-rendered table Table::getDisplayLines() can output excessive lines

2 participants

@swissspidy