I naively assume that in these kinds of foreseeable scenarios, the main stakeholders will have anticipated the contingencies, laid plans for their ascendancy, and will be prepared for the transfer of power they desire.
But in practice it rarely seems to work out that way. I suspect that in reality it does kind of work out that way, but plans don't survive enemy contact, and most of the details of what really happened never come out.
So I expect it will look like a clownshow of incompetent nincompoops who had no idea Putin was gonna die some day soon. He'll probably be replaced by a junta, backed by the same Oligarchs who backed him, none of them powerful enough to wrest control from the others. This will persist for a few years, until one of them manages to consolidate power in his own hands.
As for Ukraine... I expect that a loss of forceful leadership at the top will result in a great stalling out and withdrawal from the occupied territories. Russian commanders in the field will realize that their chain of command (such as it was) is entirely broken, that their logistics are even more stuffed up than usual, and that there is no longer any semblance of a strategic goal. There will be a lot of units that just quietly walk away from the front lines. Assuming Ukraine still has battle-ready formations in the field, a massive collapse of the Russian army will soon follow. Ukraine will ultimately end up with everything that's theirs, plus a decent chunk of Kursk and Belgorod oblasts to play with.