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.

fix(runtime): close final update web edges

Rahman032f065f10c4
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index afc5fc91..bf18938e 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -13,6 +13,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.
**Fixed**
+- `runtime` close final update web edges
- `update` emit success after runtime restore
- `update` serialize all checkout runtimes
- `gateway` reject active named tunnel switches
diff --git a/scripts/lib/gateway-config.sh b/scripts/lib/gateway-config.sh
index bf12fb55..e47311c2 100644
--- a/scripts/lib/gateway-config.sh
+++ b/scripts/lib/gateway-config.sh
@@ -113,8 +113,11 @@ gateway_cmd_web() {
state="$(gateway_active_state)" || gateway_fail "public gateway stopped during reconciliation"
url="$(jq -r .url <<<"$state")"
else rc=$?; [ "$rc" = 1 ] || return "$rc"
- if [ -n "${OS_PUBLIC_ORIGIN:-}" ]; then url="$(gateway_validate_public_origin "$OS_PUBLIC_ORIGIN" 2>/dev/null || true)"
- else gateway_health_ok || gateway_with_lock gateway_with_runtime_shared gateway_cmd_local_start_locked >/dev/null; url="$LOCAL_URL"; fi
+ # A configured public origin is metadata, not proof that its tunnel/proxy is
+ # reachable. Auto mode uses public only when gateway state is actually active;
+ # otherwise guarantee the supported local UI and open loopback.
+ gateway_health_ok || gateway_with_lock gateway_with_runtime_shared gateway_cmd_local_start_locked >/dev/null
+ url="$LOCAL_URL"
fi ;;
esac
case "$url" in http:*) url="$(gateway_validate_loopback_origin "$url" 2>/dev/null || true)" ;;
diff --git a/scripts/mso-gateway-web.test.ts b/scripts/mso-gateway-web.test.ts
new file mode 100644
index 00000000..20673980
--- /dev/null
+++ b/scripts/mso-gateway-web.test.ts
@@ -0,0 +1,17 @@
+import { describe, expect, it } from "vitest";
+import { cleanupGatewayFixtures, fixture, runGateway } from "./mso-gateway-test-fixture";
+
+describe("mso web routing", () => {
+ it("falls back to loopback when a public origin is configured but no gateway is active", () => {
+ const f = fixture();
+ try {
+ const out = runGateway(["web", "--print"], {
+ ...f.baseEnv,
+ OS_PUBLIC_ORIGIN: "https://mso.example.test",
+ });
+ expect(out.trim()).toBe("http://127.0.0.1:4005");
+ } finally {
+ cleanupGatewayFixtures();
+ }
+ });
+});
diff --git a/scripts/mso-service-update b/scripts/mso-service-update
index d7c3d9c9..f8dc997a 100755
--- a/scripts/mso-service-update
+++ b/scripts/mso-service-update
@@ -30,6 +30,12 @@ cleanup_locks() {
trap cleanup_locks EXIT
trap 'exit 129' HUP; trap 'exit 130' INT; trap 'exit 143' TERM
+# Settings decides success from this log after the transient unit exits. Start each
+# outer lifecycle with a fresh attempt log so a failure before self-update.sh takes
+# over cannot inherit an old UPDATE OK marker.
+printf 'UPDATE STARTING\n' | mso_private_state_atomic_write "$LOG" >/dev/null \
+ || fail "could not initialize private update attempt log"
+
update_lock_acquire
runtime_exclusion_acquire_exclusive \
|| fail "could not acquire checkout runtime exclusion before service update"
diff --git a/scripts/mso-service-update.test.ts b/scripts/mso-service-update.test.ts
index d0bb43c8..aee3d714 100644
--- a/scripts/mso-service-update.test.ts
+++ b/scripts/mso-service-update.test.ts
@@ -90,6 +90,23 @@ describe("service-active update lifecycle", () => {
expect(fs.existsSync(log) ? fs.readFileSync(log, "utf8") : "").not.toContain("UPDATE OK");
});
+ it("clears a stale success marker before any pre-build lifecycle failure", () => {
+ const f = fixture();
+ const log = path.join(f.env.HOME as string, ".mso/self-update.log");
+ fs.mkdirSync(path.dirname(log), { recursive: true, mode: 0o700 });
+ fs.writeFileSync(log, "UPDATE OK\n", { mode: 0o600 });
+ const key = createHash("sha256").update(fs.realpathSync(f.repo)).digest("hex");
+ const dir = path.join(f.base, "update-state", key); fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
+ fs.chmodSync(path.join(f.base, "update-state"), 0o700);
+ fs.writeFileSync(path.join(dir, "gateway-runtimes.json"), "{bad\n", { mode: 0o600 });
+
+ const out = spawnSync(WRAPPER, [], { env: f.env, encoding: "utf8" });
+ expect(out.status).not.toBe(0);
+ expect(fs.readFileSync(log, "utf8")).toBe("UPDATE STARTING\n");
+ expect(fs.readFileSync(log, "utf8")).not.toContain("UPDATE OK");
+ expect(fs.existsSync(f.capture) ? fs.readFileSync(f.capture, "utf8") : "").not.toContain("self-start");
+ });
+
it("fails closed on a corrupt persisted gateway restore inventory", () => {
const f = fixture();
const key = createHash("sha256").update(fs.realpathSync(f.repo)).digest("hex");