-
Notifications
You must be signed in to change notification settings - Fork 0
Description
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
- Refactor
_render_session_tableto accept an optionaltitle: strparameter (default"Sessions") so_render_historical_sectioncan pass"Sessions (Shutdown Data)"without duplication. - Replace the inline table-build blocks in
_render_historical_sectionwith calls to_render_model_tableand_render_session_table, passing the already-filteredhistoricallist. - 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 bothrender_summaryandrender_full_summary— i.e., the same code path is exercised.
Generated by Code Health Analysis · ◷