fix: banking shell screen rendering artifacts and transfer panic
Fix rendering issues where content from previous screens bled through when switching between views of different heights/widths: - Pad every line to full terminal width (ANSI-aware) so shorter lines overwrite leftover content from previous renders - Track terminal height via WindowSizeMsg and pad between content and footer to fill the screen - Send tea.ClearScreen on all screen transitions for height changes - Fix panic in transfer completion when routing number is < 4 chars Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
|
||||
"git.t-juice.club/torjus/oubliette/internal/shell"
|
||||
"git.t-juice.club/torjus/oubliette/internal/storage"
|
||||
@@ -520,7 +521,7 @@ func TestConfigString(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestScreenFrame(t *testing.T) {
|
||||
frame := screenFrame("TESTBANK", "TB-0001", "NORTHEAST", "content here")
|
||||
frame := screenFrame("TESTBANK", "TB-0001", "NORTHEAST", "content here", 0)
|
||||
if !strings.Contains(frame, "TESTBANK FEDERAL RESERVE SYSTEM") {
|
||||
t.Error("frame should contain bank name in header")
|
||||
}
|
||||
@@ -531,3 +532,29 @@ func TestScreenFrame(t *testing.T) {
|
||||
t.Error("frame should contain the content")
|
||||
}
|
||||
}
|
||||
|
||||
func TestScreenFramePadsLines(t *testing.T) {
|
||||
frame := screenFrame("TESTBANK", "TB-0001", "NE", "short\n", 0)
|
||||
for i, line := range strings.Split(frame, "\n") {
|
||||
w := lipgloss.Width(line)
|
||||
if w > 0 && w < termWidth {
|
||||
t.Errorf("line %d has visual width %d, want at least %d: %q", i, w, termWidth, line)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestScreenFramePadsToHeight(t *testing.T) {
|
||||
short := screenFrame("TESTBANK", "TB-0001", "NE", "line1\nline2\n", 30)
|
||||
lines := strings.Count(short, "\n")
|
||||
// Total newlines should be at least height-1 (since the last line has no trailing newline).
|
||||
if lines < 29 {
|
||||
t.Errorf("padded frame has %d newlines, want at least 29 for height=30", lines)
|
||||
}
|
||||
|
||||
// Without height, no padding.
|
||||
noPad := screenFrame("TESTBANK", "TB-0001", "NE", "line1\nline2\n", 0)
|
||||
noPadLines := strings.Count(noPad, "\n")
|
||||
if noPadLines >= 29 {
|
||||
t.Errorf("unpadded frame has %d newlines, should be much less than 29", noPadLines)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user