@@ -1158,6 +1158,37 @@ describe("ClineProvider - Parallel Mode Support", () => {
11581158 } )
11591159 } )
11601160
1161+ describe ( "provider profile activation" , ( ) => {
1162+ it ( "should sync view-local apiConfiguration when activating an upserted profile" , async ( ) => {
1163+ const provider = new ClineProvider ( mockContext , mockOutputChannel , "sidebar" , new ContextProxy ( mockContext ) )
1164+ await ( provider as any ) . saveViewState ( "apiConfiguration" , {
1165+ apiProvider : "openrouter" ,
1166+ openRouterModelId : "openai/gpt-4.1" ,
1167+ } )
1168+
1169+ const providerSettings = {
1170+ apiProvider : "zai" as const ,
1171+ zaiApiKey : "mock-key" ,
1172+ zaiApiLine : "international_api" as const ,
1173+ apiModelId : "glm-5.1" ,
1174+ }
1175+ vi . spyOn ( provider . providerSettingsManager , "saveConfig" ) . mockResolvedValue ( "zai-profile-id" )
1176+ vi . spyOn ( provider . providerSettingsManager , "listConfig" ) . mockResolvedValue ( [
1177+ { name : "default" , id : "zai-profile-id" , apiProvider : "zai" } ,
1178+ ] )
1179+
1180+ await provider . upsertProviderProfile ( "default" , providerSettings , true )
1181+
1182+ const state = await provider . getState ( )
1183+ expect ( state . currentApiConfigName ) . toBe ( "default" )
1184+ expect ( state . apiConfiguration ) . toMatchObject ( providerSettings )
1185+ expect ( state . apiConfiguration . apiProvider ) . toBe ( "zai" )
1186+ expect ( ( provider as any ) . viewLocalState . apiConfiguration ) . toMatchObject ( providerSettings )
1187+
1188+ await provider . dispose ( )
1189+ } )
1190+ } )
1191+
11611192 describe ( "_clearViewLocalState" , ( ) => {
11621193 it ( "should clear all view-local state values" , async ( ) => {
11631194 const provider = new ClineProvider ( mockContext , mockOutputChannel , "sidebar" , new ContextProxy ( mockContext ) )
0 commit comments