The optics of the summit between President Trump and Kim Jong Un were undeniably poor. To see the American flag flying next to the symbol of a Stalinist museum is enraging. So too was it infuriating to hear a murderous dictator exalted as some kind of champion of his people's freedom and prosperity.

The substance of the summit was also hardly worth bragging about. The president is characteristically overselling both the promises listed in the communique and the reliability of the North Korean dictator as a negotiating partner. North Korea has broken many similar vows to denuclearize before.

Yet despite all these caveats, it's important to identify what went right in Singapore. Long term, the summit may simply be the latest addition in the list of U.S. diplomatic failures to deal with the North Korea nuclear problem, but in the short- to medium-term, it has succeeded in one thing: bringing us all back from the brink.

That is still worth commending — even if much of the summit punditry, so ghoulishly eager for Trump to fail, is incapable of rising to the occasion.

Remember: Just a few months ago, it seemed we were headed toward a greater conflict with a nuclear-armed North Korea. Trump's own rhetorical escalation against "Little Rocket Man" Kim appeared to be a contributing factor.

Preventive war against North Korea would jeopardize the lives of millions, including our own allies in South Korea and beyond. The risks of war at present outweigh the risks of the weapons Pyongyang possesses, though that calculus could always change in the absence of effective negotiations — in which case we will truly be out of good options.

When the talks temporarily fell apart, it was easy to imagine Trump reacting petulantly, as he has done in response to lesser provocations from friendlier international leaders. Instead Trump responded in an unusually somber tone and Kim came back to the bargaining table.

Too much of Trump's approach to diplomacy has consisted of dictating maximalist terms to foreign governments and then becoming indignant when they don't agree to them. Here this has been truer of Trump's critics. And while Trump has puffed up the summit in recent days, the administration reset expectations when they agreed the Singapore meeting was on again, but construed it more as a first date than a wedding.

After a false start in response to a reporter's question, Trump also talked the more conventional Republicans in his administration off the ledge when it came to "Libya model" talk. The government of Libya disarming and then less than a decade later being destroyed with U.S. help is hardly worth touting to a reclusive despot one is attempting to coax away from the bomb.

A moralistic foreign policy is only actually moral if its aims are realistically achievable. If it results in the loss of life in the pursuit of unattainable goals, or, worse, it incentivizes the pursuit of the most lethal weapons by the world's worst governments as an insurance policy against U.S.-initiated regime change, it is not truly moral.

Perhaps Trump will take from this experience that even flawed agreements with loathsome regimes are an alternative to inaction or war. More likely, he will apply "maximum pressure" to everyone from Canada to Iran.

There remain significant risks that North Korea will continue its nuclearization, emboldening those who reject diplomatic solutions to this issue and making military action more politically palatable. It's possible Trump wants this too much to walk away, even at risk to South Korean sovereignty.

So let's not hand out any Nobel Peace Prizes yet. But let's take a deep breathe, be thankful things no longer appear to be spiraling out of control — and give a little credit (even if it's very little) where it is due.