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.

test(gateway): await complete browser argv capture

Rahmandb9e315c843a
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index c8715b1a..dfd34d82 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -25,6 +25,10 @@ this is the *what*, and it is what Settings → About shows as “What's new”.
- `agent` add repeatable corpus runner
- `agent` expand objective repo corpus
+**Tests**
+
+- `gateway` await complete browser argv capture
+
**Docs**
- `agent` record P8 calibration baseline
diff --git a/scripts/mso-gateway.test.ts b/scripts/mso-gateway.test.ts
index cf6276de..af864851 100644
--- a/scripts/mso-gateway.test.ts
+++ b/scripts/mso-gateway.test.ts
@@ -192,11 +192,17 @@ printf '%s\n' "$@" > "${capture}"
MSO_GATEWAY_STATE_DIR: f.state, MSO_GATEWAY_CURL: f.curl, MSO_GATEWAY_CLOUDFLARED: f.cloudflared },
});
expect(out).toContain("opened http://127.0.0.1:4555");
- // The browser launcher is deliberately detached. Under full coverage the child
- // can be scheduled later than the old 500 ms fixture window, so wait boundedly
- // for its one small argv file instead of turning host load into a flaky failure.
- for (let i = 0; i < 200 && !fs.existsSync(capture); i++) await new Promise((r) => setTimeout(r, 10));
- const argv = fs.readFileSync(capture, "utf8").trim().split(/\n/);
+ // The browser launcher is deliberately detached. A redirection can create the
+ // capture file before printf has finished writing argv, so waiting only for
+ // existence is racy under full-suite load. Wait boundedly for the expected
+ // complete payload instead of reading a newly-created partial file.
+ let captured = "";
+ for (let i = 0; i < 500; i++) {
+ try { captured = fs.readFileSync(capture, "utf8"); } catch {}
+ if (captured.includes("Start-Process $args[0]") && captured.includes("http://127.0.0.1:4555")) break;
+ await new Promise((r) => setTimeout(r, 10));
+ }
+ const argv = captured.trim().split(/\n/);
expect(argv).toContain("Start-Process $args[0]");
expect(argv.at(-1)).toBe("http://127.0.0.1:4555");
expect(argv.filter((v) => v.includes("http://127.0.0.1:4555"))).toHaveLength(1);