My husband and I purchased a house together. The mortgage is in both names. I moved out and am legally separated. He rents out a room now to the same person for many years. In the future, will the renter have any claims to the property since she has been living there for so many years?
You must be careful here. Your estranged husband obviously has no personal stake in your recovering the 50% of your equity in the home. There are complex legal questions about who is paying the mortgage and what happens in this case. Given the value of the asset, it's worth having a lawyer review it every couple of years just to make sure you aren't being gypped. (either by neglect or nefarious plan).
Now as far as the tenant staking a claim
"Adverse Possession" is what you're thinking of. However adverse possession has several components, most of which make no sense here unless the tenant is your husband's new wife.
The usage must be for a long time. "Long time" means 10-30 years depending on state law - a significant fraction of a lifetime.
The usage must be Unauthorized. Adverse possession fails if there's any sort of agreement: lease, payment of rent, exchange of value, anything like that. So an agreement with your husband voids the tenant's claim of adverse possession against you.
The usage must be continuous -- if you regain control of the property even for 1 day, that voids adverse possession. Say you fumigate the house where they tent the house for a weekend and everyone must stay out, that probably voids adverse possession. If you "accidentally" jump the gun on an eviction and lock them out and remove their stuff too soon, it violates the eviction law but may still be valid to void adverse possession.
The usage must be Open and Notorious - if they squat an old farmhouse, only come at night, hide the car inside the barn, black the windows so no one knows anyone's living there, then they don't qualify for adverse possession.
It must be Exclusive. Housemate shares automatically fail because they are not exclusive. Here's why: Adverse possession would mean they are claiming two separate occupancies in one building, i.e. a condominium. "Occupancy" is the word for a residential unit that is legal for a person or family to move into, per the local building and zoning codes. At the least it has its own entrance, kitchen, bathroom, heat, water heater, separate utility meters, separate electrical service, etc. You see where that falls apart.
Their "exclusive" part is just a bedroom, and they cannot turn that into a legal occupancy since all those items are not separated as they would need to be. (nor, do I suspect, the government would allow them to pull permits to modify the house to "condo" it, if they are not the homeowner and you the homeowner are objecting strenuously. THey certainly will not allow them to alter your home for the purpose of qualifying for adverse possession.)
Also, zoning: you cannot subdivide a home in an area zoned R1 for single-family homes only, so even if everything else was perfect, they cannot adverse-possess half the property because it can't be subdivided.
Also, codes commonly forbid subletting parts of an occupancy, and they're also changing codes to slow down AirBNB, so it's possible this sublet is already illegal, and the subletter filing for adverse possession will result in the owners being called into the City Attorney's office "for a little sit-down talk". That conversation could result in the city evicting the subletter, and that absolutely will void any attempt at adverse possession.
Normally in the United states renting a room or a house don't give the renter rights beyond those listed in the states landlord tenant laws. Those rights would be related to security deposits, living conditions, end of contract, access to the unit.
In the future when it is time to sell the property, a tenant living in the unit with a valid lease agreement does have rights regarding how long they can remain in the unit. The state regulations would specify their rights and the what options are available to the new owner.
But if the relationship isn't landlord-tenant, then it is possible that the person living in the room might have a claim to partial ownership of your spouses portion.
No, the renter's status does not change because of the duration of their stay. They only gain claims to the property if they get their name on the title of the property. Renting for 6 months, 6 years, or 6 decades makes no difference. They are still just renting the property.
There are instances of long-term tenants attempting to claim ownership without being on the title, but in order for it to succeed they have to show that they were the ones paying the property taxes and that they weren't paying rent. It's known as Adverse Possession, and does not apply to the scenario you described in your question.
If you have concerns about selling the property, consult a real estate attorney to make sure you are taking the appropriate steps.