on main help sign in
fix(tui): permission: increase the default width of the dialog to 80%

and verticalize buttons on narrow screens

commitc57cca5d6f692eed7651216588b1af479799e8ea authorAyman Bagabas <ayman.bagabas@gmail.com> dateThu 10 Jul 2025, 12:20 (1 year ago) parente005d0a
2 files changed+25−3
internal/tui/components/core/core.go+15 internal/tui/components/dialogs/permissions/permissions.go+10−3
internal/tui/components/core/core.go+15
@@ -191,6 +191,21 @@ func SelectableButtons(buttons []ButtonOpts, spacing string) string {
191191 return lipgloss.JoinHorizontal(lipgloss.Left, parts...)
192192}
193193
194+// SelectableButtonsVertical creates a vertical row of selectable buttons
195+func SelectableButtonsVertical(buttons []ButtonOpts, spacing int) string {
196+ var parts []string
197+ for i, button := range buttons {
198+ parts = append(parts, SelectableButton(button))
199+ if i < len(buttons)-1 {
200+ for j := 0; j < spacing; j++ {
201+ parts = append(parts, "")
202+ }
203+ }
204+ }
205+
206+ return lipgloss.JoinVertical(lipgloss.Center, parts...)
207+}
208+
194209func DiffFormatter() *diffview.DiffView {
195210 t := styles.CurrentTheme()
196211 formatDiff := diffview.New()
internal/tui/components/dialogs/permissions/permissions.go+10−3
@@ -199,6 +199,13 @@ func (p *permissionDialogCmp) renderButtons() string {
199199 }
200200
201201 content := core.SelectableButtons(buttons, " ")
202+ if lipgloss.Width(content) > p.width-4 {
203+ content = core.SelectableButtonsVertical(buttons, 1)
204+ return baseStyle.AlignVertical(lipgloss.Center).
205+ AlignHorizontal(lipgloss.Center).
206+ Width(p.width - 4).
207+ Render(content)
208+ }
202209
203210 return baseStyle.AlignHorizontal(lipgloss.Right).Width(p.width - 4).Render(content)
204211}
@@ -452,8 +459,8 @@ func (p *permissionDialogCmp) render() string {
452459 if p.supportsDiffView() {
453460 contentHelp = help.New().View(p.keyMap)
454461 }
455− // Calculate content height dynamically based on window size
456462
463+ // Calculate content height dynamically based on window size
457464 strs := []string{
458465 title,
459466 "",
@@ -491,7 +498,7 @@ func (p *permissionDialogCmp) SetSize() tea.Cmd {
491498
492499 switch p.permission.ToolName {
493500 case tools.BashToolName:
494− p.width = int(float64(p.wWidth) * 0.4)
501+ p.width = int(float64(p.wWidth) * 0.8)
495502 p.height = int(float64(p.wHeight) * 0.3)
496503 case tools.EditToolName:
497504 p.width = int(float64(p.wWidth) * 0.8)
@@ -500,7 +507,7 @@ func (p *permissionDialogCmp) SetSize() tea.Cmd {
500507 p.width = int(float64(p.wWidth) * 0.8)
501508 p.height = int(float64(p.wHeight) * 0.8)
502509 case tools.FetchToolName:
503− p.width = int(float64(p.wWidth) * 0.4)
510+ p.width = int(float64(p.wWidth) * 0.8)
504511 p.height = int(float64(p.wHeight) * 0.3)
505512 default:
506513 p.width = int(float64(p.wWidth) * 0.7)