Short answer: why not both?
Longer answer: there's no reason it has to be one or the other, since both happened at nearly the same time, and there are reasons to think both mattered to different degrees. When one gets down to it, one is talking about the specific views of a few people in the Japanese cabinet, and we lack the ability to get inside of each of their heads to see what factors mattered more, if even they knew themselves (people are complicated!).
It's clear that some were very disturbed by the bombing of Hiroshima. It is also clear that the Soviet declaration of war deeply disturbed some of them as well, notably the military hold-outs. Even both of them were not enough to compel unconditional surrender, however: they still offered conditional surrender first. Only after a US refusal, an attempted coup, and continued conventional bombing, did the Emperor himself finally take the initiative to surrender unconditionally.
At some level we lack the ability to know which factors mattered more than others — one is talking about trying to discern the content of individual human minds, as reflected in what few scraps record their views, and even their own memories are fallible after the fact. There's enough evidence to suggest that both of these events got their attention and were seen as potentially ways for the "peace" contingent of the cabinet to overwhelm the military hold-outs, and to press for surrender.
The best book that covers this period is Hasegawa's Racing the Enemy, and you can find many other discussions of this issue on /r/AskHistorians by searching for "Hasegawa" in the search bar. Hasegawa ultimately concludes that both the atomic bombings and the Soviet invasion had impact. He does not know (and who could?) whether one or the other would have been enough to end the war on its own, or whether the war would have persisted until an American invasion of Kyushu without either events. Still, he gives what evidence there is for assessing how the various members of the cabinet assessed these events and eventually were persuaded to embrace the Potsdam terms of surrender.