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(verse): show the takeover terminal at the deck's size (#1048)

Ruben Lütkea7df8b45fab1
diff --git a/dodaios/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx b/dodaios/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
index df637914c8..2de67c4aa5 100644
--- a/dodaios/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
+++ b/dodaios/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
@@ -1394,7 +1394,8 @@ export function AgenticTerminal({
};
const showPane = (afterFlush?: () => void) => {
- if (!activeRef.current) return;
+ // The Verse window is a reader even while the IDE tile is off the stage.
+ if (!activeRef.current && !presentedHost) return;
if (paneVisible) {
afterFlush?.();
return;
@@ -1795,7 +1796,9 @@ export function AgenticTerminal({
// panel narrowed: fitting there squeezed every agent behind it to a strip
// (37 columns, measured) and its output stayed wrapped at that width in
// the scrollback. Coming back on stage refits (the `active` effect).
- if (!activeRef.current) return;
+ // The Verse window is the exception: the user is reading that host, so
+ // the fit measures it (`presentedHost`) rather than the hidden tile.
+ if (!activeRef.current && !presentedHost) return;
// The pane draws at the READER'S text size, never one it picked itself.
// An auto-shrink that walked this size down until the floor grid fit the
// tile shipped and was rejected within hours (2026-08-11): it silently
@@ -2022,7 +2025,8 @@ export function AgenticTerminal({
disposeMouse();
disposeBrowse();
};
- if (activeRef.current) showPane();
+ // Un-park even when the IDE tile is hidden. The window is what is on screen.
+ showPane();
if (typeof ResizeObserver !== "undefined") {
presentedWatch = new ResizeObserver(() => {
if (presentedTimer !== undefined) window.clearTimeout(presentedTimer);
diff --git a/dodaios/ui/web/frontend/src/components/society/verse/hud/TakeoverPanel.tsx b/dodaios/ui/web/frontend/src/components/society/verse/hud/TakeoverPanel.tsx
index 707195b3d3..6371e4ed93 100644
--- a/dodaios/ui/web/frontend/src/components/society/verse/hud/TakeoverPanel.tsx
+++ b/dodaios/ui/web/frontend/src/components/society/verse/hud/TakeoverPanel.tsx
@@ -1,11 +1,14 @@
/**
* The commander takes over a desk terminal: the IDE's own xterm, at 1:1,
- * inside a small Verse window. Clicks and keystrokes land on that terminal;
- * nothing here forwards them. A pane the IDE has not mounted yet keeps the
- * prompt form. Ctrl+Q or the close button leaves; Escape belongs to the agent.
+ * in a large Verse window. Clicks and keystrokes land on that terminal;
+ * nothing here forwards them. A pane the IDE grid has not mounted is opened
+ * here, so the window still shows that pane. Until the xterm is in place the
+ * server's replay is drawn in the same face. Ctrl+Q or the close button
+ * leaves; Escape belongs to the agent.
*/
import { useEffect, useRef, useState, useSyncExternalStore } from "react";
-import { promptTerminal } from "@/lib/agenticIdeApi";
+import { AgenticTerminal } from "@/components/agentic/AgenticTerminal";
+import { paneFontSize } from "@/components/agentic/paneFont";
import { liveTerminal, liveTerminalsGeneration, presentTerminal, subscribeLiveTerminals } from "@/lib/liveTerminals";
import { useEventStore } from "@/store/events";
import { useIdeChatStore } from "@/store/ideChat";
@@ -14,6 +17,19 @@ import type { TerminalTileFace } from "../effects/terminalCanvas";
import { leavesTakeover } from "../effects/terminalKeys";
import { VerseDialog } from "./VerseDialog";
+function escapeCss(value: string): string {
+ if (typeof CSS !== "undefined" && typeof CSS.escape === "function") return CSS.escape(value);
+ return value.replace(/["\\]/g, "\\$&");
+}
+
+/** True when this workspace's IDE grid already has the pane, so a second one must not be opened. */
+function ideHostsThisPane(workspaceId: string, names: readonly string[]): boolean {
+ if (typeof document === "undefined" || !workspaceId) return false;
+ const view = document.querySelector(`[data-workspace-terminal-view="${escapeCss(workspaceId)}"]`);
+ if (!view) return false;
+ return names.some((name) => name !== "" && view.querySelector(`[data-testid="agentic-terminal-host-${escapeCss(name)}"]`) !== null);
+}
+
interface Props {
tile: TerminalTileFace;
t: (key: string) => string;
@@ -28,10 +44,9 @@ export function TakeoverPanel({ tile, t, onClose }: Props) {
const nameKey = tile.names.join("\n");
const namesRef = useRef(tile.names);
namesRef.current = tile.names;
- const [live, setLive] = useState<boolean | null>(null);
- const [draft, setDraft] = useState("");
- const [sending, setSending] = useState(false);
- const [error, setError] = useState<string | null>(null);
+ const [live, setLive] = useState(false);
+ // Kept for the life of the window: closing it disposes the xterm it opened.
+ const [spare, setSpare] = useState(false);
useEffect(() => {
const host = hostRef.current;
@@ -40,6 +55,7 @@ export function TakeoverPanel({ tile, t, onClose }: Props) {
const release = presentTerminal(workspaceId, names, host);
if (!release) {
setLive(false);
+ if (!ideHostsThisPane(workspaceId, names)) setSpare(true);
return;
}
setLive(true);
@@ -67,21 +83,6 @@ export function TakeoverPanel({ tile, t, onClose }: Props) {
return () => window.removeEventListener("keydown", onKey, true);
}, [onClose]);
- const send = async () => {
- const prompt = draft.trim();
- if (!prompt || sending) return;
- setSending(true);
- setError(null);
- try {
- await promptTerminal(tile.names[0], prompt, { workspaceId: tile.workspaceId, compose: false });
- setDraft("");
- } catch (err) {
- setError(err instanceof Error ? err.message : String(err));
- } finally {
- setSending(false);
- }
- };
-
const openChanges = () => {
onClose();
const events = useEventStore.getState();
@@ -100,28 +101,29 @@ export function TakeoverPanel({ tile, t, onClose }: Props) {
escapeCloses={false}
>
<div className="verse-takeover-screen">
+ {live !== true && tile.fallback && tile.fallback.lines.length > 0 && (
+ <pre className="verse-takeover-replay">{tile.fallback.lines.join("\n")}</pre>
+ )}
<div ref={hostRef} className="verse-takeover-host" />
+ {spare && (
+ <div className="verse-takeover-mount" aria-hidden="true">
+ <AgenticTerminal
+ name={tile.names.find((name) => name !== "") ?? tile.names[0]}
+ workspaceId={workspaceId}
+ displayName={tile.header.title}
+ appearance="dark"
+ fontSize={paneFontSize()}
+ active
+ headerMode="none"
+ sizeLead
+ />
+ </div>
+ )}
+ </div>
+ <div className="verse-takeover-foot">
+ <p className="verse-takeover-hint">{t("verse.takeover.hint_live")}</p>
+ <button type="button" className="verse-btn" onClick={openChanges}>{t("verse.takeover.changes")}</button>
</div>
- {live === true ? (
- <div className="verse-takeover-foot">
- <p className="verse-takeover-hint">{t("verse.takeover.hint_live")}</p>
- <button type="button" className="verse-btn" onClick={openChanges}>{t("verse.takeover.changes")}</button>
- </div>
- ) : live === false ? (
- <form className="verse-takeover-prompt" onSubmit={(e) => { e.preventDefault(); void send(); }}>
- <input
- className="verse-takeover-input"
- value={draft}
- onChange={(e) => setDraft(e.target.value)}
- onKeyDown={(e) => { if (leavesTakeover(e)) { e.preventDefault(); onClose(); } }}
- placeholder={t("verse.takeover.placeholder")}
- aria-label={t("verse.takeover.placeholder")}
- autoFocus
- />
- <button type="submit" className="verse-btn" data-primary="true" disabled={sending || !draft.trim()}>{t("verse.takeover.send")}</button>
- {error && <p className="verse-takeover-error" role="alert">{error}</p>}
- </form>
- ) : null}
</VerseDialog>
);
}
diff --git a/dodaios/ui/web/frontend/src/components/society/verse/hud/takeover.test.tsx b/dodaios/ui/web/frontend/src/components/society/verse/hud/takeover.test.tsx
index 25d5cfb1a2..cecf26cfbb 100644
--- a/dodaios/ui/web/frontend/src/components/society/verse/hud/takeover.test.tsx
+++ b/dodaios/ui/web/frontend/src/components/society/verse/hud/takeover.test.tsx
@@ -30,8 +30,10 @@ vi.mock("@/lib/liveTerminals", () => ({
liveTerminalsGeneration: termApi.liveTerminalsGeneration,
}));
-vi.mock("@/lib/agenticIdeApi", () => ({
- promptTerminal: vi.fn(async () => ({})),
+vi.mock("@/components/agentic/AgenticTerminal", () => ({
+ AgenticTerminal: ({ name, workspaceId }: { name: string; workspaceId?: string }) => (
+ <div data-testid="verse-takeover-spare" data-name={name} data-workspace={workspaceId ?? ""} />
+ ),
}));
import { TakeoverPanel } from "./TakeoverPanel";
@@ -96,6 +98,7 @@ describe("TakeoverPanel", () => {
expect(screen.queryByLabelText("verse.takeover.keys")).toBeNull();
expect(termApi.presentTerminal).toHaveBeenCalledWith("ws1", tile.names, expect.any(HTMLElement));
expect(termApi.last?.host).toBeInstanceOf(HTMLElement);
+ expect(screen.queryByTestId("verse-takeover-spare")).toBeNull();
expect(termApi.focus).toHaveBeenCalled();
fireEvent.keyDown(window, { key: "Escape" });
expect(onClose).not.toHaveBeenCalled();
@@ -136,14 +139,30 @@ describe("TakeoverPanel", () => {
expect(setMaximized).toHaveBeenCalledWith(false);
});
- it("offers a prompt line for a pane the IDE has not mounted", () => {
+ it("shows the screen and opens the pane when the IDE grid has not mounted it", () => {
termApi.presentTerminal.mockReturnValue(null);
const onClose = vi.fn();
- render(<TakeoverPanel tile={{ ...tile, workspaceId: "elsewhere" }} t={t} onClose={onClose} />);
- expect(screen.queryByLabelText("verse.takeover.keys")).toBeNull();
- expect(screen.getByPlaceholderText("verse.takeover.placeholder")).toBeTruthy();
+ render(<TakeoverPanel tile={{ ...tile, workspaceId: "elsewhere", fallback: { cols: 80, lines: ["Still waiting."], cursor: null, at: 1 } }} t={t} onClose={onClose} />);
+ expect(screen.getByText("Still waiting.")).toBeTruthy();
+ expect(screen.getByTestId("verse-takeover-spare").getAttribute("data-name")).toBe("mika");
+ expect(screen.getByTestId("verse-takeover-spare").getAttribute("data-workspace")).toBe("elsewhere");
+ expect(screen.queryByPlaceholderText("verse.takeover.placeholder")).toBeNull();
expect(termApi.focus).not.toHaveBeenCalled();
- fireEvent.keyDown(screen.getByPlaceholderText("verse.takeover.placeholder"), { key: "q", ctrlKey: true });
+ fireEvent.keyDown(window, { key: "q", ctrlKey: true });
expect(onClose).toHaveBeenCalledTimes(1);
});
+
+ it("does not open a second pane when the IDE grid already has this one", () => {
+ termApi.presentTerminal.mockReturnValue(null);
+ const view = document.createElement("div");
+ view.setAttribute("data-workspace-terminal-view", "ws1");
+ const host = document.createElement("div");
+ host.setAttribute("data-testid", "agentic-terminal-host-mika");
+ view.appendChild(host);
+ document.body.appendChild(view);
+ render(<TakeoverPanel tile={{ ...tile, fallback: { cols: 40, lines: ["still working"], cursor: null, at: 2 } }} t={t} onClose={vi.fn()} />);
+ expect(screen.queryByTestId("verse-takeover-spare")).toBeNull();
+ expect(screen.getByText("still working")).toBeTruthy();
+ view.remove();
+ });
});
diff --git a/dodaios/ui/web/frontend/src/components/society/verse/verse.css b/dodaios/ui/web/frontend/src/components/society/verse/verse.css
index 25058ca706..931cf25b8e 100644
--- a/dodaios/ui/web/frontend/src/components/society/verse/verse.css
+++ b/dodaios/ui/web/frontend/src/components/society/verse/verse.css
@@ -557,14 +557,20 @@
.verse-switch i { transition: none; }
}
-/* The IDE's own terminal, at 1:1, in a small window the commander can resize. */
+/* The IDE's own terminal, at 1:1, about the size of the deck in front of the commander.
+ Absolute, because a percentage height on a grid-centered dialog collapses. */
.verse-dialog.verse-takeover {
- width: min(760px, calc(100% - 32px));
- height: min(480px, calc(100% - 32px));
- min-width: 480px;
- min-height: 280px;
- max-width: calc(100% - 32px);
- max-height: calc(100% - 32px);
+ position: absolute;
+ left: 11%;
+ right: 11%;
+ top: 10%;
+ bottom: 10%;
+ width: auto;
+ height: auto;
+ min-width: min(640px, calc(100% - 24px));
+ min-height: min(400px, calc(100% - 24px));
+ max-width: none;
+ max-height: none;
display: flex;
flex-direction: column;
overflow: hidden;
@@ -578,8 +584,33 @@
overflow: hidden;
background: #0b0c0f;
}
-.verse-takeover-host { position: absolute; inset: 0; }
+.verse-takeover-host { position: absolute; inset: 0; z-index: 1; }
+.verse-takeover-host:empty { pointer-events: none; }
.verse-takeover-host > .xterm { width: 100%; height: 100%; }
+/* The server's replay, until the pane's own xterm is in the window. Same face as the terminal: monospace on black. */
+.verse-takeover-replay {
+ position: absolute;
+ inset: 0;
+ margin: 0;
+ padding: 8px 10px;
+ overflow: auto;
+ white-space: pre;
+ font-family: var(--verse-mono);
+ font-size: 15px;
+ line-height: 1.35;
+ color: #f4f4f6;
+ background: #0b0c0f;
+}
+/* Holds a pane the IDE grid has not mounted. Laid out at the window's size so xterm
+ can measure it. Invisible, but still painted: a visibility:hidden canvas comes
+ back blank after it is moved into the window. */
+.verse-takeover-mount {
+ position: absolute;
+ inset: 0;
+ z-index: 0;
+ opacity: 0;
+ pointer-events: none;
+}
.verse-takeover-foot {
flex: none;
display: flex;
@@ -590,6 +621,3 @@
}
.verse-takeover-hint { margin: 0; flex: 1; min-width: 0; font-size: 12px; color: var(--verse-ink); opacity: 0.7; }
.verse-takeover-foot .verse-btn { flex: none; white-space: nowrap; }
-.verse-takeover-prompt { flex: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--verse-line); }
-.verse-takeover-input { flex: 1 1 260px; min-width: 0; padding: 8px 10px; background: transparent; color: var(--verse-ink); border: 1px solid var(--verse-line-strong); font: inherit; font-size: 13px; }
-.verse-takeover-error { flex-basis: 100%; margin: 0; font-size: 12px; color: var(--verse-red); }