refactor(tui): two-tier responsive table layout (compact/wide at 120 cols)
CI / test (pull_request) Successful in 2m54s
CI / lint (pull_request) Failing after 1m12s
CI / vulncheck (pull_request) Successful in 56s

Replace continuous surplus distribution with two fixed layouts per table.
Breakpoint at 120 columns — matches how btop/k9s do it.

Compact (<120): short headers (LAT, UP%, RT, ST, MON, SENT, VER),
  tight fixed widths, no surplus guessing.

Wide (≥120): full headers (LATENCY, UPTIME, RETRIES, STATUS, MONITORS,
  LAST SENT, VERSION), generous widths.

Sites tab keeps content-aware NAME sizing + sparkline flex.
All other tabs (Alerts, Maint, Nodes, Users) use simple fixed tiers.

Removed old computeTableLayout/colDef/tierCol/pickTier — no longer needed.
This commit is contained in:
2026-05-28 15:50:23 -04:00
parent a84f4894f8
commit 5401266e83
6 changed files with 64 additions and 179 deletions
+11 -17
View File
@@ -148,23 +148,17 @@ func (m Model) viewAlertsTab() string {
return "\n No alert channels configured. Press [n] to add one."
}
maxName := 0
for _, a := range m.alerts {
if n := len([]rune(a.Name)); n > maxName {
maxName = n
}
var headers []string
var widths []int
if m.isWide() {
headers = []string{"#", "", "NAME", "TYPE", "CONFIG", "LAST SENT"}
widths = []int{4, 3, 18, 12, 40, 12}
} else {
headers = []string{"#", "", "NAME", "TYPE", "CONFIG", "SENT"}
widths = []int{4, 3, 14, 10, 24, 8}
}
cols := []colDef{
{"#", "#", 4, 4, false},
{"", "", 3, 3, false},
{"NAME", "NAME", 10, 20, false},
{"TYPE", "TYPE", 10, 12, false},
{"CONFIG", "CONFIG", 15, 40, true},
{"SENT", "LAST SENT", 8, 12, false},
}
headers, widths := m.computeTableLayout(cols, 0)
nameW := widths[2]
cfgW := widths[4]
return m.renderTable(
headers,
@@ -179,10 +173,10 @@ func (m Model) viewAlertsTab() string {
fmtAlertHealth(h),
m.zones.Mark(fmt.Sprintf("alert-%d", i), limitStr(a.Name, nameW-2)),
fmtAlertType(a.Type),
fmtAlertConfig(struct {
limitStr(fmtAlertConfig(struct {
Type string
Settings map[string]string
}{a.Type, a.Settings}),
}{a.Type, a.Settings}), cfgW-2),
fmtAlertLastSent(h),
})
}