@@ -665,6 +665,53 @@ fn test_remote_typing_resumes_bottom_follow_mode() {
665665 ) ;
666666}
667667
668+ #[ test]
669+ fn test_local_typing_resumes_bottom_follow_mode ( ) {
670+ let mut app = create_test_app ( ) ;
671+ app. scroll_offset = 7 ;
672+ app. auto_scroll_paused = true ;
673+
674+ app. handle_key ( KeyCode :: Char ( 'x' ) , KeyModifiers :: empty ( ) )
675+ . unwrap ( ) ;
676+
677+ assert_eq ! ( app. input, "x" ) ;
678+ assert_eq ! ( app. cursor_pos, 1 ) ;
679+ assert_eq ! ( app. scroll_offset, 0 ) ;
680+ assert ! (
681+ !app. auto_scroll_paused,
682+ "local typing should follow newest content just like remote typing"
683+ ) ;
684+ }
685+
686+ #[ test]
687+ fn test_local_typing_snaps_rendered_viewport_to_bottom_in_one_frame ( ) {
688+ let _lock = scroll_render_test_lock ( ) ;
689+ crate :: tui:: ui:: clear_test_render_state_for_tests ( ) ;
690+
691+ let ( mut app, mut terminal) = create_scroll_test_app ( 50 , 12 , 0 , 32 ) ;
692+ let _ = render_and_snap ( & app, & mut terminal) ;
693+ let max_scroll = crate :: tui:: ui:: last_max_scroll ( ) ;
694+ assert ! ( max_scroll > 8 , "expected a long transcript, got {max_scroll}" ) ;
695+
696+ app. auto_scroll_paused = true ;
697+ app. scroll_offset = max_scroll - 8 ;
698+ let _ = render_and_snap ( & app, & mut terminal) ;
699+ assert_eq ! (
700+ crate :: tui:: ui:: last_resolved_chat_scroll( ) ,
701+ max_scroll - 8
702+ ) ;
703+
704+ app. handle_key ( KeyCode :: Char ( 'x' ) , KeyModifiers :: empty ( ) )
705+ . unwrap ( ) ;
706+ let _ = render_and_snap ( & app, & mut terminal) ;
707+
708+ assert_eq ! (
709+ crate :: tui:: ui:: last_resolved_chat_scroll( ) ,
710+ crate :: tui:: ui:: last_max_scroll( ) ,
711+ "typing should explicitly snap to the exact transcript tail, not use content catch-up"
712+ ) ;
713+ }
714+
668715#[ test]
669716fn test_remote_shift_slash_preserves_layout_translated_slash ( ) {
670717 let mut app = create_test_app ( ) ;
@@ -851,6 +898,26 @@ fn test_remote_typing_scroll_lock_preserves_scroll_position() {
851898 ) ;
852899}
853900
901+ #[ test]
902+ fn test_local_typing_scroll_lock_preserves_scroll_position ( ) {
903+ let mut app = create_test_app ( ) ;
904+ app. scroll_offset = 7 ;
905+ app. auto_scroll_paused = true ;
906+
907+ app. handle_key ( KeyCode :: Char ( 's' ) , KeyModifiers :: ALT )
908+ . unwrap ( ) ;
909+ app. handle_key ( KeyCode :: Char ( 'x' ) , KeyModifiers :: empty ( ) )
910+ . unwrap ( ) ;
911+
912+ assert_eq ! ( app. input, "x" ) ;
913+ assert_eq ! ( app. cursor_pos, 1 ) ;
914+ assert_eq ! ( app. scroll_offset, 7 ) ;
915+ assert ! (
916+ app. auto_scroll_paused,
917+ "typing scroll lock should preserve local paused scroll state"
918+ ) ;
919+ }
920+
854921#[ test]
855922fn test_remote_typing_scroll_lock_can_be_toggled_back_off ( ) {
856923 let mut app = create_test_app ( ) ;
0 commit comments