Skip to content

tui/pg: dedupe render helpers, share SQL, add coverage#1

Merged
brainexe merged 1 commit into
masterfrom
md_fable_cleanup
Jul 5, 2026
Merged

tui/pg: dedupe render helpers, share SQL, add coverage#1
brainexe merged 1 commit into
masterfrom
md_fable_cleanup

Conversation

@brainexe

@brainexe brainexe commented Jul 3, 2026

Copy link
Copy Markdown
Member

Quality pass over the whole codebase (no behaviour change).

Simplification / reuse:

  • Unify the info-overlay scaffolding into shared row.go helpers: padInfo (was 2 private copies + 14 inline loops), infoHeader (1 helper + 15 copies), and swatch for the "▇" legend glyph.
  • Collapse the three per-function bar-cell closures in row.go into one bytesToCells helper; add screen.resetCursor() for the paired cursor/offset resets.
  • Move the generic fmt* formatters from view_queries.go to format.go where their other consumers live.
  • Quote SQL identifiers via the existing qualifiedIdent() in bloat/reindex/vacuum instead of Go %q.
  • Build sqlBufferStats / sqlBufferStatByOID from one template (was ~50 duplicated lines); generated SQL is byte-identical to the old consts.

Tests: shmemCatOf ordering, appliedWindowPaths/snapTime snapshot anchors, the statements column registry (uniqueness, track_planning gating, toggles, cells∥columns parallelism), containsFold vs a strings.Contains oracle, lessBy*Extractor unknown-below-known, viewportRange boundaries, barWidth clamps, a barReserve smoke test, and QueryStat derived-metric edges.

Quality pass over the whole codebase (no behaviour change).

Simplification / reuse:
- Unify the info-overlay scaffolding into shared row.go helpers: padInfo
  (was 2 private copies + 14 inline loops), infoHeader (1 helper + 15
  copies), and swatch for the "▇" legend glyph.
- Collapse the three per-function bar-cell closures in row.go into one
  bytesToCells helper; add screen.resetCursor() for the paired
  cursor/offset resets.
- Move the generic fmt* formatters from view_queries.go to format.go
  where their other consumers live.
- Quote SQL identifiers via the existing qualifiedIdent() in
  bloat/reindex/vacuum instead of Go %q.
- Build sqlBufferStats / sqlBufferStatByOID from one template (was ~50
  duplicated lines); generated SQL is byte-identical to the old consts.

Tests: shmemCatOf ordering, appliedWindowPaths/snapTime snapshot anchors,
the statements column registry (uniqueness, track_planning gating, toggles,
cells∥columns parallelism), containsFold vs a strings.Contains oracle,
lessBy*Extractor unknown-below-known, viewportRange boundaries, barWidth
clamps, a barReserve smoke test, and QueryStat derived-metric edges.
@brainexe brainexe merged commit b5a94be into master Jul 5, 2026
2 checks passed
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.

1 participant