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_presentation_li: true,
inc_presenter_li: true,
enabled: 'all',
hidden: 'all',
enabled: 'enabled',
hidden: 'not_hidden',
limit: 150,
log_lvl
});

View File

@@ -1,76 +1,67 @@
/**
* Aether Native Bridge Relay (TypeScript)
* Standardizes communication between SvelteKit and the Electron Main process.
* electron_relay.ts
* 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;
export async function get_device_config(): Promise<any> {
if (!native) return null;
return await native.get_device_config();
export const is_native = !!native;
// 1. Core Config
export async function get_device_config() {
if (!native) return null;
return await native.get_device_config();
}
// --- File Operations ---
export async function check_hash_file_cache({ cache_root, hash }: { cache_root: string; hash: string }): Promise<boolean> {
if (!native) return false;
// Uses the specific bridge method instead of generic invoke
return await native.check_cache({ cache_root, hash });
export async function get_device_info() {
if (!native) return null;
return await native.get_device_info();
}
export async function download_to_cache({
url,
cache_root,
hash,
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 });
// 2. File & Cache Management
export async function check_hash_file_cache({ cache_root, hash, hash_prefix_length = 2 }: any) {
if (!native) return false;
return await native.check_cache({ cache_root, hash, hash_prefix_length });
}
export async function launch_from_cache({
cache_root,
hash,
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 });
export async function download_to_cache({ url, cache_root, hash, api_key, account_id, hash_prefix_length = 2 }: any) {
if (!native) return { success: false, error: 'Native bridge not available' };
return await native.download_to_cache({ url, cache_root, hash, api_key, account_id, hash_prefix_length });
}
// --- OS Operations ---
export async function open_folder(path: string): Promise<void> {
if (!native) return;
return await native.open_folder(path);
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' };
return await native.launch_from_cache({ cache_root, hash, temp_root, filename, hash_prefix_length });
}
export async function run_cmd({ cmd, return_stdout = false }: { cmd: string; return_stdout?: boolean }): Promise<string | boolean> {
if (!native) return false;
return await native.run_command({ cmd, return_stdout });
// 3. OS Shell Commands (Phase 3)
export async function open_folder(path: string) {
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> {
if (!native) return false;
// Legacy mapping to the same command handler
return await native.run_command({ cmd, return_stdout });
export async function run_cmd({ cmd, timeout = 30000, return_stdout = true }: { cmd: string, timeout?: number, return_stdout?: boolean }) {
if (!native) return { success: false, error: 'Native bridge not available' };
return await native.run_cmd({ cmd, timeout, return_stdout });
}
// --- Compatibility Aliases (Legacy) ---
export const open_local_file_v2 = launch_from_cache;
export const get_device_info = get_device_config;
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_cmd_sync({ cmd, return_stdout = true }: { cmd: string, return_stdout?: boolean }) {
if (!native) return { success: false, error: 'Native bridge not available' };
return await native.run_cmd_sync({ cmd, return_stdout });
}
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 ***
// If window.native_app or window.aetherNative exists, we are running inside the Electron bridge
// @ts-ignore - native_app is injected by legacy, aetherNative by new V3 bridge
// Explicitly set is_native if the bridge is detected, ensuring reactivity for all child components
// @ts-ignore
if (window.native_app || window.aetherNative) {
console.log('ELECTRON: Native environment detected. Switching to native app_mode.');
$events_loc.launcher.app_mode = 'native';
$ae_loc.is_native = true;
if (!$ae_loc.is_native) {
console.log('ELECTRON: Native environment detected via window bridge.');
$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}
<span class="fas fa-chevron-right"></span>
{/if}
Native OS Folders
Native OS Handlers & Folders
</span>
<span class="badge variant-filled-success">Active</span>
</button>