Not long ago, Chinese propaganda was warning that American attempts at easing tensions were mere performance. Its state security agency was urging people to be on guard against American spies. The country’s leader, Xi Jinping, declared that the United States was engaged in a campaign of “all-around containment, encirclement and suppression,” in remarks broadcast across state media.

Now, the tone used to discuss the United States has suddenly shifted. Xinhua, the state news agency, on Monday published a lengthy article in English about the “enduring strength” of Mr. Xi’s affection for ordinary Americans. It included old photos of him sitting in a tractor with an Iowa farmer, and revisiting the home where he once stayed in an American college student’s “Star Trek”-themed bedroom.

“More delightful moments unfolded when Xi showed up to watch an N.B.A. game,” the article continued, describing a visit by Mr. Xi to the United States in 2012. “He remained remarkably focused on the game.”

Separately, Xinhua has published a five-part series in Chinese on “Getting China-U.S. Relations Back on Track.” A torrent of other state media articles has highlighted recent visits to China by the American Ballet Theater and the Philadelphia Orchestra, or the story of U.S. veterans who helped China fight Japan during World War II, some of whom visited China this month. “Veterans visit Chinese cities, anticipating everlasting China-U.S. friendship,” one headline declared.

The about-face is part of Beijing’s preparation for Mr. Xi’s trip to San Francisco this week, his first visit to the United States in more than six years. He is expected to meet with President Biden on Wednesday, in an attempt by both leaders to stabilize relations between the two countries.

Beijing, in particular, may be motivated to play up the meeting to reassure investors and foreign businesses, said Titus Chen, an associate professor of political science at Taiwan’s National Sun Yat-sen University. As China’s economy struggles, with anemic consumer spending and high youth unemployment, Chinese leaders are likely eager to show companies and investors that their relationship with the United States is not a major risk factor.

“Propaganda of this type is not meant for persuasion — it is not persuasive at all,” Professor Chen said. “It is mainly designed for signaling, in the hope that recipients will get the signal and implement the proper response, which is investment, or resumption of exchanges.”

But even if the intended audience is primarily overseas, many Chinese social media users have taken note of the abrupt turn — and have been left reeling, or at least wryly amused. On the platform Weibo, some joked that several new TV shows about fighting Americans during the Korean War would need to be shelved. One popular meme purported to show an editorial by People’s Daily, the Communist Party mouthpiece, promising legal repercussions for anyone who sought to derail U.S.-China relations.

Under another post showing true, recent state media editorials promoting U.S.-China relations, a commenter wrote: “So, going forward, do we or don’t we need to hate America? So unclear.”

Beyond social media snark, some Chinese academics and writers have also struck a more cautious or pessimistic note on the prospects of a thaw with the United States. On Guancha.cn, a nationalistic news and commentary site, columnists have noted that both countries are making short-term concessions for their own long-term strategic gain.

Even the most flowery Chinese articles have drawn distinctions between warm ties between American and Chinese people, and their governments; some state media outlets have continued to warn that the outcome of the California meeting will hinge on the United States, in line with Beijing’s stance that the strained relationship is entirely Washington’s fault.

In one widely circulated article published on Monday, Wang Jisi, a prominent professor of international relations at Peking University, wrote that a meeting between Mr. Xi and Mr. Biden was valuable — and likely to be in short supply going forward — as the United States enters an election year, when anti-China rhetoric might surge.

On the future of U.S.-China relations, Professor Wang wrote, “I am only cautious, not optimistic.”