feat(tui): consolidate tabs 6→3, add log sidebar #145

Merged
lerko merged 5 commits from feat/tab-consolidation into main 2026-06-20 22:32:33 +00:00
3 changed files with 66 additions and 21 deletions
Showing only changes of commit 8323d27e7d - Show all commits
-20
View File
@@ -107,23 +107,3 @@ func (m *Model) refreshLogContent() {
m.logShown = shown m.logShown = shown
m.logViewport.SetContent(strings.Join(rendered, "\n")) m.logViewport.SetContent(strings.Join(rendered, "\n"))
} }
func (m Model) viewLogsTab() string {
if m.logTotal == 0 {
return m.emptyState("No log entries yet.", "Logs appear as monitors run checks")
}
filterLabel := "All"
if m.logFilterImportant {
filterLabel = "Important"
}
header := m.st.subtleStyle.Render(fmt.Sprintf(
" %d entries Filter: %s", m.logShown, filterLabel))
if m.logFilterImportant && m.logShown < m.logTotal {
header += m.st.subtleStyle.Render(fmt.Sprintf(" (%d hidden)", m.logTotal-m.logShown))
}
return "\n" + header + "\n\n" + m.logViewport.View()
}
+64
View File
@@ -0,0 +1,64 @@
package tui
import (
"fmt"
"strings"
)
func (m Model) renderCompactLogLine(line string, maxW int) string {
sev := classifyLog(line)
var tag string
switch sev {
case severityDown:
tag = m.st.dangerStyle.Render("▼")
case severityUp:
tag = m.st.specialStyle.Render("▲")
case severityWarn:
tag = m.st.warnStyle.Render("◆")
case severitySystem:
tag = m.st.titleStyle.Render("●")
default:
tag = m.st.subtleStyle.Render("·")
}
ts := ""
msg := line
if len(line) > 10 && line[0] == '[' {
if idx := strings.Index(line, "]"); idx > 0 && idx < 12 {
ts = line[1:idx]
msg = strings.TrimSpace(line[idx+1:])
}
}
msgW := maxW - 10
if msgW < 10 {
msgW = 10
}
msg = limitStr(msg, msgW)
if ts != "" {
return fmt.Sprintf(" %s %s %s", m.st.subtleStyle.Render(ts), tag, msg)
}
return fmt.Sprintf(" %s %s", tag, msg)
}
func (m Model) viewLogsSidebar(width int) string {
logs := m.engine.GetLogs()
if len(logs) == 0 {
return m.st.subtleStyle.Render(" No logs yet")
}
var lines []string
for _, line := range logs {
if strings.TrimSpace(line) == "" {
continue
}
if m.logFilterImportant && !isImportantLog(classifyLog(line)) {
continue
}
lines = append(lines, m.renderCompactLogLine(line, width))
}
return strings.Join(lines, "\n")
}
+2 -1
View File
@@ -158,7 +158,8 @@ func (m Model) viewDashboard() string {
leftW := availW * 70 / 100 leftW := availW * 70 / 100
rightW := availW - leftW rightW := availW - leftW
left := lipgloss.NewStyle().Width(leftW).Render(monitors) left := lipgloss.NewStyle().Width(leftW).Render(monitors)
right := lipgloss.NewStyle().Width(rightW).Render(m.viewLogsTab()) sidebar := m.viewLogsSidebar(rightW)
right := lipgloss.NewStyle().Width(rightW).Render(sidebar)
content = lipgloss.JoinHorizontal(lipgloss.Top, left, right) content = lipgloss.JoinHorizontal(lipgloss.Top, left, right)
} else { } else {
content = monitors content = monitors