Two of those men are now on their way out. And Mr. Trump has an ambiguous relationship with the third, Mr. Kelly, whom he alternately assures that his job is secure and disparages to other people. Ms. Hicks is leaving the White House in the coming days, a departure that has caused concern among his allies about how he will cope without her in the long term.

Outside the White House, there are few friends the president will listen to. Some of them warned him to back off his tariffs plan, telling him that he would undo what he had accomplished with the tax bill. Mr. Trump said he didn’t agree, and that was that.

But Mr. Trump’s moods have always been like storm clouds passing quickly over a desert island, and aides say that has not changed. Contrary to descriptions of a constantly fuming, beleaguered president, friends and advisers say Mr. Trump is more at ease than he has been in some time. What seems like unchecked chaos to almost everyone else is Mr. Trump feeling he is in his element.

“He seems more relaxed, believe it or not,” said Representative Peter T. King, a New York Republican who spent several hours with the president during two St. Patrick’s Day events on Thursday.

“I would say it’s a combination of being more relaxed and also being frustrated by the fact that he feels like a lot of what he didn’t succeed at, or what hasn’t worked, is that he wasn’t allowed to be Trump,” he said.

His close allies, like Representative Mark Meadows, the North Carolina Republican who is the chairman of the House Freedom Caucus, believe the president is finding his stride and learning how to navigate Washington.

“I see it more as a function of just, ‘O.K., I’ve taken a year to understand the different dynamics within a broad array of personalities,’ and so now it’s all about putting together a team to go the distance for the next three years,” Mr. Meadows said.