If she truly is a friend, take her aside and make up a code word. Tell her that if either of you starts to go over the boundary of comfort in a social or work situation, the friend will use the code word to request a change of topic, or at least to warn the other they are being offensive. When I have extended family at my house, I get tense easily. My daughter uses the word "chamomile" to warn me to chill out. She'll ask if I'd like a cup of chamomile tea, or ask if I have any in my garden, etc. It works!