As long as there are Christians in Vietnam, the French have an excuse to invade. Anytime the Christians are unhappy, they can claim prosecution which brings in the French or any other European power that wants to expand their empire.
Probably true. That's why I put more 'trust' in scenarios where European scenarios hobble France's ability to commit to intervention than in scenarios that rely purely on Vietnamese authorities being more kind and tolerant to Vietnamese Christians and western missionaries.
But I think that Vietnamese tolerance and patience, by removing pretexts can head off intervention *at particular moments*. For example, what ifthe Vietnamese Emperor treads lightly on all Christian sects in the 1850s, as much out of fear of attracting the wrathful attention of nearby Chinese Taipings, as westerners? The Taipings remain a concern from the 1850s into the 1860s. Meanwhile, for the French, as 1858 turns to 1859, their attention turns to the Second War of Italian independence and war with Austria, by 1860, they've pretty much wrapped up their military involvement with nearby China in the Arrow War, and by 1861 the fad of the day is getting involved in Mexico.
The Taipings, being crushed, are no longer a fear factor for the Vietnamese by 1866, so maybe the Vietnamese could go medieval on Vietnamese Christians starting from then. Even so, France may not be as prone to intervene while more concerned with Prussia and extricating from Mexico. In any case, it is a narrow window until the Franco-Prussian War in 1870, meaning potentially no Cochinchina foothold protectorate during the life of the 2nd Empire at all.
If the Lê Văn Khôi revolt succeeded, the new dynasty would be more tolerant of Vietnamese Catholics and French missionaries. This wouldn't necessarily protect Vietnam from European imperialism, but the French could treat it as a client state rather than a colony.
So keeping it whole? Not breaking off Cochinchina as a separate protectorate, but exerting heavy influence of the Imperial regime in the capital at Hue or Hanoi? And maybe not a direct French protectorate on Cambodia, but a shared one, expanding at the expense of the Thai controlled zone, a 'Franco-Vietnamese Cambodia' (name inspired by Anglo-Egyptian Sudan) Maybe process repeated with Laos later.
Vietnam had been indebted with France since the 1787 Treaty of Versailles, and IOTL the French made Vietnam pay hell for it. The earliest POD I can come up with is to butterfly away this Franco-Vietnamese alliance, which would likely prevent Gia Long's rise to power. How a surviving Tây Sơn dynasty would deal with Western powers is a whole different issue though. However, if Quang Trung/his descendants could continue their hard line against China, I can see Vietnam being backed by the West against a hostile Qing.
It would be interesting to see that develop.
you will be surprised how many times the Vietnamese would be able to dislodge the French beachhead in Saigon if the Vietnamese general have been bold in the first French conquest of Vietnam (1858)
Really! Would be interesting to see, I wonder if Louis Napoleon would come back for revenge year after year, or if he would let himself get distracted from Vietnam by his other wars and interventions, starting with his intervention against Austria in Italy (1859), and only try after a long break or never get around to it before being deposed.
if they had figured out a way to industrialize without going into debt to the Europeans
What could Vietnam have sold for export year after year to build a surplus for an investment fund, partly to be spent on foreign education, advice, and foreign technology, while using debt in a responsible and limited way?
The Japanese I think sold emergency shipping supplies (coal), probably overpriced, some silver and copper, and later on labor on which they got some remittances. I don't know what the Vietnamese had, but I suppose on the average year they had a rice surplus and they could harvest tropical hardwoods and medicines. Over time they could expand fruit growing operations and other cash crops. I'm not sure what the Siamese exported and how they controlled debt.