1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 20:15:07 +00:00

fix(status): resolve layout issue when stretching terminal window (#467)

When the terminal is stretched wide, the header info line may wrap to
multiple lines but the mole position was calculated independently based
on terminal width, causing vertical misalignment.

Separate header and mole rendering so mole always appears on dedicated
lines below the header regardless of terminal width.
This commit is contained in:
tw93
2026-02-16 19:07:42 +08:00
parent abd9791cd7
commit 8e8059b0aa
2 changed files with 21 additions and 16 deletions

View File

@@ -130,7 +130,7 @@ type cardData struct {
lines []string
}
func renderHeader(m MetricsSnapshot, errMsg string, animFrame int, termWidth int, catHidden bool) string {
func renderHeader(m MetricsSnapshot, errMsg string, animFrame int, termWidth int, catHidden bool) (string, string) {
title := titleStyle.Render("Status")
scoreStyle := getScoreStyle(m.HealthScore)
@@ -171,7 +171,7 @@ func renderHeader(m MetricsSnapshot, errMsg string, animFrame int, termWidth int
headerLine := title + " " + scoreText + " " + strings.Join(infoParts, " · ")
// Show cat unless hidden
// Show cat unless hidden - render mole centered below header
var mole string
if !catHidden {
mole = getMoleFrame(animFrame, termWidth)
@@ -179,14 +179,14 @@ func renderHeader(m MetricsSnapshot, errMsg string, animFrame int, termWidth int
if errMsg != "" {
if mole == "" {
return lipgloss.JoinVertical(lipgloss.Left, headerLine, "", dangerStyle.Render("ERROR: "+errMsg), "")
return lipgloss.JoinVertical(lipgloss.Left, headerLine, "", dangerStyle.Render("ERROR: "+errMsg)), ""
}
return lipgloss.JoinVertical(lipgloss.Left, headerLine, "", mole, dangerStyle.Render("ERROR: "+errMsg), "")
return lipgloss.JoinVertical(lipgloss.Left, headerLine, "", mole, dangerStyle.Render("ERROR: "+errMsg)), mole
}
if mole == "" {
return headerLine
return headerLine, ""
}
return headerLine + "\n" + mole
return headerLine, mole
}
func getScoreStyle(score int) lipgloss.Style {