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.

feat(office): a movable, resizable coding-session window that shares the pane's size

rubenluetke10-beep964017a42d98
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 d84ad6854e..b229b30ec4 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
@@ -16,6 +16,12 @@ const terminalHarness = vi.hoisted(() => ({
handlers: { current: null as Record<string, (...args: never[]) => void> | null },
/** What the pane opened its socket WITH — the handshake size among it. */
opened: { current: null as Record<string, unknown> | null },
+ /** Every socket opened, oldest first, with the frames sent on it — for two viewers of one pane. */
+ sockets: [] as {
+ options: Record<string, unknown>;
+ handlers: Record<string, (...args: never[]) => void>;
+ sent: unknown[];
+ }[],
/** Everything the pane types into the terminal on the user's behalf. */
input: vi.fn<(data: string) => void>(),
/** xterm's single custom key handler, so a test can press a key. */
@@ -172,8 +178,13 @@ vi.mock("./paneSocket", () => ({
) => {
terminalHarness.opened.current = options as Record<string, unknown>;
terminalHarness.handlers.current = handlers;
+ const record = { options: options as Record<string, unknown>, handlers, sent: [] as unknown[] };
+ terminalHarness.sockets.push(record);
return {
- send: (payload: unknown) => terminalHarness.send(payload),
+ send: (payload: unknown) => {
+ record.sent.push(payload);
+ return terminalHarness.send(payload);
+ },
close() {},
};
},
@@ -1976,6 +1987,101 @@ describe("pane refit", () => {
rows: 24,
});
});
+
+ /*
+ * One pane, two viewers in ONE window: the office's pane window over the
+ * same pane in the IDE grid. The cross-window rule (a gesture anywhere takes
+ * a displaced pane back) had both of them take the size from each other on
+ * every mouse move, two seconds apart — the agent redrawing for a wide and a
+ * narrow screen in turn, the office window flickering with its text squeezed
+ * into the left third (2026-09-29). The viewer opened as the pane's lead
+ * keeps the size; the other follows it, and takes the size back only when
+ * the lead is gone.
+ */
+ describe("two viewers of one pane in one window", () => {
+ const claimsOn = (index: number) =>
+ terminalHarness.sockets[index].sent.filter(
+ (frame) => (frame as { t: string }).t === "claim",
+ );
+ const open = (index: number) =>
+ act(() => {
+ terminalHarness.sockets[index].handlers.onOpen?.();
+ });
+ const displace = (index: number) =>
+ act(() => {
+ terminalHarness.sockets[index].handlers.onGeometry?.({ cols: 30, rows: 10 } as never);
+ });
+ const clearSent = () => {
+ for (const socket of terminalHarness.sockets) socket.sent.length = 0;
+ };
+ const grid = <AgenticTerminal key="grid" name="Dana" displayName="Claude Code" appearance="dark" fontSize={13} />;
+ const office = <AgenticTerminal key="office" name="Dana" displayName="Claude Code" appearance="dark" fontSize={13} sizeLead headerMode="none" />;
+
+ beforeEach(() => {
+ terminalHarness.sockets = [];
+ });
+
+ it("leaves the size with the lead instead of taking it back on a gesture", () => {
+ render(<>{grid}{office}</>);
+ open(0);
+ open(1);
+ settle();
+ // The office window claimed the pane; the grid behind it now shows its geometry.
+ displace(0);
+ clearSent();
+
+ fireEvent.pointerMove(document.body);
+ settle();
+ fireEvent.keyDown(document.body, { key: "a" });
+ settle();
+
+ expect(claimsOn(0)).toEqual([]);
+ });
+
+ it("hands the size back to the grid when the lead closes", async () => {
+ const view = render(<>{grid}{office}</>);
+ open(0);
+ open(1);
+ settle();
+ displace(0);
+ clearSent();
+
+ view.rerender(<>{grid}</>);
+ // The hand-over waits a microtask, so a lead that merely rebuilds keeps the size.
+ await act(async () => {
+ await Promise.resolve();
+ });
+ settle();
+
+ expect(claimsOn(0)).toEqual([{ t: "claim", cols: 80, rows: 24 }]);
+ });
+
+ it("gives the lead to the viewer the user presses", () => {
+ const view = render(<>{grid}{office}</>);
+ open(0);
+ open(1);
+ settle();
+ displace(0);
+ clearSent();
+
+ // A press on the grid's pane is an explicit choice: it takes the size…
+ const hosts = view.getAllByTestId("agentic-terminal-host-Dana");
+ fireEvent.mouseDown(hosts[0]);
+ settle();
+ expect(claimsOn(0)).toEqual([{ t: "claim", cols: 80, rows: 24 }]);
+
+ // …and the office window, now the one displaced, no longer takes it back
+ // on the next mouse move.
+ displace(1);
+ clearSent();
+ act(() => {
+ vi.advanceTimersByTime(2_500);
+ });
+ fireEvent.pointerMove(document.body);
+ settle();
+ expect(claimsOn(1)).toEqual([]);
+ });
+ });
});
/*
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
index 065304937e..025ad61d07 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
@@ -69,6 +69,13 @@ import {
X,
} from "lucide-react";
import { SplitBelowIcon, SplitRightIcon } from "./splitIcons";
+import {
+ mayLeadSize,
+ onSizeLeadReleased,
+ releaseSizeLead,
+ sizeLeadKey,
+ takeSizeLead,
+} from "./paneSizeLead";
// A leaf module with no DOM and no terminal in it, which is the point: the
// wizard quotes this same number before any pane exists — see ./layout.
import { cn } from "@/lib/utils";
@@ -628,6 +635,13 @@ interface AgenticTerminalProps {
* one, and the backend spawns a new agent for it.
*/
restartToken?: number;
+ /**
+ * Open as THE view of this pane in this window: while mounted it sizes the
+ * pane, and the same pane's other viewers here (the IDE grid behind the
+ * office's pane window) follow it instead of taking the size back on every
+ * gesture. Read at mount. See ./paneSizeLead.
+ */
+ sizeLead?: boolean;
}
export function AgenticTerminal({
@@ -670,6 +684,7 @@ export function AgenticTerminal({
showArrangeHandle = false,
arranging = false,
layoutBusy = false,
+ sizeLead = false,
}: AgenticTerminalProps) {
const containerRef = useRef<HTMLDivElement | null>(null);
const terminalRegionRef = useRef<HTMLDivElement | null>(null);
@@ -1570,6 +1585,17 @@ export function AgenticTerminal({
let owned = false;
/** Is this pane showing a geometry another viewer chose? See reclaimOnGesture. */
let displaced = false;
+ /*
+ * This viewer's place among the pane's viewers in THIS window. The server
+ * settles who sizes the pane between windows; inside one, a second viewer
+ * of the same pane (the office's pane window over the IDE grid) would
+ * otherwise take the size back on every gesture and the two would trade it
+ * every GESTURE_RECLAIM_MS. See ./paneSizeLead.
+ */
+ const leadKey = sizeLeadKey(workspaceId, name);
+ const leadToken = {};
+ if (sizeLead) takeSizeLead(leadKey, leadToken);
+ const mayLead = () => mayLeadSize(leadKey, leadToken);
/*
* May this pane take the shared size without being asked to?
@@ -1589,6 +1615,7 @@ export function AgenticTerminal({
* that had just been made to fill the window (2026-08-25).
*/
const viewerMayOwn = () =>
+ mayLead() &&
activeRef.current &&
(typeof document === "undefined" ||
typeof document.hasFocus !== "function" ||
@@ -1806,9 +1833,15 @@ export function AgenticTerminal({
* desktop shell's answer to that question can lag the truth, and a click
* that is not allowed to take the pane back leaves the user with no way
* to do so at all.
+ *
+ * It also makes this viewer the pane's lead in this window, so the view
+ * the user just pressed keeps the size instead of another viewer of the
+ * same pane here taking it straight back on the next mouse move.
*/
const takeOwnership = () => {
- if (activeRef.current) sendResize(true);
+ if (!activeRef.current) return;
+ takeSizeLead(leadKey, leadToken);
+ sendResize(true);
};
takeOwnershipRef.current = takeOwnership;
/**
@@ -1828,7 +1861,10 @@ export function AgenticTerminal({
*/
let lastGestureReclaimAt = 0;
const reclaimOnGesture = () => {
- if (!displaced || !activeRef.current) return;
+ // Another viewer of this pane in this very window holds it: the gesture
+ // is as much that viewer's as this one's, and taking the size back here
+ // is what made the two trade it forever.
+ if (!displaced || !activeRef.current || !mayLead()) return;
const now = Date.now();
if (now - lastGestureReclaimAt < GESTURE_RECLAIM_MS) return;
lastGestureReclaimAt = now;
@@ -1837,6 +1873,16 @@ export function AgenticTerminal({
window.addEventListener("pointermove", reclaimOnGesture, { passive: true });
window.addEventListener("pointerdown", reclaimOnGesture, true);
window.addEventListener("keydown", reclaimOnGesture, true);
+ /*
+ * The lead viewer went away (the office's pane window closed): the size is
+ * this window's to set again, and this pane's tile is what it shows. Its
+ * own refits stayed quiet while it only watched, so nothing else would
+ * hand the agent this tile's size back.
+ */
+ const stopLeadWatch = onSizeLeadReleased(leadKey, () => {
+ if (disposed) return;
+ claimResize();
+ });
/*
* The size this socket connects with. The tile's own measurement when there
@@ -2215,6 +2261,10 @@ export function AgenticTerminal({
} catch {
/* ignore */
}
+ // After the socket, so this viewer is gone before another one of the
+ // pane here takes the size back.
+ stopLeadWatch();
+ releaseSizeLead(leadKey, leadToken);
// Before the terminal: frees this pane's WebGL context slot.
renderer.dispose();
term.dispose();
diff --git a/jarvis/ui/web/frontend/src/components/agentic/paneSizeLead.test.ts b/jarvis/ui/web/frontend/src/components/agentic/paneSizeLead.test.ts
new file mode 100644
index 0000000000..3db5b1f4ee
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/paneSizeLead.test.ts
@@ -0,0 +1,86 @@
+import { describe, expect, it, vi } from "vitest";
+import { mayLeadSize, onSizeLeadReleased, releaseSizeLead, sizeLeadKey, takeSizeLead } from "./paneSizeLead";
+
+const flush = () => Promise.resolve();
+
+describe("pane size lead", () => {
+ it("lets every viewer size a pane nobody leads", () => {
+ const key = sizeLeadKey("ws-free", "Dana");
+ expect(mayLeadSize(key, {})).toBe(true);
+ expect(mayLeadSize(key, {})).toBe(true);
+ });
+
+ it("keeps the size with the lead and away from the pane's other viewers", () => {
+ const key = sizeLeadKey("ws-led", "Dana");
+ const office = {}, grid = {};
+ takeSizeLead(key, office);
+ expect(mayLeadSize(key, office)).toBe(true);
+ expect(mayLeadSize(key, grid)).toBe(false);
+ // Another pane, or the same name in another workspace, is not affected.
+ expect(mayLeadSize(sizeLeadKey("ws-led", "Eli"), grid)).toBe(true);
+ expect(mayLeadSize(sizeLeadKey("ws-other", "Dana"), grid)).toBe(true);
+ releaseSizeLead(key, office);
+ });
+
+ it("tells the other viewers once the lead is released", async () => {
+ const key = sizeLeadKey("ws-release", "Dana");
+ const office = {}, grid = {};
+ const heard = vi.fn(() => mayLeadSize(key, grid));
+ const stop = onSizeLeadReleased(key, heard);
+ takeSizeLead(key, office);
+
+ releaseSizeLead(key, office);
+ expect(heard).not.toHaveBeenCalled();
+ await flush();
+
+ expect(heard).toHaveBeenCalledOnce();
+ expect(heard).toHaveReturnedWith(true);
+ stop();
+ });
+
+ it("says nothing when the lead is taken again before anyone heard (a rebuild)", async () => {
+ const key = sizeLeadKey("ws-rebuild", "Dana");
+ const heard = vi.fn();
+ const stop = onSizeLeadReleased(key, heard);
+ const before = {}, after = {};
+ takeSizeLead(key, before);
+
+ releaseSizeLead(key, before);
+ takeSizeLead(key, after);
+ await flush();
+
+ expect(heard).not.toHaveBeenCalled();
+ stop();
+ releaseSizeLead(key, after);
+ });
+
+ it("releases nothing for a viewer that already lost the lead", async () => {
+ const key = sizeLeadKey("ws-lost", "Dana");
+ const heard = vi.fn();
+ const stop = onSizeLeadReleased(key, heard);
+ const office = {}, grid = {};
+ takeSizeLead(key, office);
+ takeSizeLead(key, grid);
+
+ releaseSizeLead(key, office);
+ await flush();
+
+ expect(heard).not.toHaveBeenCalled();
+ expect(mayLeadSize(key, office)).toBe(false);
+ stop();
+ releaseSizeLead(key, grid);
+ });
+
+ it("stops telling a viewer that unsubscribed", async () => {
+ const key = sizeLeadKey("ws-stop", "Dana");
+ const heard = vi.fn();
+ const office = {};
+ onSizeLeadReleased(key, heard)();
+ takeSizeLead(key, office);
+
+ releaseSizeLead(key, office);
+ await flush();
+
+ expect(heard).not.toHaveBeenCalled();
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/paneSizeLead.ts b/jarvis/ui/web/frontend/src/components/agentic/paneSizeLead.ts
new file mode 100644
index 0000000000..8676fdf332
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/paneSizeLead.ts
@@ -0,0 +1,80 @@
+/**
+ * Which of THIS window's viewers of a pane decides the pane's size.
+ *
+ * A pseudo-terminal has one size, and the server hands it to one viewer at a
+ * time (see `claim` in ./paneSocket). Across windows, the window the user is
+ * in wins, and a gesture anywhere in a window takes back every pane another
+ * window sized (`reclaimOnGesture` in ./AgenticTerminal). Inside ONE window
+ * that rule has no answer: two viewers of the same pane — the office's pane
+ * window and the same pane in the IDE grid behind it — both see the gesture,
+ * both are "in front", and each took the size back from the other every two
+ * seconds. The agent redrew its whole screen for each hand-over, alternating
+ * between a wide and a narrow layout: the office window flickered and showed
+ * its text squeezed into the left third (2026-09-29).
+ *
+ * So within a window a pane has at most one LEAD viewer: the one opened as the
+ * pane's focus (the office's window, while it is open) or the one the user
+ * last pressed. Every other viewer of that pane follows the lead's geometry
+ * and never claims on its own. When the lead goes away, the rest are told so
+ * they can take the size back for the tile they show.
+ *
+ * Module state on purpose: it is per window by construction, which is exactly
+ * the scope of the problem — separate windows keep the server's rule.
+ */
+
+/** A viewer's identity in the registry; any unique object will do. */
+export type SizeLeadToken = object;
+
+const leads = new Map<string, SizeLeadToken>();
+const released = new Map<string, Set<() => void>>();
+
+/** The registry key for one pane: the same name can live in two workspaces. */
+export function sizeLeadKey(workspaceId: string | undefined, name: string): string {
+ return `${workspaceId ?? ""}\u0000${name}`;
+}
+
+/** Make `token` the viewer that sizes the pane in this window. */
+export function takeSizeLead(key: string, token: SizeLeadToken): void {
+ leads.set(key, token);
+}
+
+/**
+ * Give the lead up, if `token` still holds it, and tell the pane's other
+ * viewers so one of them can size the pane again. A viewer that already lost
+ * the lead to a later press releases nothing.
+ *
+ * The others hear it a microtask later, and only if nobody took the lead in
+ * between: a lead viewer that merely rebuilds its terminal (its connect effect
+ * re-running in the same commit) must not hand the size to the grid and take
+ * it straight back — two full repaints of the agent for nothing.
+ */
+export function releaseSizeLead(key: string, token: SizeLeadToken): void {
+ if (leads.get(key) !== token) return;
+ leads.delete(key);
+ queueMicrotask(() => {
+ if (leads.has(key)) return;
+ for (const listener of [...(released.get(key) ?? [])]) listener();
+ });
+}
+
+/** May `token` size the pane: it leads, or nobody in this window does. */
+export function mayLeadSize(key: string, token: SizeLeadToken): boolean {
+ const lead = leads.get(key);
+ return lead === undefined || lead === token;
+}
+
+/** Call `listener` whenever the pane's lead is released. Returns the unsubscribe. */
+export function onSizeLeadReleased(key: string, listener: () => void): () => void {
+ let set = released.get(key);
+ if (!set) {
+ set = new Set();
+ released.set(key, set);
+ }
+ set.add(listener);
+ return () => {
+ const current = released.get(key);
+ if (!current) return;
+ current.delete(listener);
+ if (current.size === 0) released.delete(key);
+ };
+}
diff --git a/jarvis/ui/web/frontend/src/components/society/office/OfficeStage.tsx b/jarvis/ui/web/frontend/src/components/society/office/OfficeStage.tsx
index 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.tsx
index 320ad9fa3b..9566a8209d 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: Pane
const 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,77 @@ 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);
+ };
+
+ const gestureHandlers = (kind: Gesture["kind"], edge?: ResizeEdge) => ({
+ onPointerDown: (event: ReactPointerEvent<HTMLElement>) => begin(event, kind, edge),
+ onPointerMove: follow,
+ onPointerUp: finish,
+ onPointerCancel: finish,
+ });
+
+ /** 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 is measured: the first size the agent hears is the window's.
+ const ready = stage !== null;
+ 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 +253,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 +282,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 +309,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.css
index 70bf946dae..477bd83fa4 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,37 @@
.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: thin strips along each edge and squares on the corners, inside
+ the window's rounded clip. 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:5px; cursor:ns-resize; }
+.office-pane-grip[data-edge="s"] { bottom:0; left:12px; right:12px; height:6px; cursor:ns-resize; }
+.office-pane-grip[data-edge="e"] { right:0; top:12px; bottom:12px; width:6px; cursor:ew-resize; }
+.office-pane-grip[data-edge="w"] { left:0; top:12px; bottom:12px; width:6px; 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.ts
new file mode 100644
index 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.ts
new file mode 100644
index 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.json
index 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.json
index 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.json
index 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",