@@ -9770,6 +9770,19 @@ impl ThemeCapture {
97709770 }
97719771 out
97729772 }
9773+ fn drain_visible_events ( & self ) -> Vec < ( Option < u32 > , bool ) > {
9774+ let mut out = Vec :: new ( ) ;
9775+ while let Ok ( ( instr, _ctx) ) = self . plugin_rx . try_recv ( ) {
9776+ if let PluginInstruction :: Update ( updates) = instr {
9777+ for ( pid, _cid, ev) in updates {
9778+ if let Event :: Visible ( is_visible) = ev {
9779+ out. push ( ( pid, is_visible) ) ;
9780+ }
9781+ }
9782+ }
9783+ }
9784+ out
9785+ }
97739786 fn drain_pty_writes ( & self ) -> Vec < ( Vec < u8 > , u32 ) > {
97749787 let mut out = Vec :: new ( ) ;
97759788 while let Ok ( ( instr, _ctx) ) = self . pty_writer_rx . try_recv ( ) {
@@ -9781,6 +9794,41 @@ impl ThemeCapture {
97819794 }
97829795}
97839796
9797+ #[ test]
9798+ fn reattaching_a_client_restores_floating_pane_visibility_notifications ( ) {
9799+ let size = Size {
9800+ cols : 121 ,
9801+ rows : 20 ,
9802+ } ;
9803+ let ( mut screen, capture) = create_new_screen_with_theme_capture ( size) ;
9804+ new_tab ( & mut screen, 1 , 0 ) ;
9805+ screen
9806+ . get_active_tab_mut ( 1 )
9807+ . unwrap ( )
9808+ . new_pane (
9809+ PaneId :: Plugin ( 2 ) ,
9810+ None ,
9811+ None ,
9812+ false ,
9813+ true ,
9814+ NewPanePlacement :: Floating ( None ) ,
9815+ Some ( 1 ) ,
9816+ None ,
9817+ )
9818+ . unwrap ( ) ;
9819+
9820+ screen. remove_client ( 1 ) . expect ( "TEST" ) ;
9821+ screen. add_client ( 1 , false ) . expect ( "TEST" ) ;
9822+ let _ = capture. drain_visible_events ( ) ;
9823+ screen. get_active_tab_mut ( 1 ) . unwrap ( ) . hide_floating_panes ( ) ;
9824+
9825+ assert ! (
9826+ capture. drain_visible_events( ) . contains( & ( Some ( 2 ) , false ) ) ,
9827+ "a floating plugin must still be told when its surface is hidden after a reattach, \
9828+ otherwise plugins idling on a timer keep working while off screen"
9829+ ) ;
9830+ }
9831+
97849832fn create_new_screen_with_theme_capture ( size : Size ) -> ( Screen , ThemeCapture ) {
97859833 let ( plugin_tx, plugin_rx) = channels:: unbounded :: < ( PluginInstruction , ErrorContext ) > ( ) ;
97869834 let ( pty_writer_tx, pty_writer_rx) =
@@ -10269,6 +10317,50 @@ fn removing_explicit_theme_hue_hands_authority_back_to_the_host() {
1026910317 ) ;
1027010318}
1027110319
10320+ #[ test]
10321+ fn pinning_the_current_hue_repaints_the_resolved_palette ( ) {
10322+ let size = Size { cols : 80 , rows : 20 } ;
10323+ let ( mut screen, _capture) = create_new_screen_with_dark_and_light_themes ( size) ;
10324+ screen
10325+ . update_host_terminal_theme_mode ( zellij_utils:: data:: HostTerminalThemeMode :: Dark )
10326+ . expect ( "host report applied" ) ;
10327+ screen. style . colors = styling_with_background ( ( 1 , 2 , 3 ) ) ;
10328+
10329+ screen
10330+ . apply_configured_explicit_theme_hue ( Some ( zellij_utils:: data:: ThemeHue :: Dark ) )
10331+ . expect ( "explicit hue applied" ) ;
10332+
10333+ assert_eq ! (
10334+ screen. style. colors. text_unselected. background,
10335+ zellij_utils:: data:: PaletteColor :: Rgb ( TEST_DARK_BG ) ,
10336+ "pinning the hue the session is already in must still resolve the palette, \
10337+ otherwise a reconfigure leaves the session painted with the static theme"
10338+ ) ;
10339+ }
10340+
10341+ #[ test]
10342+ fn unpinning_back_to_the_current_hue_repaints_the_resolved_palette ( ) {
10343+ let size = Size { cols : 80 , rows : 20 } ;
10344+ let ( mut screen, _capture) = create_new_screen_with_dark_and_light_themes ( size) ;
10345+ screen
10346+ . update_host_terminal_theme_mode ( zellij_utils:: data:: HostTerminalThemeMode :: Dark )
10347+ . expect ( "host report applied" ) ;
10348+ screen
10349+ . apply_configured_explicit_theme_hue ( Some ( zellij_utils:: data:: ThemeHue :: Dark ) )
10350+ . expect ( "explicit hue applied" ) ;
10351+ screen. style . colors = styling_with_background ( ( 1 , 2 , 3 ) ) ;
10352+
10353+ screen
10354+ . apply_configured_explicit_theme_hue ( None )
10355+ . expect ( "unpinned" ) ;
10356+
10357+ assert_eq ! (
10358+ screen. style. colors. text_unselected. background,
10359+ zellij_utils:: data:: PaletteColor :: Rgb ( TEST_DARK_BG ) ,
10360+ "unpinning to the mode the session is already in must still resolve the palette"
10361+ ) ;
10362+ }
10363+
1027210364#[ test]
1027310365fn effective_theme_mode_is_reasserted_after_a_theme_definition_change ( ) {
1027410366 let size = Size { cols : 80 , rows : 20 } ;
0 commit comments