@@ -764,3 +764,59 @@ it("routes legacy model preference keys exclusively to the selected environment"
764764 } ,
765765 ] ) ;
766766} ) ;
767+
768+ describe ( "model selection patches at project scope" , ( ) => {
769+ const codex = ProviderInstanceId . make ( "codex" ) ;
770+ const claude = ProviderInstanceId . make ( "claudeAgent" ) ;
771+ const saved = {
772+ instanceId : codex ,
773+ model : "gpt-5.6" ,
774+ options : [ { id : "reasoningEffort" , value : "high" } ] ,
775+ } ;
776+ const customized = environment ( "Server" , {
777+ settings : {
778+ projectSettingsOverrides : {
779+ [ projectId ] : {
780+ defaultModelSelection : saved ,
781+ sourceControlWriterModelSelection : saved ,
782+ reviewGuideModelSelection : saved ,
783+ textGenerationModelSelection : saved ,
784+ } ,
785+ } ,
786+ } ,
787+ } ) ;
788+
789+ it ( "replaces old options when changing model selections" , ( ) => {
790+ const plan = planScopedSettingsPatch ( checkout , [ customized ] , {
791+ defaultModelSelection : { instanceId : claude , model : "claude-opus-4-8" } ,
792+ sourceControlWriterModelSelection : { instanceId : codex , model : "gpt-5.6-mini" } ,
793+ reviewGuideModelSelection : { instanceId : codex , model : "gpt-5.6-mini" } ,
794+ textGenerationModelSelection : { instanceId : claude , model : "claude-sonnet-4-6" } ,
795+ } ) ;
796+ expect ( plan . serverWrites [ 0 ] ?. patch . projectSettingsOverrides ?. [ projectId ] ) . toEqual ( {
797+ defaultModelSelection : { instanceId : claude , model : "claude-opus-4-8" } ,
798+ sourceControlWriterModelSelection : { instanceId : codex , model : "gpt-5.6-mini" } ,
799+ reviewGuideModelSelection : { instanceId : codex , model : "gpt-5.6-mini" } ,
800+ textGenerationModelSelection : { instanceId : claude , model : "claude-sonnet-4-6" } ,
801+ } ) ;
802+ } ) ;
803+
804+ it ( "completes partial text-generation selections without retaining old options" , ( ) => {
805+ const modelPlan = planScopedSettingsPatch ( checkout , [ customized ] , {
806+ textGenerationModelSelection : { model : "gpt-5.6-mini" } ,
807+ } ) ;
808+ expect (
809+ modelPlan . serverWrites [ 0 ] ?. patch . projectSettingsOverrides ?. [ projectId ]
810+ ?. textGenerationModelSelection ,
811+ ) . toEqual ( { instanceId : codex , model : "gpt-5.6-mini" } ) ;
812+
813+ const options = [ { id : "reasoningEffort" , value : "low" } ] ;
814+ const optionsPlan = planScopedSettingsPatch ( checkout , [ customized ] , {
815+ textGenerationModelSelection : { options } ,
816+ } ) ;
817+ expect (
818+ optionsPlan . serverWrites [ 0 ] ?. patch . projectSettingsOverrides ?. [ projectId ]
819+ ?. textGenerationModelSelection ,
820+ ) . toEqual ( { ...saved , options } ) ;
821+ } ) ;
822+ } ) ;
0 commit comments