Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

refactor(gateway): keep provisional readiness with pending lifecycle

Rahman51faf67c45b3
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 27458d29..cef22ae3 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -18,6 +18,10 @@ this is the *what*, and it is what Settings → About shows as “What's new”.
- keep the session mode badge clear of mobile navigation
- harden audited execution, integrations and release journeys
+**Changed**
+
+- `gateway` keep provisional readiness with pending lifecycle
+
**Tests**
- `pty` wait for terminal output to drain after exit
diff --git a/scripts/lib/gateway-pending.sh b/scripts/lib/gateway-pending.sh
index 24ab3d5f..9e125d53 100755
--- a/scripts/lib/gateway-pending.sh
+++ b/scripts/lib/gateway-pending.sh
@@ -77,3 +77,18 @@ gateway_spawn_held_tunnel() {
printf '1\n' | mso_private_state_atomic_write "$gate" >/dev/null || { gateway_stop_pending_tunnel; return 1; }
TUNNEL_SPAWN_PID="$pid"
}
+
+# Readiness discovery belongs to the provisional child lifetime, before final identity.
+gateway_discover_quick_url() {
+ local pid i
+ pid="$(jq -r .pid <<<"$TUNNEL_IDENTITY")"
+ for i in $(seq 1 80); do
+ GATEWAY_PUBLIC_URL="$(grep -Eo 'https://[A-Za-z0-9-]+\.trycloudflare\.(com|app)' "$CF_LOG" | tail -1 || true)"
+ [ -n "$GATEWAY_PUBLIC_URL" ] && return 0
+ # Startup may legitimately exec an interpreter before publishing the URL.
+ # Pin the spawned lifetime here; require exact executable/argv after readiness.
+ [ "$(gateway_proc_start_ticks "$pid" 2>/dev/null || true)" = "$TUNNEL_PENDING_TICKS" ] || return 1
+ sleep 0.25
+ done
+ return 1
+}
diff --git a/scripts/lib/gateway-tunnel.sh b/scripts/lib/gateway-tunnel.sh
index f5aa9272..49e3b593 100644
--- a/scripts/lib/gateway-tunnel.sh
+++ b/scripts/lib/gateway-tunnel.sh
@@ -96,19 +96,6 @@ gateway_refresh_tunnel_identity() {
TUNNEL_IDENTITY="$identity"
}
-gateway_discover_quick_url() {
- local pid i
- pid="$(jq -r .pid <<<"$TUNNEL_IDENTITY")"
- for i in $(seq 1 80); do
- GATEWAY_PUBLIC_URL="$(grep -Eo 'https://[A-Za-z0-9-]+\.trycloudflare\.(com|app)' "$CF_LOG" | tail -1 || true)"
- [ -n "$GATEWAY_PUBLIC_URL" ] && return 0
- # Startup may legitimately exec an interpreter before publishing the URL.
- # Pin the spawned lifetime here; require exact executable/argv after readiness.
- [ "$(gateway_proc_start_ticks "$pid" 2>/dev/null || true)" = "$TUNNEL_PENDING_TICKS" ] || return 1
- sleep 0.25
- done
- return 1
-}
gateway_quick_public_ipv4s() {
local host response