···1010SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
1111CONF="$SCRIPT_DIR/src-tauri/tauri.conf.json"
12121313-# Use a stable default port, only pick a random one if it's in use
1313+# Use a stable default port, kill any stale vite process on it first
1414DEFAULT_PORT=5188
1515-if python3 -c "import socket; s=socket.socket(); s.bind(('',${DEFAULT_PORT})); s.close()" 2>/dev/null; then
1616- PORT=$DEFAULT_PORT
1717-else
1818- PORT=$(python3 -c "import socket; s=socket.socket(); s.bind(('',0)); print(s.getsockname()[1]); s.close()")
1919- echo "[dev] Default port $DEFAULT_PORT in use, using $PORT instead"
2020-fi
1515+lsof -ti tcp:$DEFAULT_PORT | xargs kill 2>/dev/null || true
1616+PORT=$DEFAULT_PORT
2117echo "[dev] Using port $PORT"
22182319# Get the Mac's IP address for simulator to connect (can't use localhost in simulator)