fix: app close issue in phoenix

This commit is contained in:
KernelDeimos 2024-10-29 16:19:58 -04:00
parent b30de5bf78
commit 38adb5741b
3 changed files with 13 additions and 0 deletions

View File

@ -2522,6 +2522,8 @@ window.report_app_launched = (instance_id, { uses_sdk = true }) => {
};
// Run any callbacks to say that the app has closed
// ref(./services/ExecService.js): this is called from ExecService.js on
// close if the app does not use puter.js
window.report_app_closed = (instance_id, status_code) => {
const el_window = window.window_for_app_instance(instance_id);

View File

@ -79,6 +79,12 @@ export class ExecService extends Service {
// We also have to report an extra close event because the real one was sent already
window.report_app_closed(child_process.uuid);
}
process.references.iframe.contentWindow.postMessage({
msg: 'appClosed',
appInstanceID: connection.forward.uuid,
statusCode: 0,
});
});
return {

View File

@ -18,6 +18,7 @@
*/
import { Exit } from '../coreutils/coreutil_lib/exit.js';
import { signals } from '../../ansi-shell/signals.js';
import { TeePromise } from '../../promise.js';
const BUILT_IN_APPS = [
'explorer',
@ -72,6 +73,10 @@ export class PuterAppCommandProvider {
ctx.shell.addEventListener('signal.window-resize', resize_listener);
// Wait for app to close.
// console.log('waiting for app to close (phoenix)', window, {
// child_appid: child.targetAppInstanceID,
// phoen_appid: puter.appInstanceID,
// });
const app_close_promise = new Promise((resolve, reject) => {
child.on('close', (data) => {
if ((data.statusCode ?? 0) != 0) {