I lived in SF for 19 years, moved to London (family reasons, elderly parents with health issues) and are planning to return to the US. My wife put an absolute veto on returning to SF itself because of how dire the law and order situation has become.
Sad to say, but the city really needs a 1990s vintage Rudy Giuliani to clean house. Otherwise what it will get is Bernie Goetz (yes, I know, I am showing my age with my references). It seems unthinkable today, but in the 1950s and 60s SF was actually a fairly right-wing city, all mayors from 1912 to 1964 were Republicans.
My understanding is that prior to the "Southern Strategy" (https://en.wikipedia.org/wiki/Southern_strategy) of the 1960s, the Democratic Party was largely right wing, and the Republican Party was largely left wing.
So San Francisco flipping from Republican to Democrat aligns pretty much squarely with the change in politics of the parties due to the Southern Strategy.
This implies that in fact, San Francisco has always been fairly left-wing.