From e12f42fe16bd1cf9825d5208f592286b6cb64679 Mon Sep 17 00:00:00 2001 From: Tyler Koenig Date: Sat, 20 Jun 2026 18:14:01 -0400 Subject: [PATCH] fix(tui): use panel width for table layout in split-pane mode Table columns were computed from terminal width, causing row wrapping when the monitors panel only gets 70% of the space. Introduced contentWidth field set per-tab in viewDashboard. computeLayout, isWide, and renderTable now use contentWidth for column visibility, available space, and max table width calculations. Columns gracefully hide (SSL, RETRIES, TYPE, UPTIME) when the panel is narrower, matching the existing responsive breakpoint behavior. --- internal/tui/tab_sites.go | 8 ++++++-- internal/tui/table_helpers.go | 12 ++++++++++-- internal/tui/tui.go | 1 + internal/tui/view_dashboard.go | 11 ++++++++--- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/internal/tui/tab_sites.go b/internal/tui/tab_sites.go index b88c1a8..de1d01e 100644 --- a/internal/tui/tab_sites.go +++ b/internal/tui/tab_sites.go @@ -82,8 +82,12 @@ func (m Model) computeLayout() tableLayout { var widths []int var fixed int + cw := m.contentWidth + if cw == 0 { + cw = m.termWidth + } for _, c := range siteColumns { - if c.minTerm > 0 && m.termWidth < c.minTerm { + if c.minTerm > 0 && cw < c.minTerm { continue } active = append(active, c.key) @@ -104,7 +108,7 @@ func (m Model) computeLayout() tableLayout { numCols := len(headers) borderOverhead := 2 + (numCols - 1) - avail := m.termWidth - chromePadH - 2 - borderOverhead - fixed + avail := cw - chromePadH - 2 - borderOverhead - fixed if avail < 20 { avail = 20 } diff --git a/internal/tui/table_helpers.go b/internal/tui/table_helpers.go index 2c32182..e2dd5d8 100644 --- a/internal/tui/table_helpers.go +++ b/internal/tui/table_helpers.go @@ -13,7 +13,11 @@ const ( ) func (m Model) isWide() bool { - return m.termWidth >= wideBreakpoint + w := m.contentWidth + if w == 0 { + w = m.termWidth + } + return w >= wideBreakpoint } func (m Model) renderTable(headers []string, items int, buildRows func(start, end int) [][]string, colWidths []int, styleOverride StyleOverride) string { @@ -35,7 +39,11 @@ func (m Model) renderTable(headers []string, items int, buildRows func(start, en } borderOverhead := 2 + len(colWidths) - 1 tableWidth := colTotal + borderOverhead - maxWidth := m.termWidth - chromePadH - 2 + cw := m.contentWidth + if cw == 0 { + cw = m.termWidth + } + maxWidth := cw - chromePadH - 2 if tableWidth > maxWidth { tableWidth = maxWidth } diff --git a/internal/tui/tui.go b/internal/tui/tui.go index 602c2b1..7cb209e 100644 --- a/internal/tui/tui.go +++ b/internal/tui/tui.go @@ -123,6 +123,7 @@ type Model struct { maxTableRows int termWidth int termHeight int + contentWidth int editID int editToken string diff --git a/internal/tui/view_dashboard.go b/internal/tui/view_dashboard.go index 98482e7..9f67cd0 100644 --- a/internal/tui/view_dashboard.go +++ b/internal/tui/view_dashboard.go @@ -152,21 +152,26 @@ func (m Model) viewDashboard() string { var content string switch m.currentTab { case tabMonitors: - monitors := m.viewSitesTab() - if m.termWidth >= wideBreakpoint { + showSidebar := m.termWidth >= wideBreakpoint + if showSidebar { availW := m.termWidth - chromePadH leftW := availW * 70 / 100 rightW := availW - leftW + m.contentWidth = leftW + monitors := m.viewSitesTab() left := lipgloss.NewStyle().Width(leftW).Render(monitors) sidebar := m.viewLogsSidebar(rightW) right := lipgloss.NewStyle().Width(rightW).Render(sidebar) content = lipgloss.JoinHorizontal(lipgloss.Top, left, right) } else { - content = monitors + m.contentWidth = m.termWidth + content = m.viewSitesTab() } case tabMaint: + m.contentWidth = m.termWidth content = m.viewMaintTab() case tabSettings: + m.contentWidth = m.termWidth content = m.viewSettingsTab() }