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
feat(office): open a coding session as a movable window, not a full-width strip
rubenluetke10-beepc2b1525fa246
diff --git a/jarvis/ui/web/frontend/src/components/society/office/OfficeStage.tsx b/jarvis/ui/web/frontend/src/components/society/office/OfficeStage.tsxindex b7e3a7e981..a01dcb1865 100644--- a/jarvis/ui/web/frontend/src/components/society/office/OfficeStage.tsx+++ b/jarvis/ui/web/frontend/src/components/society/office/OfficeStage.tsx@@ -392,11 +392,13 @@ export function OfficeStage({ onOpenLedger, onSelectAgent, onCreateAgent, onOpen</div>{selection?.kind === "arcade" && <ArcadeCabinet onClose={() => select(null)} />}- {selection && selection.kind !== "arcade" && (+ {/* A coding session is a window of its own on the stage, not a panel in the corner slot. */}+ {selection?.kind === "agent" && selectedPane && (+ <PaneCommandPanel occupant={selectedPane} compact={compact} onOpen={() => openPaneSession(selectedPane.pane)} onClose={() => select(null)} />+ )}+ {selection && selection.kind !== "arcade" && !(selection.kind === "agent" && selectedPane) && (<div className="office-panel-slot" data-wide={receptionOpen || missionOpen || undefined}>- {selection.kind === "agent" && selectedAgent && (selectedPane- ? <PaneCommandPanel occupant={selectedPane} onOpen={() => openPaneSession(selectedPane.pane)} onClose={() => select(null)} />- : <AgentPanel agent={selectedAgent} actions={actions} onClose={() => select(null)} />)}+ {selection.kind === "agent" && selectedAgent && <AgentPanel agent={selectedAgent} actions={actions} onClose={() => select(null)} />}{selection.kind === "checkpoint" && (<CheckpointPanel id={selection.id} floor={floor} agents={active} layout={layout} sample={!coding && (roster.data?.sample ?? false)}profile={profile} onProfile={updateProfile} actions={actions} onClose={() => select(null)} />diff --git a/jarvis/ui/web/frontend/src/components/society/office/PaneCommandPanel.tsx b/jarvis/ui/web/frontend/src/components/society/office/PaneCommandPanel.tsxindex 320ad9fa3b..e8933200ea 100644--- a/jarvis/ui/web/frontend/src/components/society/office/PaneCommandPanel.tsx+++ b/jarvis/ui/web/frontend/src/components/society/office/PaneCommandPanel.tsx@@ -1,16 +1,27 @@/**- * A coding session on the coding floor, shown as the pane it is: the Agentic- * IDE's title bar (state dot, agent mark, the pane's title, the pane actions as- * quiet icons) over the IDE's own live terminal. Nothing else — no chips, no- * toolbar, no side notes, no second prompt box.+ * A coding session on the coding floor, shown as the pane it is — in a window+ * over the map: the Agentic IDE's title bar (state dot, agent mark, the pane's+ * title, the pane actions as quiet icons) over the IDE's own live terminal.+ * Nothing else — no chips, no toolbar, no side notes, no second prompt box.+ *+ * The window opens bottom-right at about half the stage's width, moves by its+ * title bar, resizes by any edge or corner, and remembers where the reader+ * left it (./paneWindow). Its size is fixed while nothing is being dragged, so+ * the terminal inside never resizes the agent on its own.** The terminal is the IDE pane's `AgenticTerminal` itself, attached as one more* viewer of the same PTY: the same renderer, font and colours, and typed into- * directly, exactly like the pane in the IDE. Colours come from the pane's own- * appearance tables (./terminalThemes), so the panel matches the IDE's panes in- * light and dark, including a light pane in a dark app.+ * directly, exactly like the pane in the IDE. It opens as the pane's size lead+ * in this window (../../agentic/paneSizeLead), so the same pane in the IDE grid+ * behind the office follows this window's size instead of trading it back and+ * forth. Colours come from the pane's own appearance tables (./terminalThemes),+ * so the window matches the IDE's panes in light and dark, including a light+ * pane in a dark app.*/-import { useEffect, useId, useRef, useState, type CSSProperties } from "react";+import {+ useEffect, useId, useLayoutEffect, useMemo, useRef, useState,+ type CSSProperties, type MouseEvent as ReactMouseEvent, type PointerEvent as ReactPointerEvent, type RefObject,+} from "react";import { Footprints, Hand, LocateFixed, Maximize2, Square, Trash2, X } from "lucide-react";import { useT } from "@/i18n";import { useThemeValue } from "@/hooks/useTheme";@@ -26,10 +37,17 @@ import type { PaneOccupant } from "./codingFloor";import { player, useOfficeStore } from "./officeStore";import { agentPositions } from "./walkerRegistry";import { CALL_MS } from "./AgentTalkPanel";+import {+ defaultRect, loadStoredWindow, moveRect, placeStored, resizeRect, saveStoredWindow, toStored,+ type ResizeEdge, type StageSize, type WindowRect,+} from "./paneWindow";import "./paneCommand.css";/** A second press within this window confirms closing the session. */const CONFIRM_MS = 4000;+/** How long a success line stays on the window; an error stays until the next action. */+const NOTE_MS = 4000;+const EDGES: readonly ResizeEdge[] = ["n", "s", "e", "w", "ne", "nw", "se", "sw"];function sinceLabel(at: number | null, t: (key: string) => string): string {if (!at) return "";@@ -41,11 +59,43 @@ function sinceLabel(at: number | null, t: (key: string) => string): string {}type Note = { tone: "ok" | "error"; text: string } | null;+type Gesture = {+ kind: "move" | "resize";+ edge: ResizeEdge;+ pointerId: number;+ startX: number;+ startY: number;+ start: WindowRect;+};++/** The stage the window floats over (its offset parent), measured before paint and on every resize. */+function useStageSize(panel: RefObject<HTMLElement | null>): StageSize | null {+ const [stage, setStage] = useState<StageSize | null>(null);+ useLayoutEffect(() => {+ const host = panel.current?.parentElement;+ if (!host) return;+ const measure = () => {+ const width = host.clientWidth, height = host.clientHeight;+ setStage((prev) => (prev && prev.width === width && prev.height === height ? prev : { width, height }));+ };+ measure();+ if (typeof ResizeObserver === "undefined") return;+ const observer = new ResizeObserver(measure);+ observer.observe(host);+ return () => observer.disconnect();+ }, [panel]);+ return stage;+}-export function PaneCommandPanel({ occupant, onOpen, onClose }: { occupant: PaneOccupant; onOpen: () => void; onClose: () => void }) {+export function PaneCommandPanel({ occupant, compact = false, onOpen, onClose }: {+ occupant: PaneOccupant;+ /** The office inside the IDE's side panel: the window opens clear of the HUD buttons along the bottom. */+ compact?: boolean;+ onOpen: () => void;+ onClose: () => void;+}) {const t = useT();const headingId = useId();- const office = useOfficeStore();const { agent, pane } = occupant;const panel = useRef<HTMLElement>(null);const [note, setNote] = useState<Note>(null);@@ -63,16 +113,33 @@ export function PaneCommandPanel({ occupant, onOpen, onClose }: { occupant: Paneconst since = sinceLabel(pane.activity_since || null, t);const title = paneTitle || pane.recap.trim() || agent.name;+ const stage = useStageSize(panel);+ const [stored, setStored] = useState(() => loadStoredWindow(compact));+ // The window mid-drag. Held apart from `stored` so a drag costs one small+ // render per frame and is written to storage once, when it ends.+ const [dragRect, setDragRect] = useState<WindowRect | null>(null);+ const gesture = useRef<Gesture | null>(null);+ const frame = useRef<number | null>(null);+ const [resizing, setResizing] = useState(false);+ const rest = stage ? (stored ? placeStored(stored, stage) : defaultRect(stage, compact)) : null;+ const rect = dragRect ?? rest;+useEffect(() => { panel.current?.focus({ preventScroll: true }); setNote(null); setConfirmClose(false); }, [agent.agentId]);useEffect(() => {if (!confirmClose) return;const timer = setTimeout(() => setConfirmClose(false), CONFIRM_MS);return () => clearTimeout(timer);}, [confirmClose]);+ useEffect(() => {+ if (note?.tone !== "ok") return;+ const timer = setTimeout(() => setNote(null), NOTE_MS);+ return () => clearTimeout(timer);+ }, [note]);+ useEffect(() => () => { if (frame.current !== null) cancelAnimationFrame(frame.current); }, []);const refresh = () => { void useWorkspacePanesStore.getState().load(); };- /** Run one session action; it answers with the line the panel shows once it is done. */+ /** Run one session action; it answers with the line the window shows once it is done. */const run = async (action: () => Promise<string>) => {setNote(null);try {@@ -100,6 +167,95 @@ export function PaneCommandPanel({ occupant, onOpen, onClose }: { occupant: Pane});};+ /* ---- moving and resizing ------------------------------------------------ */++ const begin = (event: ReactPointerEvent<HTMLElement>, kind: Gesture["kind"], edge: ResizeEdge = "se") => {+ if (event.button !== 0 || !rest) return;+ // The title bar's buttons stay buttons.+ if (kind === "move" && (event.target as HTMLElement).closest("button")) return;+ event.preventDefault();+ event.currentTarget.setPointerCapture?.(event.pointerId);+ gesture.current = { kind, edge, pointerId: event.pointerId, startX: event.clientX, startY: event.clientY, start: rest };+ setDragRect(rest);+ if (kind === "resize") setResizing(true);+ };++ const follow = (event: ReactPointerEvent<HTMLElement>) => {+ const g = gesture.current;+ if (!g || g.pointerId !== event.pointerId || !stage) return;+ const dx = event.clientX - g.startX, dy = event.clientY - g.startY;+ const next = g.kind === "move" ? moveRect(g.start, dx, dy, stage) : resizeRect(g.start, g.edge, dx, dy, stage);+ // At most one render per frame, however fast the pointer reports.+ if (frame.current !== null) cancelAnimationFrame(frame.current);+ frame.current = requestAnimationFrame(() => { frame.current = null; setDragRect(next); });+ };++ const finish = (event: ReactPointerEvent<HTMLElement>) => {+ const g = gesture.current;+ if (!g || g.pointerId !== event.pointerId) return;+ gesture.current = null;+ if (frame.current !== null) { cancelAnimationFrame(frame.current); frame.current = null; }+ if (stage) {+ const dx = event.clientX - g.startX, dy = event.clientY - g.startY;+ const end = g.kind === "move" ? moveRect(g.start, dx, dy, stage) : resizeRect(g.start, g.edge, dx, dy, stage);+ // A press without a real drag moves nothing and remembers nothing.+ if (end.x !== g.start.x || end.y !== g.start.y || end.w !== g.start.w || end.h !== g.start.h) {+ const next = toStored(end, stage);+ setStored(next);+ saveStoredWindow(compact, next);+ }+ }+ setDragRect(null);+ setResizing(false);+ };++ /**+ * The pointer was taken away mid-drag (the OS, a touch turned into a scroll,+ * capture lost). Its last coordinates are not a place anyone chose — a+ * cancelled pointer often reports (0, 0) — so the window goes back to where+ * the drag began and nothing is remembered. After a normal release the+ * gesture is already over and this does nothing.+ */+ const abandon = (event: ReactPointerEvent<HTMLElement>) => {+ const g = gesture.current;+ if (!g || g.pointerId !== event.pointerId) return;+ gesture.current = null;+ if (frame.current !== null) { cancelAnimationFrame(frame.current); frame.current = null; }+ setDragRect(null);+ setResizing(false);+ };++ const gestureHandlers = (kind: Gesture["kind"], edge?: ResizeEdge) => ({+ onPointerDown: (event: ReactPointerEvent<HTMLElement>) => begin(event, kind, edge),+ onPointerMove: follow,+ onPointerUp: finish,+ onPointerCancel: abandon,+ onLostPointerCapture: abandon,+ });++ /** Double-click on the title bar: back to where the window first opened. */+ const resetPlace = (event: ReactMouseEvent) => {+ if ((event.target as HTMLElement).closest("button")) return;+ setStored(null);+ saveStoredWindow(compact, null);+ };++ /* ---- the terminal ------------------------------------------------------- */++ // Built once per pane and size state, so the window re-rendering while it is+ // carried around never re-renders the terminal inside it. Mounted only once+ // the stage has a size: the first size the agent hears is the window's, and+ // a window with no room cannot hold the pane's size lead against the grid.+ const ready = stage !== null && stage.width > 0 && stage.height > 0;+ const terminal = useMemo(() => ready ? (+ // Keyed by the pane, so another session is a fresh socket, never this one's screen under a new name.+ <AgenticTerminal key={`${pane.workspace_id}/${pane.name}`} headerMode="none" sizeLead+ name={pane.name} workspaceId={pane.workspace_id} agent={pane.agent}+ displayName={pane.display_name || pane.agent || agent.name}+ appearance={appearance} fontSize={FONT_DEFAULT} layoutBusy={resizing}+ onAttachError={(message) => setNote({ tone: "error", text: message })} />+ ) : null, [ready, pane.workspace_id, pane.name, pane.agent, pane.display_name, agent.name, appearance, resizing]);+const dot = occupant.dot === "working" ? ansi.green: occupant.dot === "waiting" ? ansi.yellow: occupant.dot === "error" ? ansi.red : brand.inkFaint;@@ -115,12 +271,18 @@ export function PaneCommandPanel({ occupant, onOpen, onClose }: { occupant: Pane"--pane-float": chrome.float,"--pane-ok": ansi.green,"--pane-fault": ansi.red,- "--pane-caret": ansi.cursor ?? brand.ink,} as CSSProperties;+ const style: CSSProperties = rect+ ? { ...vars, left: rect.x, top: rect.y, width: rect.w, height: rect.h }+ // Not placed until the stage is measured, which happens before the first paint.+ : { ...vars, visibility: "hidden" };return (- <aside ref={panel} className="office-panel office-pane" data-office-ui style={vars} aria-labelledby={headingId} tabIndex={-1}>- <header className="office-pane-head">+ <aside ref={panel} className="office-pane" data-office-ui data-appearance={appearance}+ data-gesture={dragRect ? (resizing ? "resize" : "move") : undefined}+ style={style} aria-labelledby={headingId} tabIndex={-1}>+ <header className="office-pane-head" title={t("society.office.pane_window_hint")}+ {...gestureHandlers("move")} onDoubleClick={resetPlace}><span className="office-pane-dot" style={{ background: dot }} role="img"aria-label={t(`society.office.pane_state_${occupant.stateKey}`)} /><AgentMark agent={pane.agent} label={pane.display_name || pane.agent} variant="plain" size="sm"@@ -138,15 +300,15 @@ export function PaneCommandPanel({ occupant, onOpen, onClose }: { occupant: Pane<button type="button" disabled={!live} onClick={fork} title={t("society.office.cmd_fork")} aria-label={t("society.office.cmd_fork")}><BranchIcon aria-hidden /></button>- <button type="button" disabled={!where} onClick={() => where && office.requestWalk(where)}+ <button type="button" disabled={!where} onClick={() => where && useOfficeStore.getState().requestWalk(where)}title={t("society.office.action_walk")} aria-label={t("society.office.action_walk")}><Footprints aria-hidden /></button>- <button type="button" onClick={() => office.summon([agent.agentId], { x: player.x, z: player.z }, CALL_MS)}+ <button type="button" onClick={() => useOfficeStore.getState().summon([agent.agentId], { x: player.x, z: player.z }, CALL_MS)}title={t("society.office.action_call")} aria-label={t("society.office.action_call")}><Hand aria-hidden /></button>- <button type="button" disabled={!where} onClick={() => where && office.focusOn(where)}+ <button type="button" disabled={!where} onClick={() => where && useOfficeStore.getState().focusOn(where)}title={t("society.office.action_focus")} aria-label={t("society.office.action_focus")}><LocateFixed aria-hidden /></button>@@ -165,15 +327,12 @@ export function PaneCommandPanel({ occupant, onOpen, onClose }: { occupant: Pane</div></header>- {/* Keyed by the pane, so another session is a fresh socket, never this one's screen under a new name. */}- <div className="office-pane-term">- <AgenticTerminal key={`${pane.workspace_id}/${pane.name}`} headerMode="none"- name={pane.name} workspaceId={pane.workspace_id} agent={pane.agent}- displayName={pane.display_name || pane.agent || agent.name}- appearance={appearance} fontSize={FONT_DEFAULT}- onAttachError={(message) => setNote({ tone: "error", text: message })} />- </div>- {note && <p className="office-pane-status" role="status" data-tone={note.tone}>{note.text}</p>}+ <div className="office-pane-term">{terminal}</div>+ {/* Over the terminal, never below it: a line that took rows away would resize the agent. */}+ {note && <p className="office-pane-status" role="status" data-tone={note.tone} onClick={() => setNote(null)}>{note.text}</p>}+ {EDGES.map((grip) => (+ <div key={grip} className="office-pane-grip" data-edge={grip} aria-hidden {...gestureHandlers("resize", grip)} />+ ))}</aside>);}diff --git a/jarvis/ui/web/frontend/src/components/society/office/paneCommand.css b/jarvis/ui/web/frontend/src/components/society/office/paneCommand.cssindex 70bf946dae..19326a526d 100644--- a/jarvis/ui/web/frontend/src/components/society/office/paneCommand.css+++ b/jarvis/ui/web/frontend/src/components/society/office/paneCommand.css@@ -1,14 +1,20 @@-/* A coding session's panel on the office map, drawn as an Agentic IDE pane:- 36 px title bar over the IDE's own live terminal.- Every colour is a --pane-* variable the component sets from the pane- appearance tables (terminalThemes.ts), so it follows light and dark panes. */-.office-panel-slot:has(> .office-pane) { width:min(560px, calc(100% - 28px)); }-.office-stage-compact .office-panel-slot:has(> .office-pane) { width:calc(100% - 16px); }+/* A coding session's window on the office map, drawn as an Agentic IDE pane:+ 36 px title bar over the IDE's own live terminal, floating over the scene.+ Position and size are set inline from ./paneWindow; every colour is a+ --pane-* variable the component sets from the pane appearance tables+ (terminalThemes.ts), so it follows light and dark panes. */+.office-pane { position:absolute; z-index:36; display:flex; flex-direction:column; min-width:0; min-height:0; overflow:hidden; border:1px solid var(--pane-edge); border-radius:12px; background:var(--pane-ground); color:var(--pane-ink); box-shadow:0 24px 60px rgb(0 0 0 / .45), 0 4px 14px rgb(0 0 0 / .22); backdrop-filter:blur(14px); animation:office-pane-in .16s ease-out; }+.office-pane[data-appearance="light"] { box-shadow:0 24px 60px rgb(20 18 10 / .24), 0 4px 14px rgb(20 18 10 / .12); }+.office-pane:focus { outline:none; }+.office-pane:focus-visible { outline:2px solid hsl(var(--ring)); outline-offset:2px; }+.office-pane[data-gesture] { user-select:none; }+@keyframes office-pane-in { from { opacity:0; transform:translateY(6px); } }+@media (prefers-reduced-motion: reduce) { .office-pane { animation:none; } }-.office-pane { border:1px solid var(--pane-edge); border-radius:10px; background:var(--pane-ground); color:var(--pane-ink); box-shadow:0 10px 32px rgb(0 0 0 / .28); backdrop-filter:blur(14px); }--.office-pane-head { display:flex; align-items:center; gap:8px; height:36px; min-height:36px; padding:0 4px 0 10px; border-bottom:1px solid var(--pane-rule); }-.office-pane-dot { flex:none; width:6px; height:6px; border-radius:50%; }+/* The title bar is the window's handle: drag to move, double-click to put it back. */+.office-pane-head { position:relative; display:flex; flex:none; align-items:center; gap:8px; height:36px; min-height:36px; padding:0 4px 0 12px; border-bottom:1px solid var(--pane-rule); background:color-mix(in srgb, var(--pane-float) 45%, transparent); cursor:grab; user-select:none; touch-action:none; }+.office-pane[data-gesture="move"] .office-pane-head { cursor:grabbing; }+.office-pane-dot { flex:none; width:7px; height:7px; border-radius:50%; }.office-pane-head h2 { flex:0 1 auto; min-width:0; margin:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:13px; font-weight:500; color:var(--pane-ink); }.office-pane-meta { flex:1 1 auto; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:11px; color:var(--pane-ink-muted); }.office-pane-actions { display:flex; flex:none; align-items:center; gap:1px; }@@ -21,19 +27,38 @@.office-pane-actions button[data-danger][aria-pressed="true"] { background:var(--pane-chip); }.office-pane-sep { width:1px; height:16px; margin:0 3px; background:var(--pane-rule); }-/* Fixed height, rows absolutely placed: the grid is fitted to this box, so the- text can never feed back into its size. */+/* The IDE's own terminal, attached to the same PTY. The box takes whatever+ the window leaves under the title bar and the terminal fills it+ absolutely, so xterm's canvas can never feed back into the window's size. */+.office-pane-term { position:relative; flex:1 1 0; min-height:0; }+.office-pane-term > * { position:absolute; inset:0; }++/* An action's result floats over the terminal's foot: a line below it would+ take rows away and resize the agent every time one appears. */+.office-pane-status { position:absolute; z-index:2; left:12px; right:12px; bottom:10px; margin:0; padding:6px 10px; border:1px solid var(--pane-rule); border-radius:8px; background:var(--pane-float); box-shadow:0 6px 18px rgb(0 0 0 / .22); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:12px; color:var(--pane-ink-muted); cursor:pointer; }+.office-pane-status[data-tone="ok"] { color:var(--pane-ok); }+.office-pane-status[data-tone="error"] { color:var(--pane-fault); white-space:normal; }++/* Resize grips: 4 px strips along each edge and squares on the corners, inside+ the window's rounded clip — thin enough to stay clear of the terminal's+ text and scroll rail inside its padding. Only the bottom-right one is drawn. */+.office-pane-grip { position:absolute; z-index:3; touch-action:none; }+.office-pane-grip[data-edge="n"] { top:0; left:12px; right:12px; height:4px; cursor:ns-resize; }+.office-pane-grip[data-edge="s"] { bottom:0; left:12px; right:12px; height:4px; cursor:ns-resize; }+.office-pane-grip[data-edge="e"] { right:0; top:12px; bottom:12px; width:4px; cursor:ew-resize; }+.office-pane-grip[data-edge="w"] { left:0; top:12px; bottom:12px; width:4px; cursor:ew-resize; }+.office-pane-grip[data-edge="nw"] { top:0; left:0; width:12px; height:12px; cursor:nwse-resize; }+.office-pane-grip[data-edge="ne"] { top:0; right:0; width:12px; height:12px; cursor:nesw-resize; }+.office-pane-grip[data-edge="sw"] { bottom:0; left:0; width:14px; height:14px; cursor:nesw-resize; }+.office-pane-grip[data-edge="se"] { bottom:0; right:0; width:16px; height:16px; cursor:nwse-resize; }+.office-pane-grip[data-edge="se"]::after { content:""; position:absolute; right:4px; bottom:4px; width:8px; height:8px; opacity:.55; background:linear-gradient(135deg, transparent 0 45%, var(--pane-ink-faint) 45% 55%, transparent 55% 70%, var(--pane-ink-faint) 70% 80%, transparent 80%); }+.office-pane:hover .office-pane-grip[data-edge="se"]::after { opacity:.9; }++/* Mission Control's still screens of the sessions (./PaneLiveScreen). Fixed+ height, rows absolutely placed: the grid is fitted to this box, so the text+ can never feed back into its size. */.office-pane-screen { position:relative; flex:1 1 clamp(200px, 38vh, 420px); min-height:110px; margin:0 12px; cursor:zoom-in; }.office-pane-screen pre { position:absolute; inset:8px 0 0; margin:0; overflow:hidden; display:flex; flex-direction:column; justify-content:flex-end; color:var(--pane-ink); white-space:pre; text-shadow:none; font-variant-ligatures:none; }.office-pane-screen pre > div { overflow:hidden; }.office-pane-cursor { background:var(--pane-caret); color:var(--pane-ground); }.office-pane-empty { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; margin:0; font-size:12px; color:var(--pane-ink-faint); }--/* The IDE's own terminal, attached to the same PTY. The box keeps the panel's- size (the old screen plus the prompt line it replaces); the terminal fills- it absolutely, so xterm's canvas can never feed back into the box's height. */-.office-pane-term { position:relative; flex:1 1 clamp(260px, calc(38vh + 60px), 480px); min-height:160px; }-.office-pane-term > * { position:absolute; inset:0; }-.office-pane-status { margin:0; padding:4px 12px 8px; border-top:1px solid var(--pane-rule); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:11px; color:var(--pane-ink-faint); }-.office-pane-status[data-tone="ok"] { color:var(--pane-ok); }-.office-pane-status[data-tone="error"] { color:var(--pane-fault); white-space:normal; }diff --git a/jarvis/ui/web/frontend/src/components/society/office/paneWindow.test.ts b/jarvis/ui/web/frontend/src/components/society/office/paneWindow.test.tsnew file mode 100644index 0000000000..9144bc0cb5--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/society/office/paneWindow.test.ts@@ -0,0 +1,90 @@+import { afterEach, describe, expect, it } from "vitest";+import {+ EDGE, MIN_H, MIN_W, defaultRect, fitRect, loadStoredWindow, moveRect, placeStored, resizeRect, saveStoredWindow, toStored,+ type WindowRect,+} from "./paneWindow";++const IDE = { width: 1795, height: 1030 };+const inside = (rect: WindowRect, stage: { width: number; height: number }) =>+ rect.x >= EDGE && rect.y >= EDGE && rect.x + rect.w <= stage.width - EDGE && rect.y + rect.h <= stage.height - EDGE;++describe("pane window geometry", () => {+ afterEach(() => {+ window.localStorage.clear();+ });++ it("opens as a window, not a strip: about half the stage wide, bottom-right, clear of the HUD", () => {+ const rect = defaultRect(IDE, true);+ expect(rect.w).toBeLessThanOrEqual(860);+ expect(rect.w).toBeGreaterThanOrEqual(460);+ expect(rect.w).toBeLessThan(IDE.width * 0.6);+ expect(rect.h).toBeGreaterThanOrEqual(280);+ expect(rect.h).toBeLessThanOrEqual(480);+ expect(rect.x + rect.w).toBe(IDE.width - EDGE);+ // The compact stage's buttons run along its bottom edge.+ expect(IDE.height - (rect.y + rect.h)).toBe(48);+ });++ it("fits a small stage without leaving it", () => {+ const stage = { width: 420, height: 300 };+ const rect = defaultRect(stage, true);+ expect(inside(rect, stage)).toBe(true);+ expect(rect.w).toBe(stage.width - 2 * EDGE);+ });++ it("stops a move at the stage edges", () => {+ const start = defaultRect(IDE, true);+ const far = moveRect(start, 5000, 5000, IDE);+ expect(inside(far, IDE)).toBe(true);+ expect(far.w).toBe(start.w);+ const back = moveRect(start, -5000, -5000, IDE);+ expect(back.x).toBe(EDGE);+ expect(back.y).toBe(EDGE);+ });++ it("resizes from the top-left corner with the bottom-right corner held", () => {+ const start = defaultRect(IDE, true);+ const grown = resizeRect(start, "nw", -100, -60, IDE);+ expect(grown.w).toBe(start.w + 100);+ expect(grown.h).toBe(start.h + 60);+ expect(grown.x + grown.w).toBe(start.x + start.w);+ expect(grown.y + grown.h).toBe(start.y + start.h);+ });++ it("never resizes below the minimum or past the stage", () => {+ const start = defaultRect(IDE, true);+ const tiny = resizeRect(start, "se", -5000, -5000, IDE);+ expect(tiny.w).toBe(MIN_W);+ expect(tiny.h).toBe(MIN_H);+ const huge = resizeRect(start, "nw", -5000, -5000, IDE);+ expect(inside(huge, IDE)).toBe(true);+ expect(huge.x).toBe(EDGE);+ expect(huge.y).toBe(EDGE);+ });++ it("keeps the window's distance from the bottom-right corner when the stage changes", () => {+ const rect = fitRect({ x: 900, y: 500, w: 600, h: 400 }, IDE);+ const stored = toStored(rect, IDE);+ const wider = { width: IDE.width + 200, height: IDE.height };+ expect(placeStored(stored, wider)).toEqual({ ...rect, x: rect.x + 200 });+ // A stage too small for it shrinks the window rather than pushing it off.+ const narrow = { width: 500, height: 400 };+ expect(inside(placeStored(stored, narrow), narrow)).toBe(true);+ });++ it("remembers the window per stage kind and forgets it on request", () => {+ const stored = { r: 10, b: 50, w: 700, h: 420 };+ saveStoredWindow(true, stored);+ expect(loadStoredWindow(true)).toEqual(stored);+ expect(loadStoredWindow(false)).toBeNull();+ saveStoredWindow(true, null);+ expect(loadStoredWindow(true)).toBeNull();+ });++ it("ignores a stored value that is not a window", () => {+ window.localStorage.setItem("jarvis.office.paneWindow.compact", JSON.stringify({ r: "x", b: 1 }));+ expect(loadStoredWindow(true)).toBeNull();+ window.localStorage.setItem("jarvis.office.paneWindow.compact", "{not json");+ expect(loadStoredWindow(true)).toBeNull();+ });+});diff --git a/jarvis/ui/web/frontend/src/components/society/office/paneWindow.ts b/jarvis/ui/web/frontend/src/components/society/office/paneWindow.tsnew file mode 100644index 0000000000..e1e8612472--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/society/office/paneWindow.ts@@ -0,0 +1,120 @@+/**+ * Geometry of the coding-session window on the office map: where it opens,+ * how it moves and resizes, and how it stays inside the stage. Pure, apart+ * from the two storage helpers at the bottom.+ *+ * The window is placed in stage pixels (top-left origin) but remembered as a+ * distance from the stage's bottom-right corner, where it opens: a stage that+ * grows or shrinks (the IDE's side panel dragged wider) keeps the window where+ * the reader put it relative to that corner instead of stranding it mid-map.+ */++export interface WindowRect { x: number; y: number; w: number; h: number }+export interface StageSize { width: number; height: number }+/** The edge or corner a resize grips, by compass point. */+export type ResizeEdge = "n" | "s" | "e" | "w" | "ne" | "nw" | "se" | "sw";+/** How the window is remembered: its size and its distance from the stage's bottom-right corner. */+interface StoredWindow { r: number; b: number; w: number; h: number }++/** Space kept between the window and every stage edge. */+export const EDGE = 8;+/** Smallest window: a title bar and a terminal a coding CLI can still draw a prompt in. */+export const MIN_W = 360;+export const MIN_H = 220;++/** Room left under the window, per stage: the compact stage's HUD buttons sit along its bottom. */+function bottomGap(compact: boolean): number {+ return compact ? 48 : 16;+}++const clamp = (value: number, lo: number, hi: number) => Math.min(Math.max(value, lo), hi);++/** Where the window opens: bottom-right, about half the stage wide, the old panel's height. */+export function defaultRect(stage: StageSize, compact: boolean): WindowRect {+ const right = compact ? EDGE : 14;+ const bottom = bottomGap(compact);+ const w = Math.round(clamp(stage.width * 0.48, 460, 860));+ const h = Math.round(clamp(stage.height * 0.42, 280, 480));+ return fitRect({ x: stage.width - right - w, y: stage.height - bottom - h, w, h }, stage);+}++/** The rect made to fit the stage: shrunk if it is too big, then moved fully inside. */+export function fitRect(rect: WindowRect, stage: StageSize): WindowRect {+ const maxW = Math.max(0, stage.width - 2 * EDGE);+ const maxH = Math.max(0, stage.height - 2 * EDGE);+ const w = Math.round(clamp(rect.w, Math.min(MIN_W, maxW), maxW));+ const h = Math.round(clamp(rect.h, Math.min(MIN_H, maxH), maxH));+ return {+ x: Math.round(clamp(rect.x, EDGE, Math.max(EDGE, stage.width - EDGE - w))),+ y: Math.round(clamp(rect.y, EDGE, Math.max(EDGE, stage.height - EDGE - h))),+ w,+ h,+ };+}++/** The window carried by its title bar `dx`/`dy` pixels from where the drag began. */+export function moveRect(start: WindowRect, dx: number, dy: number, stage: StageSize): WindowRect {+ return fitRect({ ...start, x: start.x + dx, y: start.y + dy }, stage);+}++/**+ * The window resized by one edge or corner. The opposite edge stays where it+ * was, and the gripped one stops at the minimum size and at the stage edge.+ */+export function resizeRect(start: WindowRect, edge: ResizeEdge, dx: number, dy: number, stage: StageSize): WindowRect {+ let { x, y, w, h } = start;+ const minW = Math.min(MIN_W, stage.width - 2 * EDGE);+ const minH = Math.min(MIN_H, stage.height - 2 * EDGE);+ if (edge.includes("e")) w = clamp(start.w + dx, minW, stage.width - EDGE - start.x);+ if (edge.includes("w")) {+ const right = start.x + start.w;+ w = clamp(start.w - dx, minW, right - EDGE);+ x = right - w;+ }+ if (edge.includes("s")) h = clamp(start.h + dy, minH, stage.height - EDGE - start.y);+ if (edge.includes("n")) {+ const bottom = start.y + start.h;+ h = clamp(start.h - dy, minH, bottom - EDGE);+ y = bottom - h;+ }+ return fitRect({ x, y, w, h }, stage);+}++/** The remembered window placed on a stage of this size. */+export function placeStored(stored: StoredWindow, stage: StageSize): WindowRect {+ return fitRect({ x: stage.width - stored.r - stored.w, y: stage.height - stored.b - stored.h, w: stored.w, h: stored.h }, stage);+}++/** What to remember of a window on a stage of this size. */+export function toStored(rect: WindowRect, stage: StageSize): StoredWindow {+ return { r: stage.width - rect.x - rect.w, b: stage.height - rect.y - rect.h, w: rect.w, h: rect.h };+}++/** One place per stage kind: the IDE's side panel and the full office page differ a lot in size. */+const storageKey = (compact: boolean) => `jarvis.office.paneWindow.${compact ? "compact" : "full"}`;++/** The window the reader last left, or null (never moved, storage blocked, or garbage). */+export function loadStoredWindow(compact: boolean): StoredWindow | null {+ try {+ const raw = window.localStorage.getItem(storageKey(compact));+ if (!raw) return null;+ const value = JSON.parse(raw) as Partial<StoredWindow>;+ const numbers = [value.r, value.b, value.w, value.h];+ if (!numbers.every((n) => typeof n === "number" && Number.isFinite(n))) return null;+ return value as StoredWindow;+ } catch {+ // Storage can be blocked outright (private windows, site data off): the+ // window simply opens in its default place.+ return null;+ }+}++/** Remember the window, or forget it (null) so it opens in its default place again. */+export function saveStoredWindow(compact: boolean, stored: StoredWindow | null): void {+ try {+ if (stored) window.localStorage.setItem(storageKey(compact), JSON.stringify(stored));+ else window.localStorage.removeItem(storageKey(compact));+ } catch {+ // Blocked storage only costs the remembered place; the window still works.+ }+}diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/de.json b/jarvis/ui/web/frontend/src/i18n/locales/society/de.jsonindex 61a5df6fa5..bce3e1d64a 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/society/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/de.json@@ -893,6 +893,7 @@"pane_prompt": "Letzter Prompt","pane_unasked": "Noch nichts gefragt.","pane_open": "Session öffnen",+ "pane_window_hint": "Ziehen zum Verschieben · Doppelklick setzt es zurück","cp_mission": "Mission Control","cp_mission_hint": "Neue Coding-Agents starten oder mehreren gleichzeitig schreiben","tool_open": "Öffnen",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/en.json b/jarvis/ui/web/frontend/src/i18n/locales/society/en.jsonindex 858adbe218..503f7ce4d7 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/society/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/en.json@@ -893,6 +893,7 @@"pane_prompt": "Last prompt","pane_unasked": "Nothing asked yet.","pane_open": "Open session",+ "pane_window_hint": "Drag to move · double-click to put it back","cp_mission": "Mission Control","cp_mission_hint": "Start new coding agents or message several at once","tool_open": "Open",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/es.json b/jarvis/ui/web/frontend/src/i18n/locales/society/es.jsonindex a9f5be86d1..010cd377a4 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/society/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/es.json@@ -893,6 +893,7 @@"pane_prompt": "Último prompt","pane_unasked": "Todavía no se le ha pedido nada.","pane_open": "Abrir sesión",+ "pane_window_hint": "Arrastra para moverla · doble clic para devolverla a su sitio","cp_mission": "Mission Control","cp_mission_hint": "Inicia nuevos agentes de código o escribe a varios a la vez","tool_open": "Abrir",