Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(ui): enforce a minimum-contrast floor in the agent terminals

rubenluetke10-beep9e1a96d65e75
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
index 39befc37e7..097ce2d509 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
@@ -1261,8 +1261,9 @@ describe("pane refit", () => {
// interface out in, stops drawing altogether; the status badge reads that
// silence as a finished job, because movement is all it can read.
//
- // So the size is refused and the PTY keeps the last one a viewer really
- // had. The narrow tile shows a clipped frame; the agent stays alive.
+ // So the measurement is CLAMPED to the floors, per dimension, and the
+ // clamped size is what the agent hears: never the raw 17 columns, always
+ // a frame it can still draw. The tile clips what it cannot show.
const view = render(pane(false));
settle();
terminalHarness.send.mockClear();
@@ -1274,9 +1275,13 @@ describe("pane refit", () => {
expect(terminalHarness.send).not.toHaveBeenCalledWith(
expect.objectContaining({ cols: 17 }),
);
+ expect(terminalHarness.send).toHaveBeenCalledWith({
+ t: "r",
+ cols: 60,
+ rows: 15,
+ });
- // A tile the agent can work in is still announced, or this floor would
- // have swapped a broken pane for a frozen one.
+ // A tile the agent can work in is still announced honestly.
terminalHarness.size = { cols: 90, rows: 30 };
view.rerender(pane(false));
settle();
@@ -1288,16 +1293,16 @@ describe("pane refit", () => {
});
});
- it("keeps the local grid at the agent's geometry while below the floors", () => {
- // Refusing the size is only half of the contract (test above). The other
- // half is the LOCAL grid: fit()ing xterm to a 17-column tile while the
- // agent keeps laying its lines out for 80 re-wraps every one of them at
- // the narrower measure, and the TUI's cursor moves then land on rows that
- // no longer hold what they held when it drew them. A five-pane grid came
- // back as panes full of shredded one-word fragments (reported
- // 2026-08-10). So below the floors nothing is fit at all — the grid is
- // pinned back to the geometry the agent was last told, and the tile's
- // overflow-hidden container clips the rest.
+ it("keeps the local grid on the clamped size rather than the raw fit", () => {
+ // Clamping what the agent HEARS is only half of the contract (test
+ // above). The other half is the LOCAL grid: fit()ing xterm to the
+ // 17-column tile while the agent lays its lines out for 60 re-wraps
+ // every one of them at the narrower measure, and the TUI's cursor moves
+ // then land on rows that no longer hold what they held when it drew them
+ // — a five-pane grid came back as panes full of shredded one-word
+ // fragments (reported 2026-08-10). So below a floor nothing is fit at
+ // all: the grid takes the same clamped size the agent was told, and the
+ // tile's overflow-hidden container clips the rest.
const view = render(pane(false));
settle();
terminalHarness.fit.mockClear();
@@ -1308,7 +1313,33 @@ describe("pane refit", () => {
settle();
expect(terminalHarness.fit).not.toHaveBeenCalled();
- expect(terminalHarness.resize).toHaveBeenCalledWith(80, 24);
+ expect(terminalHarness.resize).toHaveBeenCalledWith(60, 15);
+ });
+
+ it("keeps a narrow tile's honest height so the prompt stays visible", () => {
+ // The floors fail one dimension at a time. A tile in a five-pane row
+ // measures 33 columns and a perfectly honest 40 rows — and refusing the
+ // WHOLE size left the PTY at a stale 64-row geometry, with the coding
+ // CLI anchoring its input box to row 64 of a pane showing 37 (measured
+ // live 2026-08-10: every pane in the workspace came up with no visible
+ // prompt). Clamped per dimension, only the width is lifted to the floor;
+ // the height the tile really has is what the agent hears, and its
+ // bottom-anchored prompt box lands in the bottom visible row.
+ const view = render(pane(false));
+ settle();
+ terminalHarness.send.mockClear();
+ terminalHarness.resize.mockClear();
+
+ terminalHarness.size = { cols: 33, rows: 40 };
+ view.rerender(pane(true));
+ settle();
+
+ expect(terminalHarness.resize).toHaveBeenCalledWith(60, 40);
+ expect(terminalHarness.send).toHaveBeenCalledWith({
+ t: "r",
+ cols: 60,
+ rows: 40,
+ });
});
it("tells a fresh socket the pane's size whatever the last one heard", () => {
@@ -1582,9 +1613,12 @@ describe("terminal text size across a rebuild", () => {
);
expect(newest().options.allowTransparency).toBe(true);
+ // Alpha 0 keeps the canvas clear; the RGB is the ground the
+ // minimum-contrast floor measures truecolor foregrounds against.
expect(
(newest().options.theme as Record<string, unknown>).background,
- ).toBe("rgba(0, 0, 0, 0)");
+ ).toBe("rgba(18, 20, 26, 0)");
+ expect(newest().options.minimumContrastRatio).toBe(4.5);
expect(screen.getByTestId("agentic-pane-Dana").style.background).toBe(
"rgba(10, 10, 10, 0.58)",
);
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
index 043c89da8c..8ab51dfc3f 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
@@ -70,6 +70,7 @@ import {
} from "lucide-react";
import { cn } from "@/lib/utils";
import {
+ MINIMUM_CONTRAST_RATIO,
PANE_CHROME,
themeFor,
type TerminalAppearance,
@@ -245,18 +246,31 @@ const MAX_TERMINAL_NAME = 40;
*
* 60x15 is where both installed coding CLIs still render a usable frame, with
* room under the 80x24 the handshake already falls back to when nothing has
- * been measured yet. Below it a size is REFUSED rather than clamped: the PTY
- * keeps its last honest geometry and the viewer shows as much of it as fits,
- * which costs a clipped line in a narrow tile and keeps the agent alive. A
- * clamp would instead hand the agent a size no window is actually showing.
+ * been measured yet. A measurement under a floor is CLAMPED to it — per
+ * dimension, and the clamped size is what BOTH the local grid and the agent
+ * are given, so the two can never disagree about the pane's geometry again.
*
- * "Shows as much of it as fits" is a promise about the LOCAL grid as well.
- * Refusing the size while still fit()ing xterm to the narrow tile left the
- * two halves disagreeing — the agent laying lines out for 80+ columns, the
- * viewer re-wrapping them at 25 — and every pane under the floors came back
- * as shredded one-word fragments (reported 2026-08-10). So below the floors
- * the grid is PINNED to the geometry the agent draws for (see `agentSize`),
- * and the tile's overflow-hidden container does the clipping.
+ * Per dimension, because the two floors fail differently and only one of
+ * them is usually failing. A tile in a five-pane row measures 33 columns and
+ * a perfectly honest 37 rows. Refusing the whole size (what this floor did
+ * first) left the PTY at whatever it had — measured live on 2026-08-10 at
+ * 69x64, from a mount-time fit taken at the default font — and a coding
+ * CLI anchors its input box to the BOTTOM of its screen: row 64 of a pane
+ * showing 37 rows, which is how every pane in the workspace came up with no
+ * visible prompt at all. Clamped to 60x37 instead, the height is exactly
+ * what the tile shows (the input box sits in its bottom visible row) and
+ * only the width is clipped, which a narrow tile cannot avoid: the agent
+ * cannot lay its interface out under 60 columns — squeezing a PTY below
+ * that is what printed an answer one character per line and left six agents
+ * silently stuck (2026-08-09, thirteen panes).
+ *
+ * The local grid takes the SAME clamped size, never the raw fit. Fitting
+ * xterm to the 33-column measurement while the agent lays lines out for 60+
+ * re-wraps every one of them at the narrower measure, and the TUI's cursor
+ * moves then land on rows that no longer hold what they held when it drew
+ * them — every squeezed pane came back as shredded one-word fragments (also
+ * 2026-08-10). The tile's overflow-hidden container clips what the clamped
+ * grid cannot show.
*
* Both the resize path and the connect-time handshake below refuse anything
* under these floors; the backend enforces the same ones
@@ -651,6 +665,11 @@ export function AgenticTerminal({
// paints an opaque canvas over it, hiding both that glass and the desktop
// artwork even when the surrounding React container is translucent.
allowTransparency: true,
+ // A CLI configured for the other ground paints truecolor a palette can
+ // never remap — dark-theme white text into a light pane. This floor
+ // nudges any unreadable foreground toward legibility; the theme's
+ // transparent background carries the ground RGB it measures against.
+ minimumContrastRatio: MINIMUM_CONTRAST_RATIO,
// Shared with the measurement in ./../../lib/terminalFont: a pane that
// measured a different stack from the one it draws with is the bug that
// module exists to prevent.
@@ -786,19 +805,20 @@ export function AgenticTerminal({
input: (data) => term.input(data),
});
try {
- // The same floors the resize path holds (see MIN_REAL_COLS). A pane
- // mounted straight into a narrow tile must keep the 80x24 the terminal
- // was built with — the geometry the connect handshake announces — rather
- // than fit itself below what its agent is about to draw for.
+ // The same clamp the resize path applies (see MIN_REAL_COLS), taken
+ // BEFORE the handshake below reads the terminal's geometry — so the
+ // grid this pane draws on and the size its agent is spawned at are the
+ // same thing from the very first byte.
const proposed = fit.proposeDimensions();
if (
proposed &&
Number.isFinite(proposed.cols) &&
- Number.isFinite(proposed.rows) &&
- proposed.cols >= MIN_REAL_COLS &&
- proposed.rows >= MIN_REAL_ROWS
+ Number.isFinite(proposed.rows)
) {
- fit.fit();
+ const cols = Math.max(proposed.cols, MIN_REAL_COLS);
+ const rows = Math.max(proposed.rows, MIN_REAL_ROWS);
+ if (cols === proposed.cols && rows === proposed.rows) fit.fit();
+ else term.resize(cols, rows);
}
} catch {
/* not measured yet — the ResizeObserver below will fit */
@@ -1196,25 +1216,6 @@ export function AgenticTerminal({
*/
let sentSize: { cols: number; rows: number } | null = null;
- /*
- * The geometry the agent is DRAWING for, as best this pane knows: the
- * connect-time handshake until a resize is delivered, then that resize.
- *
- * Needed because refusing to announce a size (below) is only half of the
- * floors' contract. The PTY keeps its working geometry — so the local
- * grid has to keep it too. Fitting the viewer below what the agent lays
- * its lines out for re-wraps every one of them at the narrower measure,
- * and the TUI's cursor moves then land on rows that no longer hold what
- * they held when it drew them: a five-pane grid came back as panes full
- * of shredded one-word fragments (reported 2026-08-10). Pinned to this
- * geometry instead, a narrow tile shows the top-left of an honest frame
- * and clips the rest — which is what the floors' comment promised.
- */
- let agentSize = {
- cols: term.cols >= MIN_REAL_COLS ? term.cols : 80,
- rows: term.rows >= MIN_REAL_ROWS ? term.rows : 24,
- };
-
const viewerMayOwn = () =>
activeRef.current &&
!documentHidden() &&
@@ -1228,8 +1229,8 @@ export function AgenticTerminal({
// wrecks the agent's full-screen drawing. Skip while not measurable; the
// ResizeObserver fires again when the pane comes back.
if (container.clientWidth < 8 || container.clientHeight < 8) return;
- // Measured WITHOUT being applied yet: a size the floors refuse must not
- // shrink the local grid either (see agentSize above).
+ // Measured WITHOUT being applied yet: what the tile can show is a
+ // PROPOSAL, and the floors above have the last word on it.
let proposed: { cols: number; rows: number } | undefined;
try {
proposed = fit.proposeDimensions();
@@ -1243,27 +1244,23 @@ export function AgenticTerminal({
) {
return;
}
- if (proposed.cols < MIN_REAL_COLS || proposed.rows < MIN_REAL_ROWS) {
- // Too narrow to hand to the agent — keep drawing at the geometry the
- // agent still formats for; the tile clips what it cannot show.
- if (term.cols !== agentSize.cols || term.rows !== agentSize.rows) {
- try {
- term.resize(agentSize.cols, agentSize.rows);
- } catch {
- /* mid-teardown — nothing left to pin */
- }
- }
- // Still the un-park moment: a pane squeezed under the floors is being
- // looked at all the same.
- revealIfOnScreen();
- return;
- }
+ // The one size everyone gets — the grid here, the agent below. Clamped
+ // per dimension (see the floors' comment): a narrow tile still hands
+ // the agent its honest HEIGHT, which is what keeps the CLI's
+ // bottom-anchored input box inside the visible rows.
+ const size = {
+ cols: Math.max(proposed.cols, MIN_REAL_COLS),
+ rows: Math.max(proposed.rows, MIN_REAL_ROWS),
+ };
try {
- fit.fit();
+ if (size.cols === proposed.cols && size.rows === proposed.rows) {
+ fit.fit();
+ } else if (term.cols !== size.cols || term.rows !== size.rows) {
+ term.resize(size.cols, size.rows);
+ }
} catch {
return;
}
- if (term.cols < MIN_REAL_COLS || term.rows < MIN_REAL_ROWS) return;
// Resizing a pane is the other half of the un-park story. Maximizing one,
// dragging a seam, changing the font — all of them are a user opening up
// a pane to READ it, and the pane it opens must not be a parked one still
@@ -1273,7 +1270,6 @@ export function AgenticTerminal({
// it left would otherwise stay dark. The measurement inside only un-parks
// a pane that really is on screen.
revealIfOnScreen();
- const size = { cols: term.cols, rows: term.rows };
// Already delivered and unchanged: the fit above was the whole job.
// Re-announcing a size makes the agent on the other end redraw its
// entire screen, and a pane refits several times per settling layout.
@@ -1285,10 +1281,8 @@ export function AgenticTerminal({
) {
return;
}
- if (socket?.send({ t: claimOwner ? "claim" : "r", ...size })) {
+ if (socket?.send({ t: claimOwner ? "claim" : "r", ...size }))
sentSize = size;
- agentSize = size;
- }
};
resizeRef.current = sendResize;
const claimResize = () => {
@@ -1300,18 +1294,16 @@ export function AgenticTerminal({
{
name,
workspaceId,
- // The connect-time size is a best effort, and this is the one place a
- // sliver could still slip through: the mount-time fit may have run
- // against a grid cell mid-layout and left `term.cols` at 1 — a value
- // `sendResize` refuses to SEND but which used to travel here as the
- // handshake geometry, spawning (or resizing) the PTY one column wide.
- // A size under the plausibility floor is treated as "not measured yet";
- // the real one follows from `onOpen`'s fit as soon as the cell
- // settles. `agentSize` captured exactly that at its declaration, and
- // using it HERE is what keeps the pinned local grid and the spawned
- // PTY agreeing about the pane's geometry.
- cols: agentSize.cols,
- rows: agentSize.rows,
+ // The connect-time size is a best effort. The mount-time fit above
+ // already clamped the grid to the floors, so the terminal's own
+ // geometry is normally safe to hand over as-is — the guards here are
+ // for the one case that fit could not run at all (a grid cell still
+ // mid-layout measures as nothing), where the terminal still holds
+ // whatever it was constructed with. A size under a floor is treated
+ // as "not measured yet"; the real one follows from `onOpen`'s fit as
+ // soon as the cell settles.
+ cols: term.cols >= MIN_REAL_COLS ? term.cols : 80,
+ rows: term.rows >= MIN_REAL_ROWS ? term.rows : 24,
appearance: appearanceRef.current,
claimOwner: viewerMayOwn(),
},
diff --git a/jarvis/ui/web/frontend/src/components/agentic/terminalThemes.ts b/jarvis/ui/web/frontend/src/components/agentic/terminalThemes.ts
index 090ccac83f..7a56160c0c 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/terminalThemes.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/terminalThemes.ts
@@ -14,13 +14,34 @@ import type { ITheme } from "@xterm/xterm";
* The xterm canvas itself stays transparent. The stable reading ground comes
* from the translucent pane shell below it, so the desktop artwork remains
* visible without stacking two dark fills into an effectively opaque panel.
+ *
+ * ## Why a palette alone cannot make every pane readable
+ *
+ * The 16 slots below only catch CLIs that speak classic ANSI. A modern coding
+ * agent draws most of its UI in 24-bit truecolor — exact RGB values chosen for
+ * the theme IT is configured for — and those bytes bypass this palette
+ * entirely. A CLI set to its dark theme paints near-white text into a light
+ * pane, and no slot remap can intercept that. `MINIMUM_CONTRAST_RATIO` is the
+ * floor under that hole: xterm nudges ANY foreground (truecolor included)
+ * toward black or white until it reaches the ratio against the background.
+ * For that computation to run against the pane's REAL ground, each theme's
+ * transparent `background` carries the shell's RGB at alpha 0 — invisible on
+ * screen, but the number the contrast maths reads.
*/
-const TRANSPARENT_TERMINAL_BACKGROUND = "rgba(0, 0, 0, 0)";
+/**
+ * WCAG AA for body text, and the same default VS Code ships for its
+ * integrated terminal. High enough that dark-theme truecolor becomes readable
+ * on a light pane, low enough that a CLI's deliberate dim/bright hierarchy
+ * survives.
+ */
+export const MINIMUM_CONTRAST_RATIO = 4.5;
/** Warm-paper contrast palette for light mode. */
export const LIGHT_TERMINAL_THEME: ITheme = {
- background: TRANSPARENT_TERMINAL_BACKGROUND,
+ // Alpha 0 = still transparent; the RGB is the light shell's paper tone so
+ // the minimum-contrast maths measures against the ground actually shown.
+ background: "rgba(252, 251, 248, 0)",
foreground: "#2b2b33",
cursor: "#a86b00",
cursorAccent: "#fcfbf8",
@@ -52,7 +73,9 @@ export const LIGHT_TERMINAL_THEME: ITheme = {
* pane shell below it supplies the dark reading ground.
*/
export const DARK_TERMINAL_THEME: ITheme = {
- background: TRANSPARENT_TERMINAL_BACKGROUND,
+ // #12141a at alpha 0 — the deep-slate ground the backend also reports to the
+ // CLI (jarvis/agentic_ide/terminal_input.py); see the light theme's note.
+ background: "rgba(18, 20, 26, 0)",
foreground: "#e8e8ec",
cursor: "#ffd60a",
cursorAccent: "#12141a",
diff --git a/jarvis/ui/web/frontend/src/components/missions/PtyTerminal.tsx b/jarvis/ui/web/frontend/src/components/missions/PtyTerminal.tsx
index f23ef24738..e2c50efd67 100644
--- a/jarvis/ui/web/frontend/src/components/missions/PtyTerminal.tsx
+++ b/jarvis/ui/web/frontend/src/components/missions/PtyTerminal.tsx
@@ -21,7 +21,11 @@ import "@xterm/xterm/css/xterm.css";
import { AlertCircle, Terminal as TerminalIcon } from "lucide-react";
import { useT } from "@/i18n";
import { useThemeValue } from "@/hooks/useTheme";
-import { PANE_CHROME, themeFor } from "../agentic/terminalThemes";
+import {
+ MINIMUM_CONTRAST_RATIO,
+ PANE_CHROME,
+ themeFor,
+} from "../agentic/terminalThemes";
import { buildMissionSocketUrl, fetchMissionToken } from "@/lib/missionAuth";
import { TERMINAL_FONT_STACK, syncTerminalFont } from "@/lib/terminalFont";
import {
@@ -95,6 +99,9 @@ export function PtyTerminal({ workerId }: PtyTerminalProps) {
// ground. A worker's diffs and dimmed hints are drawn with the "bright"
// row, which is unreadable on paper unless it was built for paper.
theme: themeFor(appearanceRef.current),
+ // Truecolor output bypasses that palette entirely; the floor catches
+ // it (see terminalThemes.ts).
+ minimumContrastRatio: MINIMUM_CONTRAST_RATIO,
});
const fit = new FitAddon();
term.loadAddon(fit);
diff --git a/jarvis/ui/web/frontend/src/components/workspace/WorkspaceTerminal.tsx b/jarvis/ui/web/frontend/src/components/workspace/WorkspaceTerminal.tsx
index 7b2a807ecf..c0e3ac0933 100644
--- a/jarvis/ui/web/frontend/src/components/workspace/WorkspaceTerminal.tsx
+++ b/jarvis/ui/web/frontend/src/components/workspace/WorkspaceTerminal.tsx
@@ -14,7 +14,11 @@ import { WebLinksAddon } from "@xterm/addon-web-links";
import "@xterm/xterm/css/xterm.css";
import { Terminal as TerminalIcon, AlertCircle } from "lucide-react";
import { installNewlineBridge } from "../agentic/terminalNewline";
-import { PANE_CHROME, themeFor } from "../agentic/terminalThemes";
+import {
+ MINIMUM_CONTRAST_RATIO,
+ PANE_CHROME,
+ themeFor,
+} from "../agentic/terminalThemes";
import { useThemeValue } from "@/hooks/useTheme";
import { TERMINAL_FONT_STACK, syncTerminalFont } from "@/lib/terminalFont";
import {
@@ -76,6 +80,9 @@ export function WorkspaceTerminal({
// Agentic IDE panes use — a coding agent's ANSI output is only readable
// if the "bright" row was re-derived for the ground it lands on.
theme: themeFor(appearanceRef.current),
+ // Truecolor output bypasses that palette entirely; the floor catches it
+ // (see terminalThemes.ts).
+ minimumContrastRatio: MINIMUM_CONTRAST_RATIO,
});
termRef.current = term;
const fit = new FitAddon();
diff --git a/tests/unit/agentic_ide/test_terminal_input.py b/tests/unit/agentic_ide/test_terminal_input.py
index 4b85d91722..da86a5d1be 100644
--- a/tests/unit/agentic_ide/test_terminal_input.py
+++ b/tests/unit/agentic_ide/test_terminal_input.py
@@ -150,8 +150,16 @@ def test_the_answered_colours_match_the_theme_the_pane_is_drawn_with(
)
assert block is not None, f"no {appearance} theme found in terminalThemes.ts"
declared = dict(re.findall(r"(\w+): \"(#[0-9a-fA-F]{6})\"", block.group(1)))
+ # The theme's background stays transparent on screen but carries the pane
+ # shell's RGB at alpha 0, so xterm's minimum-contrast floor measures
+ # against the real ground. That RGB is the one the CLI must be told.
+ ground = re.search(
+ r"background: \"rgba\((\d+), (\d+), (\d+), 0\)\"", block.group(1)
+ )
+ assert ground is not None, f"no ground RGB in the {appearance} theme"
+ background = "#" + "".join(f"{int(c):02x}" for c in ground.groups())
assert THEME_COLOURS[appearance] == (
declared["foreground"].lower(),
- declared["background"].lower(),
+ background,
)