@@ -86,6 +86,7 @@ pub struct UiState<'a> {
8686 pub focus : FocusedComponent ,
8787 pub tree_state : FileTreeState ,
8888 pub history_state : ListState ,
89+ pub history_follow_last : bool ,
8990 pub history_opened_state : HashSet < usize > ,
9091 pub throbber_state : throbber_widgets_tui:: ThrobberState ,
9192 pub widget_areas : HashMap < FocusedComponent , Rect > ,
@@ -110,6 +111,7 @@ impl UiState<'_> {
110111 focus : FocusedComponent :: Input ,
111112 tree_state : FileTreeState :: new ( workspace) ,
112113 history_state : ListState :: default ( ) ,
114+ history_follow_last : false ,
113115 history_opened_state : HashSet :: default ( ) ,
114116 throbber_state : throbber_widgets_tui:: ThrobberState :: default ( ) ,
115117 widget_areas : HashMap :: default ( ) ,
@@ -152,9 +154,7 @@ impl App<'_> {
152154
153155 pub async fn run ( mut self , mut terminal : DefaultTerminal ) -> color_eyre:: Result < ( ) > {
154156 if !self . model . messages . is_empty ( ) {
155- self . ui
156- . history_state
157- . select ( Some ( self . model . messages . len ( ) - 1 ) ) ;
157+ self . ui . history_follow_last = true ;
158158 }
159159 while self . running {
160160 terminal. draw ( |frame| frame. render_widget ( & mut self , frame. area ( ) ) ) ?;
@@ -288,20 +288,19 @@ impl App<'_> {
288288 AgentOutputEvent :: NewTask => {
289289 self . model . messages . clear ( ) ;
290290 self . ui . history_state . select ( None ) ;
291+ self . ui . history_follow_last = false ;
291292 self . ui . history_opened_state . clear ( ) ;
292293 self . ui . focus = FocusedComponent :: Input ;
293294 }
294295 AgentOutputEvent :: AddMessage ( message) => {
295296 self . model . messages . push ( message) ;
296- self . ui
297- . history_state
298- . select ( Some ( self . model . messages . len ( ) - 1 ) ) ;
297+ self . ui . history_follow_last = true ;
299298 }
300299 AgentOutputEvent :: UpdateMessage ( message) => {
301300 if !self . model . messages . is_empty ( ) {
302301 let len = self . model . messages . len ( ) - 1 ;
303302 self . model . messages [ len] = message;
304- self . ui . history_state . select ( Some ( len ) ) ;
303+ self . ui . history_follow_last = true ;
305304 }
306305 }
307306 AgentOutputEvent :: CommandStatus ( status) => {
0 commit comments