Truman was decisive when NK invaded South Korea in June 1950. By October a UN force led by Gen. Douglas MacArthur had pushed NK back to the 38th parallel. He gambled that China would not enter the war and took a decision to push on to the Yalu River.
MacArthur was wrong. Mao committed millions of troops to retake NK. America had no military intelligence about what was going on in China and was totally taken by surprise. Hundreds of thousands of PLA troops attacked under cover of darkness forcing the UN army into retreat. It has been described as "the largest ambush in the era of modern warfare". The Chinese army were only stopped by a failure of logistics. They were fighting in temperatures of -30 and lacked the ability to supply the soldiers.
MacArthur proposed using nuclear weapons and even wanted to invade China. He was sacked by Truman and replaced by General Matthew Ridgway. He fought and brilliant campaign and imposed massive losses on the PLA but he was unwilling to take the battle north of the 38th parallel.
Stalin and Mao dragged their feet in the armistice talks extending the war by a further pointless two years. Stalin was happy to see the USA stuck in a costly war. The millions of troops Mao was continuing to send to NK were mostly Nationalists who had previously fought under Chiang Kai-shek against the PLA in the civil war.
An armistice was not signed until the death of Stalin in 1953 by which time 400,000 Chinese troops were dead and Mao was a Socialist hero.