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 footer reads the context field that exists, and shows the queue (#268)
Abdurrahman Fakhrul99c3b1d64688
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex aa6d37c2..c8aae5dd 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -14,6 +14,7 @@ this is the *what*, and it is what Settings → Account → About shows as “Wh**Fixed**+- `tui` the footer reads the context field that exists, and shows the queue- `ui` preserve workspace state and share dynamic shell layout- `ci` stop the CodeQL analysis job from gating on open alerts- `export` create the markdown export atomically, closing a TOCTOU writediff --git a/scripts/mso-agent-footer.mjs b/scripts/mso-agent-footer.mjsindex b1445144..8f6f363a 100644--- a/scripts/mso-agent-footer.mjs+++ b/scripts/mso-agent-footer.mjs@@ -9,6 +9,9 @@// omitted rather than printed as a placeholder, because "ctx ~0/?" claims a measurement that was never// taken.+import { contextStatus } from "./mso-agent-status.mjs";+import { queueList } from "./mso-agent-queue.mjs";+const PLAIN = /\x1b\[[0-9;]*m/g;const plain = (value) => String(value ?? "").replace(PLAIN, "");const width = (value) => Array.from(plain(value)).length;@@ -53,6 +56,7 @@ const MODE_TONE = { yolo: "err", "auto-write": "warn", auto: "warn", ask: "c" };export function footerRows({ session, colors = {}, columns = 100 } = {}) {const cols = Math.max(20, Number(columns) || 100);const dim = colors.dim || "", reset = colors.reset || "", bold = colors.bold || "", c = colors.c || colors.cyan || "";+ const warn = colors.warn || "";const tone = colors[MODE_TONE[String(session?.permission || "ask")]] || c;const mode = String(session?.permission || "ask");@@ -67,10 +71,14 @@ export function footerRows({ session, colors = {}, columns = 100 } = {}) {topParts.push(`${dim}thinking ${thinking}${reset}`);const top = clamp(topParts.join(`${dim} · ${reset}`), cols);- const used = number(session?.usage?.promptTokens) ?? number(session?.usage?.totalTokens)- ?? number(session?.usage?.inputTokens) ?? number(session?.state?.modelMeta?.estimatedTokens) ?? null;- const limit = number(session?.state?.modelMeta?.contextWindow) ?? number(session?.state?.modelMeta?.contextTokens) ?? null;- const ctx = used === null ? null : limit === null ? `context ${compact(used)}` : `context ${Math.round((used / limit) * 100)}%`;+ // The window is modelMeta.context, which is what contextStatus() reads. Asking for contextWindow+ // silently produced no percentage at all, so the footer showed no context line on a session that had+ // one. The estimate comes from contextStatus so this row and /status can never disagree.+ const ctx = contextStatus(session?.history, session?.state?.modelMeta);+ // Only claim a context reading when there is something to measure: usage or history. Otherwise the row+ // would print "context 0%", which asserts a window and an occupancy nobody measured.+ const measured = (ctx.used ?? 0) > 0 || (session?.history?.length ?? 0) > 0;+ const pct = !measured ? null : ctx.limit ? `context ${ctx.percent}%` : `context ${compact(ctx.used)}`;const tokens = compact(session?.usage?.totalTokens) ?? (number(session?.usage?.inputTokens) !== null && number(session?.usage?.outputTokens) !== null? `${compact(session.usage.inputTokens)}/${compact(session.usage.outputTokens)}`@@ -81,7 +89,11 @@ export function footerRows({ session, colors = {}, columns = 100 } = {}) {const dir = shortPath(session?.cwd || process.cwd());if (dir) bottomParts.push(`${dim}${dir}${reset}`);if (tokens !== null) bottomParts.push(`${dim}${tokens} tokens${reset}`);- if (ctx) bottomParts.push(`${dim}${ctx}${reset}`);+ if (pct) bottomParts.push(`${dim}${pct}${reset}`);+ // Queued prompts are held in memory and drained per turn. Showing the count is the only way a user can+ // see that their follow-up was accepted, and it must not reorder anything.+ const queued = queueList(session?.queue).length;+ if (queued) bottomParts.push(`${warn}${queued} queued${reset}`);bottomParts.push(`${dim}^P commands${reset}`);const bottom = clamp(bottomParts.join(`${dim} · ${reset}`), cols);diff --git a/scripts/mso-agent-footer.test.ts b/scripts/mso-agent-footer.test.tsindex 4df5a19b..4a234386 100644--- a/scripts/mso-agent-footer.test.ts+++ b/scripts/mso-agent-footer.test.ts@@ -11,8 +11,9 @@ const session = {permission: "ask",showReasoning: true,cwd: "/work/mso",+ history: Array.from({ length: 20 }, () => ({ role: "user", text: "x".repeat(2000) })),usage: { totalTokens: 12_500, inputTokens: 9_000, outputTokens: 3_500 },- state: { config: { provider: "anthropic", model: "claude-sonnet" }, modelMeta: { contextWindow: 200_000 } },+ state: { config: { provider: "anthropic", model: "claude-sonnet" }, modelMeta: { context: 200_000 } },};const plain = (value: string) => String(value).replace(/\x1b\[[0-9;]*m/g, "");@@ -30,7 +31,7 @@ describe("footer rows", () => {// Derives from process.env.HOME, so the assertion is about the shortening rule, not about a user.expect(plain(bottom)).toMatch(/^(~|\/work)/);expect(plain(bottom)).toContain("13k tokens"); // 12 500 rounds to 13k- expect(plain(bottom)).toContain("context 6%");+ expect(plain(bottom)).toMatch(/context \d+%/); // measured from history via contextStatusexpect(plain(bottom)).toContain("^P commands");});@@ -40,6 +41,8 @@ describe("footer rows", () => {});it("omits a value the session does not carry instead of printing a placeholder", () => {+ // No history and no modelMeta, so there is no measurement to report. Claiming "context 0%" would+ // assert a window nobody configured.const bare = { permission: "yolo" };const [top, bottom] = footerRows({ session: bare, columns: 120 });expect(plain(top)).toBe("yolo · thinking on");@@ -55,6 +58,12 @@ describe("footer rows", () => {}});+ it("shows how many prompts are queued, because an accepted follow-up is otherwise invisible", () => {+ const queued = { ...session, queue: { items: ["one", "two"] } };+ expect(plain(footerRows({ session: queued, columns: 130 })[1])).toContain("2 queued");+ expect(plain(footerRows({ session, columns: 130 })[1])).not.toContain("queued");+ });+it("emits no ANSI when no palette is passed", () => {for (const row of footerRows({ session, columns: 100 })) expect(row).not.toContain("\x1b");});