Skip to content

refactor(cli): render database history through the shared status table renderer - #1206

Draft
aparajon wants to merge 1 commit into
mainfrom
armand/history-status-columns
Draft

refactor(cli): render database history through the shared status table renderer#1206
aparajon wants to merge 1 commit into
mainfrom
armand/history-status-columns

Conversation

@aparajon

Copy link
Copy Markdown
Collaborator

Follow-up to #1062 (review finding 6, deferred there): reuse the status list's column renderer for other CLI tables, starting with the database history table.

  • statusColumn and its helpers (retainPopulatedStatusColumns, statusColumnValue, width sizing) are now generic over the row type, and a new writeStatusTable owns the shared header+rows loop, taking a row-state accessor so colored columns work for any row type.
  • WriteDatabaseHistory defines its columns via databaseHistoryColumns() and renders through writeStatusTable, replacing its hand-rolled fmt.Printf layout and manual width tracking.
  • History output is byte-identical, pinned by exact-bytes tests with fixed clocks. The status list's colored state cell now closes its ANSI escape before the column separator rather than after (the two surfaces previously disagreed); this renders identically on any terminal and TEMPLATES.md regenerates with no diff.

🤖 Generated with Claude Code

…e renderer

Generalize statusColumn and its helpers over the row type so any CLI table
can define columns against its own row struct, add writeStatusTable as the
single header+rows renderer, and replace WriteDatabaseHistory's hand-rolled
column layout with history-specific statusColumn definitions. History output
is byte-identical, pinned by an exact-bytes test; the status list's colored
state cell now ends its color escape before the column separator, which
renders identically.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 29, 2026 16:48

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

Refactors the CLI table rendering in templates to reuse a single shared “status table” renderer across multiple outputs, starting with the database history view, while preserving the existing user-facing formatting (including ANSI coloring behavior).

Changes:

  • Generalizes statusColumn and related helpers over an arbitrary row type and introduces writeStatusTable to own the shared header/row rendering loop (including correct ANSI reset behavior around separators).
  • Refactors WriteStatusList and WriteDatabaseHistory to render via writeStatusTable, replacing bespoke printing/width tracking in history output.
  • Adds exact-bytes tests for the database history table output (including unknown-state and missing-timestamp cases) plus an empty-history test.

Reviewed changes

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

File Description
pkg/cmd/internal/templates/progress.go Introduces generic status-table primitives (statusColumn[T], writeStatusTable) and refactors status list + database history rendering to use them.
pkg/cmd/internal/templates/progress_states_test.go Adds exact-bytes tests pinning database history table output and the empty-history message.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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 participants