From f8fd8d04bcebefcb317187b11888f58978180cd8 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 31 Mar 2026 12:43:00 +0200 Subject: [PATCH 1/2] Fix typo --- pkg/gui/controllers/helpers/window_arrangement_helper_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/gui/controllers/helpers/window_arrangement_helper_test.go b/pkg/gui/controllers/helpers/window_arrangement_helper_test.go index bb36ea03d..456e86e9b 100644 --- a/pkg/gui/controllers/helpers/window_arrangement_helper_test.go +++ b/pkg/gui/controllers/helpers/window_arrangement_helper_test.go @@ -285,7 +285,7 @@ func TestGetWindowDimensions(t *testing.T) { { name: "half screen mode, enlargedSideViewLocation left", mutateArgs: func(args *WindowArrangementArgs) { - args.Height = 20 // smaller height because we don't more here + args.Height = 20 // smaller height because we don't need more here args.ScreenMode = types.SCREEN_HALF args.UserConfig.Gui.EnlargedSideViewLocation = "left" }, @@ -317,7 +317,7 @@ func TestGetWindowDimensions(t *testing.T) { { name: "half screen mode, enlargedSideViewLocation top", mutateArgs: func(args *WindowArrangementArgs) { - args.Height = 20 // smaller height because we don't more here + args.Height = 20 // smaller height because we don't need more here args.ScreenMode = types.SCREEN_HALF args.UserConfig.Gui.EnlargedSideViewLocation = "top" }, From fde4bc1fb25c097ff2ef09714c6384b6f7048ae2 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 31 Mar 2026 12:31:42 +0200 Subject: [PATCH 2/2] Allow customizing the window width/height thresholds for when to use portrait mode --- docs-master/Config.md | 10 ++ pkg/config/user_config.go | 6 ++ .../helpers/window_arrangement_helper.go | 3 +- .../helpers/window_arrangement_helper_test.go | 99 +++++++++++++++++++ schema-master/config.json | 10 ++ 5 files changed, 127 insertions(+), 1 deletion(-) diff --git a/docs-master/Config.md b/docs-master/Config.md index 02b57eb7d..5a26c2d7b 100644 --- a/docs-master/Config.md +++ b/docs-master/Config.md @@ -298,6 +298,16 @@ gui: # One of 'auto' (default) | 'always' | 'never' portraitMode: auto + # In 'auto' mode, portrait mode will be used if the window width is less than or + # equal to portraitModeAutoMaxWidth and the window height is greater than or + # equal to portraitModeAutoMinHeight. Unused when portraitMode is not 'auto'. + portraitModeAutoMaxWidth: 84 + + # In 'auto' mode, portrait mode will be used if the window width is less than or + # equal to portraitModeAutoMaxWidth and the window height is greater than or + # equal to portraitModeAutoMinHeight. Unused when portraitMode is not 'auto'. + portraitModeAutoMinHeight: 46 + # How things are filtered when typing '/'. # One of 'substring' (default) | 'fuzzy' filterMode: substring diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index 3ed5e8d90..dac5f6b8b 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -187,6 +187,10 @@ type GuiConfig struct { // Whether to stack UI components on top of each other. // One of 'auto' (default) | 'always' | 'never' PortraitMode string `yaml:"portraitMode"` + // In 'auto' mode, portrait mode will be used if the window width is less than or equal to portraitModeAutoMaxWidth and the window height is greater than or equal to portraitModeAutoMinHeight. Unused when portraitMode is not 'auto'. + PortraitModeAutoMaxWidth int `yaml:"portraitModeAutoMaxWidth"` + // In 'auto' mode, portrait mode will be used if the window width is less than or equal to portraitModeAutoMaxWidth and the window height is greater than or equal to portraitModeAutoMinHeight. Unused when portraitMode is not 'auto'. + PortraitModeAutoMinHeight int `yaml:"portraitModeAutoMinHeight"` // How things are filtered when typing '/'. // One of 'substring' (default) | 'fuzzy' FilterMode string `yaml:"filterMode" jsonschema:"enum=substring,enum=fuzzy"` @@ -820,6 +824,8 @@ func GetDefaultConfig() *UserConfig { Border: "rounded", AnimateExplosion: true, PortraitMode: "auto", + PortraitModeAutoMaxWidth: 84, + PortraitModeAutoMinHeight: 46, FilterMode: "substring", Spinner: SpinnerConfig{ Frames: []string{"|", "/", "-", "\\"}, diff --git a/pkg/gui/controllers/helpers/window_arrangement_helper.go b/pkg/gui/controllers/helpers/window_arrangement_helper.go index 04f31d0fd..9061d5177 100644 --- a/pkg/gui/controllers/helpers/window_arrangement_helper.go +++ b/pkg/gui/controllers/helpers/window_arrangement_helper.go @@ -116,7 +116,8 @@ func shouldUsePortraitMode(args WindowArrangementArgs) bool { case "always": return true default: // "auto" or any garbage values in PortraitMode value - return args.Width <= 84 && args.Height > 45 + return args.Width <= args.UserConfig.Gui.PortraitModeAutoMaxWidth && + args.Height >= args.UserConfig.Gui.PortraitModeAutoMinHeight } } diff --git a/pkg/gui/controllers/helpers/window_arrangement_helper_test.go b/pkg/gui/controllers/helpers/window_arrangement_helper_test.go index 456e86e9b..c63755ef2 100644 --- a/pkg/gui/controllers/helpers/window_arrangement_helper_test.go +++ b/pkg/gui/controllers/helpers/window_arrangement_helper_test.go @@ -346,6 +346,105 @@ func TestGetWindowDimensions(t *testing.T) { B: information `, }, + { + name: "portrait auto mode, enabled", + mutateArgs: func(args *WindowArrangementArgs) { + args.Width = 50 + args.Height = 20 + args.UserConfig.Gui.PortraitModeAutoMaxWidth = 50 + args.UserConfig.Gui.PortraitModeAutoMinHeight = 20 + }, + expected: ` + + ╭files───────────────────────────────────────────╮ + │ │ + ╰────────────────────────────────────────────────╯ + + + + ╭main────────────────────────────────────────────╮ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + │ │ + ╰────────────────────────────────────────────────╯ + A + A: statusSpacer1 + B: information + `, + }, + { + name: "portrait auto mode, disabled because width is too large", + mutateArgs: func(args *WindowArrangementArgs) { + args.Width = 50 + args.Height = 20 + args.UserConfig.Gui.PortraitModeAutoMaxWidth = 49 + args.UserConfig.Gui.PortraitModeAutoMinHeight = 20 + }, + expected: ` + ╭main───────────────────────────╮ + ╭files──────────╮│ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + ╰───────────────╯│ │ + │ │ + │ │ + ╰───────────────────────────────╯ + A + A: statusSpacer1 + B: information + `, + }, + { + name: "portrait auto mode, disabled because height is too small", + mutateArgs: func(args *WindowArrangementArgs) { + args.Width = 50 + args.Height = 20 + args.UserConfig.Gui.PortraitModeAutoMaxWidth = 50 + args.UserConfig.Gui.PortraitModeAutoMinHeight = 21 + }, + expected: ` + ╭main───────────────────────────╮ + ╭files──────────╮│ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + ╰───────────────╯│ │ + │ │ + │ │ + ╰───────────────────────────────╯ + A + A: statusSpacer1 + B: information + `, + }, { name: "search mode", mutateArgs: func(args *WindowArrangementArgs) { diff --git a/schema-master/config.json b/schema-master/config.json index 3fc88d093..d4e450493 100644 --- a/schema-master/config.json +++ b/schema-master/config.json @@ -769,6 +769,16 @@ "description": "Whether to stack UI components on top of each other.\nOne of 'auto' (default) | 'always' | 'never'", "default": "auto" }, + "portraitModeAutoMaxWidth": { + "type": "integer", + "description": "In 'auto' mode, portrait mode will be used if the window width is less than or equal to portraitModeAutoMaxWidth and the window height is greater than or equal to portraitModeAutoMinHeight. Unused when portraitMode is not 'auto'.", + "default": 84 + }, + "portraitModeAutoMinHeight": { + "type": "integer", + "description": "In 'auto' mode, portrait mode will be used if the window width is less than or equal to portraitModeAutoMaxWidth and the window height is greater than or equal to portraitModeAutoMinHeight. Unused when portraitMode is not 'auto'.", + "default": 46 + }, "filterMode": { "type": "string", "enum": [