Skip to content

Commit 3dead95

Browse files
committed
fix: electron app launching in linux but not working
1 parent f21dbfe commit 3dead95

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

src/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@
276276
if(data && data.__fsError) {
277277
throw new Error(data.message);
278278
}
279-
return data;
279+
// fsReadFile returns binary data, decode to text
280+
const decoder = new TextDecoder("utf-8");
281+
return decoder.decode(data);
280282
})
281283
.catch(err => {
282284
console.error("First boot detected or Failed to init storage from cache." +

src/main.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ function confirmReload(title, message) {
225225
});
226226
copyButton.textContent = 'Copy Error';
227227
getHelpButton.textContent = 'Get Help';
228-
reloadButton.textContent = 'Restart App';
228+
// In native apps, we can't reload because AES trust ring won't survive - must quit and restart manually
229+
reloadButton.textContent = Phoenix.isNativeApp ? 'Quit App' : 'Restart App';
229230
// Styling for visibility
230231
// Define common styles for buttons
231232
const buttonStyles = {
@@ -303,14 +304,22 @@ function confirmReload(title, message) {
303304
return new Promise(resolve =>{
304305
reloadButton.onclick = function() {
305306
resolve(true);
306-
reloadButton.textContent = 'Reloading...';
307+
reloadButton.textContent = Phoenix.isNativeApp ? 'Quitting...' : 'Reloading...';
307308
reloadButton.style.color = 'darkgray';
308309
reloadButton.style.backgroundColor = 'grey';
309310
};
310311
});
311312
}
312313

313314
function resetCacheAndRestart() {
315+
// In native apps, we can't reload because AES trust ring won't survive - must quit
316+
if (Phoenix.isNativeApp) {
317+
// wait for 3 seconds for bugsnag to send report, then quit
318+
setTimeout(() => {
319+
Phoenix.app.closeWindow(true); // force close
320+
}, 1000);
321+
return;
322+
}
314323
// try a cache reset
315324
if(window._resetCacheIfNeeded){
316325
window._resetCacheIfNeeded(true)
@@ -341,7 +350,9 @@ async function _recoverOnFailure(err) {
341350
'Critical error when loading brackets. Trying to reload again.');
342351
const restartedOnce = sessionStorage.getItem(SESSION_RESTART_ONCE_DUE_TO_CRITICAL_ERROR);
343352
let shouldRestart;
344-
if(!restartedOnce){
353+
// In native apps, we can't auto-restart because the AES trust ring won't survive a reload
354+
// without proper dismantling. Always show confirmation dialog for native apps.
355+
if(!restartedOnce && !Phoenix.isNativeApp){
345356
sessionStorage.setItem(SESSION_RESTART_ONCE_DUE_TO_CRITICAL_ERROR, "true");
346357
shouldRestart = true;
347358
} else {

test/SpecRunner.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@
173173
if(data && data.__fsError) {
174174
throw new Error(data.message);
175175
}
176-
return data;
176+
// fsReadFile returns binary data, decode to text
177+
const decoder = new TextDecoder("utf-8");
178+
return decoder.decode(data);
177179
})
178180
.catch(err => {
179181
console.error("First boot detected or Failed to init storage from cache." +

0 commit comments

Comments
 (0)