refactor(tui): remove full-page detail, SLA, and history views
CI / test (pull_request) Successful in 1m49s
CI / lint (pull_request) Successful in 1m16s
CI / vulncheck (pull_request) Successful in 56s

All monitor detail content now lives in the sidebar panel.
Delete the full-page viewDetailPanel, viewSLAPanel, viewHistoryPanel,
handleDetailKey, handleSLAKey, handleHistoryKey, openSLAView, and
related dead code (histogram, sparkline tooltip, detailViewport).

Remove stateDetail, stateSLA, stateHistory session states.
Update tests to use detailOpen/detailMode instead of removed states.
This commit was merged in pull request #163.
This commit is contained in:
2026-06-30 09:28:12 -04:00
parent 3e02833df4
commit dc79e2baaa
8 changed files with 41 additions and 848 deletions
-89
View File
@@ -1,89 +0,0 @@
package tui
import (
"fmt"
"strings"
"time"
"github.com/charmbracelet/lipgloss"
)
type latencyBucket struct {
label string
min int64
max int64
count int
}
func (m Model) latencyHistogram(latencies []time.Duration, statuses []bool, width int) string {
if len(latencies) == 0 || width < 30 {
return ""
}
buckets := []latencyBucket{
{"0-50ms", 0, 50, 0},
{"50-100ms", 50, 100, 0},
{"100-200ms", 100, 200, 0},
{"200-500ms", 200, 500, 0},
{"500ms+", 500, 999999, 0},
}
for i, l := range latencies {
if i < len(statuses) && !statuses[i] {
continue
}
ms := l.Milliseconds()
for j := range buckets {
if ms >= buckets[j].min && ms < buckets[j].max {
buckets[j].count++
break
}
}
}
maxCount := 0
for _, b := range buckets {
if b.count > maxCount {
maxCount = b.count
}
}
if maxCount == 0 {
return ""
}
labelW := 10
countW := len(fmt.Sprintf("%d", maxCount))
barW := width - labelW - countW - 4
if barW < 5 {
barW = 5
}
var sb strings.Builder
for _, b := range buckets {
fill := 0
if maxCount > 0 {
fill = b.count * barW / maxCount
}
var barColor lipgloss.Style
switch {
case b.min < 100:
barColor = m.st.specialStyle
case b.min < 500:
barColor = m.st.warnStyle
default:
barColor = m.st.dangerStyle
}
bar := barColor.Render(strings.Repeat("█", fill))
if fill < barW {
bar += m.st.subtleStyle.Render(strings.Repeat("░", barW-fill))
}
label := fmt.Sprintf("%*s", labelW, b.label)
count := fmt.Sprintf("%*d", countW, b.count)
sb.WriteString(" " + m.st.subtleStyle.Render(label) + " " + bar + " " + count + "\n")
}
return sb.String()
}