diff --git a/internal/ui/view.go b/internal/ui/view.go index 1b08dff9..943f252f 100644 --- a/internal/ui/view.go +++ b/internal/ui/view.go @@ -288,9 +288,11 @@ func renderFrameTitleWithAction(width int, title, action string, color imagecolo return borderStyle.Render(border.TopLeft + strings.Repeat(border.Top, width-2) + border.TopRight) } prefix := border.TopLeft + border.Top + " " - suffix := borderStyle.Render(" " + border.TopRight) + // Join the horizontal rule directly into the corner. Optional title actions + // retain their leading padding, but must not leave a visual hole after them. + suffix := borderStyle.Render(border.Top + border.TopRight) if actionWidth > 0 { - suffix = borderStyle.Render(" ") + action + borderStyle.Render(" "+border.TopRight) + suffix = borderStyle.Render(" ") + action + borderStyle.Render(border.Top+border.TopRight) } middleWidth := max(width-lipgloss.Width(prefix)-lipgloss.Width(title)-lipgloss.Width(suffix), 0) middle := "" diff --git a/internal/ui/view_test.go b/internal/ui/view_test.go index c0b892b7..17009af2 100644 --- a/internal/ui/view_test.go +++ b/internal/ui/view_test.go @@ -240,9 +240,12 @@ func TestFrameTitlesAreIntegratedIntoBorderInsteadOfButtonBrackets(t *testing.T) if len(lines) != 5 { t.Fatalf("frame height = %d, want 5:\n%s", len(lines), output) } - if !strings.HasPrefix(lines[0], "╭─ SESSION READOUT ") || !strings.HasSuffix(lines[0], "╮") { + if !strings.HasPrefix(lines[0], "╭─ SESSION READOUT ") || !strings.HasSuffix(lines[0], "─╮") { t.Fatalf("title was not integrated into the top border: %q", lines[0]) } + if strings.HasSuffix(lines[0], " ╮") { + t.Fatalf("title frame left a gap before the top-right corner: %q", lines[0]) + } if strings.Contains(output, "[ SESSION READOUT ]") { t.Fatalf("frame title still looks like a button:\n%s", output) } @@ -258,6 +261,18 @@ func TestFrameTitlesAreIntegratedIntoBorderInsteadOfButtonBrackets(t *testing.T) t.Errorf("narrow line %d width = %d, want 5: %q", index, width, line) } } + + const closeAction = "[ (X) CLOSE ]" + withAction := ansi.Strip(frameSizedWithTitleAction(48, 3, "RUN DETAIL", closeAction, "BODY", colors.primary, colors)) + actionLines := strings.Split(withAction, "\n") + if !strings.HasSuffix(actionLines[0], closeAction+"─╮") { + t.Fatalf("title action did not reconnect to the top-right corner: %q", actionLines[0]) + } + for index, line := range actionLines { + if width := lipgloss.Width(line); width != 48 { + t.Errorf("action frame line %d width = %d, want 48: %q", index, width, line) + } + } } func TestPieViewPlacesQuotaWindowsSideBySide(t *testing.T) {