diff options
Diffstat (limited to 'internal/tui/dashboard')
| -rw-r--r-- | internal/tui/dashboard/model.go | 13 | ||||
| -rw-r--r-- | internal/tui/dashboard/model_test.go | 19 |
2 files changed, 25 insertions, 7 deletions
diff --git a/internal/tui/dashboard/model.go b/internal/tui/dashboard/model.go index c852feb..0cc18f8 100644 --- a/internal/tui/dashboard/model.go +++ b/internal/tui/dashboard/model.go @@ -1356,20 +1356,19 @@ func bubbleTickCmdFn() tea.Cmd { } func streamViewport(width, height int) (int, int) { - width, height = common.EffectiveViewport(width, height) - height -= streamChromeRows - if height < 1 { - height = 1 - } - return width, height + return dashboardViewport(width, height, streamChromeRows) } func flameViewport(width, height int, showHelp bool) (int, int) { - width, height = common.EffectiveViewport(width, height) chromeRows := dashboardTabBarRows + dashboardHelpHintRows if showHelp { chromeRows = dashboardTabBarRows + dashboardExpandedHelpRows } + return dashboardViewport(width, height, chromeRows) +} + +func dashboardViewport(width, height, chromeRows int) (int, int) { + width, height = common.EffectiveViewport(width, height) height -= chromeRows if height < 1 { height = 1 diff --git a/internal/tui/dashboard/model_test.go b/internal/tui/dashboard/model_test.go index c2dfbba..59af73a 100644 --- a/internal/tui/dashboard/model_test.go +++ b/internal/tui/dashboard/model_test.go @@ -56,6 +56,25 @@ func firstLineContaining(value, needle string) string { return "" } +func TestStreamViewportUsesSharedChromeCalculator(t *testing.T) { + wantWidth, wantHeight := common.EffectiveViewport(120, 40) + wantHeight -= streamChromeRows + + width, height := streamViewport(120, 40) + if width != wantWidth || height != wantHeight { + t.Fatalf("streamViewport() = %dx%d, want %dx%d", width, height, wantWidth, wantHeight) + } +} + +func TestFlameViewportClampsHeightWithExpandedHelp(t *testing.T) { + wantWidth, _ := common.EffectiveViewport(80, 2) + + width, height := flameViewport(80, 2, true) + if width != wantWidth || height != 1 { + t.Fatalf("flameViewport() = %dx%d, want %dx%d", width, height, wantWidth, 1) + } +} + func TestKeySwitchingChangesActiveTab(t *testing.T) { m := NewModelWithConfig(nil, nil, 250, common.DefaultKeyMap()) |
