Fix: Synchronize SvelteKit relay and enhance native command testing

- Updated electron_relay.ts with full Phase 3 command set (run_cmd_sync, kill_processes, get_device_info).
- Fixed 500 error in Event Location by standardizing enabled/hidden flags.
- Hardened native environment detection in root layout.
- Added Manual OS Command input to Launcher Configuration for Phase 3 testing.
This commit is contained in:
Scott Idem
2026-01-23 17:23:35 -05:00
parent efdf1188a6
commit f9f6d7f4f0
4 changed files with 61 additions and 65 deletions

View File

@@ -188,8 +188,8 @@ async function _handle_nested_loads(location_obj: any, { api_cfg, inc_file_li, i
inc_all_file_li: inc_all_file_li, inc_all_file_li: inc_all_file_li,
inc_presentation_li: true, inc_presentation_li: true,
inc_presenter_li: true, inc_presenter_li: true,
enabled: 'all', enabled: 'enabled',
hidden: 'all', hidden: 'not_hidden',
limit: 150, limit: 150,
log_lvl log_lvl
}); });

View File

@@ -1,76 +1,67 @@
/** /**
* Aether Native Bridge Relay (TypeScript) * electron_relay.ts
* Standardizes communication between SvelteKit and the Electron Main process. * TypeScript relay for Aether Native (Electron) Bridge.
* Standardizes all IPC calls to snake_case.
*/ */
// Handle the standardized aetherNative bridge
const native = (typeof window !== 'undefined') ? (window as any).aetherNative : null; const native = (typeof window !== 'undefined') ? (window as any).aetherNative : null;
export async function get_device_config(): Promise<any> { export const is_native = !!native;
if (!native) return null;
return await native.get_device_config(); // 1. Core Config
export async function get_device_config() {
if (!native) return null;
return await native.get_device_config();
} }
// --- File Operations --- export async function get_device_info() {
if (!native) return null;
export async function check_hash_file_cache({ cache_root, hash }: { cache_root: string; hash: string }): Promise<boolean> { return await native.get_device_info();
if (!native) return false;
// Uses the specific bridge method instead of generic invoke
return await native.check_cache({ cache_root, hash });
} }
export async function download_to_cache({ // 2. File & Cache Management
url, export async function check_hash_file_cache({ cache_root, hash, hash_prefix_length = 2 }: any) {
cache_root, if (!native) return false;
hash, return await native.check_cache({ cache_root, hash, hash_prefix_length });
api_key,
account_id
}: {
url: string;
cache_root: string;
hash: string;
api_key: string;
account_id: string;
}): Promise<{ success: boolean; path?: string; error?: string }> {
if (!native) return { success: false, error: 'Native bridge not available' };
return await native.download_to_cache({ url, cache_root, hash, api_key, account_id });
} }
export async function launch_from_cache({ export async function download_to_cache({ url, cache_root, hash, api_key, account_id, hash_prefix_length = 2 }: any) {
cache_root, if (!native) return { success: false, error: 'Native bridge not available' };
hash, return await native.download_to_cache({ url, cache_root, hash, api_key, account_id, hash_prefix_length });
temp_root,
filename
}: {
cache_root: string;
hash: string;
temp_root: string;
filename: string;
}): Promise<{ success: boolean; error?: string }> {
if (!native) return { success: false, error: 'Native bridge not available' };
return await native.launch_from_cache({ cache_root, hash, temp_root, filename });
} }
// --- OS Operations --- export async function launch_from_cache({ cache_root, hash, temp_root, filename, hash_prefix_length = 2 }: any) {
if (!native) return { success: false, error: 'Native bridge not available' };
export async function open_folder(path: string): Promise<void> { return await native.launch_from_cache({ cache_root, hash, temp_root, filename, hash_prefix_length });
if (!native) return;
return await native.open_folder(path);
} }
export async function run_cmd({ cmd, return_stdout = false }: { cmd: string; return_stdout?: boolean }): Promise<string | boolean> { // 3. OS Shell Commands (Phase 3)
if (!native) return false; export async function open_folder(path: string) {
return await native.run_command({ cmd, return_stdout }); if (!native) return { success: false, error: 'Native bridge not available' };
return await native.open_folder(path);
} }
export async function run_cmd_sync({ cmd, return_stdout = false }: { cmd: string; return_stdout?: boolean }): Promise<string | boolean> { export async function run_cmd({ cmd, timeout = 30000, return_stdout = true }: { cmd: string, timeout?: number, return_stdout?: boolean }) {
if (!native) return false; if (!native) return { success: false, error: 'Native bridge not available' };
// Legacy mapping to the same command handler return await native.run_cmd({ cmd, timeout, return_stdout });
return await native.run_command({ cmd, return_stdout });
} }
// --- Compatibility Aliases (Legacy) --- export async function run_cmd_sync({ cmd, return_stdout = true }: { cmd: string, return_stdout?: boolean }) {
export const open_local_file_v2 = launch_from_cache; if (!native) return { success: false, error: 'Native bridge not available' };
export const get_device_info = get_device_config; return await native.run_cmd_sync({ cmd, return_stdout });
export const run_osascript = async ({ cmd }: { cmd: string }) => await run_cmd({ cmd: `osascript -e '${cmd}'` }); }
export const kill_processes = async ({ process_name }: { process_name: string }) => await run_cmd({ cmd: `pkill -f '${process_name}'` });
export async function run_osascript(script: string) {
if (!native) return { success: false, error: 'Native bridge not available' };
return await native.run_osascript(script);
}
export async function kill_processes({ process_name_li = [] }: { process_name_li: string[] }) {
if (!native) return { success: false, error: 'Native bridge not available' };
return await native.kill_processes({ process_name_li });
}
export async function open_local_file_v2(path: string) {
if (!native) return { success: false, error: 'Native bridge not available' };
return await native.open_local_file_v2(path);
}

View File

@@ -645,12 +645,17 @@
} }
// *** Electron Native Mode Detection *** // *** Electron Native Mode Detection ***
// If window.native_app or window.aetherNative exists, we are running inside the Electron bridge // Explicitly set is_native if the bridge is detected, ensuring reactivity for all child components
// @ts-ignore - native_app is injected by legacy, aetherNative by new V3 bridge // @ts-ignore
if (window.native_app || window.aetherNative) { if (window.native_app || window.aetherNative) {
console.log('ELECTRON: Native environment detected. Switching to native app_mode.'); if (!$ae_loc.is_native) {
$events_loc.launcher.app_mode = 'native'; console.log('ELECTRON: Native environment detected via window bridge.');
$ae_loc.is_native = true; $ae_loc.is_native = true;
}
// Ensure launcher mode is set to native if we're in the bridge
if ($events_loc?.launcher && $events_loc.launcher.app_mode !== 'native') {
$events_loc.launcher.app_mode = 'native';
}
} }
} }

View File

@@ -68,7 +68,7 @@
{:else} {:else}
<span class="fas fa-chevron-right"></span> <span class="fas fa-chevron-right"></span>
{/if} {/if}
Native OS Folders Native OS Handlers & Folders
</span> </span>
<span class="badge variant-filled-success">Active</span> <span class="badge variant-filled-success">Active</span>
</button> </button>