V4.6 Phase 5 follow-up: consolidate remaining hand-rolled tables

Completes the table consolidation deferred within Phase 5. Section 4 of the
review lists table construction as a duplication pattern; three call sites had
been left bypassing the canonical builder.

- table/common.py: build_table gains a row_key parameter so callers with a
  non-"id" primary key can use it.
- linked_people.py: replaces its hand-rolled ui.table with build_table
  (row_key="person_id", selection="multiple", rows_per_page=0, no search).
- print_preview_page.py: _render_metadata_table and _render_job_table now share
  a local _render_print_table helper. Print tables deliberately do not use
  build_table - they must never paginate or render a search box, and they carry
  print-only styling. The helper docstring records that rationale.
- tests/test_ui_boundaries.py: new AST guard asserting ui.table() is called from
  exactly two modules - components/table/common.py and pages/print_preview_page.py.

Also closes the intermittent tests/ui/test_jobs_page.py failure observed once
after Phase 5 as environmental. Unreproduced across ~54 sequential full-suite
runs (including a 25-run soak) and 5 concurrent-process runs. No code change.

Verification: ruff check src tests clean; 275 passed, 4 skipped.

Co-authored-by: Copilot App <[email protected]>
This commit is contained in:
zoltan57
2026-08-17 18:37:45 -05:00
co-authored by Copilot App
parent 6a3ee26733
commit 0b63b53f53
4 changed files with 75 additions and 16 deletions
+30
View File
@@ -83,3 +83,33 @@ def test_no_component_resolves_request_or_application_state():
if found:
violations[str(path.relative_to(COMPONENTS_DIR))] = found
assert violations == {}
# `build_table` owns the interactive table styling; `print_preview_page` owns the
# print-only table, which must never paginate or expose a search box.
TABLE_OWNERS = frozenset({"components/table/common.py", "pages/print_preview_page.py"})
def _calls_ui_table(tree: ast.Module) -> bool:
for node in ast.walk(tree):
if not isinstance(node, ast.Call):
continue
func = node.func
if (
isinstance(func, ast.Attribute)
and func.attr == "table"
and isinstance(func.value, ast.Name)
and func.value.id == "ui"
):
return True
return False
def test_only_the_designated_owners_construct_a_raw_table():
"""Review section 4: table styling lives in one place, not in every page."""
offenders = sorted(
str(path.relative_to(UI_DIR)).replace("\\", "/")
for path in UI_DIR.rglob("*.py")
if _calls_ui_table(ast.parse(path.read_text(encoding="utf-8")))
)
assert set(offenders) == TABLE_OWNERS