From 78fe1d124ace1093edf5cd0f89f6bf7ecf8256b1 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Sat, 21 Mar 2026 06:48:06 +0800 Subject: [PATCH 1/2] refactor(status): extract view height padding helper --- cmd/status/main.go | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/cmd/status/main.go b/cmd/status/main.go index 6df38fc..e881428 100644 --- a/cmd/status/main.go +++ b/cmd/status/main.go @@ -59,6 +59,21 @@ type model struct { catHidden bool // true = hidden, false = visible } +// padViewToHeight ensures the rendered frame always overwrites the full +// terminal region by padding with empty lines up to the current height. +func padViewToHeight(view string, height int) string { + if height <= 0 { + return view + } + + contentHeight := lipgloss.Height(view) + if contentHeight >= height { + return view + } + + return view + strings.Repeat("\n", height-contentHeight) +} + // getConfigPath returns the path to the status preferences file. func getConfigPath() string { home, err := os.UserHomeDir() @@ -194,17 +209,7 @@ func (m model) View() string { } parts = append(parts, cardContent) output := lipgloss.JoinVertical(lipgloss.Left, parts...) - - // Pad output to exactly fill the terminal height so every frame fully - // overwrites the alt screen buffer, preventing ghost lines on resize. - if m.height > 0 { - contentHeight := lipgloss.Height(output) - if contentHeight < m.height { - output += strings.Repeat("\n", m.height-contentHeight) - } - } - - return output + return padViewToHeight(output, m.height) } func (m model) collectCmd() tea.Cmd { From 546a5a292fbf217f7a496dc80e45bd133afad6c7 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Sat, 21 Mar 2026 07:18:28 +0800 Subject: [PATCH 2/2] test(core): fix shellcheck warnings in common bats --- tests/core_common.bats | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/core_common.bats b/tests/core_common.bats index 4314d99..85cd9f2 100644 --- a/tests/core_common.bats +++ b/tests/core_common.bats @@ -84,7 +84,10 @@ EOF } @test "should_protect_path protects Mole runtime logs" { - result="$(HOME="$HOME" bash --noprofile --norc -c "source '$PROJECT_ROOT/lib/core/common.sh'; should_protect_path '$HOME/Library/Logs/mole/operations.log' && echo protected || echo not-protected")" + result="$( + HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc -c \ + 'source "$PROJECT_ROOT/lib/core/common.sh"; should_protect_path "$HOME/Library/Logs/mole/operations.log" && echo protected || echo not-protected' + )" [ "$result" = "protected" ] } @@ -241,7 +244,7 @@ EOF PATH="$fake_bin:$PATH" PROJECT_ROOT="$PROJECT_ROOT" HOME="$HOME" \ /usr/bin/script -q /dev/null /bin/bash --noprofile --norc -c \ - 'source "$PROJECT_ROOT/lib/core/common.sh"; start_inline_spinner "Testing..."; /bin/sleep 0.15; stop_inline_spinner' \ + "source \"\$PROJECT_ROOT/lib/core/common.sh\"; start_inline_spinner \"Testing...\"; /bin/sleep 0.15; stop_inline_spinner" \ > /dev/null 2>&1 [ ! -f "$marker" ]