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(tui): the panel no longer scrolls itself away, and command output survives (#261)
Abdurrahman Fakhrulca2035208d88
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex b0a44b5c..7ff4a4d9 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -12,6 +12,7 @@ this is the *what*, and it is what Settings → Account → About shows as “Wh**Fixed**+- `tui` the panel no longer scrolls itself away, and command output survives- `integrations` restore three fixes a later PR silently reverted, and follow the shell theme- `integrations` the iOS zoom fix targeted a selector the page does not use@@ -20,6 +21,11 @@ this is the *what*, and it is what Settings → Account → About shows as “Wh- `integrations` parse each inline script, not one greedy concatenation- `config` document MSO_EVIDENCE_DIR, the evidence harness output path+**Chores**++- regenerate changelog after merging main+- regenerate changelog+## 2026-11-02**Added**diff --git a/scripts/mso-agent-command-lines.mjs b/scripts/mso-agent-command-lines.mjsnew file mode 100644index 00000000..28a85faa--- /dev/null+++ b/scripts/mso-agent-command-lines.mjs@@ -0,0 +1,20 @@+// Command output buffer for the panel.+//+// Why this exists at all: the transcript is rebuilt from session history on every sync, so a line written+// straight into the viewport survives only until the next sync rebuilds it. Command output is not part of+// history, so it needs somewhere durable to live and a place in the composition order.+//+// Bounded because a runaway command can print without limit and only the tail is ever visible.+const LIMIT = 2000;++export function createCommandLines(limit = LIMIT) {+ const lines = [];+ return {+ lines,+ push(line) {+ lines.push(String(line ?? ""));+ if (lines.length > limit) lines.splice(0, lines.length - limit);+ },+ clear() { lines.length = 0; },+ };+}diff --git a/scripts/mso-agent-command-lines.test.ts b/scripts/mso-agent-command-lines.test.tsnew file mode 100644index 00000000..c7914148--- /dev/null+++ b/scripts/mso-agent-command-lines.test.ts@@ -0,0 +1,47 @@+import { describe, expect, it } from "vitest";+import { createCommandLines } from "./mso-agent-command-lines.mjs";++// These three defects were all invisible to the existing suite and all found in a real terminal:+//+// 1. The composer grew its frame with CRLF while the panel still reserved the old height, so opening+// the / menu scrolled the whole screen by 8 rows and the banner never came back.+// 2. Command output was appended straight into the viewport, and the next sync rebuilt the transcript+// from history, so /help and /find printed nothing at all.+// 3. No test covered either, because every test drove the modules directly and never composed a frame.++describe("command line buffer", () => {+ it("keeps output so sync can compose it, instead of losing it to the transcript rebuild", () => {+ const command = createCommandLines();+ command.push("2 matches for \"needle\"");+ expect(command.lines).toEqual(["2 matches for \"needle\""]);+ });++ it("preserves order across many pushes, because command output reads top to bottom", () => {+ const command = createCommandLines();+ for (let i = 0; i < 5; i += 1) command.push(`line ${i}`);+ expect(command.lines).toEqual(["line 0", "line 1", "line 2", "line 3", "line 4"]);+ });++ it("bounds the buffer and drops from the front, since only the tail is ever visible", () => {+ const command = createCommandLines(3);+ for (let i = 0; i < 6; i += 1) command.push(`line ${i}`);+ expect(command.lines).toEqual(["line 3", "line 4", "line 5"]);+ });++ it("coerces null and undefined rather than printing the word, and never throws", () => {+ const command = createCommandLines();+ command.push(null);+ command.push(undefined);+ command.push(0);+ expect(command.lines).toEqual(["", "", "0"]);+ });++ it("clears to an empty array in place, so a composed reference stays valid", () => {+ const command = createCommandLines();+ command.push("a");+ const reference = command.lines;+ command.clear();+ expect(reference).toEqual([]);+ expect(reference).toBe(command.lines);+ });+});diff --git a/scripts/mso-agent-composer.mjs b/scripts/mso-agent-composer.mjsindex 6f18f4c4..83433a2c 100644--- a/scripts/mso-agent-composer.mjs+++ b/scripts/mso-agent-composer.mjs@@ -19,7 +19,7 @@ export class AgentComposer {reservedRows() { return this._reservedRows || 0; }onRows(cb) { if (typeof cb === "function") this._onRows = cb; return this; }- async question(prompt, { complete = null, history = true, onCancel = null, onTab = null, panelLabel = "commands & skills", selectOnEnter = false, escapeCancels = false, footer = null, separator = null, onToggleStatusBar = null, onRows = /** @type {((rows: number) => void)|null} */ (null) } = {}) {+ async question(prompt, { complete = /** @type {((value: string) => Array<any>) | null} */ (null), history = true, onCancel = null, onTab = null, panelLabel = "commands & skills", selectOnEnter = false, escapeCancels = false, footer = null, separator = null, onToggleStatusBar = null, onRows = /** @type {((rows: number) => void)|null} */ (null) } = {}) {if (this.closed) return null;const input = this.input, output = this.output, C = this.C;return new Promise((resolve) => {@@ -32,11 +32,9 @@ export class AgentComposer {const wasRaw = Boolean(input.isRaw);const matches = () => dismissed || !complete ? [] : complete(value) || [];- // Reserve physical rows only when the frame grows. Redraws diff row-by-row in place- // without emitting LF/CRLF, keeping terminal scrollback clean.- // Mirrored on the instance so a test can assert the reservation came back down after an overlay- // closes; otherwise the shrink is only visible as terminal side effects.- const reserve = (rows) => { reservedRows = this._reservedRows = reserveComposerRows(output, reservedRows, rows); };+ // Panel mode owns every row, so the height is reported to it and the instance mirror is what a+ // test reads. Growing with CRLF here would scroll the panel itself off the top of the screen.+ const reserve = (rows) => { reservedRows = this._reservedRows = rowCallback ? rows : reserveComposerRows(output, reservedRows, rows); };const erase = () => { cursorHome(output, lastCursorRow); eraseFrame(output, paintedLines); paintedLines = []; lastCursorRow = 0; reservedRows = 0; setRows(0); };const render = () => {cursorHome(output, lastCursorRow);diff --git a/scripts/mso-agent-row-budget.test.ts b/scripts/mso-agent-row-budget.test.tsnew file mode 100644index 00000000..3535ace1--- /dev/null+++ b/scripts/mso-agent-row-budget.test.ts@@ -0,0 +1,79 @@+import { EventEmitter } from "node:events";+import { describe, expect, it } from "vitest";+import { AgentComposer } from "./mso-agent-composer.mjs";+import { panelGeometry } from "./mso-agent-panel-geometry.mjs";++class FakeInput extends EventEmitter {+ isRaw = false;+ resume() {}+ pause() {}+ setRawMode(value: boolean) { this.isRaw = value; }+}++class FakeOutput extends EventEmitter {+ isTTY = true;+ columns = 100;+ rows = 30;+ chunks: string[] = [];+ write(value: string) { this.chunks.push(String(value)); return true; }+ // A newline scrolls the screen; in the alternate screen that is exactly what pushes the banner off+ // the top and cannot be undone, so the test counts them rather than trusting the frame maths.+ get newlines(): number { return this.chunks.join("").split("\n").length - 1; }+}++const colors = { blue: "", bold: "", reset: "", dim: "", warn: "", c: "", cyan: "", err: "" };++describe("panel and composer share one row budget", () => {+ // The bug this pins down: the panel reserved the composer's rows, and the composer ALSO grew its+ // frame with CRLF. Opening the / menu therefore scrolled the screen by the menu height, and closing+ // it left the panel shifted up for the rest of the session.+ it("never emits a newline while a completion menu opens, because a newline scrolls the panel away", async () => {+ const input = new FakeInput();+ const output = new FakeOutput();+ const composer = new AgentComposer({+ input: input as never,+ output: output as never,+ colors,+ onRows: () => {},+ });+ const options = /** @type {any} */ ({ complete: (v: string) => (v.startsWith("/") ? ["/help", "/models", "/new"] : []) });+ const answer = composer.question("› ", options);+ input.emit("keypress", "/", { sequence: "/" });+ // Measured before submit: the echo of an accepted line legitimately ends in a newline, but nothing+ // while the menu is opening may, because that scroll is what moved the panel.+ expect(output.newlines).toBe(0);+ input.emit("keypress", undefined, { name: "return" });+ await answer;+ });++ it("reports the menu height to the panel instead of growing the terminal", async () => {+ const reported: number[] = [];+ const input = new FakeInput();+ const output = new FakeOutput();+ const composer = new AgentComposer({+ input: input as never,+ output: output as never,+ colors,+ onRows: (rows: number) => reported.push(rows),+ });+ const options = /** @type {any} */ ({ complete: (v: string) => (v.startsWith("/") ? ["/help", "/models", "/new", "/session"] : []) });+ const answer = composer.question("› ", options);+ input.emit("keypress", "/", { sequence: "/" });+ // A menu of 4 items plus the prompt must be reported, not silently absorbed.+ expect(reported.some((rows) => rows >= 5)).toBe(true);+ input.emit("keypress", undefined, { name: "return" });+ await answer;+ });++ it("keeps panel rows plus composer rows inside the terminal at every reservation", () => {+ const output = { columns: 100, rows: 30 };+ const session = { agentSession: { id: "s", name: "mso", title: "t" }, statusBar: true };+ for (const reservation of [1, 3, 6, 10, 14]) {+ const g = panelGeometry({ output, session, colors: {}, getSessions: () => [], promptReservation: reservation });+ // The frame ends with one blank cursor line, and that line is where the composer's FIRST row is+ // written. So the frame already covers one reserved row: frame + reservation - 1 is the budget.+ const frame = g.viewRows + g.panel.length + 1;+ expect(frame + reservation - 1).toBeLessThanOrEqual(30);+ }+ });+});diff --git a/scripts/mso-agent-screen-loop.mjs b/scripts/mso-agent-screen-loop.mjsindex 0430ddeb..c6ff4db2 100644--- a/scripts/mso-agent-screen-loop.mjs+++ b/scripts/mso-agent-screen-loop.mjs@@ -11,11 +11,10 @@ import { renderViewport } from "./mso-agent-viewport-render.mjs";import { paneLines } from "./mso-agent-pane.mjs";import { withPreamble } from "./mso-agent-banner-lines.mjs";import { clampPromptRows, PROMPT_ROWS } from "./mso-agent-composer-ui.mjs";+import { createCommandLines } from "./mso-agent-command-lines.mjs";import { createCompactionWatcher } from "./mso-agent-compaction.mjs";import { createAttentionNotifier } from "./mso-agent-attention.mjs";import { createClickHintReporter, createMcpRefresher } from "./mso-agent-panel-effects.mjs";-import { createPrinter } from "./mso-agent-print.mjs";-import { formatClickHint, shouldShowClickHint } from "./mso-agent-click-hint.mjs";export { clampPromptRows, PROMPT_ROWS } from "./mso-agent-composer-ui.mjs";/**@@ -65,6 +64,7 @@ export function mountScreenLoop({});let painted = [];let promptReservation = PROMPT_ROWS;+ const command = createCommandLines();const setPromptRows = (rows) => {// Clamps reservation without repainting immediately; repainting while composer@@ -108,18 +108,19 @@ export function mountScreenLoop({commitStream(viewport);compaction.check(session, { colors });const trans = transcriptLines(session, { colors, width: geometry().transWidth, groupTools: session?.grouping === "auto" });- setLines(viewport, withPreamble(preamble?.() ?? null, [...trans, ...compaction.lines(colors)]));+ // Command output is composed here rather than appended straight into the viewport, because the next+ // sync rebuilds the line list from history and would drop anything that lived only in the viewport.+ setLines(viewport, withPreamble(preamble?.() ?? null, [...trans, ...command.lines, ...compaction.lines(colors)]));paint();// Background session attention: evaluated on sync when sessions list changesattentionNotifier.notify(getSessions());triggerMcpRefresh();};- // Streaming text goes into the buffer and repaints, so a long answer does not wait for the turn to- // end before it becomes visible. Command output arrives as whole lines instead of chunks, so it is- // committed immediately rather than left as a partial line.+ // Streaming repaints per chunk, so a long answer shows as it arrives instead of at turn end.session.streamSink = { write(chunk) { appendStream(viewport, chunk); paint(); } };- session.printSink = (line) => { appendStream(viewport, `${String(line ?? "")}\n`); commitStream(viewport); paint(); };+ // Re-composed on every sync, because the transcript is rebuilt from history and would drop it.+ session.printSink = (line) => { command.push(line); sync(); };const onResize = () => { viewport.rows = output.rows || 24; sync(); };output.on?.("resize", onResize);@@ -169,7 +170,7 @@ export function mountScreenLoop({const resume = () => { panelSuspend.resume(); attentionNotifier.resume(); };const initLines = transcriptLines(session, { colors, width: geometry().transWidth, groupTools: session?.grouping === "auto" });- setLines(viewport, withPreamble(preamble?.() ?? null, [...initLines, ...compaction.lines(colors)]));+ setLines(viewport, withPreamble(preamble?.() ?? null, [...initLines, ...command.lines, ...compaction.lines(colors)]));paint();const loop = {