mirror of
https://github.com/HeyPuter/puter.git
synced 2026-08-24 06:58:21 +00:00
fix(gui): honor godmode file_paths launches now that /apps returns booleans
The godmode gate in ExecService.launchApp checked `godmode === 1`, but GET /apps/:name serializes the flag as a boolean, so the check always failed and file_paths launches (e.g. Dev Center opening a worker's source in the editor, #2218) silently dropped the file. Accept both shapes, matching the existing guard in launch_app.js. Also fix the two issues hiding behind that gate: - puter.apps.get returns `uid`, not `uuid`, so the /sign call for the target app sent app_uid undefined — no write grant and no user-app token for the launched app. Use `uid` with a `uuid` fallback. - The closeApp IPC handler had the same `godmode === 1` comparison, preventing godmode apps from closing other apps' windows.
This commit is contained in:
+3
-2
@@ -1977,9 +1977,10 @@ const ipc_listener = async (event, handled) => {
|
||||
return true;
|
||||
}
|
||||
|
||||
// God-mode apps can close anything
|
||||
// God-mode apps can close anything. `godmode` arrives as a
|
||||
// boolean from /apps but was historically 0/1 — accept both.
|
||||
const app_info = await window.get_apps(app_name);
|
||||
if ( app_info.godmode === 1 ) {
|
||||
if ( app_info.godmode === true || app_info.godmode === 1 ) {
|
||||
console.log(`⚠️ Allowing GODMODE app ${appInstanceID} to close app ${targetAppInstanceID}`);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -118,8 +118,10 @@ export class ExecService extends Service {
|
||||
const caller_app_name = process.name;
|
||||
const caller_app_info = await window.get_apps(caller_app_name);
|
||||
|
||||
// Check if caller is in godmode
|
||||
if ( caller_app_info && caller_app_info.godmode === 1 ) {
|
||||
// Check if caller is in godmode. The /apps endpoint serializes
|
||||
// `godmode` as a boolean while older shapes used 0/1, so
|
||||
// accept both (same guard as launch_app.js).
|
||||
if ( caller_app_info && (caller_app_info.godmode === true || caller_app_info.godmode === 1) ) {
|
||||
// Get target app info to create file signatures
|
||||
const target_app_info = await puter.apps.get(app_name);
|
||||
|
||||
@@ -137,8 +139,10 @@ export class ExecService extends Service {
|
||||
// Get file stats to verify it exists
|
||||
const file_stat = await puter.fs.stat({ path: first_file_path, consistency: 'eventual' });
|
||||
|
||||
// Create file signature for the target app
|
||||
const file_signature_result = await puter.fs.sign(target_app_info.uuid, {
|
||||
// Create file signature for the target app.
|
||||
// puter.apps.get returns `uid`; `uuid` is kept as
|
||||
// a fallback for any older cached shape.
|
||||
const file_signature_result = await puter.fs.sign(target_app_info.uid ?? target_app_info.uuid, {
|
||||
path: first_file_path,
|
||||
action: 'write',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user