If on erev rosh codseh one starts to eat some cake before shkiah and finishes eating the cake after nightfall, should they make the insertion for rosh chodesh in al hamiyha? In this case, is it preferable to ensure some cake is eaten after nightfall?
If you started eating before nightfall, and carried on into nightfall, eating a kezayis after it is night, then the insertion should be made.
If you did not eat anything after nightfall, the case involves a dispute between the Shulchan Aruch (one says) and the Rema (one does not say).
See Shulchan Aruch, Orach Chaim 271, and Mishnah Berurah 29. The sources refer to a bread meal, but the same principles apply to cake.