How do I deal with students being unkind to each other when I'm not there?
I have a couple thoughts of how I'd handle it:


Address it with the bad actors 1-on-1, but don't assume bad faith. We might not know the whole story and there might have been a good reason to walk away from a situation or it is possible that the bad actor has poor social skills. Give them the benefit of the doubt, but explain why that kind of behavior creates a hostile environment that is not good for education.
Discuss in class what makes for a good working/learning environment. Not necessarily directly mentioning the situation, you can still emphasize a need for students to take agency in being part of a nurturing environment. I haven't had the exact same circumstances, but I have found it helpful by acknowledging that most jobs require interpersonal skills and that I've known even talented developers who have been passed up for good jobs because no one wanted to put up with their attitudes. In that same notion, I tell my software engineering students that I expect them to behave like professionals and like the class is a part-time job. That includes treating others with respect, even if they don't consider each other friends.


If you find it is a continuing problem, you might consider working into your assessment plan some way (even as a small percentage of the overall grade) to evaluate individuals' professionalism in-and-out of the classroom.