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.

feat(tui): a tab row and a footer that stay put, painted through the frame writer (#191)

Abdurrahman Fakhrul3c75d625491c
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index bf4d9517..73fa3137 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -8,11 +8,12 @@ this is the *what*, and it is what Settings → Account → About shows as “Wh
**Added**
+- `tui` a tab row and a footer that stay put, painted through the frame writer
- `tui` a transcript model, because scrollback is the only transcript that exists (#187)
-**Docs**
+**Changed**
-- `tui` record milestone status in the renderer plan
+- `tui` paint the composer through a frame writer instead of appending (#189)
## 2026-10-30
@@ -24,7 +25,6 @@ this is the *what*, and it is what Settings → Account → About shows as “Wh
**Changed**
-- `tui` paint the composer through a frame writer instead of appending
- `tui` share the cell and pane primitives instead of growing a second copy (#186)
**Tests**
diff --git a/docs/TUI-RENDERER-PLAN.md b/docs/TUI-RENDERER-PLAN.md
index 39342db2..6cf05996 100644
--- a/docs/TUI-RENDERER-PLAN.md
+++ b/docs/TUI-RENDERER-PLAN.md
@@ -591,7 +591,7 @@ those two, and mouse/scrollbar/splits are additive after M5.
| M1 | Shared cell primitives, `scripts/tui/cells.mjs` | DONE | PR #186, `5b45314`; layout.mjs 67 to 20 lines |
| M2 | Transcript model, `scripts/mso-agent-transcript.mjs` | DONE | PR #187; reuses formatEditDiff, formatTodoBlock, formatDiffBody |
| M3 | Frame writer, `scripts/mso-agent-screen.mjs`, inline mode | DONE | PR #189; composer 221 to 217 lines, ratchet 43 to 42 |
-| M4 | Chrome and tabs as a bottom block | IN PROGRESS | no alt screen yet, scrollback intact |
+| M4 | Chrome and tabs as a bottom block | DONE | PR #190; chromeLines and tabs switch; composer 216 lines |
| M5 | Alternate screen behind a flag, with teardown | NOT STARTED | irreversible step; waits for M4 |
| M6 | Transcript viewport and scrollbar | NOT STARTED | needs M5 |
| M7 | Mouse | NOT STARTED | needs the owner's selection policy |
diff --git a/scripts/mso-agent-chrome.mjs b/scripts/mso-agent-chrome.mjs
new file mode 100644
index 00000000..3e790c00
--- /dev/null
+++ b/scripts/mso-agent-chrome.mjs
@@ -0,0 +1,179 @@
+import { cellWidth, clean, fitCells } from "./tui/cells.mjs";
+import { composerFooter } from "./mso-agent-layout.mjs";
+
+/**
+ * Formats a single physical row containing session tabs.
+ * Active session is marked with a bullet and undimmed; inactive tabs are dimmed.
+ * When tabs exceed available width, excess items are dropped from the middle and
+ * replaced with a visible +N marker so the row never wraps and breaks row arithmetic.
+ *
+ * @param {Array<any>} sessions
+ * @param {string|number|null} [activeId]
+ * @param {{ colors?: any, width?: number }} [options]
+ * @returns {string}
+ */
+export function tabRow(sessions, activeId = null, { colors = {}, width = 80 } = {}) {
+ if (!Array.isArray(sessions) || sessions.length === 0) return "";
+ const maxWidth = Math.max(1, Number(width) || 80);
+ const sep = " ";
+
+ const cBold = colors?.bold || "";
+ const cBlue = colors?.blue || "";
+ const cDim = colors?.dim || "";
+ const cReset = colors?.reset || "";
+
+ const items = sessions.map((s) => {
+ const rawName = clean(s?.name || s?.agentSession?.name || "").replace(/^@/, "");
+ const name = rawName || "agent";
+ const id = String(s?.id || s?.agentSession?.id || "");
+ const isActive = activeId != null && (String(activeId) === id || String(activeId).replace(/^@/, "") === name);
+ const marker = isActive ? "● " : "";
+ const plainText = `${marker}@${name}`;
+ const styled = isActive
+ ? `${cBold}${cBlue}${marker}@${name}${cReset}`
+ : `${cDim}@${name}${cReset}`;
+ return { id, name, isActive, plainText, styled, width: cellWidth(plainText) };
+ });
+
+ const fullPlain = items.map((it) => it.plainText).join(sep);
+ if (cellWidth(fullPlain) <= maxWidth) {
+ return items.map((it) => it.styled).join(sep);
+ }
+
+ // Dropping from the middle keeps both endpoints visible while indicating hidden tabs.
+ const activeIdx = items.findIndex((it) => it.isActive);
+
+ for (let dropped = 1; dropped < items.length; dropped++) {
+ const kept = items.length - dropped;
+ const markerText = `+${dropped}`;
+ const markerStyled = `${cDim}${markerText}${cReset}`;
+
+ // Candidate splits between left and right items.
+ // When an active tab exists, prefer splits that preserve the active tab.
+ const candidateSplits = [];
+ for (let l = 0; l <= kept; l++) {
+ const r = kept - l;
+ const preservesActive = activeIdx < 0 || activeIdx < l || r > (items.length - 1 - activeIdx);
+ if (preservesActive) candidateSplits.push(l);
+ }
+ // Fall back to all splits if none could preserve active with this kept count.
+ if (candidateSplits.length === 0) {
+ for (let l = 0; l <= kept; l++) candidateSplits.push(l);
+ }
+ // Sort by proximity to balanced halves to drop symmetrically from the middle.
+ candidateSplits.sort((a, b) => Math.abs(a - kept / 2) - Math.abs(b - kept / 2));
+
+ for (const leftCount of candidateSplits) {
+ const rightCount = kept - leftCount;
+ const leftItems = items.slice(0, leftCount);
+ const rightItems = items.slice(items.length - rightCount);
+
+ const candidatePlain = [
+ ...leftItems.map((it) => it.plainText),
+ markerText,
+ ...rightItems.map((it) => it.plainText),
+ ].filter(Boolean).join(sep);
+
+ if (cellWidth(candidatePlain) <= maxWidth) {
+ const candidateStyled = [
+ ...leftItems.map((it) => it.styled),
+ markerStyled,
+ ...rightItems.map((it) => it.styled),
+ ].filter(Boolean).join(sep);
+ return candidateStyled;
+ }
+ }
+ }
+
+ // Fallback for extremely constrained terminal widths: show single active or first tab truncated.
+ const fallbackItem = activeIdx >= 0 ? items[activeIdx] : items[0];
+ return fitCells(fallbackItem.styled, maxWidth, { pad: false });
+}
+
+/**
+ * Builds the bottom chrome block: session tab row plus status footer line.
+ * Drops the footer first on short terminals (<= 8 rows), and drops both on tiny terminals (<= 6 rows)
+ * to prevent eating user input lines.
+ *
+ * @param {{
+ * session?: any,
+ * sessions?: Array<any>,
+ * activeId?: string|number|null,
+ * colors?: any,
+ * width?: number,
+ * rows?: number|null,
+ * footer?: any,
+ * }} [options]
+ * @returns {Array<string>}
+ */
+export function chromeLines({
+ session = null,
+ sessions = /** @type {Array<any>} */ ([]),
+ activeId = null,
+ colors = {},
+ width = 80,
+ rows = null,
+ footer = null,
+} = {}) {
+ const termRows = rows != null ? Number(rows) : null;
+ if (termRows !== null && termRows <= 6) return [];
+
+ const tab = tabRow(sessions, activeId, { colors, width });
+ if (termRows !== null && termRows <= 8) {
+ return tab ? [tab] : [];
+ }
+
+ let foot = "";
+ if (footer != null) {
+ foot = typeof footer === "function" ? String(footer() || "") : String(footer || "");
+ } else if (session != null) {
+ foot = String(composerFooter(session, colors, width) || "");
+ }
+
+ return [tab, foot].filter((line) => typeof line === "string" && line.trim().length > 0).slice(0, 2);
+}
+
+/**
+ * Resolves a target session from a /tabs switch query.
+ * Supports 1-based index, exact name, exact id, unique prefix name, and unique prefix id.
+ * Refuses ambiguous matches rather than guessing to avoid accidental state switching.
+ *
+ * @param {Array<any>} sessions
+ * @param {any} args
+ * @returns {any}
+ */
+export function tabsToSwitch(sessions, args) {
+ if (!Array.isArray(sessions) || sessions.length === 0) return null;
+ const raw = Array.isArray(args) ? args.join(" ").trim() : String(args ?? "").trim();
+ if (!raw) return null;
+
+ if (/^\d+$/.test(raw)) {
+ const idx = Number.parseInt(raw, 10);
+ if (idx >= 1 && idx <= sessions.length) {
+ return sessions[idx - 1] ?? null;
+ }
+ return null;
+ }
+
+ const query = raw.toLowerCase().replace(/^@/, "");
+ const getSessionName = (s) => clean(s?.name || s?.agentSession?.name || "").toLowerCase().replace(/^@/, "");
+ const getSessionId = (s) => String(s?.id || s?.agentSession?.id || "").toLowerCase();
+
+ const exactNameMatches = sessions.filter((s) => getSessionName(s) === query);
+ if (exactNameMatches.length === 1) return exactNameMatches[0];
+ if (exactNameMatches.length > 1) return null;
+
+ const exactIdMatches = sessions.filter((s) => getSessionId(s) === query);
+ if (exactIdMatches.length === 1) return exactIdMatches[0];
+ if (exactIdMatches.length > 1) return null;
+
+ const prefixNameMatches = sessions.filter((s) => getSessionName(s).startsWith(query));
+ if (prefixNameMatches.length === 1) return prefixNameMatches[0];
+ if (prefixNameMatches.length > 1) return null;
+
+ const prefixIdMatches = sessions.filter((s) => getSessionId(s).startsWith(query));
+ if (prefixIdMatches.length === 1) return prefixIdMatches[0];
+ if (prefixIdMatches.length > 1) return null;
+
+ return null;
+}
diff --git a/scripts/mso-agent-chrome.test.ts b/scripts/mso-agent-chrome.test.ts
new file mode 100644
index 00000000..c91d9b2a
--- /dev/null
+++ b/scripts/mso-agent-chrome.test.ts
@@ -0,0 +1,145 @@
+import { EventEmitter } from "node:events";
+import { describe, expect, it } from "vitest";
+import { chromeLines, tabRow, tabsToSwitch } from "./mso-agent-chrome.mjs";
+import { cellWidth, stripAnsi } from "./tui/cells.mjs";
+import { AgentComposer } from "./mso-agent-composer.mjs";
+
+describe("MSO Agent TUI chrome and session tabs", () => {
+ it("a tab row with three sessions marks the active one and fits the width", () => {
+ const sessions = [{ id: "s1", name: "main" }, { id: "s2", name: "worker" }, { id: "s3", name: "review" }];
+ const colors = { blue: "\x1b[34m", bold: "\x1b[1m", dim: "\x1b[2m", reset: "\x1b[0m" };
+ const row = tabRow(sessions, "s2", { colors, width: 80 });
+ expect(row).toContain("● @worker");
+ expect(row).toContain("@main");
+ expect(row).toContain("@review");
+ expect(cellWidth(row)).toBeLessThanOrEqual(80);
+ });
+
+ it("tabs that do not fit are dropped from the middle with a +N marker and the row stays within width", () => {
+ const sessions = [
+ { id: "s1", name: "alpha-orchestration" },
+ { id: "s2", name: "beta-worker-pool" },
+ { id: "s3", name: "gamma-analytics" },
+ { id: "s4", name: "delta-subagent" },
+ { id: "s5", name: "epsilon-monitoring" },
+ ];
+ const row = tabRow(sessions, "s1", { width: 34 });
+ expect(row).toContain("+");
+ expect(row).toContain("@alpha-orchestration");
+ expect(cellWidth(row)).toBeLessThanOrEqual(34);
+ });
+
+ it("chromeLines returns at most two rows and drops empties", () => {
+ const sessions = [{ id: "s1", name: "alpha" }];
+ const twoLines = chromeLines({ sessions, activeId: "s1", footer: "mode ask : Tab cycle", width: 80 });
+ expect(twoLines).toHaveLength(2);
+ expect(twoLines[0]).toContain("@alpha");
+ expect(twoLines[1]).toBe("mode ask : Tab cycle");
+
+ const onlyFooter = chromeLines({ sessions: [], footer: "mode ask : Tab cycle", width: 80 });
+ expect(onlyFooter).toEqual(["mode ask : Tab cycle"]);
+
+ const onlyTabs = chromeLines({ sessions, activeId: "s1", footer: "", width: 80 });
+ expect(onlyTabs).toHaveLength(1);
+ expect(onlyTabs[0]).toContain("@alpha");
+
+ expect(chromeLines({ sessions: [], footer: "" })).toEqual([]);
+ });
+
+ it("a terminal with 8 rows drops the footer, and with 6 rows drops both", () => {
+ const sessions = [{ id: "s1", name: "primary" }];
+ const footer = "mode ask : anthropic/claude-3-5-sonnet";
+
+ const eightRows = chromeLines({ sessions, activeId: "s1", footer, width: 80, rows: 8 });
+ expect(eightRows).toHaveLength(1);
+ expect(eightRows[0]).toContain("@primary");
+ expect(eightRows[0]).not.toContain("mode ask");
+
+ const sixRows = chromeLines({ sessions, activeId: "s1", footer, width: 80, rows: 6 });
+ expect(sixRows).toEqual([]);
+ });
+
+ it("no ANSI codes when no palette is passed", () => {
+ const sessions = [{ id: "s1", name: "one" }, { id: "s2", name: "two" }];
+ const row = tabRow(sessions, "s1", { width: 80 });
+ expect(row).toBe(stripAnsi(row));
+ expect(row).not.toMatch(/\x1b\[/);
+
+ const lines = chromeLines({ sessions, activeId: "s1", footer: "mode ask : Tab cycle", width: 80 });
+ for (const line of lines) {
+ expect(line).toBe(stripAnsi(line));
+ expect(line).not.toMatch(/\x1b\[/);
+ }
+ });
+
+ it("tabsToSwitch resolves a valid index, resolves a unique name, and refuses an ambiguous name instead of picking one", () => {
+ const s1 = { id: "sess-1", name: "alpha" }, s2 = { id: "sess-2", name: "beta" }, s3 = { id: "sess-3", name: "gamma" };
+ const sessions = [s1, s2, s3];
+
+ expect(tabsToSwitch(sessions, "1")).toBe(s1);
+ expect(tabsToSwitch(sessions, 2)).toBe(s2);
+ expect(tabsToSwitch(sessions, ["3"])).toBe(s3);
+ expect(tabsToSwitch(sessions, "99")).toBe(null);
+
+ expect(tabsToSwitch(sessions, "alpha")).toBe(s1);
+ expect(tabsToSwitch(sessions, "@beta")).toBe(s2);
+
+ const ambiguousSessions = [{ id: "a1", name: "worker" }, { id: "a2", name: "worker" }, { id: "a3", name: "leader" }];
+ expect(tabsToSwitch(ambiguousSessions, "worker")).toBe(null);
+ expect(tabsToSwitch(ambiguousSessions, "@worker")).toBe(null);
+
+ const prefixSessions = [{ id: "b1", name: "job-run-1" }, { id: "b2", name: "job-run-2" }];
+ expect(tabsToSwitch(prefixSessions, "job")).toBe(null);
+ });
+
+ it("an empty session list renders no tab row and does not throw", () => {
+ expect(() => tabRow([], "s1", { width: 80 })).not.toThrow();
+ expect(tabRow([], "s1", { width: 80 })).toBe("");
+ expect(tabRow(null as never, "s1", { width: 80 })).toBe("");
+
+ expect(() => chromeLines({ sessions: [] })).not.toThrow();
+ expect(chromeLines({ sessions: [] })).toEqual([]);
+
+ expect(() => tabsToSwitch([], "1")).not.toThrow();
+ expect(tabsToSwitch([], "1")).toBe(null);
+ expect(tabsToSwitch(null as never, "1")).toBe(null);
+ });
+
+ it("the composer paints chrome via writeFrame and emits no newline on repaint", async () => {
+ class FakeInput extends EventEmitter {
+ isRaw = false; resume() {} pause() {} setRawMode(value: boolean) { this.isRaw = value; }
+ }
+ class FakeOutput {
+ isTTY = true; columns = 80; rows = 24; 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: "", dim: "", reset: "" },
+ });
+
+ const sessions = [{ id: "s1", name: "primary" }, { id: "s2", name: "worker" }];
+ const answer = composer.question("prompt > ", {
+ footer: () => chromeLines({ sessions, activeId: "s1", footer: "mode ask : Tab cycle", width: output.columns, rows: output.rows }),
+ } as never);
+
+ const initialText = output.chunks.join("");
+ expect(initialText).toContain("@primary");
+ expect(initialText).toContain("@worker");
+ expect(initialText).toContain("mode ask");
+
+ const beforeKey = output.chunks.length;
+ input.emit("keypress", "a", { name: "a", sequence: "a" });
+ const redrawChunks = output.chunks.slice(beforeKey).join("");
+ expect(redrawChunks).not.toContain("\n");
+ expect(redrawChunks).toContain("prompt > a");
+
+ input.emit("keypress", undefined, { ctrl: true, name: "c" });
+ input.emit("keypress", undefined, { ctrl: true, name: "c" });
+ await answer;
+ composer.close();
+ });
+});
diff --git a/scripts/mso-agent-cmd-session.mjs b/scripts/mso-agent-cmd-session.mjs
index c2fca9c9..9ec1d900 100644
--- a/scripts/mso-agent-cmd-session.mjs
+++ b/scripts/mso-agent-cmd-session.mjs
@@ -6,10 +6,12 @@ import {
startNewSession,
resumePicker,
} from "./mso-agent-session-ui.mjs";
-import { api, state } from "./mso-agent-api.mjs";
+import { api, listCliSessions, state } from "./mso-agent-api.mjs";
import { C } from "./mso-agent-runtime.mjs";
import { clearTodos, formatTodoBlock, latestTodos } from "./mso-agent-todos.mjs";
import { handleKeybindCommand } from "./mso-agent-keybinds.mjs";
+import { visibleSessionRows } from "./mso-agent-sessions.mjs";
+import { tabsToSwitch } from "./mso-agent-chrome.mjs";
export async function handleTodos(ctx, args = []) {
const { C: colors = C } = ctx;
@@ -26,6 +28,36 @@ export async function handleTodos(ctx, args = []) {
return "handled";
}
+export async function handleTabs(ctx, args = []) {
+ const { rl, session, C: colors = C } = ctx;
+ const rows = visibleSessionRows(await listCliSessions(20));
+ if (!args.length) {
+ if (!rows.length) {
+ console.log("No active sessions.");
+ return "handled";
+ }
+ console.log(`${colors.bold || ""}Sessions${colors.reset || ""}`);
+ rows.forEach((row, idx) => {
+ const isCurrent = String(row.id) === String(session?.agentSession?.id);
+ const mark = isCurrent ? `${colors.blue || ""}${colors.bold || ""}●${colors.reset || ""}` : " ";
+ const name = `@${row.name || "agent"}`;
+ const title = row.title || "MSO Agent session";
+ console.log(` ${mark} ${idx + 1}. ${name} · ${title}${isCurrent ? " (current)" : ""}`);
+ });
+ return "handled";
+ }
+ const target = tabsToSwitch(rows, args);
+ if (!target) {
+ console.log(`could not resolve session: ${args.join(" ")}`);
+ return "handled";
+ }
+ // Reuses the existing resume path and clears cached todos so the status
+ // chip never reflects a different session after switching.
+ await resumeInto(rl, session, target.id);
+ clearTodos();
+ return "refresh";
+}
+
export async function handleSessionCommand(ctx, cmd, args) {
if (cmd === "/todos") {
return handleTodos(ctx, args);
@@ -33,6 +65,9 @@ export async function handleSessionCommand(ctx, cmd, args) {
if (cmd === "/keybind" || cmd === "/keybinds") {
return handleKeybindCommand(ctx, args);
}
+ if (cmd === "/tabs" || cmd === "/tab") {
+ return handleTabs(ctx, args);
+ }
const { rl, session, C: colors = C } = ctx;
switch (cmd) {
case "/new":
diff --git a/scripts/mso-agent-composer-ui.mjs b/scripts/mso-agent-composer-ui.mjs
index 16a63718..62c19e77 100644
--- a/scripts/mso-agent-composer-ui.mjs
+++ b/scripts/mso-agent-composer-ui.mjs
@@ -111,3 +111,12 @@ export function menuLines(items, selected, columns, C, panelLabel = "commands &
const bottom = `╰─${bottomText}${"─".repeat(Math.max(0, panelWidth - width(bottomText) - 3))}╯`;
return [`${C.blue}${top}${C.reset}`, ...body, `${C.blue}${bottom}${C.reset}`];
}
+
+// Normalizes footer input (string, array of strings, or supplier function) into clean rows.
+// Splits multi-line strings so writeFrame never receives embedded newlines that would cause scrollback.
+export function footerLines(footer) {
+ const raw = typeof footer === "function" ? footer() : footer;
+ if (!raw) return [];
+ const list = Array.isArray(raw) ? raw : [raw];
+ return list.flatMap((row) => String(row ?? "").split(/\r?\n/)).filter(Boolean);
+}
diff --git a/scripts/mso-agent-composer.mjs b/scripts/mso-agent-composer.mjs
index 5ef846c8..7795ec7b 100644
--- a/scripts/mso-agent-composer.mjs
+++ b/scripts/mso-agent-composer.mjs
@@ -4,7 +4,7 @@ import process from "node:process";
import { resumeActiveActivity, suspendActiveActivity } from "./mso-agent-activity.mjs";
import { getKeybinds, resolveKeybind } from "./mso-agent-keybinds.mjs";
import { cursorHome, eraseFrame, frameHeight, withCursorHidden, writeFrame } from "./mso-agent-screen.mjs";
-import { chars, clamp, CLEAR_SCREEN, completionWindow, CURSOR_DOWN, CURSOR_RIGHT, inputLayout, inputViewport, menuLines, reserveComposerRows, verticalCursor, width } from "./mso-agent-composer-ui.mjs";
+import { chars, clamp, CLEAR_SCREEN, completionWindow, CURSOR_DOWN, CURSOR_RIGHT, footerLines, inputLayout, inputViewport, menuLines, reserveComposerRows, verticalCursor, width } from "./mso-agent-composer-ui.mjs";
export { completionWindow, inputLayout, inputViewport, verticalCursor } from "./mso-agent-composer-ui.mjs";
export class AgentComposer {
@@ -22,7 +22,6 @@ export class AgentComposer {
let value = "", cursor = 0, selected = 0, reservedRows = 0, paintedLines = [], lastCursorRow = 0;
let dismissed = false, historyIndex = null, draft = "", settled = false, verticalColumn = null;
const promptText = () => String(typeof prompt === "function" ? prompt() : prompt);
- const footerText = () => String(typeof footer === "function" ? footer() : (footer || ""));
const separatorText = () => String(typeof separator === "function" ? separator() : (separator || ""));
const wasRaw = Boolean(input.isRaw);
@@ -36,16 +35,16 @@ export class AgentComposer {
const currentPrompt = promptText(), promptWidth = width(currentPrompt), items = matches();
selected = items.length ? clamp(selected, 0, items.length - 1) : 0;
const menu = menuLines(items, selected, output.columns, C, panelLabel);
- const footerRow = footerText(), footerRows = footerRow ? 1 : 0;
+ const foot = footerLines(footer);
const terminalRows = Math.max(8, Number(output.rows || 24));
- const maxInputRows = Math.max(2, Math.min(12, terminalRows - menu.length - footerRows - 4, Math.floor(terminalRows * 0.32)));
+ const maxInputRows = Math.max(2, Math.min(12, terminalRows - menu.length - foot.length - 4, Math.floor(terminalRows * 0.32)));
const layout = inputLayout(value, cursor, { columns: output.columns, rows: terminalRows, promptWidth, maxRows: maxInputRows });
const continuation = " ".repeat(promptWidth);
const lines = [
`${currentPrompt}${layout.lines[0] || ""}`,
...layout.lines.slice(1).map((row) => `${continuation}${row}`),
...menu,
- ...(footerRow ? [footerRow] : []),
+ ...foot,
];
reserve(Math.max(0, frameHeight(lines) - 1));
withCursorHidden(output, () => { paintedLines = writeFrame(output, paintedLines, lines); });
diff --git a/scripts/mso-agent-help.mjs b/scripts/mso-agent-help.mjs
index 8a6eb683..21f05cc2 100644
--- a/scripts/mso-agent-help.mjs
+++ b/scripts/mso-agent-help.mjs
@@ -4,6 +4,7 @@ export const HELP_LINES = [
" /restart soft-reload Agent runtime; keep this session",
" /session [query] open picker or resume latest/index/id/@name/title (alias: /sessions)",
" /resume [query] alias-style resume command; bare opens same picker",
+ " /tabs [n|name] list session tabs or switch by index or @name",
" /rename <name> rename the short @agent handle",
" /title <text> rename the session title/description",
" /export [ref] [--out f] export session transcript to stdout or a file",
diff --git a/scripts/mso-agent.mjs b/scripts/mso-agent.mjs
index 1974702c..a9a060d8 100644
--- a/scripts/mso-agent.mjs
+++ b/scripts/mso-agent.mjs
@@ -5,17 +5,19 @@ import { AgentInterruptManager } from "./mso-agent-interrupt.mjs";
import { slashCompletionItems } from "./mso-agent-slash.mjs";
import { persistSession, restartSessionArg, resumeArg, startupSession, syncPromptHistory } from "./mso-agent-session-ui.mjs";
import { C, printBanner } from "./mso-agent-runtime.mjs";
-import { state } from "./mso-agent-api.mjs";
+import { listCliSessions, state } from "./mso-agent-api.mjs";
import { handleSlash } from "./mso-agent-commands.mjs";
import { nextPermissionMode, permissionMode } from "./mso-agent-permissions.mjs";
import { consumeRestartUiState, relaunchCurrentAgentSession } from "./mso-agent-lifecycle.mjs";
import { oneShotHelp, parseOneShot } from "./mso-agent-oneshot.mjs";
import { LocalAgentBridge, handleLocalAgentMentionInput, runForegroundSubagent } from "./mso-agent-collaboration.mjs";
-import { composerFooter, composerPrompt, composerSeparator } from "./mso-agent-layout.mjs";
+import { composerPrompt, composerSeparator } from "./mso-agent-layout.mjs";
import { agentRound, executeTool, renderInteractionFailure, runInteractiveRound } from "./mso-agent-turn.mjs";
import { pathToFileURL } from "node:url";
import { createQueue, dequeue } from "./mso-agent-queue.mjs";
import { pendingImageBlock } from "./mso-agent-image.mjs";
+import { visibleSessionRows } from "./mso-agent-sessions.mjs";
+import { chromeLines } from "./mso-agent-chrome.mjs";
async function runOneShot(opts) {
const requested = resumeArg(process.argv.slice(2));
@@ -81,6 +83,9 @@ async function main() {
// Ephemeral queue: held only in memory for this TUI process and not persisted to server state.
queue: createQueue(),
};
+ let recentSessions = session.agentSession ? [session.agentSession] : [];
+ const refreshSessions = () => { listCliSessions(20).then((rows) => { recentSessions = visibleSessionRows(rows); }).catch(() => {}); };
+ refreshSessions();
const rl = new AgentComposer({ input: process.stdin, output: process.stdout, colors: C, onToggleStatusBar: () => { session.statusBar = !session.statusBar; } }); syncPromptHistory(rl, session);
let inboundRequestQueued = false;
const localBridge = new LocalAgentBridge({
@@ -145,7 +150,14 @@ async function main() {
complete: completeSlash,
onTab: () => { session.permission = nextPermissionMode(session.permission).id; },
separator: () => composerSeparator(session, C, process.stdout.columns),
- footer: () => composerFooter(session, C, process.stdout.columns),
+ footer: () => chromeLines({
+ session,
+ sessions: recentSessions,
+ activeId: session?.agentSession?.id,
+ colors: C,
+ width: process.stdout.columns,
+ rows: process.stdout.rows,
+ }),
});
if (answer === null) {
if (inboundRequestQueued) continue;
@@ -159,7 +171,7 @@ async function main() {
const result = await handleSlash(rl, line, session, { runTurn: (skill) => runInteractiveRound(rl, session, skill, interrupts, localBridge), runSubagent: (input) => runForegroundSubagent({ rl, session, input, executeTool, colors: C }) });
if (result === "exit") break;
if (result === "restart") { restartRequested = true; break; }
- if (result === "refresh") await localBridge.syncSession();
+ if (result === "refresh") { await localBridge.syncSession(); refreshSessions(); }
if (result === "drain") {
lastTurnInterrupted = false;
await drainQueue();