feat(tui): responsive table layout for all tabs
CI / test (pull_request) Successful in 2m45s
CI / lint (pull_request) Successful in 1m12s
CI / vulncheck (pull_request) Successful in 1m6s

Extract shared computeTableLayout() into table_helpers.go — takes column
definitions with short/full headers, min/max widths, and a flex column
that absorbs surplus space. All tabs now use it:

- Alerts: CONFIG column is flex, NAME/TYPE/SENT expand with width
- Maint: TITLE column is flex, TYPE/MONITORS/STATUS/dates expand
- Nodes: NAME column is flex, REGION/LAST SEEN/VERSION expand
- Users: PUBLIC KEY column is flex, USERNAME expands
- Sites: uses same colDef type (keeps special dual-flex for NAME+HISTORY)

Headers auto-switch short/full based on available width across all tabs.
This commit is contained in:
2026-05-28 15:20:12 -04:00
parent 217276ca18
commit d05bbd007b
6 changed files with 144 additions and 30 deletions
+9 -16
View File
@@ -341,23 +341,16 @@ type tableLayout struct {
}
func (m Model) computeLayout() tableLayout {
type colDef struct {
short string
full string
minWidth int
maxWidth int
}
cols := []colDef{
{"#", "#", 4, 4},
{"", "", 0, 0}, // NAME (dynamic)
{"TYPE", "TYPE", 8, 10},
{"STATUS", "STATUS", 8, 10},
{"LAT", "LATENCY", 7, 10},
{"UP%", "UPTIME", 8, 8},
{"", "", 0, 0}, // HISTORY (dynamic)
{"SSL", "SSL", 5, 5},
{"RT", "RETRIES", 5, 9},
{"#", "#", 4, 4, false},
{"", "", 0, 0, false}, // NAME (special)
{"TYPE", "TYPE", 8, 10, false},
{"STATUS", "STATUS", 8, 10, false},
{"LAT", "LATENCY", 7, 10, false},
{"UP%", "UPTIME", 8, 8, false},
{"", "", 0, 0, false}, // HISTORY (special)
{"SSL", "SSL", 5, 5, false},
{"RT", "RETRIES", 5, 9, false},
}
numCols := len(cols)