Skip to content

[aw][code health] report.py: _render_historical_section duplicates _render_model_table and session table logic #22

@github-actions

Description

@github-actions

Root Cause

_render_historical_section (report.py ~lines 762–822) contains two copy-pasted Rich table builds that are nearly identical to _render_model_table (lines 614–639) and the inner loop of _render_session_table (lines 642–692). The columns, column styles, sort logic, and cell formatting are all duplicated.

This means any future change to the table layout (add a column, fix a format string, adjust styles) must be made in two places with no compiler safety net — a divergence is inevitable.

Specific duplication

Private helper Duplicated in
_render_model_table(console, sessions) inner block of _render_historical_section (lines ~764–782)
session-table block of _render_session_table(console, sessions) inner block of _render_historical_section (lines ~784–822)

The duplicated session table differs only in the title string ("Sessions (Shutdown Data)" vs "Sessions") and that it filters to historical sessions. Both the sorting lambda and every column definition are identical.

Fix spec

  1. Refactor _render_session_table to accept an optional title: str parameter (default "Sessions") so _render_historical_section can pass "Sessions (Shutdown Data)" without duplication.
  2. Replace the inline table-build blocks in _render_historical_section with calls to _render_model_table and _render_session_table, passing the already-filtered historical list.
  3. Verify that render_full_summary (the public entry point for interactive mode) still produces output that matches its current behaviour — the rendered content must be identical.

Testing requirement

Add or update unit tests for render_full_summary that assert:

  • The historical section output contains "Sessions (Shutdown Data)" as the table title.
  • The per-model breakdown table is present.
  • Changing a column in _render_model_table (e.g. column header rename) is reflected in both render_summary and render_full_summary — i.e., the same code path is exercised.

Generated by Code Health Analysis ·

Metadata

Metadata

Assignees

No one assigned

    Labels

    awCreated by agentic workflowcode-healthCode cleanup and maintenance

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions