@@ -3584,6 +3584,66 @@ async fn collab_mode_shift_tab_cycles_only_when_enabled_and_idle() {
35843584 assert_eq ! ( chat. active_collaboration_mode_kind( ) , before) ;
35853585}
35863586
3587+ #[ tokio:: test]
3588+ async fn mode_switch_surfaces_model_change_notification_when_effective_model_changes ( ) {
3589+ let ( mut chat, mut rx, _op_rx) = make_chatwidget_manual ( Some ( "gpt-5" ) ) . await ;
3590+ chat. set_feature_enabled ( Feature :: CollaborationModes , true ) ;
3591+ let default_model = chat. current_model ( ) . to_string ( ) ;
3592+
3593+ let mut plan_mask =
3594+ collaboration_modes:: mask_for_kind ( chat. models_manager . as_ref ( ) , ModeKind :: Plan )
3595+ . expect ( "expected plan collaboration mode" ) ;
3596+ plan_mask. model = Some ( "gpt-5.1-codex-mini" . to_string ( ) ) ;
3597+ chat. set_collaboration_mask ( plan_mask) ;
3598+
3599+ let plan_messages = drain_insert_history ( & mut rx)
3600+ . iter ( )
3601+ . map ( |lines| lines_to_single_string ( lines) )
3602+ . collect :: < Vec < _ > > ( )
3603+ . join ( "\n " ) ;
3604+ assert ! (
3605+ plan_messages. contains( "Model changed to gpt-5.1-codex-mini medium for Plan mode." ) ,
3606+ "expected Plan-mode model switch notice, got: {plan_messages:?}"
3607+ ) ;
3608+
3609+ let default_mask = collaboration_modes:: default_mask ( chat. models_manager . as_ref ( ) )
3610+ . expect ( "expected default collaboration mode" ) ;
3611+ chat. set_collaboration_mask ( default_mask) ;
3612+
3613+ let default_messages = drain_insert_history ( & mut rx)
3614+ . iter ( )
3615+ . map ( |lines| lines_to_single_string ( lines) )
3616+ . collect :: < Vec < _ > > ( )
3617+ . join ( "\n " ) ;
3618+ let expected_default_message =
3619+ format ! ( "Model changed to {default_model} default for Default mode." ) ;
3620+ assert ! (
3621+ default_messages. contains( & expected_default_message) ,
3622+ "expected Default-mode model switch notice, got: {default_messages:?}"
3623+ ) ;
3624+ }
3625+
3626+ #[ tokio:: test]
3627+ async fn mode_switch_surfaces_reasoning_change_notification_when_model_stays_same ( ) {
3628+ let ( mut chat, mut rx, _op_rx) = make_chatwidget_manual ( Some ( "gpt-5.3-codex" ) ) . await ;
3629+ chat. set_feature_enabled ( Feature :: CollaborationModes , true ) ;
3630+ chat. set_reasoning_effort ( Some ( ReasoningEffortConfig :: High ) ) ;
3631+
3632+ let plan_mask = collaboration_modes:: plan_mask ( chat. models_manager . as_ref ( ) )
3633+ . expect ( "expected plan collaboration mode" ) ;
3634+ chat. set_collaboration_mask ( plan_mask) ;
3635+
3636+ let plan_messages = drain_insert_history ( & mut rx)
3637+ . iter ( )
3638+ . map ( |lines| lines_to_single_string ( lines) )
3639+ . collect :: < Vec < _ > > ( )
3640+ . join ( "\n " ) ;
3641+ assert ! (
3642+ plan_messages. contains( "Model changed to gpt-5.3-codex medium for Plan mode." ) ,
3643+ "expected reasoning-change notice in Plan mode, got: {plan_messages:?}"
3644+ ) ;
3645+ }
3646+
35873647#[ tokio:: test]
35883648async fn collab_slash_command_opens_picker_and_updates_mode ( ) {
35893649 let ( mut chat, mut rx, mut op_rx) = make_chatwidget_manual ( None ) . await ;
@@ -3649,7 +3709,12 @@ async fn plan_slash_command_switches_to_plan_mode() {
36493709
36503710 chat. dispatch_command ( SlashCommand :: Plan ) ;
36513711
3652- assert ! ( rx. try_recv( ) . is_err( ) , "plan should not emit an app event" ) ;
3712+ while let Ok ( event) = rx. try_recv ( ) {
3713+ assert ! (
3714+ matches!( event, AppEvent :: InsertHistoryCell ( _) ) ,
3715+ "plan should not emit a non-history app event: {event:?}"
3716+ ) ;
3717+ }
36533718 assert_eq ! ( chat. active_collaboration_mode_kind( ) , ModeKind :: Plan ) ;
36543719 assert_eq ! ( chat. current_collaboration_mode( ) , & initial) ;
36553720}
0 commit comments