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.
TypeScript browser-shellcontrol-planefile-managerhomelabmobile-firstnextjsptyreactself-hostedserver-managementshadcn-uisysadmintailwindcssterminaltypescriptvpsweb-desktopweb-terminal
test(terminal): isolate real PTY fixture from owner shell state
rahmanef63945ec0b154d8
diff --git a/docs/PROGRESS.md b/docs/PROGRESS.mdindex a162f094..cafd7849 100644--- a/docs/PROGRESS.md+++ b/docs/PROGRESS.md@@ -1,3 +1,11 @@+## 2026-10-18: Isolate the real PTY integration fixture from owner shell state++Two complete candidate gates passed before a later concurrent full run observed no PTY exit callback within the unchanged eight-second close deadline. Command execution and replay had succeeded; the exact native scheduling cause was not established. The standalone test passed under the same host load.++The real integration fixture now declares a private executable shell wrapper through scoped `SHELL`, preserves the production login-shell arguments, and runs actual Bash with `--noprofile --norc`. Private history and readline files replace the owner's shell startup, history and input configuration. A `finally` block detaches listeners, closes any remaining fixture PTY, restores the scoped environment and removes temporary files. Production PTY code, signal behavior, real echo/replay/kill/exit/idempotence assertions, and the original eight-second/twenty-second time limits are unchanged.++Focused validation includes ten repeated real-PTY runs and nine ownership/limit/stream tests. Full preflight, strict security and normal hooked publication must still pass on the committed candidate; earlier successful gates do not certify this new head.+## 2026-10-18: Reconcile preserved laptop changes onto current main for reviewThe laptop-only observation/connection diagnostics, agent PR-readiness policy, and hidden local password setup were preserved as five original commits and replayed onto `53fa602e`. The source changes remain a review candidate in an isolated branch; they have not been merged or deployed. Existing main already contains the custom-provider model-discovery work, which is excluded from this candidate.diff --git a/lib/host/pty.test.ts b/lib/host/pty.test.tsindex af63e80e..d0d710a2 100644--- a/lib/host/pty.test.ts+++ b/lib/host/pty.test.ts@@ -1,7 +1,9 @@-// E2E probe for the PTY manager: spawn a real shell, type a command, read the-// echoed output, kill it. Skipped on Windows (node-pty winpty path untested-// here; the product host is Linux).-import { describe, expect, it } from "vitest";+// Linux host probe for the PTY manager: spawn real Bash, execute a command,+// replay the output, and observe shell exit after close.+import { mkdtempSync, rmSync, writeFileSync } from "node:fs";+import { tmpdir } from "node:os";+import path from "node:path";+import { describe, expect, it, vi } from "vitest";import { attachPty, closePty, hasPty, openPty, writePty } from "./pty";@@ -15,33 +17,61 @@ const OWNER = "owner-a";describe("pty session manager", () => {it("opens a shell, runs echo, replays buffer, and dies on close", async () => {- const { id, cwd } = await openPty({ cols: 80, rows: 24, owner: OWNER });- expect(cwd.length).toBeGreaterThan(0);- expect(hasPty(id, OWNER)).toBe(true);-- let out = "";- let exit: number | null = null;- const detach = attachPty(id, OWNER, 0, {- onData: (chunk) => (out += chunk),- onExit: (code) => (exit = code),- });-- // $((20+22)) proves the SHELL ran it (the keystroke echo alone still- // contains the literal "$((20+22))", never the expanded 42).- writePty(id, OWNER, "echo pty-e2e-$((20+22))\n");- await until(() => out.includes("pty-e2e-42"), 8000);- expect(out).toContain("pty-e2e-42");-- // A second attach from offset 0 must replay the same buffered output.- let replay = "";- const detach2 = attachPty(id, OWNER, 0, { onData: (c) => (replay += c), onExit: () => {} });- expect(replay).toContain("pty-e2e-42");- detach2();-- expect(closePty(id, OWNER)).toBe(true);- await until(() => exit !== null, 8000);- expect(exit).not.toBeNull();- expect(closePty(id, OWNER)).toBe(false); // idempotent after death- detach();+ // The real PTY must not load the host owner's startup, readline or history+ // files. Keep the production login-shell arguments and exercise actual Bash.+ const fixture = mkdtempSync(path.join(tmpdir(), "mso-pty-e2e-"));+ let id: string | undefined;+ let detach = () => {};+ let detach2 = () => {};+ try {+ const shell = path.join(fixture, "shell");+ writeFileSync(path.join(fixture, "history"), "", { mode: 0o600 });+ writeFileSync(path.join(fixture, "inputrc"), "", { mode: 0o600 });+ writeFileSync(shell, `#!/bin/sh+MSO_PTY_FIXTURE_DIR=\${0%/*}+export HISTFILE="$MSO_PTY_FIXTURE_DIR/history"+export INPUTRC="$MSO_PTY_FIXTURE_DIR/inputrc"+exec /bin/bash --noprofile --norc "$@"+`, { mode: 0o700 });+ vi.stubEnv("SHELL", shell);+ const opened = await openPty({ cols: 80, rows: 24, owner: OWNER });+ id = opened.id;+ const { cwd } = opened;+ expect(cwd.length).toBeGreaterThan(0);+ expect(hasPty(id, OWNER)).toBe(true);++ let out = "";+ let exit: number | null = null;+ detach = attachPty(id, OWNER, 0, {+ onData: (chunk) => (out += chunk),+ onExit: (code) => (exit = code),+ });++ // $((20+22)) proves the SHELL ran it (the keystroke echo alone still+ // contains the literal "$((20+22))", never the expanded 42).+ writePty(id, OWNER, "echo pty-e2e-$((20+22))\n");+ await until(() => out.includes("pty-e2e-42"), 8000);+ expect(out).toContain("pty-e2e-42");++ // A second attach from offset 0 must replay the same buffered output.+ let replay = "";+ detach2 = attachPty(id, OWNER, 0, { onData: (c) => (replay += c), onExit: () => {} });+ expect(replay).toContain("pty-e2e-42");+ detach2();++ expect(closePty(id, OWNER)).toBe(true);+ await until(() => exit !== null, 8000);+ expect(exit).not.toBeNull();+ expect(closePty(id, OWNER)).toBe(false); // idempotent after death+ detach();+ } finally {+ detach2();+ detach();+ try { if (id) closePty(id, OWNER); }+ finally {+ vi.unstubAllEnvs();+ rmSync(fixture, { recursive: true, force: true });+ }+ }}, 20_000);});