As the Senate convened for a rare August work period, the late-summer session serves as a reminder of how much has changed in the partnership between Senate Majority Leader Mitch McConnell and President Trump.

This time last year, the two men were barely on speaking terms. Mr. Trump bashed the GOP leader on Twitter after the collapse of Republican efforts to repeal President Barack Obama's health care law. McConnell said Mr. Trump had "excessive expectations" for what was possible. The phone lines between them went quiet for days.

But both learned how to better relate to the other. The president now keeps the Kentuckian close as a needed ally in accomplishing his agenda on Capitol Hill. And McConnell talks to the president almost daily as the two chat strategy, monitor campaigns and count votes.

Get Breaking News Delivered to Your Inbox

It's a course correction that's enabling Senate Republicans to motor through their agenda this summer. They're confirming Mr. Trump's new judges, approving funding bills ahead of a government shutdown deadline and laying the groundwork for a fall vote on Supreme Court nominee Brett Kavanaugh. They've decided that forfeiting the August break is a small price to pay to prevent another round of Republican-on-Republican infighting before the midterm election.

"As the Senate reconvenes to cross more items off our to-do list, we should take pride in all we have already accomplished this summer," McConnell said in opening remarks for the August session. "Important work remains for the weeks ahead."

Republicans acknowledge that last summer was not the party's finest hour, as former McConnell adviser Josh Holmes put it.

The Senate had failed in dramatic fashion to repeal "Obamacare," drawing Mr. Trump's wrath. He implored the Republican leader: "Mitch, get to work."

The feud laid bare the tensions generated by Mr. Trump's populist approach, fostered by his former campaign strategist Steve Bannon. At the time, Bannon was vowing to take on McConnell, along with every incumbent senator, in a scorched-earth approach to GOP primaries. Fox News' Sean Hannity called for McConnell to retire.

But a year later, simmering battles between the Trump and McConnell wings of the GOP seem to be taking a back seat to the party's drive to save the Republican majority in Congress.

Republicans in the White House and on Capitol Hill see their priority as working more closely to prevent a blowout, said one former administration official who spoke on condition of anonymity to discuss private thinking.

Keeping the Senate in session for part of August — even on this week's modest Wednesday-Thursday schedule — disrupts campaign plans for Democratic senators in the most competitive re-election battles in Trump-won states. It could also help protect the few endangered Senate Republicans.

The stay-in-session strategy can also be seen as payback to Democrats, who often force several days of procedural steps to delay final votes on Trump-backed nominees or legislative priorities.

Holmes said "the whole point" of the summer workload is to finish up the priorities Democrats slow-walked earlier. "Now they have to stay in August when it's pretty valuable campaign time," he said.

It's not been without its setbacks, though. Some 10 senators, mostly Republicans, were no-shows as the Senate returned to session Wednesday for a truncated week of votes on judges.

At the senators' private lunch Thursday, McConnell "re-emphasized how important it is that we all be here," said Sen. John Kennedy, R-La., who was among those pushing for the summer work period. "Some of my colleagues didn't like it, and I respect that."

McConnell and Mr. Trump were always unusual allies. They talked regularly as Mr. Trump campaigned as the party's presidential nominee, according to the senator's office. But it had been a decade since McConnell had an active relationship with the White House. He and Obama rarely spoke.

As they worked to patch things up last fall, the Trump-McConnell alliance seemed to be in danger. McConnell headed to the White House after Labor Day with other congressional leaders, only to sit by while Trump cut a budget deal with Democrats. A month later, Trump and McConnell stood side by side in the Rose Garden to declare their strong partnership, even if reality seemed to tell a different story.

But McConnell is not one to take slights too personally, and Mr. Trump is often looking for the next deal. Soon Republicans would pass the GOP tax plan and head toward the new year, and all sides started seeing the benefits of a unified front.

"They respect each other," said Kennedy, who talks with both. Mr. Trump has learned that the slow-moving Senate operates differently from the executive branch. And McConnell has demonstrated patience, and "he's very good at holding his tongue."

Now, McConnell can often be heard highlighting Republican accomplishments, delivering a not-so-subtle reminder of what they have done together. He talks to the president at all hours, increasingly about the campaigns ahead. He says he's even warmed to Trump's tweets.

And perhaps most pointedly, Team McConnell worked aggressively to counter Bannon's influence, mocking the strategist's support for controversial candidates, including Roy Moore in the Alabama special election, which cost Republicans the long-held Senate seat.

The president, for his part, understands that it's better to unify the party for the midterms. But theirs is more of a business partnership than a budding friendship, according to the former administration official.

It wouldn't be surprising, the official added, to see Trump dash off criticism of the Senate again, even if the tweets don't mention McConnell.