Sun will become a red giant in about 5 billion years. Space habitats, and habitats on moons of gas giants will still be possible.
By then we could probably tow Sol over to a comparable system using a Shkadov thruster and jump ship to a new sun.
After one billion years, the speed would be 20 km/s and the displacement 34,000 light-years, a little over a third of the estimated width of the Milky Way galaxy.
In 5 billion years, humanity will either not exist anymore, or will be a Type III+ civilization. We certainly won't be impacted by anything that might happen to the sun in terms of its life cycle. A coronal mass ejection might be a problem at some point though.