How do laptops seamlessly switch from AC wall power to battery
So the question lies in how does the laptop switch from using AC wall power to using the battery, without shutting down for that split second when you unplug the machine from the wall power adapter?


Short answer: very fast controls.

There are many ways of implementing this functionality, but on modern (circa 2020) motherboards this is done by means of a dedicated charger IC that controls when power should come from the AC wall power or from the battery by connecting/disconnecting the battery by means of a MOSFET between the battery and the rest of the motherboard.


The example schematic above comes from the ISL9238 datasheet.  This IC measures the AC input voltage (which is DC by the time it arrives to this IC) and if present, uses that input to power the motherboard + charge the battery.  Otherwise the IC switches to powering the system from the battery only, and the switching occurs within a few microseconds.  

During that small n-microsecond window the decoupling capacitors on the board hold enough charge to power the motherboard.  And should these capacitors, for some reason, be not enough to power the motherboard during the switching period, the body-diode of the series MOSFET will conduct until the IC fully switches on the MOSFET.

There are other operating modes available from this IC (such as battery supplemental mode), but that's outside the scope of this question.

There's a whole world of charger ICs out there that do this: the ISL9238 is just one of them.  Checkout Digikey's Battery Chargers section if you're curious to learn more.