From 2a0639d9bb21e25d5ef90f0decc6c5d19fcca453 Mon Sep 17 00:00:00 2001 From: Kyriakos Akriotis Date: Fri, 23 Oct 2026 12:21:42 +0200 Subject: [PATCH] hide default command when there is no space for the context #188 --- internal/ui/render.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/internal/ui/render.go b/internal/ui/render.go index e2c7c3c..bbb69a2 100644 --- a/internal/ui/render.go +++ b/internal/ui/render.go @@ -41,7 +41,8 @@ func (m Model) renderHeader() string { // The logo is independently anchored to the right edge. // Hide the context if it would reduce the commands below their // preferred width. - showContext := m.showHeaderContext() + // m.showHeaderContext() + showContext := true if !showContext { leftWidth = 0 @@ -135,12 +136,16 @@ func (m Model) renderHeaderContext() (string, int) { } func (m Model) renderHeaderCommands(availableWidth int) string { - commands := []resource.Command{ - {Key: "ctrl+x", Description: "Quit"}, - {Key: ":", Description: "Resource"}, - {Key: "r", Description: "Refresh"}, - {Key: "c", Description: "Copy"}, - {Key: "esc", Description: "Dismiss/Return"}, + var commands []resource.Command + + if m.showHeaderContext() || m.width <= compactWidth || m.detailMode { + commands = []resource.Command{ + {Key: "ctrl+x", Description: "Quit"}, + {Key: ":", Description: "Resource"}, + {Key: "r", Description: "Refresh"}, + {Key: "c", Description: "Copy"}, + {Key: "esc", Description: "Dismiss/Return"}, + } } if m.resource != nil && !m.detailMode { @@ -153,12 +158,11 @@ func (m Model) renderHeaderCommands(availableWidth int) string { keyWidth = 10 ) - columnCount := (len(commands) + commandsPerColumn - 1) / commandsPerColumn - if availableWidth <= 0 { return strings.Repeat("\n", commandsPerColumn-1) } + columnCount := max(1, (len(commands)+commandsPerColumn-1)/commandsPerColumn) widths := make([]int, columnCount) baseWidth := availableWidth / columnCount remainder := availableWidth % columnCount