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(agentic-ide): prevent terminal bottom clipping

Ruben Lütke9316c6ad0145
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
new file mode 100644
index 0000000000..904517c6fe
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
@@ -0,0 +1,102 @@
+import { render, screen } from "@testing-library/react";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+const terminalHarness = vi.hoisted(() => ({
+ open: vi.fn(),
+ observe: vi.fn(),
+}));
+
+vi.mock("@xterm/xterm", () => ({
+ Terminal: class {
+ cols = 80;
+ rows = 24;
+ options: Record<string, unknown> = {};
+ unicode = { activeVersion: "" };
+
+ loadAddon() {}
+ open(host: HTMLElement) {
+ terminalHarness.open(host);
+ }
+ focus() {}
+ paste() {}
+ getSelection() {
+ return "";
+ }
+ onData() {
+ return { dispose() {} };
+ }
+ write() {}
+ resize() {}
+ dispose() {}
+ clearTextureAtlas() {}
+ },
+}));
+
+vi.mock("@xterm/addon-fit", () => ({
+ FitAddon: class {
+ fit() {}
+ },
+}));
+vi.mock("@xterm/addon-web-links", () => ({ WebLinksAddon: class {} }));
+vi.mock("@xterm/addon-canvas", () => ({ CanvasAddon: class {} }));
+vi.mock("@xterm/addon-unicode11", () => ({ Unicode11Addon: class {} }));
+
+vi.mock("./paneSocket", () => ({
+ openPaneSocket: () => ({ send() {}, close() {} }),
+}));
+vi.mock("./terminalPaste", () => ({
+ installPasteBridge: () => () => undefined,
+}));
+vi.mock("./paneFileDrag", () => ({
+ usePaneFileDrag: () => ({ dragging: false, handlers: {} }),
+}));
+vi.mock("@/lib/editActions", () => ({ attachTerminalBridge: () => undefined }));
+vi.mock("@/lib/agenticIdeApi", () => ({ attachToTerminal: vi.fn() }));
+
+import { AgenticTerminal } from "./AgenticTerminal";
+
+class ResizeObserverHarness implements ResizeObserver {
+ constructor(_callback: ResizeObserverCallback) {}
+ observe(target: Element) {
+ terminalHarness.observe(target);
+ }
+ unobserve() {}
+ disconnect() {}
+}
+
+describe("AgenticTerminal layout", () => {
+ beforeEach(() => {
+ terminalHarness.open.mockClear();
+ terminalHarness.observe.mockClear();
+ globalThis.ResizeObserver = ResizeObserverHarness;
+ });
+
+ afterEach(() => {
+ vi.restoreAllMocks();
+ });
+
+ it("measures an unpadded host inside the padded shrinking viewport", () => {
+ render(
+ <AgenticTerminal
+ name="Dana"
+ displayName="Claude Code"
+ appearance="dark"
+ fontSize={13}
+ />,
+ );
+
+ const host = screen.getByTestId("agentic-terminal-host-Dana");
+ const viewport = host.parentElement;
+
+ expect(viewport).not.toBeNull();
+ expect(viewport?.className).toContain("min-h-0");
+ expect(viewport?.className).toContain("px-2");
+ expect(viewport?.className).toContain("pb-1");
+ expect(viewport?.className).toContain("pt-1");
+ expect(host.className).toContain("h-full");
+ expect(host.className).toContain("min-h-0");
+ expect(host.className).not.toMatch(/(?:^|\s)p[trblxy]?-/);
+ expect(terminalHarness.open).toHaveBeenCalledWith(host);
+ expect(terminalHarness.observe).toHaveBeenCalledWith(host);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
index 548815a34e..079ea70af9 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
@@ -544,7 +544,22 @@ export function AgenticTerminal({
onClose={onClose}
splitDisabled={splitDisabled}
/>
- <div ref={containerRef} className="flex-1 overflow-hidden px-2 pb-1 pt-1" />
+ {/*
+ Keep the visual inset OUTSIDE xterm's measured host. FitAddon reads the
+ host's border-box but does not subtract padding on that host, so putting
+ the inset there made it report one row more than the pane could show.
+ The last terminal line was consequently clipped after a vertical resize.
+
+ `min-h-0` is equally load-bearing: this is a shrinking flex child, and
+ xterm's canvas must not become its implicit minimum height.
+ */}
+ <div className="min-h-0 flex-1 overflow-hidden px-2 pb-1 pt-1">
+ <div
+ ref={containerRef}
+ data-testid={`agentic-terminal-host-${name}`}
+ className="h-full min-h-0 w-full overflow-hidden"
+ />
+ </div>
{(dragging || attaching) && (
<div className="pointer-events-none absolute inset-0 flex items-center justify-center bg-background/70 backdrop-blur-[2px]">
<div className="flex items-center gap-2 rounded-xl border border-primary/50 bg-card px-4 py-2.5 text-sm shadow-lg">