@@ -86,6 +86,7 @@ pub struct UiState<'a> {
86
86
pub focus : FocusedComponent ,
87
87
pub tree_state : FileTreeState ,
88
88
pub history_state : ListState ,
89
+ pub history_follow_last : bool ,
89
90
pub history_opened_state : HashSet < usize > ,
90
91
pub throbber_state : throbber_widgets_tui:: ThrobberState ,
91
92
pub widget_areas : HashMap < FocusedComponent , Rect > ,
@@ -110,6 +111,7 @@ impl UiState<'_> {
110
111
focus : FocusedComponent :: Input ,
111
112
tree_state : FileTreeState :: new ( workspace) ,
112
113
history_state : ListState :: default ( ) ,
114
+ history_follow_last : false ,
113
115
history_opened_state : HashSet :: default ( ) ,
114
116
throbber_state : throbber_widgets_tui:: ThrobberState :: default ( ) ,
115
117
widget_areas : HashMap :: default ( ) ,
@@ -152,9 +154,7 @@ impl App<'_> {
152
154
153
155
pub async fn run ( mut self , mut terminal : DefaultTerminal ) -> color_eyre:: Result < ( ) > {
154
156
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 ;
158
158
}
159
159
while self . running {
160
160
terminal. draw ( |frame| frame. render_widget ( & mut self , frame. area ( ) ) ) ?;
@@ -288,20 +288,19 @@ impl App<'_> {
288
288
AgentOutputEvent :: NewTask => {
289
289
self . model . messages . clear ( ) ;
290
290
self . ui . history_state . select ( None ) ;
291
+ self . ui . history_follow_last = false ;
291
292
self . ui . history_opened_state . clear ( ) ;
292
293
self . ui . focus = FocusedComponent :: Input ;
293
294
}
294
295
AgentOutputEvent :: AddMessage ( message) => {
295
296
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 ;
299
298
}
300
299
AgentOutputEvent :: UpdateMessage ( message) => {
301
300
if !self . model . messages . is_empty ( ) {
302
301
let len = self . model . messages . len ( ) - 1 ;
303
302
self . model . messages [ len] = message;
304
- self . ui . history_state . select ( Some ( len ) ) ;
303
+ self . ui . history_follow_last = true ;
305
304
}
306
305
}
307
306
AgentOutputEvent :: CommandStatus ( status) => {
0 commit comments