They were fighting Japanese forces for months but declared war only after the atomic detonations?
The Soviets and Japanese weren't fighting for months. They signed an agreement with Japan following the Battle of Khalkhin Gol on 16 Sept. '39. Japan and the Soviet Union weren't at war until 9 Aug '45.
In fact the Japanese wanted no part in a war with the Soviet Union after having their arses handed to them in '39. This reluctance to fight and confirmation of this reluctance through Soviets spies in Japan allowed the Soviets to shift forces
west.Fresh Siberian troops were crucial in stopping and counter attacking the Germans at Moscow and played an important role in Germany's defeat at Stalingrad...
The Soviet commitment to the Western Allies to declare war on Japan was always based on the defeat of Germany first. Some of the same troops that fought in or near Berlin had to shipped around the world before the invasion could begin.
The attack on Manchuria was no small blow. If you understand why the Japanese invaded Manchuria to begin with then you will know the importance it had in Japanese war production.
It took the Soviets that long to shift forces from Europe to the East. The Soviets had strung along the Japanese during this time frame by entertaining various Japanese proposals.
The Japanese made an offer of surrender as long as the Emperor could remain in power. It was rejected obviously because the Soviets declared war on Japan.
Even after the bomb was dropped the Japanese made this same offer directly to the Western allies and it was rejected. It was even implied by the US that the Emperor might stand trial for war crimes and if found guilty maybe even executed.
MacArthur intervened when he heard of this stating that to the Japanese executing their emperor would be like crucifying Christ.
Finally the the allies backed down from that position and excepted surrender with the Emperor still holding his position.
Why did Japan give up? Many reasons but at least some in the government were looking for a way out for some time.