11use ratatui:: {
2+ Frame ,
23 layout:: { Constraint , Layout , Rect } ,
34 style:: { Color , Modifier , Style } ,
45 text:: { Line , Span } ,
56 widgets:: { Block , Borders , Cell , Paragraph , Row , Table , Wrap } ,
6- Frame ,
77} ;
88
9- use crate :: {
10- app:: message_picker:: MessagePickerState ,
11- ui:: sidebar:: relative_time_from_updated,
12- } ;
9+ use crate :: { app:: message_picker:: MessagePickerState , ui:: sidebar:: relative_time_from_updated} ;
1310
1411pub fn render_message_picker ( frame : & mut Frame , picker : & mut MessagePickerState , area : Rect ) {
1512 let block = Block :: default ( )
@@ -31,19 +28,21 @@ pub fn render_message_picker(frame: &mut Frame, picker: &mut MessagePickerState,
3128 ] )
3229 . areas ( inner) ;
3330
34- let [ table_area, preview_area] = Layout :: vertical ( [
35- Constraint :: Percentage ( 55 ) ,
36- Constraint :: Percentage ( 45 ) ,
37- ] )
38- . areas ( body_area) ;
31+ let [ table_area, preview_area] =
32+ Layout :: vertical ( [ Constraint :: Percentage ( 55 ) , Constraint :: Percentage ( 45 ) ] ) . areas ( body_area) ;
3933
4034 let search_line = Line :: from ( vec ! [
41- Span :: styled( " Search: " , Style :: default ( ) . fg( Color :: Cyan ) . add_modifier( Modifier :: BOLD ) ) ,
35+ Span :: styled(
36+ " Search: " ,
37+ Style :: default ( )
38+ . fg( Color :: Cyan )
39+ . add_modifier( Modifier :: BOLD ) ,
40+ ) ,
4241 Span :: raw( & picker. query) ,
4342 Span :: styled( "█" , Style :: default ( ) . fg( Color :: Cyan ) ) ,
4443 ] ) ;
4544 frame. render_widget ( Paragraph :: new ( search_line) , search_area) ;
46-
45+
4746 // Render empty spacer
4847 frame. render_widget ( Paragraph :: new ( "" ) , spacer_area) ;
4948
@@ -64,15 +63,21 @@ pub fn render_message_picker(frame: &mut Frame, picker: &mut MessagePickerState,
6463 let header = Row :: new ( vec ! [
6564 Cell :: from( Span :: styled(
6665 "Session" ,
67- Style :: default ( ) . add_modifier( Modifier :: BOLD ) . fg( Color :: Cyan ) ,
66+ Style :: default ( )
67+ . add_modifier( Modifier :: BOLD )
68+ . fg( Color :: Cyan ) ,
6869 ) ) ,
6970 Cell :: from( Span :: styled(
7071 "Message" ,
71- Style :: default ( ) . add_modifier( Modifier :: BOLD ) . fg( Color :: Cyan ) ,
72+ Style :: default ( )
73+ . add_modifier( Modifier :: BOLD )
74+ . fg( Color :: Cyan ) ,
7275 ) ) ,
7376 Cell :: from( Span :: styled(
7477 "Time" ,
75- Style :: default ( ) . add_modifier( Modifier :: BOLD ) . fg( Color :: Cyan ) ,
78+ Style :: default ( )
79+ . add_modifier( Modifier :: BOLD )
80+ . fg( Color :: Cyan ) ,
7681 ) ) ,
7782 ] ) ;
7883
@@ -81,30 +86,49 @@ pub fn render_message_picker(frame: &mut Frame, picker: &mut MessagePickerState,
8186 . enumerate ( )
8287 . map ( |( i, ( entry, title_idx, text_idx) ) | {
8388 let is_selected = i + picker. scroll_offset == picker. selected ;
84-
89+
8590 // Session Title Styling
8691 let ( title_normal, title_highlight) = if is_selected {
87- ( Style :: default ( ) . fg ( Color :: White ) . bg ( Color :: DarkGray ) . add_modifier ( Modifier :: BOLD ) , selected_matched_style)
92+ (
93+ Style :: default ( )
94+ . fg ( Color :: White )
95+ . bg ( Color :: DarkGray )
96+ . add_modifier ( Modifier :: BOLD ) ,
97+ selected_matched_style,
98+ )
8899 } else {
89- ( Style :: default ( ) . fg ( Color :: Cyan ) . add_modifier ( Modifier :: BOLD ) , matched_style)
100+ (
101+ Style :: default ( )
102+ . fg ( Color :: Cyan )
103+ . add_modifier ( Modifier :: BOLD ) ,
104+ matched_style,
105+ )
90106 } ;
91107
92108 // Message Preview Styling (dimmer)
93109 let ( text_normal, text_highlight) = if is_selected {
94- ( Style :: default ( ) . fg ( Color :: White ) . bg ( Color :: DarkGray ) , selected_matched_style)
110+ (
111+ Style :: default ( ) . fg ( Color :: White ) . bg ( Color :: DarkGray ) ,
112+ selected_matched_style,
113+ )
95114 } else {
96115 ( Style :: default ( ) . fg ( Color :: DarkGray ) , matched_style)
97116 } ;
98-
117+
99118 // Time Styling
100119 let time_style = if is_selected {
101120 Style :: default ( ) . fg ( Color :: White ) . bg ( Color :: DarkGray )
102121 } else {
103122 Style :: default ( ) . fg ( Color :: DarkGray )
104123 } ;
105124
106- let title_cell = Cell :: from ( highlight_text ( & entry. session_title , title_idx, title_normal, title_highlight) ) ;
107-
125+ let title_cell = Cell :: from ( highlight_text (
126+ & entry. session_title ,
127+ title_idx,
128+ title_normal,
129+ title_highlight,
130+ ) ) ;
131+
108132 // Truncate text for the table view so it doesn't wrap awkwardly
109133 let max_text_len = 100 ; // Arbitrary max length for the preview column
110134 let display_text = if entry. compact_text . chars ( ) . count ( ) > max_text_len {
@@ -114,9 +138,14 @@ pub fn render_message_picker(frame: &mut Frame, picker: &mut MessagePickerState,
114138 } else {
115139 entry. compact_text . clone ( )
116140 } ;
117-
118- let text_cell = Cell :: from ( highlight_text ( & display_text, text_idx, text_normal, text_highlight) ) ;
119-
141+
142+ let text_cell = Cell :: from ( highlight_text (
143+ & display_text,
144+ text_idx,
145+ text_normal,
146+ text_highlight,
147+ ) ) ;
148+
120149 let time = relative_time_from_updated ( Some ( entry. time_created ) ) ;
121150 let time_cell = Cell :: from ( Span :: styled ( time, time_style) ) ;
122151
@@ -156,7 +185,10 @@ pub fn render_message_picker(frame: &mut Frame, picker: &mut MessagePickerState,
156185 ) ;
157186 } else {
158187 frame. render_widget (
159- Paragraph :: new ( Span :: styled ( "No matching messages." , Style :: default ( ) . fg ( Color :: DarkGray ) ) ) ,
188+ Paragraph :: new ( Span :: styled (
189+ "No matching messages." ,
190+ Style :: default ( ) . fg ( Color :: DarkGray ) ,
191+ ) ) ,
160192 preview_inner,
161193 ) ;
162194 }
0 commit comments