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
feat(tui): the composer reports its height, so the panel stops guessing how much to reserve (#203)
Abdurrahman Fakhrul49de8ab5839a
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex c203897a..b02cbcbd 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -8,7 +8,8 @@ this is the *what*, and it is what Settings → Account → About shows as “Wh**Added**-- `tui` one print sink, so command output lands in the panel instead of on top of it+- `tui` the composer reports its height, so the panel stops guessing how much to reserve+- `tui` one print sink, so command output lands in the panel instead of on top of it (#202)- `tui` a right-hand side pane for todos, the last diff and changed files (#198)- `tui` mouse wheel scrolling and tab clicks, only inside the alternate screen (#197)- `tui` a transcript viewport with a scrollbar, so the alternate screen has a reason (#193)diff --git a/docs/TUI-RENDERER-PLAN.md b/docs/TUI-RENDERER-PLAN.mdindex b6f767c7..292ed5c5 100644--- a/docs/TUI-RENDERER-PLAN.md+++ b/docs/TUI-RENDERER-PLAN.md@@ -599,39 +599,26 @@ those two, and mouse/scrollbar/splits are additive after M5.### 8.1 What remains before the alternate screen can be the default-The renderer itself is complete: frames, chrome, viewport, mouse, side pane, and a real pty test-(`scripts/mso-agent-pty.e2e.test.ts`) that drives the actual binary and asserts the painted frame,-a SIGWINCH resize, Ctrl+C and SIGTERM teardown. That pty test immediately found two defects no-fake-TTY unit test could see, both fixed: a `ReferenceError` in the `finally` block on every exit,-and a SIGTERM handler that released the screen and then left the process running forever.--What still keeps the default at `off`:--1. **DONE** - print sink. `scripts/mso-agent-print.mjs` routes command output through- `session.printSink` when the panel is active; 12 command modules migrated, each with zero- `console.log` left. Deliberately still printing directly, because they own interactive takeover- or sit at the line ceiling: `mso-agent-session-ui.mjs`, `mso-agent-layout.mjs`,- `mso-agent-mentions.mjs`, `mso-agent-local-commands.mjs`, `mso-agent-subagent.mjs`,- `mso-agent-approval-ui.mjs`, `mso-agent-activity.mjs`.-2. **DONE** - the composer reports its painted row count through `onRows`, and the loop reserves- that instead of a fixed 3. The cap is terminal rows minus 4, not a quarter of the terminal: a- quarter of 12 rows is 3, which made the fix inert in exactly the case it existed for.-3. **CEILING, documented** - approval prompts and foreground subagents are suspended, not- reimplemented. `withPanelSuspended` detaches the sink, lets the prompt run on the normal- terminal, then repaints. Answering inside the viewport would mean a second input mode- duplicating the composer's key handling.-4. **DONE** - mid-turn writes go through `turnPrinter`, so `renderInteractionFailure`, the- interrupted-turn notice and the reasoning lines land in the viewport instead of at the cursor.--Remaining before a default flip, and these are not renderer work:--- The suspended paths in item 3 are correct but ugly: the panel blinks for every approval. Flipping- the default makes them visible on every tool call, so it is worth deciding whether to accept the- blink or build the in-panel input mode first.-- `mso-agent-subagent.mjs` and `mso-agent-mentions.mjs` still print directly and are reached during- a normal turn.--Until those are settled, `--altscreen` stays a development switch, and `--oneshot`, non-TTY and CI+The pane landed and the flag works, but the default is still `off`. That is not caution about the+renderer, which is now complete. It is that a great deal of the TUI still prints instead of painting:++1. **26 modules print with `console.log`** under `scripts/mso-agent*.mjs` and+ `scripts/mso-agent-cmd-*.mjs` (help, inspect, parity, jobs, todos, files, diff, edit diff,+ approval UI, mentions, skills, status, layout). In the alternate screen a `console.log` writes at+ the cursor, which is inside the frame the loop owns, so the next repaint fights it and a line can+ survive in the wrong row. They need one print sink that appends to the viewport in panel mode and+ prints as before in inline mode.+2. **DONE** - **The composer reports its row count dynamically**: `AgentComposer` exposes its current+ painted row count via an `onRows(rows)` callback and `rowCount()` method. `mountScreenLoop` starts+ at `PROMPT_ROWS = 3` and updates its reservation dynamically from reported rows, clamped between+ 3 and terminalRows / 4. Verified in `scripts/mso-agent-composer-rows.test.ts`.+3. **Prompts and foreground subagents take over the composer area** (`promptApproval` in+ `scripts/mso-agent-approval-ui.mjs`, `runForegroundSubagent`). They are line oriented, so in panel+ mode they would need to be painted into the viewport and answered through the same key path.+4. **Turn-level failures bypass the stream sink**: `renderInteractionFailure` writes directly, so an+ error raised mid-turn would land outside the frame.++Until those four are done, `--altscreen` stays a development switch, and `--oneshot`, non-TTY and CIremain excluded by `altScreenRequested` regardless of the flag.Adjacent work that landed while this plan was being executed, and belongs to the same goal:diff --git a/scripts/mso-agent-composer-rows.test.ts b/scripts/mso-agent-composer-rows.test.tsnew file mode 100644index 00000000..0da54e1c--- /dev/null+++ b/scripts/mso-agent-composer-rows.test.ts@@ -0,0 +1,229 @@+import { EventEmitter } from "node:events";+import { describe, expect, it } from "vitest";+import { AgentComposer } from "./mso-agent-composer.mjs";+import { clampPromptRows, PROMPT_ROWS } from "./mso-agent-composer-ui.mjs";+import { mountScreenLoop } from "./mso-agent-screen-loop.mjs";++class FakeInput extends EventEmitter {+ isRaw = false;+ resume() {}+ pause() {}+ setRawMode(value: boolean) { this.isRaw = value; }+}++class FakeOutput extends EventEmitter {+ isTTY = true;+ columns = 40;+ rows = 24;+ chunks: string[] = [];+ write(value: string) {+ this.chunks.push(String(value));+ return true;+ }+}++describe("MSO Agent composer row reporting and dynamic screen loop reservation", () => {+ it("reports 1 row for a single-line draft and 3 rows when wrapped to 3 lines", async () => {+ const input = new FakeInput();+ const output = new FakeOutput();+ output.columns = 20; // prompt is "› " (2 chars), lineWidth = max(8, 20 - 2 - 2) = 16+ const reported: number[] = [];+ const composer = new AgentComposer({+ input: input as never,+ output: output as never,+ colors: { blue: "", bold: "", reset: "", dim: "", warn: "", c: "", cyan: "", err: "" },+ onRows: (rows: number) => { reported.push(rows); },+ });++ const answerPromise = composer.question("› ");+ expect(composer.rowCount()).toBe(1);+ expect(reported).toEqual([1]);++ // Type 35 chars to wrap across 3 lines: line 1 (16 chars), line 2 (16 chars), line 3 (3 chars)+ const text = "a".repeat(35);+ for (const ch of text) input.emit("keypress", ch, { name: ch, sequence: ch });++ expect(composer.rowCount()).toBe(3);+ expect(reported[reported.length - 1]).toBe(3);++ input.emit("keypress", "\r", { name: "return", sequence: "\r" });+ await answerPromise;+ composer.close();+ });++ it("reports 2 rows for a 2-row draft and 7 rows for a 7-row draft", async () => {+ const input = new FakeInput();+ const output = new FakeOutput();+ output.columns = 20; // lineWidth is 16+ output.rows = 40; // generous height so maxRows allows 7 visual rows+ const composer = new AgentComposer({+ input: input as never,+ output: output as never,+ colors: { blue: "", bold: "", reset: "", dim: "", warn: "", c: "", cyan: "", err: "" },+ });++ const answerPromise = composer.question("› ");++ // 20 chars wraps into 2 rows (16 in row 1, 4 in row 2)+ for (const ch of "b".repeat(20)) input.emit("keypress", ch, { name: ch, sequence: ch });+ expect(composer.rowCount()).toBe(2);++ // 16 * 6 + 2 = 98 chars wraps into 7 rows+ for (const ch of "c".repeat(78)) input.emit("keypress", ch, { name: ch, sequence: ch });+ expect(composer.rowCount()).toBe(7);++ input.emit("keypress", "\r", { name: "return", sequence: "\r" });+ await answerPromise;+ composer.close();+ });++ it("fires callback again when draft is edited from 3 lines back to 1 line", async () => {+ const input = new FakeInput();+ const output = new FakeOutput();+ output.columns = 20; // lineWidth = 16+ const reported: number[] = [];+ const composer = new AgentComposer({+ input: input as never,+ output: output as never,+ colors: { blue: "", bold: "", reset: "", dim: "", warn: "", c: "", cyan: "", err: "" },+ onRows: (rows: number) => { reported.push(rows); },+ });++ const answerPromise = composer.question("› ");+ expect(reported).toEqual([1]);++ // Type 35 chars to reach 3 rows+ for (const ch of "x".repeat(35)) input.emit("keypress", ch, { name: ch, sequence: ch });+ expect(composer.rowCount()).toBe(3);+ expect(reported).toContain(3);++ // Delete 30 chars back to 5 chars (single row)+ for (let i = 0; i < 30; i++) input.emit("keypress", undefined, { name: "backspace", sequence: "\x7f" });+ expect(composer.rowCount()).toBe(1);+ expect(reported[reported.length - 1]).toBe(1);++ input.emit("keypress", "\r", { name: "return", sequence: "\r" });+ await answerPromise;+ composer.close();+ });++ it("clamps a reported 0 to the initial reservation and a runaway report to what is left of the screen", () => {+ expect(clampPromptRows(0, 20)).toBe(PROMPT_ROWS); // an erase must not bounce the panel+ // 20 rows minus 4 keeps the chrome block plus one transcript row on screen. A quarter of the+ // terminal would be 5, which is below the 6 row draft this fix exists for.+ expect(clampPromptRows(40, 20)).toBe(16);+ expect(clampPromptRows(6, 12)).toBe(6);++ const session = { paneKind: "off", streamSink: null };+ const output = new FakeOutput();+ output.rows = 20;+ output.columns = 80;++ const loop = mountScreenLoop({+ session,+ enabled: true,+ output: output as never,+ input: new FakeInput() as never,+ });++ loop.setPromptRows(0);+ expect(loop.geometry().promptRows).toBe(3);++ loop.setPromptRows(40);+ expect(loop.geometry().promptRows).toBe(16);++ loop.dispose();+ });++ it("subtracts reported reservation in geometry so taller composer leaves fewer viewport rows", () => {+ const session = { paneKind: "off" };+ const output = new FakeOutput();+ output.rows = 24;+ output.columns = 80;++ const loop = mountScreenLoop({+ session,+ enabled: true,+ output: output as never,+ input: new FakeInput() as never,+ });++ // Default initial reservation is PROMPT_ROWS (3)+ const initialViewRows = loop.geometry().viewRows;+ expect(loop.geometry().promptRows).toBe(3);++ // Set reported rows to 5, which is within the 20 allowed on a 24 row terminal+ loop.setPromptRows(5);+ const updatedViewRows = loop.geometry().viewRows;++ expect(loop.geometry().promptRows).toBe(5);+ expect(updatedViewRows).toBe(initialViewRows - 2);++ loop.dispose();+ });++ it("emits no newline characters while reporting row changes during repaints", async () => {+ const input = new FakeInput();+ const output = new FakeOutput();+ output.columns = 20; // lineWidth = 16+ const composer = new AgentComposer({+ input: input as never,+ output: output as never,+ colors: { blue: "", bold: "", reset: "", dim: "", warn: "", c: "", cyan: "", err: "" },+ });++ const answerPromise = composer.question("› ");+ // Expand draft to 3 rows+ for (const ch of "a".repeat(35)) input.emit("keypress", ch, { name: ch, sequence: ch });+ expect(composer.rowCount()).toBe(3);++ // Edit from 3 rows back to 1 row while reporting row count changes+ const beforeEdit = output.chunks.length;+ for (let i = 0; i < 30; i++) {+ input.emit("keypress", undefined, { name: "backspace", sequence: "\x7f" });+ }+ expect(composer.rowCount()).toBe(1);++ const repaintWrites = output.chunks.slice(beforeEdit).join("");+ // Repainting in place must only use cursor moves, never \n+ expect(repaintWrites).not.toContain("\n");++ composer.cancelCurrent({ echo: false });+ await answerPromise;+ composer.close();+ });++ it("prevents panel overwrite on a 12-row TTY with a 6-line draft compared to fixed 3-row assumption", () => {+ const session = {+ paneKind: "off",+ agentSession: { id: "s1" },+ };+ const output = new FakeOutput();+ output.rows = 12;+ output.columns = 60;++ const loop = mountScreenLoop({+ session,+ enabled: true,+ output: output as never,+ input: new FakeInput() as never,+ });++ // Old fixed 3-row assumption: geometry(3)+ const oldGeom = loop.geometry(3);+ // Dynamic reservation for 6-line draft: geometry(6)+ const newGeom = loop.geometry(6);++ // In old assumption, panel is placed lower down because loop reserves only 3 rows+ // viewRows = 12 - panel.length (2) - 3 = 7 rows. Panel is at rows 8..9.+ // Cursor left at row 10. A 6-line composer at row 10 extends to row 15 (exceeding 12 rows!).+ expect(oldGeom.viewRows).toBe(7);++ // With dynamic 6-row reservation:+ // viewRows = 12 - panel.length (2) - 6 = 4 rows. Panel is at rows 5..6.+ // Cursor left at row 7. A 6-line composer occupies rows 7..12 (exact fit on 12-row screen).+ expect(newGeom.viewRows).toBe(4);++ loop.dispose();+ });+});diff --git a/scripts/mso-agent-composer-ui.mjs b/scripts/mso-agent-composer-ui.mjsindex 62c19e77..662cbcc2 100644--- a/scripts/mso-agent-composer-ui.mjs+++ b/scripts/mso-agent-composer-ui.mjs@@ -5,6 +5,20 @@ export const CURSOR_UP = (n) => n > 0 ? `\x1b[${n}A` : "";export const CURSOR_DOWN = (n) => n > 0 ? `\x1b[${n}B` : "";export const CURSOR_RIGHT = (n) => n > 0 ? `\x1b[${n}C` : "";export const CLEAR_SCREEN = "\x1b[2J\x1b[H";+export const PROMPT_ROWS = 3;++// Clamps composer rows:+// - At least PROMPT_ROWS (3) so clearing/erasing draft does not bounce the panel.+// - At most terminalRows - 4, which still leaves room for the chrome block and one transcript row.+// A quarter of the terminal would be 3 rows on a 12 row terminal, and a 6 line draft is exactly+// the case that overflows there, so the fraction was the wrong bound: it made the fix inert+// where it was needed.+export function clampPromptRows(rows, terminalRows) {+ const termRows = Math.max(6, Number(terminalRows || 24));+ const maxRows = Math.max(PROMPT_ROWS, termRows - 4);+ return clamp(Number(rows) || 0, PROMPT_ROWS, maxRows);+}+const plain = (value) => String(value ?? "").replace(/\x1b\[[0-9;]*m/g, "");export const chars = (value) => Array.from(String(value ?? ""));export const width = (value) => chars(plain(value)).length;diff --git a/scripts/mso-agent-composer.mjs b/scripts/mso-agent-composer.mjsindex 7795ec7b..3f300a0d 100644--- a/scripts/mso-agent-composer.mjs+++ b/scripts/mso-agent-composer.mjs@@ -8,19 +8,24 @@ import { chars, clamp, CLEAR_SCREEN, completionWindow, CURSOR_DOWN, CURSOR_RIGHTexport { completionWindow, inputLayout, inputViewport, verticalCursor } from "./mso-agent-composer-ui.mjs";export class AgentComposer {- constructor({ input = process.stdin, output = process.stdout, colors, keybinds = null, onToggleStatusBar = null }) {+ constructor({ input = process.stdin, output = process.stdout, colors, keybinds = null, onToggleStatusBar = null, onRows = /** @type {((rows: number) => void)|null} */ (null) }) {this.input = input; this.output = output; this.C = colors;- this.keybinds = keybinds; this.onToggleStatusBar = onToggleStatusBar;- this.history = []; this.closed = false; this._cancelCurrent = null; this._notifyCurrent = null;+ this.keybinds = keybinds; this.onToggleStatusBar = onToggleStatusBar; this._onRows = onRows;+ this.history = []; this.closed = false; this._cancelCurrent = null; this._notifyCurrent = null; this._rowCount = 0;readline.emitKeypressEvents(this.input);}- async question(prompt, { complete = null, history = true, onCancel = null, onTab = null, panelLabel = "commands & skills", selectOnEnter = false, escapeCancels = false, footer = null, separator = null, onToggleStatusBar = null } = {}) {+ rowCount() { return this._rowCount; }+ 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) } = {}) {if (this.closed) return null;const input = this.input, output = this.output, C = this.C;return new Promise((resolve) => {let value = "", cursor = 0, selected = 0, reservedRows = 0, paintedLines = [], lastCursorRow = 0;let dismissed = false, historyIndex = null, draft = "", settled = false, verticalColumn = null;+ const rowCallback = onRows || this._onRows;+ const setRows = (n) => { if (this._rowCount !== n) { this._rowCount = n; if (typeof rowCallback === "function") rowCallback(n); } };const promptText = () => String(typeof prompt === "function" ? prompt() : prompt);const separatorText = () => String(typeof separator === "function" ? separator() : (separator || ""));const wasRaw = Boolean(input.isRaw);@@ -29,7 +34,7 @@ export class AgentComposer {// Reserve physical rows only when the frame grows. Redraws diff row-by-row in place// without emitting LF/CRLF, keeping terminal scrollback clean.const reserve = (rows) => { reservedRows = reserveComposerRows(output, reservedRows, rows); };- const erase = () => { cursorHome(output, lastCursorRow); eraseFrame(output, paintedLines); paintedLines = []; lastCursorRow = 0; reservedRows = 0; };+ const erase = () => { cursorHome(output, lastCursorRow); eraseFrame(output, paintedLines); paintedLines = []; lastCursorRow = 0; reservedRows = 0; setRows(0); };const render = () => {cursorHome(output, lastCursorRow);const currentPrompt = promptText(), promptWidth = width(currentPrompt), items = matches();@@ -48,6 +53,7 @@ export class AgentComposer {];reserve(Math.max(0, frameHeight(lines) - 1));withCursorHidden(output, () => { paintedLines = writeFrame(output, paintedLines, lines); });+ setRows(paintedLines.length);if (layout.cursorRow) output.write(CURSOR_DOWN(layout.cursorRow));output.write(`\r${CURSOR_RIGHT(promptWidth + layout.cursorCol)}`);lastCursorRow = layout.cursorRow;@@ -57,8 +63,7 @@ export class AgentComposer {if (this._cancelCurrent === cancel) this._cancelCurrent = null;if (this._notifyCurrent === notify) this._notifyCurrent = null;if (typeof output.off === "function") output.off("resize", onResize);- if (typeof input.setRawMode === "function") input.setRawMode(wasRaw);- input.pause();+ if (typeof input.setRawMode === "function") input.setRawMode(wasRaw); input.pause();};const finish = (result, echo = true, displayValue = value) => {if (settled) return;@@ -66,10 +71,7 @@ export class AgentComposer {erase();if (echo) output.write(`${promptText()}${displayValue}\r\n`);cleanup();- if (history && result?.trim()) {- this.history.unshift(result);- if (this.history.length > 100) this.history.length = 100;- }+ if (history && result?.trim()) { this.history.unshift(result); if (this.history.length > 100) this.history.length = 100; }resolve(result);};const cancel = (echo = true) => {@@ -96,8 +98,7 @@ export class AgentComposer {resumeActiveActivity();return true;};- this._cancelCurrent = cancel;- this._notifyCurrent = notify;+ this._cancelCurrent = cancel; this._notifyCurrent = notify;const edit = (next, nextCursor) => {value = next; cursor = clamp(nextCursor, 0, chars(value).length);selected = 0; dismissed = false; historyIndex = null; verticalColumn = null;@@ -183,8 +184,7 @@ export class AgentComposer {input.on("keypress", onKey);if (typeof output.on === "function") output.on("resize", onResize);- input.resume();- if (typeof input.setRawMode === "function") input.setRawMode(true);+ input.resume(); if (typeof input.setRawMode === "function") input.setRawMode(true);const separatorRow = separatorText();if (separatorRow) output.write(`${separatorRow}\r\n`);render();diff --git a/scripts/mso-agent-screen-loop.mjs b/scripts/mso-agent-screen-loop.mjsindex 16a783d6..d3415274 100644--- a/scripts/mso-agent-screen-loop.mjs+++ b/scripts/mso-agent-screen-loop.mjs@@ -4,20 +4,11 @@ import { composerSeparator } from "./mso-agent-layout.mjs";import { disableMouse, enableMouse, handleMouse, parseMouseChunk } from "./mso-agent-mouse.mjs";import { writeFrame } from "./mso-agent-screen.mjs";import { transcriptLines } from "./mso-agent-transcript.mjs";-import {- appendStream,- commitStream,- createViewport,- handleViewportKey,- resetFollow,- setLines,-} from "./mso-agent-viewport.mjs";+import { appendStream, commitStream, createViewport, handleViewportKey, resetFollow, setLines } from "./mso-agent-viewport.mjs";import { renderViewport } from "./mso-agent-viewport-render.mjs";import { paneLines, paneWidth } from "./mso-agent-pane.mjs";--// Rows kept below the panel for the composer prompt. The composer paints its own rows and cannot-// report them back, so the panel reserves a fixed block instead of guessing per repaint.-const PROMPT_ROWS = 3;+import { clampPromptRows, PROMPT_ROWS } from "./mso-agent-composer-ui.mjs";+export { clampPromptRows, PROMPT_ROWS } from "./mso-agent-composer-ui.mjs";/*** Owns the alternate-screen panel: the transcript viewport, its chrome, and key and mouse@@ -42,6 +33,7 @@ export function mountScreenLoop({colors = {},getSessions = () => [],onTabClick,+ composer = null,} = {}) {if (!enabled || !session) {return {@@ -49,6 +41,8 @@ export function mountScreenLoop({paint() {},sync() {},follow() {},+ geometry() { return { cols: 80, rows: 24, panel: [], viewRows: 0, tabRowY: 0, pWidth: 0, transWidth: 80, kind: null, promptRows: PROMPT_ROWS }; },+ setPromptRows() {},dispose() {},};}@@ -66,28 +60,41 @@ export function mountScreenLoop({let painted = [];let keysPatched = false;let originalEmit = null;+ let promptReservation = PROMPT_ROWS;++ const setPromptRows = (rows) => {+ // When the composer reports its painted row count, clamp it so the panel+ // never jumps on erase (0) and never gets pushed off screen by tall drafts.+ const termRows = Math.max(6, Number(output.rows) || 24);+ const clamped = clampPromptRows(rows, termRows);+ if (clamped !== promptReservation) {+ promptReservation = clamped;+ paint();+ }+ };++ if (composer) {+ if (typeof composer.onRows === "function") composer.onRows(setPromptRows);+ else composer.onRows = setPromptRows;+ }+ if (session) {+ session.onComposerRows = setPromptRows;+ }- const geometry = () => {+ const geometry = (reservation = promptReservation) => {const cols = Math.max(20, Number(output.columns) || 80);const rows = Math.max(6, Number(output.rows) || 24);- const chrome = chromeLines({- session,- sessions: getSessions(),- activeId: session.agentSession?.id,- colors,- width: cols,- rows: null,- });+ const chrome = chromeLines({ session, sessions: getSessions(), activeId: session.agentSession?.id, colors, width: cols, rows: null });const separator = composerSeparator(session, colors, cols);const hasSep = typeof separator === "string" && separator.length > 0;// The separator belongs to the panel in this mode; the composer is told to draw none.const panel = [hasSep ? separator : "", ...chrome].filter((line) => line.length > 0);- const viewRows = Math.max(0, rows - panel.length - PROMPT_ROWS);+ const viewRows = Math.max(0, rows - panel.length - reservation);const tabRowY = viewRows + (hasSep ? 1 : 0);const kind = session?.paneKind && session.paneKind !== "off" ? session.paneKind : null;const pWidth = kind ? paneWidth(cols) : 0;const transWidth = cols - pWidth;- return { cols, rows, panel, viewRows, tabRowY, pWidth, transWidth, kind };+ return { cols, rows, panel, viewRows, tabRowY, pWidth, transWidth, kind, promptRows: reservation };};// Repaints from the top of the screen and leaves the cursor where the composer expects to start,@@ -190,12 +197,15 @@ export function mountScreenLoop({paint,sync,follow: () => resetFollow(viewport),+ geometry,+ setPromptRows,dispose() {["exit", "SIGINT", "SIGTERM", "SIGHUP"].forEach((sig) => detach(process, sig, onTeardown));output.off?.("resize", onResize);if (keysPatched) input.emit = originalEmit;disableMouse(output);if (session.streamSink) delete session.streamSink;+ if (session.onComposerRows) delete session.onComposerRows;// The panel owns the whole screen, so the inline transcript is repainted once on the way out// instead of leaving the alternate buffer's last frame on screen.painted = [];diff --git a/scripts/mso-agent.mjs b/scripts/mso-agent.mjsindex 7410991d..29a284d2 100644--- a/scripts/mso-agent.mjs+++ b/scripts/mso-agent.mjs@@ -83,7 +83,7 @@ async function main() {screenLoop.sync();},});- rl = new AgentComposer({ input: process.stdin, output: process.stdout, colors: C, onToggleStatusBar: () => { session.statusBar = !session.statusBar; screenLoop.paint(); } }); syncPromptHistory(rl, session);+ rl = new AgentComposer({ input: process.stdin, output: process.stdout, colors: C, onRows: (rows) => screenLoop.setPromptRows(rows), onToggleStatusBar: () => { session.statusBar = !session.statusBar; screenLoop.paint(); } }); syncPromptHistory(rl, session);let inboundRequestQueued = false;localBridge = new LocalAgentBridge({session,