From 8e8059b0aac11b441763c37a981072034fbc2708 Mon Sep 17 00:00:00 2001 From: tw93 Date: Mon, 16 Feb 2026 19:07:42 +0800 Subject: [PATCH] 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. --- cmd/status/main.go | 25 +++++++++++++++---------- cmd/status/view.go | 12 ++++++------ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/cmd/status/main.go b/cmd/status/main.go index e1e2d77..3a5f349 100644 --- a/cmd/status/main.go +++ b/cmd/status/main.go @@ -139,7 +139,7 @@ func (m model) View() string { return "Loading..." } - header := renderHeader(m.metrics, m.errMessage, m.animFrame, m.width, m.catHidden) + header, mole := renderHeader(m.metrics, m.errMessage, m.animFrame, m.width, m.catHidden) cardWidth := 0 if m.width > 80 { cardWidth = max(24, m.width/2-4) @@ -154,20 +154,25 @@ func (m model) View() string { } rendered = append(rendered, renderCard(c, cardWidth, 0)) } - result := header + "\n" + lipgloss.JoinVertical(lipgloss.Left, rendered...) - // Add extra newline if cat is hidden for better spacing - if m.catHidden { - result = header + "\n\n" + lipgloss.JoinVertical(lipgloss.Left, rendered...) + // Combine header, mole, and cards with consistent spacing + var content []string + content = append(content, header) + if mole != "" { + content = append(content, mole) } - return result + content = append(content, lipgloss.JoinVertical(lipgloss.Left, rendered...)) + return lipgloss.JoinVertical(lipgloss.Left, content...) } twoCol := renderTwoColumns(cards, m.width) - // Add extra newline if cat is hidden for better spacing - if m.catHidden { - return header + "\n\n" + twoCol + // Combine header, mole, and cards with consistent spacing + var content []string + content = append(content, header) + if mole != "" { + content = append(content, mole) } - return header + "\n" + twoCol + content = append(content, twoCol) + return lipgloss.JoinVertical(lipgloss.Left, content...) } func (m model) collectCmd() tea.Cmd { diff --git a/cmd/status/view.go b/cmd/status/view.go index f64df1d..018aa8b 100644 --- a/cmd/status/view.go +++ b/cmd/status/view.go @@ -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 {