@@ -570,6 +570,98 @@ def marker_cleared() -> bool:
570570 assert retry_until (marker_cleared , raises = False )
571571
572572
573+ class PostBuildSuppressHistoryFixture (t .NamedTuple ):
574+ """Fixture for post-build suppress_history behavior."""
575+
576+ test_id : str
577+ suppress_history : bool | None
578+ expected_suppress_history : bool
579+
580+
581+ POST_BUILD_SUPPRESS_HISTORY_FIXTURES : list [PostBuildSuppressHistoryFixture ] = [
582+ PostBuildSuppressHistoryFixture (
583+ test_id = "default" ,
584+ suppress_history = None ,
585+ expected_suppress_history = True ,
586+ ),
587+ PostBuildSuppressHistoryFixture (
588+ test_id = "explicit-false" ,
589+ suppress_history = False ,
590+ expected_suppress_history = False ,
591+ ),
592+ ]
593+
594+
595+ @pytest .mark .parametrize (
596+ list (PostBuildSuppressHistoryFixture ._fields ),
597+ POST_BUILD_SUPPRESS_HISTORY_FIXTURES ,
598+ ids = [fixture .test_id for fixture in POST_BUILD_SUPPRESS_HISTORY_FIXTURES ],
599+ )
600+ def test_post_build_commands_honor_suppress_history (
601+ session : Session ,
602+ monkeypatch : pytest .MonkeyPatch ,
603+ test_id : str ,
604+ suppress_history : bool | None ,
605+ expected_suppress_history : bool ,
606+ ) -> None :
607+ """Post-build commands use the window suppress_history setting."""
608+ sent : list [tuple [str | None , bool | None ]] = []
609+ original_send_keys = Pane .send_keys
610+
611+ def spy_send_keys (
612+ self : Pane ,
613+ cmd : str | None = None ,
614+ enter : bool | None = True ,
615+ suppress_history : bool | None = False ,
616+ literal : bool | None = False ,
617+ reset : bool | None = None ,
618+ copy_mode_cmd : str | None = None ,
619+ repeat : int | None = None ,
620+ expand_formats : bool | None = None ,
621+ hex_keys : bool | None = None ,
622+ target_client : str | None = None ,
623+ key_name : bool | None = None ,
624+ ) -> None :
625+ sent .append ((cmd , suppress_history ))
626+ original_send_keys (
627+ self ,
628+ cmd = cmd ,
629+ enter = enter ,
630+ suppress_history = suppress_history ,
631+ literal = literal ,
632+ reset = reset ,
633+ copy_mode_cmd = copy_mode_cmd ,
634+ repeat = repeat ,
635+ expand_formats = expand_formats ,
636+ hex_keys = hex_keys ,
637+ target_client = target_client ,
638+ key_name = key_name ,
639+ )
640+
641+ monkeypatch .setattr (Pane , "send_keys" , spy_send_keys )
642+
643+ window_config : dict [str , t .Any ] = {
644+ "window_name" : f"post-build-history-{ test_id } " ,
645+ "shell_command_after" : ["echo __POST_BUILD_AFTER__" ],
646+ "clear" : True ,
647+ "panes" : ["echo pane" ],
648+ }
649+ if suppress_history is not None :
650+ window_config ["suppress_history" ] = suppress_history
651+
652+ workspace : dict [str , t .Any ] = {
653+ "session_name" : session .name ,
654+ "windows" : [window_config ],
655+ }
656+ workspace = loader .expand (workspace )
657+
658+ builder = WorkspaceBuilder (session_config = workspace , server = session .server )
659+ builder .build (session = session )
660+
661+ assert ("echo __POST_BUILD_AFTER__" , expected_suppress_history ) in sent
662+ assert ("clear" , expected_suppress_history ) in sent
663+
664+
573665def test_window_shell (
574666 session : Session ,
575667) -> None :
0 commit comments