fix(launcher): skip post_delay sleep when no post_script
The sleep step was running unconditionally, meaning files that open with the 'default' catch-all profile (zip, unknown ext, etc.) would wait 2 seconds for no reason — there's no AppleScript to prepare for. Gate the sleep inside the post_script check so it only delays when there's actually automation to run after app launch. Also update the test mode popup to show '0ms — skipped (no post_script)' and display post_delay_ms as '(default: 2000ms)' when unset.
This commit is contained in:
@@ -267,7 +267,8 @@ async function handle_open_file() {
|
||||
}
|
||||
|
||||
// --- Step 5: Wait for app to load before running post-script ---
|
||||
if (open_ok) {
|
||||
// Only delay if there is actually a post_script to run — no point waiting for nothing.
|
||||
if (open_ok && profile.post_script) {
|
||||
const delay = profile.post_delay_ms ?? 2000;
|
||||
open_file_status_message = `Waiting for ${profile.app}...`;
|
||||
await sleep(delay);
|
||||
@@ -700,7 +701,7 @@ function prevent_default<T extends Event>(fn: (event: T) => void) {
|
||||
{#if test_mode_popup_data.display_override}
|
||||
<div><span class="text-warning-500 opacity-80">display_override (cfg_json): </span><span class="text-warning-500">{test_mode_popup_data.display_override}</span></div>
|
||||
{/if}
|
||||
<div><span class="opacity-50">post_delay_ms: </span>{test_mode_popup_data.profile.post_delay_ms ?? 2000}</div>
|
||||
<div><span class="opacity-50">post_delay_ms: </span>{test_mode_popup_data.profile.post_delay_ms ?? '(default: 2000ms)'}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -735,7 +736,7 @@ function prevent_default<T extends Event>(fn: (event: T) => void) {
|
||||
<div class="flex flex-col gap-1">
|
||||
<span class="text-[9px] font-bold uppercase opacity-50">Steps 5–6 — Wait + Post-Script</span>
|
||||
<div class="rounded bg-surface-500/10 px-3 py-2">
|
||||
<div class="mb-1 opacity-50">sleep({test_mode_popup_data.profile.post_delay_ms ?? 2000}ms)</div>
|
||||
<div class="mb-1 opacity-50">sleep({test_mode_popup_data.profile.post_script ? (test_mode_popup_data.profile.post_delay_ms ?? 2000) : 0}ms){test_mode_popup_data.profile.post_script ? '' : ' — skipped (no post_script)'}</div>
|
||||
{#if test_mode_popup_data.profile.post_script}
|
||||
{#if test_mode_popup_data.profile.post_script.startsWith('shell:')}
|
||||
<div class="mb-1 opacity-50 text-[9px]">native.run_cmd() [shell prefix]</div>
|
||||
|
||||
Reference in New Issue
Block a user