▍ humdrum codex / glint v1.1.2
license AGPL-3.0

fix: dialog box width must fit within content column

d39ddc5656a19a617840c02736e9d901f4ce1d76
humdrum-tiv <45084903+humdrum-tiv@users.noreply.github.com> · 2026-07-30 19:09

parent c722d38c

fix: dialog box width must fit within content column

Replace hard minimum width (boxMin=24) with adaptive floor (w >= 1) so the
box shrinks to fit narrow columns, preventing overflow. Extend
TestViewFitsContentWidth to verify widths 12 and 20 alongside 40 to catch
regressions (TASK-046).

2 files changed

internal/dialog/dialog.go +2 −5
@@ -85,9 +85,6 @@ 	m.input, cmd = m.input.Update(msg)
 	return ResultNone, cmd
 }
 
-// boxMin is the narrowest the dialog box gets before it just takes the column.
-const boxMin = 24
-
 // View renders the dialog as a centered bordered box: title, the folder the
 // name lands in, the input, an optional validation line, then the key footer.
 func (m *Model) View() string {
@@ -103,8 +100,8 @@ 	inner += "\n\n" + lipgloss.NewStyle().Foreground(m.th.Muted).
 		Render("Enter to confirm · Esc to cancel")
 
 	w := m.width - 2 // the border takes one cell each side
-	if w < boxMin {
-		w = boxMin
+	if w < 1 {
+		w = 1
 	}
 	box := lipgloss.NewStyle().
 		Border(lipgloss.RoundedBorder()).
internal/dialog/dialog_test.go +8 −6
@@ -135,12 +135,14 @@ 	}
 }
 
 func TestViewFitsContentWidth(t *testing.T) {
-	m := newModel()
-	m.SetWidth(40)
-	m.Open("New note", "~/Notes/", "")
-	for i, ln := range strings.Split(m.View(), "\n") {
-		if w := lipgloss.Width(ln); w > 40 {
-			t.Errorf("line %d width = %d, want <= 40", i, w)
+	for _, w := range []int{40, 20, 12} {
+		m := newModel()
+		m.SetWidth(w)
+		m.Open("New note", "~/Notes/", "")
+		for i, ln := range strings.Split(m.View(), "\n") {
+			if got := lipgloss.Width(ln); got > w {
+				t.Errorf("width %d: line %d is %d cells, want <= %d", w, i, got, w)
+			}
 		}
 	}
 }