My dog only loves me sometimes?

If any of you out here know about dog personalities I need your help. My family got a new dog, Kepler, 4 months ago. He’s a year old and a rescue so we don’t know much about his past. Kepler loves cuddling, hugging and licking me except when my moms near by. Last night I was sitting on the couch with Kepler and my mom came and sat in between us and his mood immediately changed. He was looking at me with this kind of scared wide-eyed look so my mom blocked his view and then he got up and tried coming at me with a not very nice bark. After that my mom switched couches I went to go pet him and he started cuddling with me again. The same thing happens in the kitchen if my moms doing something and I get in the way he angry barks at me.

My mom is definitely his main care giver and he kind of views her as the top dog cause when he’s doing something bad my mom can get him to stop immediately without trying. This behavior is kind of recent and might be related to the sedative medication he’s been on cause a month ago he got surgery to fix his trick knee. I was just wondering if anyone had any insight.