From 5c4062998740db75edce224bc3d8c890a6aef884 Mon Sep 17 00:00:00 2001 From: Tyler Koenig Date: Sat, 20 Jun 2026 18:17:08 -0400 Subject: [PATCH] fix(tui): clamp log sidebar width, strip redundant prefixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Log lines now hard-clamped to panel width via lipgloss MaxWidth. Stripped "Monitor " and "Push " prefixes from sidebar messages — redundant in a monitoring app, saves 8 chars per line. Improved prefix width calculation to prevent line wrapping at narrow widths. --- internal/tui/tab_logs_sidebar.go | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/internal/tui/tab_logs_sidebar.go b/internal/tui/tab_logs_sidebar.go index 96cdc45..7dcf140 100644 --- a/internal/tui/tab_logs_sidebar.go +++ b/internal/tui/tab_logs_sidebar.go @@ -1,8 +1,9 @@ package tui import ( - "fmt" "strings" + + "github.com/charmbracelet/lipgloss" ) func (m Model) renderCompactLogLine(line string, maxW int) string { @@ -31,16 +32,24 @@ func (m Model) renderCompactLogLine(line string, maxW int) string { } } - msgW := maxW - 10 - if msgW < 10 { - msgW = 10 + msg = strings.TrimPrefix(msg, "Monitor ") + msg = strings.TrimPrefix(msg, "Push ") + + // prefix: " HH:MM ● " = 9 visible chars, or " ● " = 3 without timestamp + prefixW := 3 + if ts != "" { + prefixW = len(ts) + 4 + } + msgW := maxW - prefixW + if msgW < 5 { + msgW = 5 } msg = limitStr(msg, msgW) if ts != "" { - return fmt.Sprintf(" %s %s %s", m.st.subtleStyle.Render(ts), tag, msg) + return " " + m.st.subtleStyle.Render(ts) + " " + tag + " " + msg } - return fmt.Sprintf(" %s %s", tag, msg) + return " " + tag + " " + msg } func (m Model) viewLogsSidebar(width int) string { @@ -49,6 +58,8 @@ func (m Model) viewLogsSidebar(width int) string { return m.st.subtleStyle.Render(" No logs yet") } + sidebarStyle := lipgloss.NewStyle().Width(width).MaxWidth(width) + var lines []string for _, line := range logs { if strings.TrimSpace(line) == "" { @@ -60,5 +71,5 @@ func (m Model) viewLogsSidebar(width int) string { lines = append(lines, m.renderCompactLogLine(line, width)) } - return strings.Join(lines, "\n") + return sidebarStyle.Render(strings.Join(lines, "\n")) }