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
fix(agent): wake prompt after child tty sigint
Rahman5c2a00ebe5b9
diff --git a/bin/mso b/bin/msoindex 437e12cb..ad306f66 100755--- a/bin/mso+++ b/bin/mso@@ -126,7 +126,7 @@# Docs: https://github.com/rahmanef63/msoset -euo pipefail-VERSION="1.5.7"+VERSION="1.5.8"ROOT="$(cd "$(dirname "$(readlink -f "$0")")/.." && pwd)"die() { echo "mso: $*" >&2; exit 1; }diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex 310103f6..dde9018c 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -20,6 +20,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.**Fixed**+- `agent` wake prompt after child tty sigint- `cli` clarify version and update labels- `agent` stabilize terminal banner navigation- `cli` make updates visible and idempotentdiff --git a/docs/PROGRESS.md b/docs/PROGRESS.mdindex edfdc38f..80ccad43 100644--- a/docs/PROGRESS.md+++ b/docs/PROGRESS.md@@ -2,6 +2,12 @@Running log of what shipped each phase. Newest at top.+## 2026-09-01 — External TTY Ctrl+C handoff hardening — SHIPPED++MSO Agent 1.5.8 closes one live-only SIGINT edge case found after the 1.5.7 deployment: cancelling the `/model` child TUI could leave the shared terminal in cooked mode, so the next Ctrl+C arrived as an OS `SIGINT` while the parent composer was awaiting a keypress. The interrupt manager correctly requested exit, but the waiting prompt was not resolved. `AgentComposer` now exposes one idempotent `cancelCurrent()` primitive shared by raw-key Ctrl+C and OS-level SIGINT. The parent SIGINT bridge wakes the current prompt on exit/interrupt, so child TTY handoffs cannot strand the Agent.++Regression coverage now includes programmatic cancellation of a waiting composer prompt in addition to the 1.5.7 raw-key and AbortController tests. Live PTY verification specifically covers `/model` cancel → returned Agent prompt → Ctrl+C clean exit.+## 2026-09-01 — Agent terminal control semantics + interrupt-safe history — SHIPPEDMSO Agent 1.5.7 aligns terminal control behavior with mature agent harnesses. Ctrl+C now clears a non-empty draft, exits cleanly from an empty idle prompt, and aborts an active assistant/tool HTTP turn through a real `AbortController`; a quick second Ctrl+C while a turn is still stopping requests exit. Ctrl+D follows readline semantics (delete-right with text, EOF exit when empty), Ctrl+L clears/repaints, Ctrl+W deletes the previous word, Ctrl+P/N mirror history ↑/↓, and Ctrl+A/E plus Ctrl+B/F provide standard line navigation. `/quit` is now an explicit `/exit` alias.diff --git a/scripts/mso-agent-composer.mjs b/scripts/mso-agent-composer.mjsindex 416f4cbf..7e66aef5 100644--- a/scripts/mso-agent-composer.mjs+++ b/scripts/mso-agent-composer.mjs@@ -1,4 +1,5 @@import readline from "node:readline";+import { fit, pad, wordLeftIndex, wordRightIndex } from "./mso-agent-editing.mjs";import process from "node:process";const CLEAR_LINE = "\x1b[2K";@@ -11,33 +12,6 @@ const chars = (value) => Array.from(String(value ?? ""));const width = (value) => chars(plain(value)).length;const clamp = (value, min, max) => Math.min(Math.max(value, min), max);-export function wordLeftIndex(value, cursor) {- const row = chars(value);- let index = clamp(cursor, 0, row.length);- while (index > 0 && /\s/u.test(row[index - 1])) index--;- while (index > 0 && !/\s/u.test(row[index - 1])) index--;- return index;-}--export function wordRightIndex(value, cursor) {- const row = chars(value);- let index = clamp(cursor, 0, row.length);- while (index < row.length && /\s/u.test(row[index])) index++;- while (index < row.length && !/\s/u.test(row[index])) index++;- return index;-}--function fit(value, max) {- const row = chars(plain(value).replace(/[\r\n\t]+/g, " "));- if (row.length <= max) return row.join("");- return max <= 1 ? "…".slice(0, max) : row.slice(0, max - 1).join("") + "…";-}--function pad(value, max) {- const clean = fit(value, max);- return clean + " ".repeat(Math.max(0, max - width(clean)));-}-export function inputViewport(value, cursor, maxWidth) {const row = chars(value);const max = Math.max(1, maxWidth);@@ -95,6 +69,7 @@ export class AgentComposer {this.C = colors;this.history = [];this.closed = false;+ this._cancelCurrent = null;readline.emitKeypressEvents(this.input);}@@ -103,7 +78,7 @@ export class AgentComposer {const input = this.input, output = this.output, C = this.C;return new Promise((resolve) => {let value = "", cursor = 0, selected = 0, reservedMenuRows = 0;- let dismissed = false, historyIndex = null, draft = "";+ let dismissed = false, historyIndex = null, draft = "", settled = false;const wasRaw = Boolean(input.isRaw);const matches = () => dismissed || !complete ? [] : complete(value) || [];@@ -136,10 +111,13 @@ export class AgentComposer {};const cleanup = () => {input.off("keypress", onKey);+ if (this._cancelCurrent === cancel) this._cancelCurrent = null;if (typeof input.setRawMode === "function") input.setRawMode(wasRaw);input.pause();};const finish = (result, echo = true) => {+ if (settled) return;+ settled = true;erase();if (echo) output.write(`${prompt}${value}\r\n`);cleanup();@@ -149,6 +127,17 @@ export class AgentComposer {}resolve(result);};+ const cancel = (echo = true) => {+ if (settled) return false;+ if (typeof onCancel === "function") onCancel();+ settled = true;+ erase();+ if (echo) output.write("^C\r\n");+ cleanup();+ resolve(null);+ return true;+ };+ this._cancelCurrent = cancel;const edit = (next, nextCursor) => {value = next; cursor = clamp(nextCursor, 0, chars(value).length);selected = 0; dismissed = false; historyIndex = null;@@ -171,8 +160,7 @@ export class AgentComposer {const items = matches();if (key.ctrl && key.name === "c") {if (value) return edit("", 0);- if (typeof onCancel === "function") onCancel();- erase(); output.write("^C\r\n"); cleanup(); return resolve(null);+ return cancel(true);}if (key.ctrl && key.name === "l") {output.write(CLEAR_SCREEN); reservedMenuRows = 0; return render();@@ -226,6 +214,10 @@ export class AgentComposer {});}+ cancelCurrent({ echo = true } = {}) {+ return typeof this._cancelCurrent === "function" ? this._cancelCurrent(echo) : false;+ }+close() {this.closed = true;if (typeof this.input.setRawMode === "function" && this.input.isRaw) this.input.setRawMode(false);diff --git a/scripts/mso-agent-composer.test.ts b/scripts/mso-agent-composer.test.tsindex f2b1664f..8d53b5b7 100644--- a/scripts/mso-agent-composer.test.ts+++ b/scripts/mso-agent-composer.test.ts@@ -174,4 +174,18 @@ describe("MSO Agent interactive composer primitives", () => {composer.close();});++ it("can cancel a waiting prompt when Ctrl+C arrives as an OS SIGINT after an external TTY child", async () => {+ class FakeInput extends EventEmitter { isRaw = false; resume() {} pause() {} setRawMode(value: boolean) { this.isRaw = value; } }+ class FakeOutput { columns = 88; chunks: string[] = []; write(value: string) { this.chunks.push(String(value)); return true; } }+ const input = new FakeInput(); const output = new FakeOutput();+ const composer = new AgentComposer({ input: input as never, output: output as never, colors: { blue: "", bold: "", reset: "", dim: "" } });+ const waiting = composer.question("› ");+ expect(composer.cancelCurrent()).toBe(true);+ await expect(waiting).resolves.toBeNull();+ expect(output.chunks.join("")).toContain("^C\r\n");+ expect(composer.cancelCurrent()).toBe(false);+ composer.close();+ });+});diff --git a/scripts/mso-agent-editing.mjs b/scripts/mso-agent-editing.mjsnew file mode 100644index 00000000..84c9a8ab--- /dev/null+++ b/scripts/mso-agent-editing.mjs@@ -0,0 +1,32 @@+const ANSI = /\x1b\[[0-9;]*m/g;+const chars = (value) => Array.from(String(value ?? ""));+const plain = (value) => String(value ?? "").replace(ANSI, "");+const width = (value) => chars(plain(value)).length;+const clamp = (value, min, max) => Math.min(Math.max(value, min), max);++export function fit(value, max) {+ const row = chars(plain(value).replace(/[\r\n\t]+/g, " "));+ if (row.length <= max) return row.join("");+ return max <= 1 ? "…".slice(0, max) : row.slice(0, max - 1).join("") + "…";+}++export function pad(value, max) {+ const clean = fit(value, max);+ return clean + " ".repeat(Math.max(0, max - width(clean)));+}++export function wordLeftIndex(value, cursor) {+ const row = chars(value);+ let index = clamp(cursor, 0, row.length);+ while (index > 0 && /\s/u.test(row[index - 1])) index--;+ while (index > 0 && !/\s/u.test(row[index - 1])) index--;+ return index;+}++export function wordRightIndex(value, cursor) {+ const row = chars(value);+ let index = clamp(cursor, 0, row.length);+ while (index < row.length && /\s/u.test(row[index])) index++;+ while (index < row.length && !/\s/u.test(row[index])) index++;+ return index;+}diff --git a/scripts/mso-agent.mjs b/scripts/mso-agent.mjsindex 369af624..9d82a4e1 100644--- a/scripts/mso-agent.mjs+++ b/scripts/mso-agent.mjs@@ -120,7 +120,14 @@ async function main() {};const rl = new AgentComposer({ input: process.stdin, output: process.stdout, colors: C });const interrupts = new AgentInterruptManager({ output: process.stdout, colors: C });- const onSigint = () => interrupts.handleSigint();+ const onSigint = () => {+ const action = interrupts.handleSigint();+ // External child TUIs can restore the shared terminal to cooked mode. In that+ // state Ctrl+C arrives as SIGINT instead of a raw keypress, so wake whichever+ // composer prompt is currently waiting instead of leaving it hung.+ if (action === "exit") rl.cancelCurrent({ echo: true });+ else if (action === "interrupt") rl.cancelCurrent({ echo: false });+ };process.on("SIGINT", onSigint);const completeSlash = (line) => slashCompletionItems(session.state.skills, line, process.cwd(), session);try {diff --git a/scripts/mso-model-dx-contract.test.ts b/scripts/mso-model-dx-contract.test.tsindex a055f3aa..53b9a8c0 100644--- a/scripts/mso-model-dx-contract.test.ts+++ b/scripts/mso-model-dx-contract.test.ts@@ -14,7 +14,7 @@ const all = [cli, agentCli, configRoute, oauthRoute, slash, picker].join("\n");describe("MSO model/provider/session CLI contract", () => {it("keeps provider auth (`models`) separate from active selection (`model`)", () => {- expect(cli).toContain('VERSION="1.5.7"');+ expect(cli).toContain('VERSION="1.5.8"');expect(cli).toContain("models * Configure AI providers/auth");expect(cli).toContain("model [ref] Select active model");expect(agentCli).toContain("run_models()");