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.
This commit is contained in:
2026-06-20 18:14:01 -04:00
parent 8323d27e7d
commit e12f42fe16
4 changed files with 25 additions and 7 deletions
+6 -2
View File
@@ -82,8 +82,12 @@ func (m Model) computeLayout() tableLayout {
var widths []int var widths []int
var fixed int var fixed int
cw := m.contentWidth
if cw == 0 {
cw = m.termWidth
}
for _, c := range siteColumns { for _, c := range siteColumns {
if c.minTerm > 0 && m.termWidth < c.minTerm { if c.minTerm > 0 && cw < c.minTerm {
continue continue
} }
active = append(active, c.key) active = append(active, c.key)
@@ -104,7 +108,7 @@ func (m Model) computeLayout() tableLayout {
numCols := len(headers) numCols := len(headers)
borderOverhead := 2 + (numCols - 1) borderOverhead := 2 + (numCols - 1)
avail := m.termWidth - chromePadH - 2 - borderOverhead - fixed avail := cw - chromePadH - 2 - borderOverhead - fixed
if avail < 20 { if avail < 20 {
avail = 20 avail = 20
} }
+10 -2
View File
@@ -13,7 +13,11 @@ const (
) )
func (m Model) isWide() bool { 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 { 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 borderOverhead := 2 + len(colWidths) - 1
tableWidth := colTotal + borderOverhead tableWidth := colTotal + borderOverhead
maxWidth := m.termWidth - chromePadH - 2 cw := m.contentWidth
if cw == 0 {
cw = m.termWidth
}
maxWidth := cw - chromePadH - 2
if tableWidth > maxWidth { if tableWidth > maxWidth {
tableWidth = maxWidth tableWidth = maxWidth
} }
+1
View File
@@ -123,6 +123,7 @@ type Model struct {
maxTableRows int maxTableRows int
termWidth int termWidth int
termHeight int termHeight int
contentWidth int
editID int editID int
editToken string editToken string
+8 -3
View File
@@ -152,21 +152,26 @@ func (m Model) viewDashboard() string {
var content string var content string
switch m.currentTab { switch m.currentTab {
case tabMonitors: case tabMonitors:
monitors := m.viewSitesTab() showSidebar := m.termWidth >= wideBreakpoint
if m.termWidth >= wideBreakpoint { if showSidebar {
availW := m.termWidth - chromePadH availW := m.termWidth - chromePadH
leftW := availW * 70 / 100 leftW := availW * 70 / 100
rightW := availW - leftW rightW := availW - leftW
m.contentWidth = leftW
monitors := m.viewSitesTab()
left := lipgloss.NewStyle().Width(leftW).Render(monitors) left := lipgloss.NewStyle().Width(leftW).Render(monitors)
sidebar := m.viewLogsSidebar(rightW) sidebar := m.viewLogsSidebar(rightW)
right := lipgloss.NewStyle().Width(rightW).Render(sidebar) right := lipgloss.NewStyle().Width(rightW).Render(sidebar)
content = lipgloss.JoinHorizontal(lipgloss.Top, left, right) content = lipgloss.JoinHorizontal(lipgloss.Top, left, right)
} else { } else {
content = monitors m.contentWidth = m.termWidth
content = m.viewSitesTab()
} }
case tabMaint: case tabMaint:
m.contentWidth = m.termWidth
content = m.viewMaintTab() content = m.viewMaintTab()
case tabSettings: case tabSettings:
m.contentWidth = m.termWidth
content = m.viewSettingsTab() content = m.viewSettingsTab()
} }