I have a kinda related story, no idea if it helps in any way, but I feel like sharing.
I've been close friends with a couple, let's call them John and Mary, for quite a while, they were happily in a relationship for well over 4 years, and they ran into similiar problems. Mary liked to flirt around, which sometimes troubled John, but for a long time, it has not been a serious problem. John always told her things could turn complicated if some guy she flirted with developed feelings for her, Mary always brushed it off saying they would realize it was harmless flirting.
More recently, Mary started flirting with me and as I wasn't expecting it to lead anywhere, having a track record of not falling in love with women who are already in relationship, I played along. What I didn't know at that point was that Mary and John were fighting a lot in the months before that, that their relationship was not as happy as I assumed it to be, and even though the flirting was harmless to me at first, it wasn't as harmless to her.
Eventually, she admitted to falling in love with me and wishing to be with me instead. Out of respect for John, being unsure if things would stay this way, and both of them having big exams coming up, I told her we should think about how to go on about this in the future after their exams (I should have probably broken it off at the point it got obvious it was more serious for her than I thought, but being on the forever alone track I enjoyed spending time with her too much to be able to do that).
I think this emotionally confused Mary, she didn't really know what to do while also being stressed by exam preperations, she wasn't sure if she wanted to be with me, if she just wanted to get out of her current relationship, or if she just needed to get things right with John again. Also not being able to diffentiate between harmless and harmful flirting anymore, she ended up (physically) cheating on John with another guy who also flirted a lot with her. Which led to John breaking up with her.
Only then Mary realized how wrong everything she did was, how much she had with John, how wrong it was risking everything she had for a bit of fun with someone she knew not half as long as John (she knew me for a year when it all started, not sure about the other guy, but not much longer), where a bit of flirting could eventually lead, that losing John was more than she could handle etc etc. I think what hit mer most that she not only lost her partner, but also her closest friend who has been always there for her, no matter what problems she faced, throughout all those years.
While I don't think John will be able to forgive her and Mary realized her mistakes way too late, it still goes to show people can learn from their mistakes and even when they appear to have given up on the relationship, deep down they still care, but it takes the right triggers to bring that back up to the surface.
I don't know if you can find that trigger for your wife, I don't know if it's too late for you too, but maybe you can find a way to make her realize what she is really risking there, and maybe that will help her clear up her mind.