fix(modes): deep-linked mode scripts fail when body not yet parsed

ensureModeScript() used document.body.appendChild() to load lazy mode
scripts, but the preload for ?mode= query params runs in <head> before
<body> exists, causing all deep-linked modes to silently fail.

Also fix cross-mode handoffs (BT→BT Locate, WiFi→WiFi Locate,
Spy Stations→Waterfall) that assumed target module was already loaded.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Smittix
2026-03-12 20:49:08 +00:00
parent 7c425dbd99
commit ba631811a6
87 changed files with 9128 additions and 8368 deletions
+16 -1
View File
@@ -86,6 +86,11 @@ done
export INTERCEPT_HOST="$HOST"
export INTERCEPT_PORT="$PORT"
# ── macOS: allow fork() after ObjC initialisation (gunicorn + gevent) ────
if [[ "$(uname)" == "Darwin" ]]; then
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
fi
# ── Fix ownership of user data dirs when run via sudo ────────────────────────
# When invoked via sudo the server process runs as root, so every file it
# creates (configs, logs, database) ends up owned by root. On the *next*
@@ -152,7 +157,17 @@ fi
# ── Resolve LAN address for display ──────────────────────────────────────────
if [[ "$HOST" == "0.0.0.0" ]]; then
LAN_IP=$(hostname -I 2>/dev/null | awk '{print $1}')
LAN_IP=$(hostname -I 2>/dev/null | awk '{print $1}' || true)
# hostname -I on macOS fails or returns empty — try macOS methods
if [[ -z "$LAN_IP" ]]; then
LAN_IP=$(ipconfig getifaddr en0 2>/dev/null || true)
fi
if [[ -z "$LAN_IP" ]]; then
LAN_IP=$(ipconfig getifaddr en1 2>/dev/null || true)
fi
if [[ -z "$LAN_IP" ]]; then
LAN_IP=$(ifconfig 2>/dev/null | grep "inet " | grep -v 127.0.0.1 | head -1 | awk '{print $2}' || true)
fi
LAN_IP="${LAN_IP:-localhost}"
else
LAN_IP="$HOST"