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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(verse): show the IDE terminal 1:1 in the takeover window (#1047)
Ruben Lütke765121b9e1e8
diff --git a/dodaios/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx b/dodaios/ui/web/frontend/src/components/agentic/AgenticTerminal.tsxindex 9e1babe105..df637914c8 100644--- a/dodaios/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx+++ b/dodaios/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx@@ -132,8 +132,9 @@ import {import { installPasteBridge } from "./terminalPaste";import { installCopyBridge } from "./terminalCopy";import { createKeyEventChain } from "./terminalKeyChain";-import { registerLiveTerminal } from "@/lib/liveTerminals";+import { registerLiveTerminal, registerTerminalPresenter } from "@/lib/liveTerminals";import { PANE_INPUT_EVENT, type PaneInputDetail } from "./ideHotkeys";+import { useIdeChatStore } from "@/store/ideChat";import { installNewlineBridge } from "./terminalNewline";import { cancelPaneReflow, queuePaneReflow } from "./paneReflowQueue";import {@@ -915,6 +916,13 @@ export function AgenticTerminal({/** The pane's recorded conversation, opened from the header book button. */const [historyOpen, setHistoryOpen] = useState(false);const [changesOpen, setChangesOpen] = useState(false);+ const paneRequest = useIdeChatStore((state) => state.paneRequest);+ useEffect(() => {+ if (!workspaceId || paneRequest?.open !== "changes") return;+ if (paneRequest.workspaceId !== workspaceId || paneRequest.pane !== name) return;+ setChangesOpen(true);+ useIdeChatStore.getState().settlePaneOpen(paneRequest.nonce);+ }, [paneRequest, workspaceId, name]);// Latest callbacks/appearance without re-running the connect effect.const onStatusRef = useRef(onStatus);const onAttachErrorRef = useRef(onAttachError);@@ -1198,11 +1206,16 @@ export function AgenticTerminal({attachCustomKeyEventHandler: keys.add,input: (data) => term.input(data),});+ /**+ * Set while the Verse window is showing this xterm. Fit then measures that+ * window, and the hidden IDE tile must not park the pane or resize it to 0.+ */+ let presentedHost: HTMLElement | null = null;/** Is this pane's tile something that can honestly be measured right now? */- const measurable = () =>- !windowCollapsed() &&- container.clientWidth >= 8 &&- container.clientHeight >= 8;+ const measurable = () => {+ const box = presentedHost ?? container;+ return !windowCollapsed() && box.clientWidth >= 8 && box.clientHeight >= 8;+ };/** Did the grid below come from the tile, or is it still the constructed default? */let mountMeasured = false;@@ -1394,6 +1407,7 @@ export function AgenticTerminal({};const parkPane = () => {+ if (presentedHost) return;paneVisible = false;// The next chunk of output measures immediately rather than waiting out// an interval that started before this pane was even parked.@@ -1971,6 +1985,59 @@ export function AgenticTerminal({*/const claimResize = () => sendResize(viewerMayOwn());claimResizeRef.current = claimResize;+ // The Verse takeover borrows this xterm: the element itself moves into the+ // window, so clicks and keystrokes hit it with no forwarding. FitAddon+ // measures term.element's parent, which is that window while it is borrowed.+ let presentedWatch: ResizeObserver | null = null;+ let presentedTimer: number | undefined;+ let releasePresentedExtras = () => {};+ const releasePresented = () => {+ if (!presentedHost) return;+ if (presentedTimer !== undefined) window.clearTimeout(presentedTimer);+ presentedTimer = undefined;+ presentedWatch?.disconnect();+ presentedWatch = null;+ presentedHost = null;+ releasePresentedExtras();+ releasePresentedExtras = () => {};+ const element = term.element;+ if (element && element.parentElement !== container && container.isConnected) container.appendChild(element);+ const box = container.getBoundingClientRect();+ const viewport = { width: window.innerWidth || 0, height: window.innerHeight || 0 };+ if (!boxOnScreen(box, viewport)) parkPane();+ };+ const unregisterPresent = registerTerminalPresenter(workspaceId ?? "", name, (host) => {+ releasePresented();+ presentedHost = host;+ const element = term.element;+ if (element && element.parentElement !== host) host.appendChild(element);+ attachTerminalBridge(host, {+ getSelection: () => term.getSelection(),+ paste: (text) => term.paste(text),+ focus: () => term.focus(),+ });+ const disposeMouse = installMouseSelection(host, term, isMac);+ const disposeBrowse = installBrowseExit(host, term);+ releasePresentedExtras = () => {+ disposeMouse();+ disposeBrowse();+ };+ if (activeRef.current) showPane();+ if (typeof ResizeObserver !== "undefined") {+ presentedWatch = new ResizeObserver(() => {+ if (presentedTimer !== undefined) window.clearTimeout(presentedTimer);+ presentedTimer = window.setTimeout(() => {+ presentedTimer = undefined;+ // This window is the one the user is reading, so it takes the size.+ if (presentedHost) sendResize(true);+ }, 80);+ });+ presentedWatch.observe(host);+ }+ sendResize(true);+ if (term.rows > 0) term.refresh(0, term.rows - 1);+ return releasePresented;+ });/*** Make the agent paint its whole screen again at the size this pane holds:* one row short, then back, like the server's repaint nudge. An agent@@ -2401,6 +2468,8 @@ export function AgenticTerminal({}, NARROW_SETTLE_MS);};const scheduleResize = () => {+ // The Verse window has its own observer. The hidden tile must not fit this pane back to 0.+ if (presentedHost) return;// While a seam or the prompt bar is being dragged the pane still// follows, but on a leash: at most one refit per DRAG_REFIT_MS, so the// text flows toward the seam in steps instead of freezing until release.@@ -2554,6 +2623,8 @@ export function AgenticTerminal({heldLeadRef.current = holdsSizeLead(leadKey, leadToken);releaseSizeLead(leadKey, leadToken);// Before the terminal: frees this pane's WebGL context slot.+ releasePresented();+ unregisterPresent();unregisterLive();renderer.dispose();term.dispose();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.tsxindex e35b1cc941..707195b3d3 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,20 +1,17 @@/**- * The commander takes over a desk terminal: the coding pane's screen, large,- * and the keyboard goes to the agent as if typed in the IDE.- *- * A pane the IDE has mounted gets every key as it is pressed (Enter, arrows,- * Escape, Ctrl+C, paste), through the same window event the IDE's own key- * menu uses, without moving focus to the hidden pane. A pane the IDE has not- * mounted shows the server's replay and takes a whole prompt at a time.- * Ctrl+Q or the close button leaves; Escape belongs to the agent.+ * 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.*/-import { useEffect, useRef, useState } from "react";-import { PANE_INPUT_EVENT, type PaneInputDetail } from "@/components/agentic/ideHotkeys";+import { useEffect, useRef, useState, useSyncExternalStore } from "react";import { promptTerminal } from "@/lib/agenticIdeApi";-import { liveTerminal } from "@/lib/liveTerminals";-import { tileSnapshot, tileStamp } from "../effects/ScreensLayer";-import { paintTerminalTile, type TerminalTileFace } from "../effects/terminalCanvas";-import { keyToTerminalData, leavesTakeover } from "../effects/terminalKeys";+import { liveTerminal, liveTerminalsGeneration, presentTerminal, subscribeLiveTerminals } from "@/lib/liveTerminals";+import { useEventStore } from "@/store/events";+import { useIdeChatStore } from "@/store/ideChat";+import { useIdeSidePanelStore } from "@/store/ideSidePanel";+import type { TerminalTileFace } from "../effects/terminalCanvas";+import { leavesTakeover } from "../effects/terminalKeys";import { VerseDialog } from "./VerseDialog";interface Props {@@ -23,65 +20,52 @@ interface Props {onClose: () => void;}-/** Type `data` into the pane, as the IDE's key menu does; the pane keeps its focus where it was. */-export function typeIntoPane(tile: Pick<TerminalTileFace, "workspaceId" | "names">, data: string): void {- for (const pane of new Set(tile.names)) {- const detail: PaneInputDetail = { workspaceId: tile.workspaceId, pane, data, focus: false };- window.dispatchEvent(new CustomEvent(PANE_INPUT_EVENT, { detail }));- }-}-export function TakeoverPanel({ tile, t, onClose }: Props) {- const canvas = useRef<HTMLCanvasElement>(null);- const keys = useRef<HTMLTextAreaElement>(null);- const live = !!liveTerminal(tile.workspaceId, tile.names);+ const hostRef = useRef<HTMLDivElement>(null);+ const generation = useSyncExternalStore(subscribeLiveTerminals, liveTerminalsGeneration, liveTerminalsGeneration);+ const workspaceId = tile.workspaceId;+ // Name lists are rebuilt by the stage; the joined key is the stable dependency.+ 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);- // Repaint whenever the pane's screen changes (and for the cursor blink).- const tileRef = useRef(tile);- tileRef.current = tile;useEffect(() => {- let frame = 0;- let painted = "";- const paint = () => {- frame = requestAnimationFrame(paint);- const el = canvas.current;- if (!el) return;- const dpr = Math.min(2, window.devicePixelRatio || 1);- const w = Math.round(el.clientWidth * dpr), h = Math.round(el.clientHeight * dpr);- const blink = Math.floor(performance.now() / 530) % 2 === 0;- const stamp = `${tileStamp(tileRef.current)}|${w}x${h}|${blink}`;- if (stamp === painted || w === 0 || h === 0) return;- painted = stamp;- if (el.width !== w) el.width = w;- if (el.height !== h) el.height = h;- const ctx = el.getContext("2d");- if (!ctx) return;- const shot = tileSnapshot(tileRef.current);- paintTerminalTile(ctx, 0, 0, w, h, shot.header, shot.snap, blink);+ const host = hostRef.current;+ if (!host) return;+ const names = namesRef.current;+ const release = presentTerminal(workspaceId, names, host);+ if (!release) {+ setLive(false);+ return;+ }+ setLive(true);+ // After the dialog's own focus pass, so the caret lands in the terminal.+ const focus = () => liveTerminal(workspaceId, names)?.term.focus();+ focus();+ const frame = requestAnimationFrame(focus);+ const timer = window.setTimeout(focus, 50);+ return () => {+ cancelAnimationFrame(frame);+ window.clearTimeout(timer);+ release();};- paint();- return () => cancelAnimationFrame(frame);- }, []);+ }, [workspaceId, nameKey, generation]);- const onKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {- if (leavesTakeover(e)) { e.preventDefault(); onClose(); return; }- // Ctrl+V / Shift+Insert paste through the paste event below.- if ((e.ctrlKey && e.key.toLowerCase() === "v") || (e.shiftKey && e.key === "Insert")) return;- const data = keyToTerminalData(e);- if (data === null) return;- e.preventDefault();- e.stopPropagation();- typeIntoPane(tile, data);- };- const onPaste = (e: React.ClipboardEvent<HTMLTextAreaElement>) => {- const text = e.clipboardData.getData("text");- e.preventDefault();- // Bracketed so a TUI takes a multi-line paste as one paste, not as Enter presses.- if (text) typeIntoPane(tile, `\x1b[200~${text}\x1b[201~`);- };+ // Capture phase, so the terminal below does not also receive Ctrl+Q.+ useEffect(() => {+ const onKey = (event: KeyboardEvent) => {+ if (!leavesTakeover(event)) return;+ event.stopPropagation();+ event.preventDefault();+ onClose();+ };+ window.addEventListener("keydown", onKey, true);+ return () => window.removeEventListener("keydown", onKey, true);+ }, [onClose]);const send = async () => {const prompt = draft.trim();@@ -98,34 +82,32 @@ export function TakeoverPanel({ tile, t, onClose }: Props) {}};+ const openChanges = () => {+ onClose();+ const events = useEventStore.getState();+ if (events.activeSection !== "agentic-ide") events.setActiveSection("agentic-ide");+ useIdeChatStore.getState().requestPane(tile.workspaceId, tile.names[0], { open: "changes" });+ // A full-screen side panel would hide the pane this just opened.+ useIdeSidePanelStore.getState().setMaximized(false);+ };+return (<VerseDialogtitle={`${t("verse.takeover.title")} · ${tile.header.title}`}closeLabel={t("verse.card.close")}onClose={onClose}className="verse-takeover"- initialFocus={live ? keys : undefined}escapeCloses={false}>- <div className="verse-takeover-screen" onMouseDown={(e) => { if (live) { e.preventDefault(); keys.current?.focus(); } }}>- <canvas ref={canvas} className="verse-takeover-canvas" aria-label={tile.header.title} />- {live && (- <textarea- ref={keys}- className="verse-takeover-keys"- aria-label={t("verse.takeover.keys")}- value=""- onChange={() => undefined}- onKeyDown={onKeyDown}- onPaste={onPaste}- spellCheck={false}- autoComplete="off"- />- )}+ <div className="verse-takeover-screen">+ <div ref={hostRef} className="verse-takeover-host" /></div>- {live ? (- <p className="verse-takeover-hint">{t("verse.takeover.hint_live")}</p>- ) : (+ {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(); }}><inputclassName="verse-takeover-input"@@ -139,7 +121,7 @@ export function TakeoverPanel({ tile, t, onClose }: Props) {<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.tsxindex 5d83457443..25d5cfb1a2 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@@ -1,14 +1,51 @@-import { fireEvent, render, screen } from "@testing-library/react";-import { afterEach, describe, expect, it, vi } from "vitest";-import type { Terminal } from "@xterm/xterm";-import { PANE_INPUT_EVENT, type PaneInputDetail } from "@/components/agentic/ideHotkeys";-import { registerLiveTerminal } from "@/lib/liveTerminals";+import { cleanup, fireEvent, render, screen } from "@testing-library/react";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { useEventStore } from "@/store/events";+import { useIdeChatStore } from "@/store/ideChat";+import { useIdeSidePanelStore } from "@/store/ideSidePanel";import { keyToTerminalData, leavesTakeover } from "../effects/terminalKeys";++const termApi = vi.hoisted(() => {+ const focus = vi.fn();+ const release = vi.fn();+ const api = {+ focus,+ release,+ last: null as { workspaceId: string; names: readonly string[]; host: HTMLElement } | null,+ presentTerminal: vi.fn((workspaceId: string, names: readonly string[], host: HTMLElement): (() => void) | null => {+ api.last = { workspaceId, names, host };+ return release;+ }),+ liveTerminal: vi.fn(() => ({ term: { focus } })),+ subscribeLiveTerminals: vi.fn(() => () => undefined),+ liveTerminalsGeneration: vi.fn(() => 0),+ };+ return api;+});++vi.mock("@/lib/liveTerminals", () => ({+ presentTerminal: termApi.presentTerminal,+ liveTerminal: termApi.liveTerminal,+ subscribeLiveTerminals: termApi.subscribeLiveTerminals,+ liveTerminalsGeneration: termApi.liveTerminalsGeneration,+}));++vi.mock("@/lib/agenticIdeApi", () => ({+ promptTerminal: vi.fn(async () => ({})),+}));+import { TakeoverPanel } from "./TakeoverPanel";const key = (k: string, mods: Partial<{ ctrlKey: boolean; altKey: boolean; metaKey: boolean; shiftKey: boolean }> = {}) =>({ key: k, ctrlKey: false, altKey: false, metaKey: false, shiftKey: false, ...mods });+const restore: Array<() => void> = [];++function spyGetState(store: { getState: () => unknown }, value: unknown): void {+ const spy = vi.spyOn(store, "getState").mockReturnValue(value);+ restore.push(() => spy.mockRestore());+}+describe("keys to a taken-over terminal", () => {it("sends what a terminal sends", () => {expect(keyToTerminalData(key("a"))).toBe("a");@@ -34,33 +71,79 @@ describe("keys to a taken-over terminal", () => {describe("TakeoverPanel", () => {const t = (k: string) => k;const tile = { header: { title: "Mika", status: "Working", tone: "live" as const }, workspaceId: "ws1", names: ["mika", "mika"] };- let unregister: (() => void) | null = null;- afterEach(() => { unregister?.(); unregister = null; });-- it("types every key into the live pane without taking its focus, once per pane, and Ctrl+Q leaves", () => {- const term = { cols: 80, rows: 24, buffer: { active: { length: 0, viewportY: 0, getLine: () => undefined, cursorX: 0, cursorY: 0 } }, options: { theme: {} } } as unknown as Terminal;- unregister = registerLiveTerminal("ws1", "mika", term);- const seen: PaneInputDetail[] = [];- const listen = (e: Event) => seen.push((e as CustomEvent<PaneInputDetail>).detail);- window.addEventListener(PANE_INPUT_EVENT, listen);++ beforeEach(() => {+ termApi.last = null;+ termApi.focus.mockClear();+ termApi.release.mockClear();+ termApi.liveTerminal.mockClear();+ termApi.presentTerminal.mockClear();+ termApi.presentTerminal.mockImplementation((workspaceId: string, names: readonly string[], host: HTMLElement) => {+ termApi.last = { workspaceId, names, host };+ return termApi.release;+ });+ });++ afterEach(() => {+ cleanup();+ while (restore.length) restore.pop()?.();+ });++ it("presents the live pane in the window and leaves only on Ctrl+Q", () => {const onClose = vi.fn();- render(<TakeoverPanel tile={tile} t={t} onClose={onClose} />);- const keys = screen.getByLabelText("verse.takeover.keys");- fireEvent.keyDown(keys, { key: "h" });- fireEvent.keyDown(keys, { key: "Enter" });- fireEvent.keyDown(keys, { key: "Escape" });- expect(seen.map((d) => d.data)).toEqual(["h", "\r", "\x1b"]);- expect(seen.every((d) => d.focus === false && d.workspaceId === "ws1" && d.pane === "mika")).toBe(true);- // Escape went to the agent; the terminal stays open.+ const view = render(<TakeoverPanel tile={tile} t={t} onClose={onClose} />);+ expect(document.querySelector("canvas")).toBeNull();+ expect(screen.queryByLabelText("verse.takeover.keys")).toBeNull();+ expect(termApi.presentTerminal).toHaveBeenCalledWith("ws1", tile.names, expect.any(HTMLElement));+ expect(termApi.last?.host).toBeInstanceOf(HTMLElement);+ expect(termApi.focus).toHaveBeenCalled();+ fireEvent.keyDown(window, { key: "Escape" });expect(onClose).not.toHaveBeenCalled();- fireEvent.keyDown(keys, { key: "q", ctrlKey: true });+ fireEvent.keyDown(window, { key: "q", ctrlKey: true });expect(onClose).toHaveBeenCalledTimes(1);- window.removeEventListener(PANE_INPUT_EVENT, listen);+ expect(termApi.release).not.toHaveBeenCalled();+ view.unmount();+ expect(termApi.release).toHaveBeenCalledTimes(1);+ });++ it("leaves for the Agentic IDE and opens the pane's changes", () => {+ const onClose = vi.fn();+ const setActiveSection = vi.fn();+ const requestPane = vi.fn();+ const setMaximized = vi.fn();+ spyGetState(useEventStore, { activeSection: "chats", setActiveSection });+ spyGetState(useIdeChatStore, { requestPane });+ spyGetState(useIdeSidePanelStore, { setMaximized });+ render(<TakeoverPanel tile={tile} t={t} onClose={onClose} />);+ fireEvent.click(screen.getByRole("button", { name: "verse.takeover.changes" }));+ expect(onClose).toHaveBeenCalledTimes(1);+ expect(setActiveSection).toHaveBeenCalledWith("agentic-ide");+ expect(requestPane).toHaveBeenCalledWith("ws1", "mika", { open: "changes" });+ expect(setMaximized).toHaveBeenCalledWith(false);+ });++ it("does not switch section when the Agentic IDE is already open", () => {+ const setActiveSection = vi.fn();+ const requestPane = vi.fn();+ const setMaximized = vi.fn();+ spyGetState(useEventStore, { activeSection: "agentic-ide", setActiveSection });+ spyGetState(useIdeChatStore, { requestPane });+ spyGetState(useIdeSidePanelStore, { setMaximized });+ render(<TakeoverPanel tile={tile} t={t} onClose={vi.fn()} />);+ fireEvent.click(screen.getByRole("button", { name: "verse.takeover.changes" }));+ expect(setActiveSection).not.toHaveBeenCalled();+ expect(requestPane).toHaveBeenCalledWith("ws1", "mika", { open: "changes" });+ expect(setMaximized).toHaveBeenCalledWith(false);});it("offers a prompt line for a pane the IDE has not mounted", () => {- render(<TakeoverPanel tile={{ ...tile, workspaceId: "elsewhere" }} t={t} onClose={() => undefined} />);+ 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();+ expect(termApi.focus).not.toHaveBeenCalled();+ fireEvent.keyDown(screen.getByPlaceholderText("verse.takeover.placeholder"), { key: "q", ctrlKey: true });+ expect(onClose).toHaveBeenCalledTimes(1);});});diff --git a/dodaios/ui/web/frontend/src/components/society/verse/verse.css b/dodaios/ui/web/frontend/src/components/society/verse/verse.cssindex 703ddc59b3..25058ca706 100644--- a/dodaios/ui/web/frontend/src/components/society/verse/verse.css+++ b/dodaios/ui/web/frontend/src/components/society/verse/verse.css@@ -557,13 +557,39 @@.verse-switch i { transition: none; }}-/* A desk terminal the commander has taken over: the pane large, the keyboard to the agent. */-.verse-dialog.verse-takeover { width: min(1180px, calc(100% - 32px)); }-.verse-takeover-screen { position: relative; height: min(64vh, 680px); background: #0b0c0f; cursor: text; }-.verse-takeover-canvas { display: block; width: 100%; height: 100%; }-.verse-takeover-screen:focus-within { outline: 1px solid var(--verse-line-strong); outline-offset: -1px; }-.verse-takeover-keys { position: absolute; inset: 0; opacity: 0; resize: none; border: 0; padding: 0; caret-color: transparent; cursor: text; }-.verse-takeover-hint { margin: 0; padding: 10px 14px; font-size: 12px; color: var(--verse-ink); opacity: 0.7; }-.verse-takeover-prompt { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 14px; }+/* The IDE's own terminal, at 1:1, in a small window the commander can resize. */+.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);+ display: flex;+ flex-direction: column;+ overflow: hidden;+ resize: both;+}+.verse-dialog.verse-takeover > .verse-dialog-head { flex: none; }+.verse-takeover-screen {+ flex: 1;+ min-height: 0;+ position: relative;+ overflow: hidden;+ background: #0b0c0f;+}+.verse-takeover-host { position: absolute; inset: 0; }+.verse-takeover-host > .xterm { width: 100%; height: 100%; }+.verse-takeover-foot {+ flex: none;+ display: flex;+ align-items: center;+ gap: 12px;+ padding: 10px 14px;+ border-top: 1px solid var(--verse-line);+}+.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); }diff --git a/dodaios/ui/web/frontend/src/i18n/locales/ship/verse.de.json b/dodaios/ui/web/frontend/src/i18n/locales/ship/verse.de.jsonindex d7e516f46e..88323a7eda 100644--- a/dodaios/ui/web/frontend/src/i18n/locales/ship/verse.de.json+++ b/dodaios/ui/web/frontend/src/i18n/locales/ship/verse.de.json@@ -269,7 +269,8 @@"title": "Terminal","action": "Terminal übernehmen","keys": "Tastatur an den Agenten",- "hint_live": "Deine Tasten gehen direkt an den Agenten: tippen, Enter schickt ab, Esc unterbricht ihn, Strg+V fügt ein. Strg+Q verlässt das Terminal.",+ "hint_live": "Du kannst im Terminal klicken und tippen. Enter schickt ab, Esc unterbricht, Strg+V fügt ein, Strg+Q verlässt.",+ "changes": "Änderungen","placeholder": "Prompt für diesen Agenten","send": "Senden"}diff --git a/dodaios/ui/web/frontend/src/i18n/locales/ship/verse.en.json b/dodaios/ui/web/frontend/src/i18n/locales/ship/verse.en.jsonindex 6084010e27..78440089b4 100644--- a/dodaios/ui/web/frontend/src/i18n/locales/ship/verse.en.json+++ b/dodaios/ui/web/frontend/src/i18n/locales/ship/verse.en.json@@ -269,7 +269,8 @@"title": "Terminal","action": "Take over the terminal","keys": "Keyboard to the agent",- "hint_live": "Your keys go straight to the agent: type, Enter sends, Esc interrupts it, Ctrl+V pastes. Ctrl+Q leaves the terminal.",+ "hint_live": "You can click and type in the terminal. Enter sends, Esc interrupts, Ctrl+V pastes, Ctrl+Q leaves.",+ "changes": "Changes","placeholder": "Prompt for this agent","send": "Send"}diff --git a/dodaios/ui/web/frontend/src/i18n/locales/ship/verse.es.json b/dodaios/ui/web/frontend/src/i18n/locales/ship/verse.es.jsonindex 146f76507b..7936db2ed9 100644--- a/dodaios/ui/web/frontend/src/i18n/locales/ship/verse.es.json+++ b/dodaios/ui/web/frontend/src/i18n/locales/ship/verse.es.json@@ -269,7 +269,8 @@"title": "Terminal","action": "Tomar el terminal","keys": "Teclado al agente",- "hint_live": "Tus teclas van directamente al agente: escribe, Intro envía, Esc lo interrumpe, Ctrl+V pega. Ctrl+Q sale del terminal.",+ "hint_live": "Puedes hacer clic y escribir en el terminal. Intro envía, Esc interrumpe, Ctrl+V pega, Ctrl+Q sale.",+ "changes": "Cambios","placeholder": "Prompt para este agente","send": "Enviar"}diff --git a/dodaios/ui/web/frontend/src/i18n/locales/ship/verse.pt.json b/dodaios/ui/web/frontend/src/i18n/locales/ship/verse.pt.jsonindex 9479a2c71b..1ad408c0cd 100644--- a/dodaios/ui/web/frontend/src/i18n/locales/ship/verse.pt.json+++ b/dodaios/ui/web/frontend/src/i18n/locales/ship/verse.pt.json@@ -269,7 +269,8 @@"title": "Terminal","action": "Assumir o terminal","keys": "Teclado para o agente",- "hint_live": "Suas teclas vão direto para o agente: digite, Enter envia, Esc o interrompe, Ctrl+V cola. Ctrl+Q sai do terminal.",+ "hint_live": "Você pode clicar e digitar no terminal. Enter envia, Esc interrompe, Ctrl+V cola, Ctrl+Q sai.",+ "changes": "Alterações","placeholder": "Prompt para este agente","send": "Enviar"}diff --git a/dodaios/ui/web/frontend/src/i18n/locales/ship/verse.zh.json b/dodaios/ui/web/frontend/src/i18n/locales/ship/verse.zh.jsonindex f553a54e2e..21ef516a6c 100644--- a/dodaios/ui/web/frontend/src/i18n/locales/ship/verse.zh.json+++ b/dodaios/ui/web/frontend/src/i18n/locales/ship/verse.zh.json@@ -269,7 +269,8 @@"title": "终端","action": "接管终端","keys": "键盘输入给代理",- "hint_live": "按键直接发送给代理:输入文字,Enter 发送,Esc 中断,Ctrl+V 粘贴。Ctrl+Q 离开终端。",+ "hint_live": "你可以在终端里点击并输入。Enter 发送,Esc 中断,Ctrl+V 粘贴,Ctrl+Q 离开。",+ "changes": "更改","placeholder": "给这个代理的提示","send": "发送"}diff --git a/dodaios/ui/web/frontend/src/lib/liveTerminals.test.ts b/dodaios/ui/web/frontend/src/lib/liveTerminals.test.tsindex ca5c2bb577..ec9ac9ec56 100644--- a/dodaios/ui/web/frontend/src/lib/liveTerminals.test.ts+++ b/dodaios/ui/web/frontend/src/lib/liveTerminals.test.ts@@ -1,6 +1,6 @@import { describe, expect, it, vi } from "vitest";import { Terminal } from "@xterm/xterm";-import { liveTerminal, liveTerminalsGeneration, registerLiveTerminal, subscribeLiveTerminals } from "./liveTerminals";+import { liveTerminal, liveTerminalsGeneration, presentTerminal, registerLiveTerminal, registerTerminalPresenter, subscribeLiveTerminals } from "./liveTerminals";describe("live terminal registry", () => {it("finds a pane by any of its names and counts its writes", async () => {@@ -32,3 +32,37 @@ describe("live terminal registry", () => {a.dispose(); b.dispose();});});++describe("terminal presenter", () => {+ it("places a pane by any of its names and releases only that presenter", () => {+ const host = { nodeType: 1 } as HTMLElement;+ const release = vi.fn();+ const present = vi.fn(() => release);+ const listener = vi.fn();+ const stop = subscribeLiveTerminals(listener);+ const before = liveTerminalsGeneration();+ const unregister = registerTerminalPresenter("ws1", "T1", present);+ expect(listener).toHaveBeenCalledTimes(1);+ expect(liveTerminalsGeneration()).toBe(before + 1);+ expect(presentTerminal("ws1", ["Claude", "T1"], host)).toBe(release);+ expect(present).toHaveBeenCalledWith(host);+ expect(presentTerminal("ws9", ["T1"], host)).toBeNull();+ unregister();+ expect(presentTerminal("ws1", ["T1"], host)).toBeNull();+ stop();+ });++ it("leaves a newer presenter of the same pane registered", () => {+ const first = vi.fn(() => () => undefined);+ const second = vi.fn(() => () => undefined);+ const offFirst = registerTerminalPresenter("ws2", "T1", first);+ const offSecond = registerTerminalPresenter("ws2", "T1", second);+ offFirst();+ const host = { nodeType: 1 } as HTMLElement;+ presentTerminal("ws2", ["T1"], host);+ expect(first).not.toHaveBeenCalled();+ expect(second).toHaveBeenCalledWith(host);+ offSecond();+ expect(presentTerminal("ws2", ["T1"], host)).toBeNull();+ });+});diff --git a/dodaios/ui/web/frontend/src/lib/liveTerminals.ts b/dodaios/ui/web/frontend/src/lib/liveTerminals.tsindex cd1635a32d..2684fe6920 100644--- a/dodaios/ui/web/frontend/src/lib/liveTerminals.ts+++ b/dodaios/ui/web/frontend/src/lib/liveTerminals.ts@@ -68,3 +68,36 @@ export function subscribeLiveTerminals(listener: () => void): () => void {export function liveTerminalsGeneration(): number {return generation;}++/**+ * Shows one pane's existing xterm inside another element.+ *+ * The Verse window calls this so the commander gets the IDE's own terminal,+ * clicks and keystrokes included. The presenter moves that xterm into the+ * window; this module does not focus, resize, or write.+ */+export type TerminalPresenter = (host: HTMLElement) => () => void;++const presenters = new Map<string, TerminalPresenter>();++/** Register the function that places a pane's terminal into `host`; returns the matching unregister. */+export function registerTerminalPresenter(workspaceId: string, name: string, present: TerminalPresenter): () => void {+ const key = keyOf(workspaceId, name);+ presenters.set(key, present);+ changed();+ return () => {+ if (presenters.get(key) === present) {+ presenters.delete(key);+ changed();+ }+ };+}++/** Place the pane in `host`, trying each of its names. Null when the IDE has not mounted it. */+export function presentTerminal(workspaceId: string, names: readonly string[], host: HTMLElement): (() => void) | null {+ for (const name of names) {+ const present = presenters.get(keyOf(workspaceId, name));+ if (present) return present(host);+ }+ return null;+}diff --git a/dodaios/ui/web/frontend/src/store/ideChat.ts b/dodaios/ui/web/frontend/src/store/ideChat.tsindex dbae3cd75d..da663a4274 100644--- a/dodaios/ui/web/frontend/src/store/ideChat.ts+++ b/dodaios/ui/web/frontend/src/store/ideChat.ts@@ -48,6 +48,11 @@ export interface PaneRequest {* The grid clears it once it has obeyed, so a later remount never maximizes again.*/maximize?: boolean;+ /**+ * Open that pane's changes dialog once the view has the pane.+ * Cleared after the pane obeys, so a later remount does not open it again.+ */+ open?: "changes";}/**@@ -126,9 +131,11 @@ interface IdeChatStore {setView: (next: WorkspaceView) => void;setWorkspace: (next: IdeWorkspace | null) => void;/** Bring a pane to the front, switching to the grid and to its workspace when it lives elsewhere. */- requestPane: (workspaceId: string, pane: string, options?: { maximize?: boolean }) => void;+ requestPane: (workspaceId: string, pane: string, options?: { maximize?: boolean; open?: "changes" }) => void;/** The grid maximized request `nonce`; drop its maximize flag. */settlePaneMaximize: (nonce: number) => void;+ /** The pane opened its changes dialog for request `nonce`; drop that flag. */+ settlePaneOpen: (nonce: number) => void;setStagedPane: (pane: string | null) => void;setWorkspaces: (rows: IdeWorkspaceRow[]) => void;setAgents: (agents: SplitAgentChoice[]) => void;@@ -172,6 +179,7 @@ export const useIdeChatStore = create<IdeChatStore>((set) => ({pane,nonce: (state.paneRequest?.nonce ?? 0) + 1,...(options?.maximize ? { maximize: true } : {}),+ ...(options?.open ? { open: options.open } : {}),},}));},@@ -181,6 +189,14 @@ export const useIdeChatStore = create<IdeChatStore>((set) => ({? { paneRequest: { ...state.paneRequest, maximize: false } }: state,),+ settlePaneOpen: (nonce) =>+ set((state) => {+ const request = state.paneRequest;+ if (!request || request.nonce !== nonce || !request.open) return state;+ const rest = { ...request };+ delete rest.open;+ return { paneRequest: rest };+ }),setStagedPane: (pane) =>// Guarded: the grid publishes this from an effect that runs on every poll,// and an unconditional set would wake every subscriber each time.