I have a mother who is so profoundly mentally ill that we don't have contact. That said, there is another key parent person in my life who also has some mental illness and we do see them from time to time.
I do things which help me to feel good while being around them. Like making sure I get enough sleep and feel good before going to visit them. This person has gone off their meds before our visits, so I figure that I don't have the luxury of messing with my own body chemistry. (I have medication to treat anxiety). One of us has to stay sane. ;)
I also sort of 'front load' myself with safe topics to discuss. I don't talk politics with this person, and they aren't a discreet person, so I know that anything I tell them can be repeated to the entire family with their own additional commentary and opinion. So, I don't share anything very personal regarding myself, my husband or Kiddo. I do stick to benign things: that person's other interests, the weather, favorite movies or tv shows, places we have gone to... safe memories.
I love this person very much and they were truly a lifeline in a time of need a long time ago. I've gotten better, more mature as this person has declined, both in mental health and memory issues. I have a lot of compassion for them, because I know they mean well and are just stuck in their thinking, which is unproductive. I also keep visits very short, otherwise I get to feeling angry at their constant need for validation. It's a drain. So, we stay at a hotel instead of their home if in town. I have noticed that this person has a compulsive need to pick at me at times and confront me on things which most people would not even care about. They need constant agreement of their opinion. So, again, I gently try to steer the conversation to things which they are 'okay' with other people having different opinions about. (again, books and movies, steering away from religion, politics, family business, etc). I stay in relationship because A. I genuinely care about this person, B. they are *trying* and do want relationship and will sometimes admit their mistakes in a moment of clarity and C. I was extremely deliberate in choosing to make a big boundary with my mom, for health and safety reasons, and while this person does annoying things, it's not to the same detrimental level.
Complex but I've worked on this for a long, long time and feel good about the choices we are making. That person also feels loved by us, which is important. I want to give back to them the love that they gave me when I needed it most.