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(browser): stop Camoufox session cleanly

Rahmanb851c7744136
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index ff43c464..bff46f8f 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -15,6 +15,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.
**Fixed**
+- `browser` stop Camoufox session cleanly
- `plugin` distinguish staging from ChatGPT app install
- `memory` persist workflow and organization actions
- `browser` settle Camoufox viewer auth before reload
diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md
index 87f6a220..0061d403 100644
--- a/docs/PROGRESS.md
+++ b/docs/PROGRESS.md
@@ -1,3 +1,16 @@
+## 2026-09-20 — Make the Camoufox session stop leave a clean user unit
+
+Final production Browser QA proved viewer/auth transport clean, but stopping the Browser left
+`camoufox-vnc.service` in `failed (Result: timeout)`. The launcher installed a cleanup trap and
+then replaced itself with `exec websockify`, so the shell that owned the trap no longer existed.
+x11vnc could remain alive until systemd's 90-second stop timeout.
+
+The launcher now remains the service supervisor: websockify runs as a child, the shell waits for
+it, and the TERM path first asks x11vnc to stop through its X11 control channel before terminating
+remaining direct child jobs. The persistent profile, viewer cookie boundary, `Restart=no`,
+disabled-at-boot policy, and finite runtime lease are unchanged. Production acceptance requires
+the UI's final OFF state to correspond to `inactive/dead`, not merely `running=false`.
+
## 2026-09-19 — Settle the Camoufox viewer ticket exchange before reloading noVNC
Production Browser QA showed the split-origin ticket exchange returning HTTP 204, setting the
diff --git a/lib/camoufox/service-script.test.ts b/lib/camoufox/service-script.test.ts
index 1f0ed721..2a3d9dc8 100644
--- a/lib/camoufox/service-script.test.ts
+++ b/lib/camoufox/service-script.test.ts
@@ -9,5 +9,10 @@ describe("Camoufox noVNC webroot", () => {
expect(script).toContain('NOVNC_WEBROOT/package.json');
expect(script).toContain('websockify --web="$NOVNC_WEBROOT"');
expect(script).not.toContain("websockify --web=/usr/share/novnc");
+ expect(script).toContain('x11vnc -remote stop');
+ expect(script).toContain("trap 'exit 0' TERM");
+ expect(script).toContain('wait "$!"');
+ expect(script).not.toContain("exec websockify");
+ expect(script).not.toContain("trap cleanup EXIT INT TERM");
});
});
diff --git a/scripts/camoufox-vnc-service b/scripts/camoufox-vnc-service
index 2910a070..597f2b23 100755
--- a/scripts/camoufox-vnc-service
+++ b/scripts/camoufox-vnc-service
@@ -66,9 +66,12 @@ grep -qs "browser.startup.page" "$PROFILE/user.js" ||
rm -f "/tmp/.X${DISPLAY_NUM}-lock"
cleanup() {
+ DISPLAY="$DISPLAY" x11vnc -remote stop >/dev/null 2>&1 || true
jobs -pr | xargs -r kill 2>/dev/null || true
}
-trap cleanup EXIT INT TERM
+trap cleanup EXIT
+trap 'exit 0' TERM
+trap 'exit 130' INT
Xvfb "$DISPLAY" -screen 0 "$GEOMETRY" -nolisten tcp &
sleep 0.5
@@ -129,4 +132,5 @@ NOVNC_VERSION="$(dpkg-query -W -f='${Version}' novnc 2>/dev/null || printf 'syst
printf '{"version":"%s"}\n' "$NOVNC_VERSION" >"$NOVNC_WEBROOT/package.json"
chmod 600 "$NOVNC_WEBROOT/package.json"
-exec websockify --web="$NOVNC_WEBROOT" "127.0.0.1:${NOVNC_PORT}" "127.0.0.1:${VNC_PORT}"
+websockify --web="$NOVNC_WEBROOT" "127.0.0.1:${NOVNC_PORT}" "127.0.0.1:${VNC_PORT}" &
+wait "$!"