Longstreet would take command of the army and try to retreat to Virginia.
Difficult to say. It depends on when Lee dies and how. My impression from the OP is he drops dead in mid-stride in the early morning hours of Day 3.
On Day 1, it was mostly a meeting engagement of divisional commanders, starting with Heth followed up by Pender on the Union left flank, and later Rodes then Early on the Union right flank. Lee was in little position to do more than order a general attack once he finally reached the field.
On Day 2 his orders were mostly ineffectual except for the two present divisions of Longstreet's Corps, but unfortunately for Lee he wasn't being kept informed of the casualties building up in his army.
Hence, his almost surreal orders for Day 3 seemed to be for an army almost completely intact. And while Longstreet was able to convince Lee that Hood and McLaws' Divisions were in no condition to fight (and were needed to serve as the right flank anyway), Hill as usual was a command non-entity in terms of determining the state of his own badly battered corps.
Longstreet represented no panacea for the AoNV at Gettysburg. With a completely free hand, he could well have followed his own reeds and made his planned attack that he begged Lee to do (march around the Round Tops and flank the Union Army.
He does that, and the US Civil War has the Union Army in Richmond by Thanksgiving and the war ends no later than 1/1/1864!
However, once back there, it's unclear who Jeff Davis would put in command -- probably Joe Johnston or Beauregard
Have you considered Braxton Bragg?
Davis valued loyalty above all, and no one supported Davis more than Bragg, save a now deceased Lee.
but Davis had some dislike for both.
Obsessive vendettas. Davis didn't hate in half measures.
In either case, I think it's safe to assume that Davis would interfere more than with Lee.
An unparalleled micro-manager. He left Lee alone because Lee knew how to do the big suckup, always kept him informed, was a national hero himself, and gave him lots of victories that helped balanced the near constant tale of woe in the West.
Either might perform fairly well in the subsequent campaigns, but CSA morale would definitely take a blow and this (with greater desertions, etc) might shorten the war a bit.
I doubt that with Johnston's caution and/or Beauregard's tactical incompetence Grant fails to turn their right flank and slip into Richmond. Game Over, 1864. The Wilderness? IDK. Bermuda Hundred will probably be OTL though.
How about how EARLY (which day) at that battle ? Also Lee maybe not dead but significantly incapacitated...
The OP says "final day of the battle".
Picketts charge never made (manpower gain minor - morale difference probably more significant).
The only way Pickett's Charge happens is if Longstreet stops a bullet
But again, if he does as HE wants, future historians will probably be asking why he DIDN'T do something like a frontal assault on the Federal Center, since the strength there was so "light" (5000 men), and because the Union troops would be too chicken
to redeploy their troops and re-enforce that center. That WAS Lee's thinking, after all. Still was one year later, according to his writings.
Longstreet supposedly wanted to withdraw and let the Union attack them at a better location
THERE WAS NONE. Just because you need a better place to defend from doesn't mean that it exists. Any other place risks the Union AotP cutting the AoNV from home.
-- a bloody Wilderness type battle that might have cost the Union more dearly and maybe a bigger (union) political loss (no won battle, major casualties, confeds still loose in northern territory) that would have had some (?) effect on the coming elections ? (and as usual all the 'butterfly wing' effects)
The nearest thing to a "Wilderness" or "Fredricksburg" in that region is Hancock Maryland, and even Lincoln would have seen that the AoNV trying to hold out there turns them into an enormous self-sustaining PoW camp. Vicksburg on steroids.
Grant was still taking Vicksburg, so as usual its muddy what significant overall effects - but him NOT facing Lee for all the meatgrinding battles later (but then could other confederate generals have done similar to what Lee did on the defensive ??)
Lee got where he was by audacity and audacity and audacity. Did I mention audacity? But with the arrival of Meade, he finally found an enemy upon whom he couldn't put the "scare". With Grant in the Wilderness against second-stringers, and please note the Wilderness was very nearly an utter disaster for the AoNV, Grant gets to Spotsylvania Court House first, and Game Over.
My guess is Davis would promote Longstreet to full general and allow him to retain command of the AONV. That would be the most logical thing to do.
IF Longstreet makes it out OK by withdrawing before Day 3, yes. But when was Davis ever logical about his command appointments?
Agreed. And it would keep him from having to place either Johnston or Beauregard, both of whom he detested, in command. This would cause both Johnston and Beauregard to become more angry with Davis, but that's a little like making the surface of Venus even more hot, so it probably wouldn't matter that much.