diff --git a/internal/tui/components/core/core.go b/internal/tui/components/core/core.go index f5605db3927a9c1e55bd5706e2059c1ba9006106..1db79e954350a11a4a843797b07a091736a1cae9 100644 --- a/internal/tui/components/core/core.go +++ b/internal/tui/components/core/core.go @@ -191,6 +191,21 @@ func SelectableButtons(buttons []ButtonOpts, spacing string) string { return lipgloss.JoinHorizontal(lipgloss.Left, parts...) } +// SelectableButtonsVertical creates a vertical row of selectable buttons +func SelectableButtonsVertical(buttons []ButtonOpts, spacing int) string { + var parts []string + for i, button := range buttons { + parts = append(parts, SelectableButton(button)) + if i < len(buttons)-1 { + for j := 0; j < spacing; j++ { + parts = append(parts, "") + } + } + } + + return lipgloss.JoinVertical(lipgloss.Center, parts...) +} + func DiffFormatter() *diffview.DiffView { t := styles.CurrentTheme() formatDiff := diffview.New() diff --git a/internal/tui/components/dialogs/permissions/permissions.go b/internal/tui/components/dialogs/permissions/permissions.go index e7f6dd517b1504e2f938c9310e95b8a7086cbbf0..9d8215d640826b4113e8288ea1c7f7559779a001 100644 --- a/internal/tui/components/dialogs/permissions/permissions.go +++ b/internal/tui/components/dialogs/permissions/permissions.go @@ -199,6 +199,13 @@ func (p *permissionDialogCmp) renderButtons() string { } content := core.SelectableButtons(buttons, " ") + if lipgloss.Width(content) > p.width-4 { + content = core.SelectableButtonsVertical(buttons, 1) + return baseStyle.AlignVertical(lipgloss.Center). + AlignHorizontal(lipgloss.Center). + Width(p.width - 4). + Render(content) + } return baseStyle.AlignHorizontal(lipgloss.Right).Width(p.width - 4).Render(content) } @@ -452,8 +459,8 @@ func (p *permissionDialogCmp) render() string { if p.supportsDiffView() { contentHelp = help.New().View(p.keyMap) } - // Calculate content height dynamically based on window size + // Calculate content height dynamically based on window size strs := []string{ title, "", @@ -491,7 +498,7 @@ func (p *permissionDialogCmp) SetSize() tea.Cmd { switch p.permission.ToolName { case tools.BashToolName: - p.width = int(float64(p.wWidth) * 0.4) + p.width = int(float64(p.wWidth) * 0.8) p.height = int(float64(p.wHeight) * 0.3) case tools.EditToolName: p.width = int(float64(p.wWidth) * 0.8) @@ -500,7 +507,7 @@ func (p *permissionDialogCmp) SetSize() tea.Cmd { p.width = int(float64(p.wWidth) * 0.8) p.height = int(float64(p.wHeight) * 0.8) case tools.FetchToolName: - p.width = int(float64(p.wWidth) * 0.4) + p.width = int(float64(p.wWidth) * 0.8) p.height = int(float64(p.wHeight) * 0.3) default: p.width = int(float64(p.wWidth) * 0.7)