@@ -960,3 +960,65 @@ pub fn render_motd_compact(
960960
961961 Paragraph :: new ( lines) . render ( text_area, buf) ;
962962}
963+
964+ /// Renders an update notification banner above the input box.
965+ /// Shows different states: Available, Downloading (with progress), ReadyToRestart
966+ pub fn render_update_banner (
967+ area : Rect ,
968+ buf : & mut Buffer ,
969+ colors : & AdaptiveColors ,
970+ update_status : & crate :: app:: UpdateStatus ,
971+ ) {
972+ use crate :: app:: UpdateStatus ;
973+
974+ if area. is_empty ( ) || area. height < 1 {
975+ return ;
976+ }
977+
978+ let ( icon, text, style) = match update_status {
979+ UpdateStatus :: Available { version } => {
980+ let icon = "↑" ;
981+ let text = format ! ( " A new version ({}) is available " , version) ;
982+ let style = Style :: default ( )
983+ . fg ( colors. accent )
984+ . add_modifier ( Modifier :: BOLD ) ;
985+ ( icon, text, style)
986+ }
987+ UpdateStatus :: Downloading {
988+ version : _,
989+ progress,
990+ } => {
991+ let icon = "⟳" ;
992+ let text = format ! ( " Downloading update... {}% " , progress) ;
993+ let style = Style :: default ( ) . fg ( colors. warning ) ;
994+ ( icon, text, style)
995+ }
996+ UpdateStatus :: ReadyToRestart { version : _ } => {
997+ let icon = "✓" ;
998+ let text = " You must restart to run the latest version " . to_string ( ) ;
999+ let style = Style :: default ( )
1000+ . fg ( colors. success )
1001+ . add_modifier ( Modifier :: BOLD ) ;
1002+ ( icon, text, style)
1003+ }
1004+ _ => return , // Don't render for other states
1005+ } ;
1006+
1007+ // Calculate banner width
1008+ let banner_width = ( icon. len ( ) + text. len ( ) + 2 ) as u16 ; // +2 for spacing
1009+
1010+ // Position at left side of the area with some padding
1011+ let x = area. x + 2 ;
1012+ let y = area. y ;
1013+
1014+ // Ensure we don't overflow
1015+ if x + banner_width > area. right ( ) {
1016+ return ;
1017+ }
1018+
1019+ // Render icon
1020+ buf. set_string ( x, y, icon, style) ;
1021+
1022+ // Render text
1023+ buf. set_string ( x + icon. len ( ) as u16 + 1 , y, & text, style) ;
1024+ }
0 commit comments