After a dismal Election Day for Democrats, the fight for Ms. Pelosi’s post had become a proxy battle for the future of the party, with House Democrats agonizing over how to reconnect with the working-class voters who abandoned them.