1414// Frozen Turns
1515// one that has already passed into scrollback
1616
17- use std:: collections:: { HashSet , HashMap , VecDeque } ;
17+ use std:: collections:: { HashMap , HashSet , VecDeque } ;
1818use std:: io:: Stdout ;
1919
2020use chrono:: Local ;
21- use ratatui: {
21+ use ratatui:: {
2222 backend:: CrosstermBackend ,
2323 buffer:: Buffer ,
2424 layout:: Rect ,
@@ -30,7 +30,7 @@ use ratatui:{
3030
3131#[ cfg( feature = "profiling" ) ]
3232use crate :: profile_span;
33- use crate :: transcript:: { Role , Status , Transcript , Turn , Block } ;
33+ use crate :: transcript:: { Block , Role , Status , Transcript , Turn } ;
3434
3535/// Chat view with native scrollback support.
3636///
@@ -81,20 +81,13 @@ impl ChatView {
8181 // ==================== Transcript mutation + render ====================
8282
8383 /// Begin a new turn and render
84- pub fn begin_turn (
85- & mut self ,
86- role : Role ,
87- terminal : & mut Terminal < CrosstermBackend < Stdout > > ,
88- ) {
84+ pub fn begin_turn ( & mut self , role : Role , terminal : & mut Terminal < CrosstermBackend < Stdout > > ) {
8985 self . transcript . begin_turn ( role) ;
9086 self . render ( terminal)
9187 }
9288
9389 /// Finish the current turn and render
94- pub fn finish_turn (
95- & mut self ,
96- terminal : & mut Terminal < CrosstermBackend < Stdout > > ,
97- ) {
90+ pub fn finish_turn ( & mut self , terminal : & mut Terminal < CrosstermBackend < Stdout > > ) {
9891 self . transcript . finish_turn ( ) ;
9992 self . render ( terminal)
10093 }
@@ -136,10 +129,7 @@ impl ChatView {
136129
137130 /// Render active (non-frozen) turns into the hot zone.
138131 /// Overflow lines are committed to native scrollback via `insert_before()`.
139- pub fn render (
140- & mut self ,
141- terminal : & mut Terminal < CrosstermBackend < Stdout > > ,
142- ) {
132+ pub fn render ( & mut self , terminal : & mut Terminal < CrosstermBackend < Stdout > > ) {
143133 #[ cfg( feature = "profiling" ) ]
144134 let _span = profile_span ! ( "ChatView::render" ) ;
145135
@@ -162,7 +152,9 @@ impl ChatView {
162152
163153 tracing:: trace!(
164154 "render(): hot_lines={}, committed_count={}, max_lines={}" ,
165- hot_lines. len( ) , self . committed_count, self . max_lines
155+ hot_lines. len( ) ,
156+ self . committed_count,
157+ self . max_lines
166158 ) ;
167159
168160 self . lines . clear ( ) ;
@@ -173,10 +165,14 @@ impl ChatView {
173165 // Overflow promotes to scrollback
174166 while self . lines . len ( ) > self . max_lines {
175167 let committed = self . lines . pop_front ( ) . unwrap ( ) ;
176- let line_preview: String = committed. spans . iter ( ) . map ( |s| s. content . as_ref ( ) ) . collect ( ) ;
168+ let line_preview: String =
169+ committed. spans . iter ( ) . map ( |s| s. content . as_ref ( ) ) . collect ( ) ;
177170 tracing:: trace!(
178171 "Scrollback commit: line={:?}, committed_count={}, lines.len={}, max={}" ,
179- line_preview, self . committed_count, self . lines. len( ) , self . max_lines
172+ line_preview,
173+ self . committed_count,
174+ self . lines. len( ) ,
175+ self . max_lines
180176 ) ;
181177
182178 if let Err ( e) = terminal. insert_before ( 1 , |buf| {
@@ -294,5 +290,3 @@ impl Widget for ChatViewWidget<'_> {
294290 Paragraph :: new ( visible) . render ( area, buf) ;
295291 }
296292}
297-
298-
0 commit comments