fix(tui): quick wins — version, columns, zebra, sparkline #60

Merged
lerko merged 1 commits from fix/tui-quick-wins into main 2026-06-04 19:18:28 +00:00
6 changed files with 17 additions and 11 deletions
+2 -2
View File
@@ -413,7 +413,7 @@ func runServe(args []string) {
sshSrv := startSSHServer(*port, s, eng, kc)
if isatty.IsTerminal(os.Stdout.Fd()) || isatty.IsCygwinTerminal(os.Stdout.Fd()) {
p := tea.NewProgram(tui.InitialModel(true, s, eng), tea.WithAltScreen(), tea.WithMouseCellMotion())
p := tea.NewProgram(tui.InitialModel(true, s, eng, version), tea.WithAltScreen(), tea.WithMouseCellMotion())
if _, err := p.Run(); err != nil {
fmt.Fprintf(os.Stderr, "error: %v\n", err)
}
@@ -449,7 +449,7 @@ func startSSHServer(port int, db store.Store, eng *monitor.Engine, kc *keyCache)
}),
wish.WithMiddleware(
bm.Middleware(func(s ssh.Session) (tea.Model, []tea.ProgramOption) {
return tui.InitialModel(false, db, eng), []tea.ProgramOption{tea.WithAltScreen(), tea.WithMouseCellMotion()}
return tui.InitialModel(false, db, eng, version), []tea.ProgramOption{tea.WithAltScreen(), tea.WithMouseCellMotion()}
}),
),
)
+2 -2
View File
@@ -131,9 +131,9 @@ func (m Model) groupSparkline(groupID int, width int) string {
}
for _, up := range aggregated {
if up {
sb.WriteString(specialStyle.Render(""))
sb.WriteString(specialStyle.Render(""))
} else {
sb.WriteString(dangerStyle.Render(""))
sb.WriteString(dangerStyle.Render(""))
}
}
return sb.String()
+4 -4
View File
@@ -78,13 +78,13 @@ func (m Model) computeLayout() tableLayout {
if nameW < 13 {
nameW = 13
}
if nameW > 40 {
nameW = 40
if nameW > 35 {
nameW = 35
}
sparkW := avail - nameW
if sparkW < 10 {
sparkW = 10
if sparkW < 15 {
sparkW = 15
}
widths[1] = nameW
+3
View File
@@ -66,6 +66,9 @@ func (m Model) renderTable(headers []string, items int, buildRows func(start, en
if styleOverride != nil {
if s := styleOverride(row, col); s != nil {
style := *s
if row%2 == 1 {
style = style.Background(tableZebraStyle.GetBackground())
}
if isSelected {
style = tableSelectedStyle.Foreground(s.GetForeground())
}
+3 -1
View File
@@ -138,9 +138,10 @@ type Model struct {
// demoMode renders a stable status dot instead of the animated pulse so
// screenshots/recordings don't capture the spinner mid-frame. Set via UPTOP_DEMO=1.
demoMode bool
version string
}
func InitialModel(isAdmin bool, s store.Store, eng *monitor.Engine) Model {
func InitialModel(isAdmin bool, s store.Store, eng *monitor.Engine, version string) Model {
vpLogs := viewport.New(100, 20)
vpLogs.SetContent("Waiting for logs...")
z := zone.New()
@@ -172,6 +173,7 @@ func InitialModel(isAdmin bool, s store.Store, eng *monitor.Engine) Model {
theme: theme,
themeIndex: themeIdx,
demoMode: os.Getenv("UPTOP_DEMO") == "1",
version: version,
}
}
+3 -2
View File
@@ -275,9 +275,10 @@ func (m Model) renderFooter(stats dashboardStats) string {
keys = "[T]Theme [Tab]Switch [q]Quit"
}
footer := "\n" + statusLine + " " + subtleStyle.Render(keys)
ver := subtleStyle.Render("v" + m.version)
footer := "\n" + statusLine + " " + subtleStyle.Render(keys) + " " + ver
if m.filterText != "" && m.currentTab == 0 {
footer = "\n" + subtleStyle.Render(fmt.Sprintf("filter: %s", m.filterText)) + " " + statusLine + " " + subtleStyle.Render(keys)
footer = "\n" + subtleStyle.Render(fmt.Sprintf("filter: %s", m.filterText)) + " " + statusLine + " " + subtleStyle.Render(keys) + " " + ver
}
return footer
}