okami.mom/albedo
git clone https://git.nkp.pet/okami.mom/albedo
8499f48
main
1// Jump-to-user keyboard navigation is interactive viewport state; headless daemon E2E has no PTY to drive shift+up/down. 2package tui 3 4import ( 5"strings" 6"testing" 7 8"albedo/cli/internal/daemon" 9"github.com/charmbracelet/x/ansi" 10) 11 12func plainRows (lines []string ) []string { 13var rows []string 14for _ ,row := range lines { 15plain := []rune (strings .TrimRight (ansi .Strip (row )," " )) 16rows = append (rows ,string (plain [min (railWidth ,len (plain )):])) 17 } 18return rows 19} 20 21func TestJumpToYouLandsOnYourMessages (t * testing.T ) { 22m := newTestChatModel (t ,& daemon.Session {ID :"s" }) 23m .SetSize (100 ,20 ) 24for i := range int64 (4 ) { 25m .appendSettledEntry (HistoryEntry {Kind :EntryUser ,Speaker :"You" ,Text :"question" ,Timestamp :1 + i }) 26m .appendSettledEntry (HistoryEntry {Kind :EntryAssistant ,Speaker :"albedo" ,Text :strings .Repeat ("line\n" ,15 ),Timestamp :1 + i }) 27 } 28m .refreshViewportContent () 29var landed []string 30for range 3 { 31m .jumpToYou (true ) 32landed = append (landed ,plainRows (strings .Split (m .Viewport .View (),"\n" )[:1 ])[0 ]) 33 } 34for _ ,top := range landed { 35if top != "you" { 36t .Fatalf ("jump should put your message at the top, got %q" ,landed ) 37 } 38 } 39for range 4 { 40m .jumpToYou (false ) 41 } 42if ! m .Follow { 43t .Fatal ("jumping forward past your newest message should follow the live transcript" ) 44 } 45}