“the US gave the northern part of the peninsula to one set of commies, who couldn’t deal while they were picking themselves up from WWII”
You assume, of course, that the US had the right to “give the northern part” to “one set of commies.” And in one sense you are: the division was the work of the US under Bonesteel and Rusk, who drew up the dividing line and then presented Stalin with a fait accompli. This was not acceptable for that “set of commies” who already had their people setting up local self-governments in much of the country. It was to demolish these local entities that massacres by the US-selected Synman Rhee puppet government, such as those at CheJu island, occurred.
As for China taking “the opportunity” to confront the US, that must be a joke. China had just suffered a devastating civil war, and its coastal areas facing Taiwan were still suffering from intermittent sabotage attempts from Chiang Kaishek, and war anywhere was the last thing they wanted. But they certainly wouldn’t want American troops at their border, so they requested the Indian ambassador K. M. Panikkar to tell the US that China wouldn’t intervene in any conflict between North and South. China, however, would not stand idly by if US troops were to invade the North right up to its border, that was, the Yalu River. China’s warning was received with contempt - some Americans laughed at the idea of those peasants daring to face the strongest armed forces in the world, and there were talks about “one American can defeat nine Chinese” etc, etc. Worse, MacArthur was saying in Tokyo about first going to the Yalu River, then on to Manchuria and the rest of China. It was a war that China could not afford NOT to fight. Some ideas could be gleaned from Bevin Alexander’s book “MacArthur’s War” regarding China’s entry into the conflict.