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(agents): replace the Mars map with a cosy agent office

rubenluetke10-beepb7888313eb36
diff --git a/docs/agent-society/mars-runtime.md b/docs/agent-society/mars-runtime.md
index 7c0c2a4be8..bb8da06614 100644
--- a/docs/agent-society/mars-runtime.md
+++ b/docs/agent-society/mars-runtime.md
@@ -1,8 +1,9 @@
# Mars runtime reference
-Status: development reference, not the completed colony. **Agents > Map** opens
-Mars directly in both normal and Dev instances and offers no previous-world
-selector, including when an older URL requests another world. The Agents workspace and communications-station
+Status: development reference, not the completed colony. Since 2026-09-28
+**Agents > Map** opens the agent office ([office-map.md](office-map.md)) instead
+of Mars; this page documents the Mars code and backend contracts, which remain
+in the tree. No older URL restores a previous world. The Agents workspace and communications-station
controls remain separate from rendering. Final character/rover art, player
boarding and remaining districts are unfinished.
The art study has no user visual approval and must not be rolled out by family.
diff --git a/docs/agent-society/office-map.md b/docs/agent-society/office-map.md
new file mode 100644
index 0000000000..fba0d88d5e
--- /dev/null
+++ b/docs/agent-society/office-map.md
@@ -0,0 +1,84 @@
+# Agent office map
+
+Status: **first map built 2026-09-28, awaiting the maintainer's visual review.**
+It replaces the Mars colony as the renderer behind **Agents > Map**. The Mars
+code, its backend contracts and the communications station remain in the tree
+and reachable from the Agents workspace; only the map surface changed.
+
+Per [game-art-pipeline.md](game-art-pipeline.md) §3 this runtime scene is the
+reference for the office direction. Do not roll its style out to other asset
+families or replace figures before the maintainer approves it.
+
+Code: `jarvis/ui/web/frontend/src/components/society/office/`.
+
+## 1. Why an office
+
+The previous worlds (pixel island, Mars colony) were large, navigable places
+that cost a lot of authored art and backend navigation to show one thing: what
+the agents are doing. The office answers that question in one screen. Every
+agent has a desk, departments group them, and a status ring, a monitor face and
+a name pill show the run state. It is a projection of the roster only: the map
+never moves an agent, starts work or invents activity (world-behaviour-manual
+§1 still holds).
+
+## 2. Style guide (derived from the maintainer's reference screenshots)
+
+| Aspect | Rule |
+|---|---|
+| Genre | Stylised "toy office" diorama: chunky low-poly 3D, not anime, not pixel art, not realistic. Close to casual social-game and avatar-app styling. |
+| Characters | Chibi proportions (big head, short body), dot eyes, flat matte colours, no textures. Seated at desks; the stored figure recipe is kept, agents without one get a stable chibi look. |
+| Furniture | Simple primitives with small rounded edges: light-wood desk tops on white pedestals, black monitors, dark swivel chairs, dark-wood name boards with light slats, potted low-poly plants, bookshelves with coloured books, dark couches in a lounge. |
+| Materials | Matte (roughness ~0.85), no metalness except the railings; colour does the work. Wood-plank floor, desaturated carpet per department. |
+| Light | Cool sky / warm ground hemisphere light plus one soft directional sun with PCF shadows. Always bright enough to read, never moody. |
+| Setting | The floor floats in a starry night sky behind glass railings. |
+| Camera | Perspective, 35° FOV, three-quarter view from the south-east about 40° below the horizon. Orbit, pan and zoom within limits (20°–72° polar, 4–140 m). Home view frames the occupied desks. |
+| Labels | Dark translucent pill above each agent: hexagon badge (initial, star for the lead), name, state dot; the state word only when it is not idle. Scale is clamped by distance. |
+| State language | Green = working (pulsing floor ring, code on the monitor), amber = waiting for the person, grey = idle (smiley monitor) or paused (dark monitor). |
+| HUD | Theme-token cards over the canvas (title, working/waiting/idle counts, Overview and Agents list buttons), so light and dark mode both work. The diorama itself keeps one palette in both modes. |
+
+## 3. Technology decision
+
+**Three.js through React Three Fiber, in the existing frontend.** This beat the
+runner-up (a Blender-authored scene exported as GLB) because the office look is
+built from boxes, cylinders and rounded boxes: code builds it in milliseconds,
+it adapts to any roster size, and it needs no asset pipeline. Blender stays the
+tool for anything organic later (new character bases, special props), following
+the game-art pipeline. No engine change (Unity, Godot, Babylon) is warranted:
+the renderer is already Three.js inside the WebView, the figures and their
+animation clips (`sit`, `work`, `idle`, `walk`, …) already exist, and every OS
+target runs WebGL.
+
+## 4. Layout model
+
+`officeLayout.ts` is pure and tested:
+
+- Departments = provider families (`providerLabel`; empty means Jarvis' own
+ brain). At most six; the rest fold into "Other". The floor always shows at
+ least four; spare ones are "Open space" with free desks.
+- Each department is benches of back-to-back desks, four per row, eight per
+ bench, one to four benches.
+- The lead tier sits in a glass office at the back; a lounge fills the front.
+- Seating is by arrival (`createdMs`, then id), so a refetch never re-seats
+ anyone; run state changes only repaint monitors and rings.
+
+## 5. Plan
+
+1. **First map (done):** floor, departments, lead office, lounge, seated
+ figures, state rings/monitors/pills, HUD counts, camera, click-to-open.
+2. **Review:** the maintainer looks at the map in the app. Capture feedback on
+ look, camera and department grouping before any further art.
+3. **Life:** optional short walks (desk ↔ lounge when idle for long), typing
+ animation while working, a "waiting for you" bubble. Driven only by real
+ state changes, never by LLM calls.
+4. **Detail pass:** a coffee corner, meeting room for group chats, per-department
+ decor, name boards with provider logos.
+5. **Scale and performance:** instanced desks for large rosters, measured frame
+ times on a laptop GPU and a low-end integrated GPU.
+
+## 6. Verification so far
+
+- Unit tests: `officeLayout.test.ts` (grouping, stable seating, no overlap,
+ empty roster, camera framing), `JarvisAgentsView.test.tsx`.
+- Runtime: checked in Chrome against the live roster (ten agents, one lead)
+ through a temporary dev preview: rendering, click on figure and on pill.
+- Not yet measured: frame time and device coverage; macOS/Linux WebViews.
diff --git a/jarvis/ui/web/frontend/src/components/society/office/OfficeAgents.tsx b/jarvis/ui/web/frontend/src/components/society/office/OfficeAgents.tsx
new file mode 100644
index 0000000000..a7f1bbd13c
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/society/office/OfficeAgents.tsx
@@ -0,0 +1,125 @@
+/**
+ * Agents at their desks: the stored character, seated, with a floating name
+ * pill and a floor ring in the colour of its run state. The office is a
+ * projection of the roster — nothing here moves an agent or starts work.
+ */
+import { useMemo, useRef } from "react";
+import { Html } from "@react-three/drei";
+import { useFrame } from "@react-three/fiber";
+import { DoubleSide, Vector3, type Group, type Mesh, type MeshBasicMaterial } from "three";
+import { useT } from "@/i18n";
+import type { SocietyAgent } from "../data";
+import { FigureRig, type FigureDrive } from "../figures/FigureRig";
+import { shufflePalette, type FigureRecipe } from "../figures/figureRecipe";
+import { OFFICE } from "./officePalette";
+import type { DeskSlot } from "./officeLayout";
+
+/** Seated figures share one toy scale, so the desks read the same everywhere. */
+export const OFFICE_FIGURE_HEIGHT_M = 1.3;
+
+/** Agents without a stored character get a stable chibi look from their id. */
+export function fallbackRecipe(agentId: string): FigureRecipe {
+ let hash = 0;
+ for (const ch of agentId) hash = (hash * 31 + ch.charCodeAt(0)) >>> 0;
+ return { contract: 1, archetype: "biped", base: "chibi", parts: {}, palette: shufflePalette((hash % 10_000) / 10_000) };
+}
+
+const RING_COLOUR = {
+ working: OFFICE.ringWorking,
+ idle: OFFICE.ringIdle,
+ waiting: OFFICE.ringWaiting,
+ paused: OFFICE.ringPaused,
+} as const;
+
+function StatusRing({ state, animate }: { state: SocietyAgent["state"]; animate: boolean }) {
+ const ref = useRef<Mesh>(null);
+ useFrame(({ clock }) => {
+ if (!ref.current || !animate || state !== "working") return;
+ (ref.current.material as MeshBasicMaterial).opacity = 0.55 + Math.sin(clock.elapsedTime * 3) * 0.3;
+ });
+ return (
+ <mesh ref={ref} rotation={[-Math.PI / 2, 0, 0]} position={[0, 0.015, 0]}>
+ <ringGeometry args={[0.46, 0.54, 40]} />
+ <meshBasicMaterial color={RING_COLOUR[state]} transparent opacity={0.8} side={DoubleSide} depthWrite={false} />
+ </mesh>
+ );
+}
+
+/** Nameplate scale by camera distance: readable up close, compact in the overview, never huge. */
+export function plateScale(distance: number): number {
+ return Math.min(1.05, Math.max(0.8, 24 / Math.max(1, distance)));
+}
+
+function Nameplate({ agent, onSelect }: { agent: SocietyAgent; onSelect: (id: string) => void }) {
+ const t = useT();
+ const lead = agent.tier === "lead";
+ const anchor = useRef<Group>(null);
+ const plate = useRef<HTMLButtonElement>(null);
+ const last = useRef(0);
+ const world = useMemo(() => new Vector3(), []);
+ useFrame(({ camera }) => {
+ if (!anchor.current || !plate.current) return;
+ const scale = plateScale(camera.position.distanceTo(anchor.current.getWorldPosition(world)));
+ if (Math.abs(scale - last.current) < 0.02) return;
+ last.current = scale;
+ plate.current.style.transform = `scale(${scale.toFixed(2)})`;
+ });
+ return (
+ <group ref={anchor} position={[0, OFFICE_FIGURE_HEIGHT_M + 0.35, 0]}>
+ <Html center zIndexRange={[20, 0]}>
+ <button ref={plate} type="button" data-office-ui className="office-plate" data-state={agent.state}
+ onClick={(event) => { event.stopPropagation(); onSelect(agent.agentId); }}
+ aria-label={t("society.office.open_agent").replace("{0}", agent.name)}>
+ <span className="office-plate-badge" style={{ background: agent.palette.primary }} aria-hidden>
+ {lead ? "★" : agent.name.slice(0, 1).toUpperCase()}
+ </span>
+ <span className="office-plate-name">{agent.name}</span>
+ <span className="office-plate-state" title={t(`society.office.state_${agent.state}`)}>
+ <i aria-hidden />
+ {agent.state === "idle" ? null : <em>{t(`society.office.state_${agent.state}`)}</em>}
+ </span>
+ </button>
+ </Html>
+ </group>
+ );
+}
+
+function SeatedAgent({ agent, desk, awake, reduced, onSelect }: {
+ agent: SocietyAgent; desk: DeskSlot; awake: boolean; reduced: boolean; onSelect: (id: string) => void;
+}) {
+ const recipe = useMemo(() => agent.figure ?? fallbackRecipe(agent.agentId), [agent.figure, agent.agentId]);
+ // Seated at every state; the monitor and the ring carry the difference.
+ const drive = useRef<FigureDrive>({ mode: "sit", speed: 0 });
+ return (
+ <group position={[desk.x, 0, desk.z]} rotation={[0, desk.facing === "north" ? 0 : Math.PI, 0]}>
+ <group position={[0, 0, 0.72]}>
+ <StatusRing state={agent.state} animate={awake && !reduced} />
+ {/* Figures face +z; the agent looks at its monitor on the local -z side. */}
+ <group rotation={[0, Math.PI, 0]} position={[0, SEAT_LIFT_M, SEAT_BACK_M]}
+ onClick={(event) => { event.stopPropagation(); onSelect(agent.agentId); }}
+ onPointerOver={() => { document.body.style.cursor = "pointer"; }}
+ onPointerOut={() => { document.body.style.cursor = ""; }}>
+ <FigureRig recipe={recipe} drive={drive} paused={!awake || reduced} heightM={OFFICE_FIGURE_HEIGHT_M} />
+ </group>
+ <Nameplate agent={agent} onSelect={onSelect} />
+ </group>
+ </group>
+ );
+}
+
+/** Seat offsets for the shared "sit" clip, measured in the runtime against the chair. */
+export const SEAT_LIFT_M = 0.12;
+export const SEAT_BACK_M = 0.04;
+
+export function OfficeAgents({ desks, agents, awake, reduced, onSelect }: {
+ desks: DeskSlot[]; agents: ReadonlyMap<string, SocietyAgent>; awake: boolean; reduced: boolean; onSelect: (id: string) => void;
+}) {
+ return (
+ <group>
+ {desks.map((desk) => {
+ const agent = desk.agentId ? agents.get(desk.agentId) : undefined;
+ return agent ? <SeatedAgent key={agent.agentId} agent={agent} desk={desk} awake={awake} reduced={reduced} onSelect={onSelect} /> : null;
+ })}
+ </group>
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/components/society/office/OfficeFurniture.tsx b/jarvis/ui/web/frontend/src/components/society/office/OfficeFurniture.tsx
new file mode 100644
index 0000000000..88f125b06e
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/society/office/OfficeFurniture.tsx
@@ -0,0 +1,235 @@
+/**
+ * The office kit: every piece is a few rounded primitives with flat, matte
+ * colours — the "toy office" look needs no authored meshes or textures.
+ * Geometries and materials are module-level singletons shared by every copy.
+ */
+import { useMemo } from "react";
+import {
+ BoxGeometry, CanvasTexture, CylinderGeometry, DoubleSide, IcosahedronGeometry,
+ MeshStandardMaterial, SRGBColorSpace, type Texture,
+} from "three";
+import { RoundedBoxGeometry } from "three-stdlib";
+import { OFFICE } from "./officePalette";
+import { screenTexture, type ScreenFace } from "./screenTextures";
+
+const matte = (color: string, extra: Partial<ConstructorParameters<typeof MeshStandardMaterial>[0]> = {}) =>
+ new MeshStandardMaterial({ color, roughness: 0.85, metalness: 0, ...extra });
+
+export const MAT = {
+ deskTop: matte(OFFICE.deskTop),
+ deskBody: matte(OFFICE.deskBody),
+ deskLeg: matte(OFFICE.deskLeg),
+ chair: matte(OFFICE.chair),
+ chairSeat: matte(OFFICE.chairSeat),
+ monitor: matte(OFFICE.monitor, { roughness: 0.5 }),
+ keyboard: matte(OFFICE.keyboard),
+ railing: matte(OFFICE.railing, { roughness: 0.4, metalness: 0.3 }),
+ glass: new MeshStandardMaterial({ color: OFFICE.glass, transparent: true, opacity: 0.18, roughness: 0.1, side: DoubleSide, depthWrite: false }),
+ wall: matte(OFFICE.wallWhite),
+ sign: matte(OFFICE.signBoard),
+ wood: matte(OFFICE.wood),
+ woodDark: matte(OFFICE.woodDark),
+ couch: matte(OFFICE.couch),
+ cushion: matte(OFFICE.couchCushion),
+ pot: matte(OFFICE.plantPot),
+ leaf: matte(OFFICE.leaf, { flatShading: true }),
+ leafDark: matte(OFFICE.leafDark, { flatShading: true }),
+ trunk: matte(OFFICE.trunk),
+ rug: matte(OFFICE.rug),
+ books: OFFICE.book.map((c) => matte(c)),
+};
+
+const GEO = {
+ box: new BoxGeometry(1, 1, 1),
+ cyl: new CylinderGeometry(1, 1, 1, 16),
+ potCyl: new CylinderGeometry(1, 0.8, 1, 16),
+ blob: new IcosahedronGeometry(1, 0),
+};
+
+function Box({ size, position, material, cast = true }: {
+ size: [number, number, number]; position: [number, number, number]; material: MeshStandardMaterial; cast?: boolean;
+}) {
+ return <mesh geometry={GEO.box} material={material} position={position} scale={size} castShadow={cast} receiveShadow />;
+}
+
+/** Rounded boxes are cached by size: every desk shares the same few geometries. */
+const roundedCache = new Map<string, RoundedBoxGeometry>();
+function Rounded({ size, radius, position, material, cast = true }: {
+ size: [number, number, number]; radius: number; position: [number, number, number]; material: MeshStandardMaterial; cast?: boolean;
+}) {
+ const key = `${size.join("x")}:${radius}`;
+ let geometry = roundedCache.get(key);
+ if (!geometry) {
+ geometry = new RoundedBoxGeometry(size[0], size[1], size[2], 2, radius);
+ roundedCache.set(key, geometry);
+ }
+ return <mesh geometry={geometry} material={material} position={position} castShadow={cast} receiveShadow />;
+}
+
+const screenMaterials = new Map<ScreenFace, MeshStandardMaterial>();
+function screenMaterial(face: ScreenFace): MeshStandardMaterial {
+ let material = screenMaterials.get(face);
+ if (!material) {
+ const map = screenTexture(face);
+ const lit = face !== "empty" && face !== "paused";
+ material = new MeshStandardMaterial({
+ color: "#ffffff", map, roughness: 0.4,
+ emissive: lit ? "#ffffff" : "#000000", emissiveMap: lit ? map : null, emissiveIntensity: lit ? 0.9 : 0,
+ });
+ screenMaterials.set(face, material);
+ }
+ return material;
+}
+
+/**
+ * One workstation in local space: the agent sits at +z and looks north (-z)
+ * at its monitor. The parent rotates the whole station for south-facing rows.
+ */
+export function Desk({ face }: { face: ScreenFace }) {
+ return (
+ <group>
+ {/* Top and the white pedestal/legs of a bench desk. */}
+ <Rounded size={[1.5, 0.06, 0.8]} radius={0.02} position={[0, 0.74, 0]} material={MAT.deskTop} />
+ <Box size={[0.36, 0.7, 0.72]} position={[0.53, 0.36, 0]} material={MAT.deskBody} />
+ <Box size={[0.05, 0.7, 0.7]} position={[-0.7, 0.36, 0]} material={MAT.deskLeg} />
+ {/* Privacy divider between the back-to-back pair. */}
+ <Box size={[1.5, 0.34, 0.03]} position={[0, 0.94, -0.41]} material={MAT.deskBody} />
+ {/* Monitor on its stand. */}
+ <Box size={[0.08, 0.2, 0.08]} position={[0, 0.87, -0.22]} material={MAT.monitor} />
+ <Box size={[0.24, 0.02, 0.16]} position={[0, 0.78, -0.22]} material={MAT.monitor} />
+ <Rounded size={[0.72, 0.44, 0.05]} radius={0.02} position={[0, 1.18, -0.24]} material={MAT.monitor} />
+ <mesh position={[0, 1.18, -0.212]} material={screenMaterial(face)}>
+ <planeGeometry args={[0.66, 0.38]} />
+ </mesh>
+ <Box size={[0.42, 0.02, 0.14]} position={[0, 0.78, 0.1]} material={MAT.keyboard} />
+ <Chair />
+ </group>
+ );
+}
+
+/** Office swivel chair behind the desk (local +z side). */
+export function Chair() {
+ return (
+ <group position={[0, 0, 0.72]}>
+ <mesh geometry={GEO.cyl} material={MAT.chair} position={[0, 0.03, 0]} scale={[0.3, 0.04, 0.3]} castShadow />
+ <mesh geometry={GEO.cyl} material={MAT.chair} position={[0, 0.25, 0]} scale={[0.03, 0.42, 0.03]} />
+ <Rounded size={[0.5, 0.08, 0.48]} radius={0.03} position={[0, 0.48, 0]} material={MAT.chairSeat} />
+ <Rounded size={[0.48, 0.5, 0.07]} radius={0.03} position={[0, 0.78, 0.24]} material={MAT.chairSeat} />
+ </group>
+ );
+}
+
+/** A potted plant; `size` scales the whole plant (1 ≈ 1.2 m tall). */
+export function Plant({ position, size = 1 }: { position: [number, number, number]; size?: number }) {
+ return (
+ <group position={position} scale={size}>
+ <mesh geometry={GEO.potCyl} material={MAT.pot} position={[0, 0.22, 0]} scale={[0.26, 0.44, 0.26]} castShadow receiveShadow />
+ <mesh geometry={GEO.cyl} material={MAT.trunk} position={[0, 0.6, 0]} scale={[0.04, 0.5, 0.04]} castShadow />
+ <mesh geometry={GEO.blob} material={MAT.leaf} position={[0, 1.0, 0]} scale={[0.42, 0.36, 0.42]} castShadow />
+ <mesh geometry={GEO.blob} material={MAT.leafDark} position={[0.18, 0.86, 0.1]} scale={0.24} castShadow />
+ <mesh geometry={GEO.blob} material={MAT.leaf} position={[-0.16, 0.9, -0.12]} scale={0.22} castShadow />
+ </group>
+ );
+}
+
+/** A low wooden bookshelf with a few coloured books. */
+export function Bookshelf({ position, rotationY = 0 }: { position: [number, number, number]; rotationY?: number }) {
+ const books = useMemo(() => Array.from({ length: 14 }, (_, i) => ({
+ x: -0.72 + (i % 7) * 0.22 + ((i * 13) % 5) * 0.01,
+ y: i < 7 ? 0.42 : 0.98,
+ h: 0.3 + ((i * 7) % 4) * 0.04,
+ m: MAT.books[i % MAT.books.length],
+ })), []);
+ return (
+ <group position={position} rotation={[0, rotationY, 0]}>
+ <Box size={[1.8, 1.4, 0.36]} position={[0, 0.7, 0]} material={MAT.woodDark} />
+ <Box size={[1.7, 0.03, 0.34]} position={[0, 0.72, 0.02]} material={MAT.wood} cast={false} />
+ {books.map((b, i) => <Box key={i} size={[0.14, b.h, 0.26]} position={[b.x, b.y + b.h / 2 - 0.12, 0.06]} material={b.m} />)}
+ </group>
+ );
+}
+
+/** A two-seat lounge couch facing +z. */
+export function Couch({ position, rotationY = 0 }: { position: [number, number, number]; rotationY?: number }) {
+ return (
+ <group position={position} rotation={[0, rotationY, 0]}>
+ <Rounded size={[2.2, 0.42, 0.9]} radius={0.08} position={[0, 0.25, 0]} material={MAT.couch} />
+ <Rounded size={[2.2, 0.55, 0.22]} radius={0.08} position={[0, 0.6, -0.36]} material={MAT.couch} />
+ <Rounded size={[0.2, 0.36, 0.9]} radius={0.06} position={[-1.08, 0.5, 0]} material={MAT.couch} />
+ <Rounded size={[0.2, 0.36, 0.9]} radius={0.06} position={[1.08, 0.5, 0]} material={MAT.couch} />
+ <Rounded size={[0.96, 0.12, 0.66]} radius={0.05} position={[-0.5, 0.5, 0.06]} material={MAT.cushion} />
+ <Rounded size={[0.96, 0.12, 0.66]} radius={0.05} position={[0.5, 0.5, 0.06]} material={MAT.cushion} />
+ </group>
+ );
+}
+
+/** A glass railing run from (x1,z1) to (x2,z2): posts, a top rail and a pane. */
+export function Railing({ from, to, height = 1.05 }: { from: [number, number]; to: [number, number]; height?: number }) {
+ const [x1, z1] = from;
+ const [x2, z2] = to;
+ const length = Math.hypot(x2 - x1, z2 - z1);
+ const angle = Math.atan2(z2 - z1, x2 - x1);
+ const posts = Math.max(2, Math.round(length / 2.4) + 1);
+ return (
+ <group position={[(x1 + x2) / 2, 0, (z1 + z2) / 2]} rotation={[0, -angle, 0]}>
+ <Box size={[length, 0.06, 0.08]} position={[0, height, 0]} material={MAT.railing} />
+ <Box size={[length, height - 0.1, 0.02]} position={[0, (height - 0.1) / 2 + 0.05, 0]} material={MAT.glass} cast={false} />
+ {Array.from({ length: posts }, (_, i) => (
+ <Box key={i} size={[0.06, height, 0.06]} position={[-length / 2 + (length * i) / (posts - 1), height / 2, 0]} material={MAT.railing} />
+ ))}
+ </group>
+ );
+}
+
+const signTextures = new Map<string, Texture | null>();
+function signTexture(label: string): Texture | null {
+ if (signTextures.has(label)) return signTextures.get(label) ?? null;
+ const canvas = typeof document !== "undefined" ? document.createElement("canvas") : null;
+ const ctx = canvas?.getContext("2d") ?? null;
+ let texture: Texture | null = null;
+ if (canvas && ctx) {
+ canvas.width = 512;
+ canvas.height = 96;
+ ctx.fillStyle = OFFICE.signBoard;
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+ ctx.fillStyle = OFFICE.signText;
+ ctx.font = "600 52px system-ui, -apple-system, 'Segoe UI', sans-serif";
+ ctx.textAlign = "center";
+ ctx.textBaseline = "middle";
+ ctx.fillText(label.length > 18 ? `${label.slice(0, 17)}…` : label, canvas.width / 2, canvas.height / 2 + 2);
+ const made = new CanvasTexture(canvas);
+ made.colorSpace = SRGBColorSpace;
+ made.anisotropy = 4;
+ texture = made;
+ }
+ signTextures.set(label, texture);
+ return texture;
+}
+
+/** A department's back wall: white partition, dark-wood name board, slatted wood panels. */
+export function SignWall({ label, width, position }: { label: string; width: number; position: [number, number, number] }) {
+ const texture = signTexture(label);
+ const slats = Math.max(2, Math.floor(width / 0.5));
+ return (
+ <group position={position}>
+ <Box size={[width, 1.9, 0.14]} position={[0, 0.95, 0]} material={MAT.wall} />
+ <Box size={[width * 0.52, 0.5, 0.05]} position={[0, 1.35, 0.1]} material={MAT.sign} />
+ {texture && (
+ <mesh position={[0, 1.35, 0.13]}>
+ <planeGeometry args={[width * 0.5, (width * 0.5 * 96) / 512]} />
+ <meshStandardMaterial map={texture} roughness={0.8} />
+ </mesh>
+ )}
+ {Array.from({ length: slats }, (_, i) => {
+ const x = -width / 2 + 0.25 + i * ((width - 0.5) / (slats - 1));
+ if (Math.abs(x) < width * 0.3) return null;
+ return <Box key={i} size={[0.12, 1.7, 0.05]} position={[x, 0.95, 0.1]} material={MAT.woodDark} />;
+ })}
+ </group>
+ );
+}
+
+/** A flat rug under the lounge. */
+export function Rug({ position, size }: { position: [number, number, number]; size: [number, number] }) {
+ return <Box size={[size[0], 0.02, size[1]]} position={position} material={MAT.rug} cast={false} />;
+}
diff --git a/jarvis/ui/web/frontend/src/components/society/office/OfficeScene.tsx b/jarvis/ui/web/frontend/src/components/society/office/OfficeScene.tsx
new file mode 100644
index 0000000000..899fa241ba
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/society/office/OfficeScene.tsx
@@ -0,0 +1,205 @@
+/**
+ * The office floor: a wood-and-carpet plate floating in a starry night, glass
+ * railings around it, one carpeted department per provider family, the lead's
+ * glass office at the back and a lounge at the front.
+ */
+import { useEffect, useMemo, useRef } from "react";
+import { OrbitControls, Stars } from "@react-three/drei";
+import { useThree } from "@react-three/fiber";
+import { CanvasTexture, Color, RepeatWrapping, SRGBColorSpace, type Texture } from "three";
+import { useT } from "@/i18n";
+import type { OrbitControls as OrbitControlsImpl } from "three-stdlib";
+import type { SocietyAgent } from "../data";
+import { Bookshelf, Couch, Desk, MAT, Plant, Railing, Rug, SignWall } from "./OfficeFurniture";
+import { OfficeAgents } from "./OfficeAgents";
+import { allDesks, type Department, type OfficeLayout } from "./officeLayout";
+import { DEPARTMENT_TINTS, OFFICE } from "./officePalette";
+import { cameraHome, CAMERA_LIMITS, focusBounds } from "./officeCamera";
+import type { ScreenFace } from "./screenTextures";
+
+/** Warm planks drawn once; repeated across the floor at about 1 m per plank run. */
+let plankTexture: Texture | null | undefined;
+function planks(): Texture | null {
+ if (plankTexture !== undefined) return plankTexture;
+ const canvas = typeof document !== "undefined" ? document.createElement("canvas") : null;
+ const ctx = canvas?.getContext("2d") ?? null;
+ plankTexture = null;
+ if (canvas && ctx) {
+ canvas.width = 256;
+ canvas.height = 256;
+ const tones = ["#c9a27a", "#c29a71", "#cfa983", "#bf966c"];
+ ctx.fillStyle = tones[0];
+ ctx.fillRect(0, 0, 256, 256);
+ for (let row = 0; row < 8; row += 1) {
+ // Staggered joints; segments run past both edges so the tile wraps seamlessly.
+ const offset = ((row % 2) * 64 + ((row * 53) % 64)) - 128;
+ for (let seg = 0; seg < 4; seg += 1) {
+ ctx.fillStyle = tones[(row + seg + 4) % tones.length];
+ ctx.fillRect(offset + seg * 128, row * 32, 128, 32);
+ ctx.fillStyle = "rgba(90,60,35,0.35)";
+ ctx.fillRect(offset + seg * 128, row * 32, 2, 32);
+ }
+ ctx.fillStyle = "rgba(90,60,35,0.3)";
+ ctx.fillRect(0, row * 32, 256, 2);
+ }
+ const texture = new CanvasTexture(canvas);
+ texture.colorSpace = SRGBColorSpace;
+ texture.wrapS = texture.wrapT = RepeatWrapping;
+ texture.anisotropy = 8;
+ plankTexture = texture;
+ }
+ return plankTexture;
+}
+
+function Slab({ layout }: { layout: OfficeLayout }) {
+ const { minX, maxX, minZ, maxZ } = layout.bounds;
+ const w = maxX - minX, d = maxZ - minZ, cx = (minX + maxX) / 2, cz = (minZ + maxZ) / 2;
+ const floorMap = useMemo(() => {
+ const base = planks();
+ if (!base) return null;
+ const map = base.clone();
+ map.repeat.set(w / 3, d / 3);
+ map.needsUpdate = true;
+ return map;
+ }, [w, d]);
+ return (
+ <group>
+ <mesh position={[cx, -0.3, cz]} receiveShadow>
+ <boxGeometry args={[w, 0.6, d]} />
+ <meshStandardMaterial color={OFFICE.slabEdge} roughness={0.9} />
+ </mesh>
+ {/* Warm wood floor everywhere; departments lay carpet on top. */}
+ <mesh position={[cx, 0.001, cz]} rotation={[-Math.PI / 2, 0, 0]} receiveShadow>
+ <planeGeometry args={[w, d]} />
+ <meshStandardMaterial color={floorMap ? "#ffffff" : OFFICE.walkway} map={floorMap} roughness={0.8} />
+ </mesh>
+ <Railing from={[minX + 0.2, minZ + 0.2]} to={[maxX - 0.2, minZ + 0.2]} />
+ <Railing from={[maxX - 0.2, minZ + 0.2]} to={[maxX - 0.2, maxZ - 0.2]} />
+ <Railing from={[maxX - 0.2, maxZ - 0.2]} to={[minX + 0.2, maxZ - 0.2]} />
+ <Railing from={[minX + 0.2, maxZ - 0.2]} to={[minX + 0.2, minZ + 0.2]} />
+ </group>
+ );
+}
+
+function deskFace(agentId: string | null, agents: ReadonlyMap<string, SocietyAgent>): ScreenFace {
+ const agent = agentId ? agents.get(agentId) : undefined;
+ return agent ? agent.state : "empty";
+}
+
+function DepartmentArea({ dept, agents }: { dept: Department; agents: ReadonlyMap<string, SocietyAgent> }) {
+ const t = useT();
+ const w = dept.maxX - dept.minX, d = dept.maxZ - dept.minZ;
+ const cx = (dept.minX + dept.maxX) / 2, cz = (dept.minZ + dept.maxZ) / 2;
+ const tint = DEPARTMENT_TINTS[dept.tint % DEPARTMENT_TINTS.length];
+ return (
+ <group>
+ <mesh position={[cx, 0.006, cz]} rotation={[-Math.PI / 2, 0, 0]} receiveShadow>
+ <planeGeometry args={[w, d]} />
+ <meshStandardMaterial color={tint} roughness={0.95} />
+ </mesh>
+ <SignWall label={dept.label || t("society.office.open_space")} width={w - 0.4} position={[cx, 0, dept.minZ + 0.1]} />
+ {dept.desks.map((desk) => (
+ <group key={desk.id} position={[desk.x, 0, desk.z]} rotation={[0, desk.facing === "north" ? 0 : Math.PI, 0]}>
+ <Desk face={deskFace(desk.agentId, agents)} />
+ </group>
+ ))}
+ <Plant position={[dept.minX + 0.45, 0, dept.maxZ - 0.45]} size={0.9} />
+ <Plant position={[dept.maxX - 0.45, 0, dept.maxZ - 0.45]} size={0.9} />
+ </group>
+ );
+}
+
+function LeadOfficeRoom({ layout, agents }: { layout: OfficeLayout; agents: ReadonlyMap<string, SocietyAgent> }) {
+ const { minX, maxX, minZ, maxZ } = layout.lead;
+ const w = maxX - minX, d = maxZ - minZ, cx = (minX + maxX) / 2, cz = (minZ + maxZ) / 2;
+ return (
+ <group>
+ <mesh position={[cx, 0.006, cz]} rotation={[-Math.PI / 2, 0, 0]} receiveShadow>
+ <planeGeometry args={[w, d]} />
+ <meshStandardMaterial color={OFFICE.wood} roughness={0.8} />
+ </mesh>
+ <SignWall label="Lead" width={w - 0.4} position={[cx, 0, minZ + 0.1]} />
+ {/* Glass walls on the open sides, with a door gap facing the floor. */}
+ <Railing from={[maxX, minZ + 0.3]} to={[maxX, maxZ]} height={2.1} />
+ <Railing from={[minX + 0.2, maxZ]} to={[cx - 0.7, maxZ]} height={2.1} />
+ <Railing from={[cx + 0.7, maxZ]} to={[maxX, maxZ]} height={2.1} />
+ {layout.lead.desks.map((desk) => (
+ <group key={desk.id} position={[desk.x, 0, desk.z]} rotation={[0, Math.PI, 0]}>
+ <Desk face={deskFace(desk.agentId, agents)} />
+ </group>
+ ))}
+ <Bookshelf position={[maxX - 1.3, 0, minZ + 0.45]} />
+ <Plant position={[minX + 0.5, 0, maxZ - 0.5]} size={1.2} />
+ </group>
+ );
+}
+
+function Lounge({ layout }: { layout: OfficeLayout }) {
+ const { minX, maxX, minZ, maxZ } = layout.lounge;
+ const cx = (minX + maxX) / 2, cz = (minZ + maxZ) / 2;
+ return (
+ <group>
+ <Rug position={[cx - 3, 0.01, cz]} size={[6.5, 4]} />
+ <Couch position={[cx - 3, 0, cz - 1]} />
+ <Couch position={[cx - 5.4, 0, cz + 0.3]} rotationY={Math.PI / 2} />
+ <mesh position={[cx - 3, 0.22, cz + 0.4]} castShadow receiveShadow material={MAT.wood}>
+ <cylinderGeometry args={[0.55, 0.55, 0.06, 24]} />
+ </mesh>
+ <Bookshelf position={[cx + 2.5, 0, maxZ - 0.5]} rotationY={Math.PI} />
+ <Bookshelf position={[cx + 4.6, 0, maxZ - 0.5]} rotationY={Math.PI} />
+ <Plant position={[minX + 0.6, 0, maxZ - 0.6]} size={1.4} />
+ <Plant position={[maxX - 0.6, 0, minZ + 0.6]} size={1.2} />
+ <Plant position={[cx + 0.4, 0, cz - 1.2]} size={1.1} />
+ </group>
+ );
+}
+
+function CameraRig({ layout, reset }: { layout: OfficeLayout; reset: number }) {
+ const focus = useMemo(() => focusBounds(allDesks(layout).filter((d) => d.agentId)), [layout]);
+ const controls = useRef<OrbitControlsImpl>(null);
+ const camera = useThree((s) => s.camera);
+ const size = useThree((s) => s.size);
+ useEffect(() => {
+ const home = cameraHome(layout.bounds, size.width / Math.max(1, size.height), focus);
+ camera.position.set(...home.position);
+ controls.current?.target.set(...home.target);
+ controls.current?.update();
+ // Dev-only handle for runtime screenshots at chosen angles.
+ if (import.meta.env.DEV) (window as unknown as Record<string, unknown>).__office = { camera, controls: controls.current };
+ // `size` only matters for the first framing; a resize keeps the user's view.
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [camera, layout.bounds, focus, reset]);
+ return (
+ <OrbitControls ref={controls} makeDefault enableDamping dampingFactor={0.12} screenSpacePanning={false}
+ minPolarAngle={CAMERA_LIMITS.minPolar} maxPolarAngle={CAMERA_LIMITS.maxPolar}
+ minDistance={CAMERA_LIMITS.minDistance} maxDistance={CAMERA_LIMITS.maxDistance} />
+ );
+}
+
+export function OfficeScene({ layout, agents, awake, reduced, reset, onSelect }: {
+ layout: OfficeLayout; agents: ReadonlyMap<string, SocietyAgent>; awake: boolean; reduced: boolean; reset: number; onSelect: (id: string) => void;
+}) {
+ const desks = useMemo(() => allDesks(layout), [layout]);
+ const background = useMemo(() => new Color(OFFICE.space), []);
+ const { minX, maxX, minZ, maxZ } = layout.bounds;
+ const span = Math.max(maxX - minX, maxZ - minZ);
+ return (
+ <>
+ <primitive attach="background" object={background} />
+ <fog attach="fog" args={[OFFICE.space, span * 2.2, span * 4.5]} />
+ <Stars radius={span * 3} depth={span} count={2500} factor={4} saturation={0} fade speed={reduced ? 0 : 0.3} />
+ <hemisphereLight args={["#dfe9ff", "#6b5a48", 0.9]} />
+ <ambientLight intensity={0.25} />
+ <directionalLight position={[maxX + 10, 26, maxZ + 6]} intensity={1.6} castShadow
+ shadow-mapSize={[2048, 2048]} shadow-bias={-0.0004} shadow-normalBias={0.03}
+ shadow-camera-left={-span * 0.7} shadow-camera-right={span * 0.7}
+ shadow-camera-top={span * 0.7} shadow-camera-bottom={-span * 0.7} shadow-camera-far={120} />
+ <Slab layout={layout} />
+ <LeadOfficeRoom layout={layout} agents={agents} />
+ {layout.departments.map((dept) => <DepartmentArea key={dept.id} dept={dept} agents={agents} />)}
+ <Lounge layout={layout} />
+ <OfficeAgents desks={desks} agents={agents} awake={awake} reduced={reduced} onSelect={onSelect} />
+ <CameraRig layout={layout} reset={reset} />
+ </>
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/components/society/office/OfficeStage.tsx b/jarvis/ui/web/frontend/src/components/society/office/OfficeStage.tsx
new file mode 100644
index 0000000000..f159667a4d
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/society/office/OfficeStage.tsx
@@ -0,0 +1,113 @@
+/**
+ * Agents > Map: the office. One overview of every agent at its desk, grouped
+ * into departments, with a live working/idle count. Clicking an agent opens
+ * its card; the map itself never starts or stops work.
+ */
+import { Component, Suspense, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
+import { useQueryClient } from "@tanstack/react-query";
+import { Canvas } from "@react-three/fiber";
+import { useReducedMotion } from "framer-motion";
+import { useCanvasAwake } from "@/hooks/useCanvasAwake";
+import { useWebglSurface } from "@/hooks/useWebglSurface";
+import { useWebglSupported } from "@/lib/graphDimension";
+import { useT } from "@/i18n";
+import { useSocietyRoster, type SocietyAgent } from "../data";
+import { OfficeScene } from "./OfficeScene";
+import { buildOfficeLayout, countStates, MAX_SEATED } from "./officeLayout";
+import { CAMERA_FOV } from "./officeCamera";
+import "./office.css";
+
+/** Status refresh while the office is on screen; jittered so windows never poll in lockstep (AP-33). */
+const REFRESH_MS = 5000;
+const REFRESH_JITTER_MS = 1500;
+
+class RenderBoundary extends Component<{ children: ReactNode; fallbackText: string }, { failed: boolean }> {
+ state = { failed: false };
+ static getDerivedStateFromError() { return { failed: true }; }
+ componentDidCatch(error: Error) { console.warn("Office renderer unavailable", error); }
+ render() {
+ return this.state.failed ? <div className="office-fallback" role="status">{this.props.fallbackText}</div> : this.props.children;
+ }
+}
+
+export interface OfficeStageProps {
+ onOpenLedger: () => void;
+ onSelectAgent?: (id: string | null) => void;
+}
+
+export function OfficeStage({ onOpenLedger, onSelectAgent }: OfficeStageProps) {
+ const t = useT();
+ const hostRef = useRef<HTMLDivElement>(null);
+ const awake = useCanvasAwake(hostRef);
+ const reduced = useReducedMotion() ?? false;
+ const { generation } = useWebglSurface(hostRef);
+ const webgl = useWebglSupported();
+ const roster = useSocietyRoster();
+ const client = useQueryClient();
+ const [reset, setReset] = useState(0);
+
+ useEffect(() => {
+ if (!awake) return;
+ let timer: ReturnType<typeof setTimeout>;
+ const schedule = () => {
+ timer = setTimeout(() => {
+ void client.invalidateQueries({ queryKey: ["society", "roster"] });
+ schedule();
+ }, REFRESH_MS + Math.random() * REFRESH_JITTER_MS);
+ };
+ schedule();
+ return () => clearTimeout(timer);
+ }, [awake, client]);
+
+ const active = useMemo(() => (roster.data?.agents ?? []).filter((a) => a.lifecycle !== "archived"), [roster.data]);
+ const agents = useMemo(() => new Map<string, SocietyAgent>(active.map((a) => [a.agentId, a])), [active]);
+ // The layout only depends on who works where, never on run state, so a
+ // status refresh repaints monitors without re-seating anyone.
+ const seatingKey = active.map((a) => `${a.agentId}|${a.tier}|${a.providerLabel}|${a.createdMs}`).join(",");
+ const layout = useMemo(() => buildOfficeLayout(active),
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [seatingKey]);
+ const counts = countStates(active);
+ const select = (id: string) => onSelectAgent?.(id);
+
+ return (
+ <section className="office-stage" aria-label={t("society.office.title")} data-office-agents={active.length}>
+ <div ref={hostRef} className="office-viewport" tabIndex={0} role="application" aria-label={t("society.office.viewport")}>
+ {webgl ? (
+ <RenderBoundary key={generation} fallbackText={t("society.office.no_graphics")}>
+ <Suspense fallback={<div className="office-fallback" role="status">{t("society.office.loading")}</div>}>
+ <Canvas shadows="percentage" camera={{ fov: CAMERA_FOV, near: 0.2, far: 800, position: [30, 30, 30] }} dpr={[1, 1.75]}
+ gl={{ antialias: true, alpha: false, preserveDrawingBuffer: import.meta.env.DEV }} frameloop={!awake ? "never" : reduced ? "demand" : "always"}
+ onPointerMissed={() => onSelectAgent?.(null)}>
+ <OfficeScene layout={layout} agents={agents} awake={awake} reduced={reduced} reset={reset} onSelect={select} />
+ </Canvas>
+ </Suspense>
+ </RenderBoundary>
+ ) : <div className="office-fallback" role="status">{t("society.office.no_graphics")}</div>}
+ </div>
+
+ <div className="office-hud office-hud-left" data-office-ui>
+ <div className="office-card office-title">
+ <strong>{t("society.office.title")}</strong>
+ <span>{t("society.office.subtitle").replace("{0}", String(active.length))}</span>
+ </div>
+ <div className="office-card office-counts" role="status" aria-live="polite">
+ <span data-tone="working"><i aria-hidden />{t("society.office.count_working").replace("{0}", String(counts.working))}</span>
+ <span data-tone="waiting"><i aria-hidden />{t("society.office.count_waiting").replace("{0}", String(counts.waiting))}</span>
+ <span data-tone="idle"><i aria-hidden />{t("society.office.count_idle").replace("{0}", String(counts.idle + counts.paused))}</span>
+ </div>
+ {roster.data?.sample && <p className="office-card office-note">{t("society.office.sample")}</p>}
+ {active.length > MAX_SEATED && <p className="office-card office-note">{t("society.office.overflow").replace("{0}", String(MAX_SEATED))}</p>}
+ </div>
+
+ <div className="office-hud office-hud-right" data-office-ui>
+ <button type="button" className="office-button" onClick={() => setReset((v) => v + 1)}>{t("society.office.overview")}</button>
+ <button type="button" className="office-button" onClick={onOpenLedger}>{t("society.office.ledger")}</button>
+ </div>
+
+ <p className="office-hud office-help" data-office-ui>{t("society.office.help")}</p>
+ </section>
+ );
+}
+
+export default OfficeStage;
diff --git a/jarvis/ui/web/frontend/src/components/society/office/office.css b/jarvis/ui/web/frontend/src/components/society/office/office.css
new file mode 100644
index 0000000000..c3192ad5ee
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/society/office/office.css
@@ -0,0 +1,34 @@
+/* HUD over the office canvas: theme tokens, so it follows light and dark mode. */
+.office-stage { position:relative; height:100%; min-height:0; overflow:hidden; background:#0b1024; }
+.office-viewport { position:absolute; inset:0; touch-action:none; }
+.office-viewport:focus-visible { outline:2px solid hsl(var(--ring)); outline-offset:-2px; }
+.office-fallback { display:flex; align-items:center; justify-content:center; height:100%; padding:24px; font-size:13px; color:hsl(var(--muted-foreground)); background:hsl(var(--background)); }
+.office-hud { position:absolute; z-index:30; }
+.office-hud-left { left:14px; top:14px; display:flex; flex-direction:column; align-items:flex-start; gap:8px; max-width:min(320px, calc(100% - 28px)); }
+.office-hud-right { right:14px; top:14px; display:flex; gap:6px; }
+.office-card { border:1px solid hsl(var(--border)); border-radius:12px; background:hsl(var(--popover) / .92); color:hsl(var(--popover-foreground)); box-shadow:0 4px 18px rgb(0 0 0 / .25); backdrop-filter:blur(6px); }
+.office-title { display:flex; flex-direction:column; gap:2px; padding:8px 12px; font-size:14px; }
+.office-title span { font-size:11px; color:hsl(var(--muted-foreground)); }
+.office-counts { display:flex; gap:14px; padding:7px 12px; font-size:12px; font-weight:600; }
+.office-counts span { display:inline-flex; align-items:center; gap:6px; }
+.office-counts i { width:8px; height:8px; border-radius:50%; background:#94a3b8; }
+.office-counts [data-tone="working"] i { background:#22c55e; }
+.office-counts [data-tone="waiting"] i { background:#f59e0b; }
+.office-note { margin:0; padding:6px 10px; font-size:11px; color:hsl(var(--muted-foreground)); }
+.office-button { border:1px solid hsl(var(--border)); border-radius:10px; padding:6px 11px; background:hsl(var(--popover) / .92); color:hsl(var(--popover-foreground)); font-size:12px; cursor:pointer; backdrop-filter:blur(6px); }
+.office-button:hover { background:hsl(var(--secondary)); }
+.office-button:focus-visible { outline:2px solid hsl(var(--ring)); outline-offset:2px; }
+.office-help { left:50%; bottom:12px; transform:translateX(-50%); margin:0; padding:5px 12px; border-radius:999px; font-size:11px; white-space:nowrap; background:hsl(var(--popover) / .85); color:hsl(var(--muted-foreground)); border:1px solid hsl(var(--border)); }
+
+/* In-world name pills: part of the diorama, so they keep one dark look in both modes. */
+.office-plate { transform-origin:center bottom; display:inline-flex; align-items:center; gap:5px; padding:2px 8px 2px 2px; border:0; border-radius:999px; background:rgb(24 26 32 / .84); color:#f8fafc; cursor:pointer; font-family:inherit; white-space:nowrap; user-select:none; box-shadow:0 2px 8px rgb(0 0 0 / .35); }
+.office-plate:hover { background:rgb(36 39 48 / .95); }
+.office-plate-name { max-width:11em; overflow:hidden; text-overflow:ellipsis; font-size:12px; font-weight:700; }
+.office-plate-badge { display:inline-flex; align-items:center; justify-content:center; width:18px; height:18px; font-size:10px; font-weight:800; color:#fff; clip-path:polygon(25% 3%, 75% 3%, 100% 50%, 75% 97%, 25% 97%, 0 50%); }
+.office-plate-state { display:inline-flex; align-items:center; gap:4px; font-size:10px; font-weight:600; color:#cbd5e1; }
+.office-plate-state em { font-style:normal; }
+.office-plate-state i { width:7px; height:7px; border-radius:50%; background:#94a3b8; }
+.office-plate[data-state="working"] .office-plate-state i { background:#4ade80; box-shadow:0 0 6px #4ade80; }
+.office-plate[data-state="waiting"] .office-plate-state i { background:#fbbf24; }
+.office-plate:focus-visible { outline:2px solid #93c5fd; outline-offset:2px; }
+@media (max-width:600px) { .office-help { display:none; } .office-counts { gap:8px; } }
diff --git a/jarvis/ui/web/frontend/src/components/society/office/officeCamera.ts b/jarvis/ui/web/frontend/src/components/society/office/officeCamera.ts
new file mode 100644
index 0000000000..9e22d0c0cb
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/society/office/officeCamera.ts
@@ -0,0 +1,64 @@
+/**
+ * The office camera: a three-quarter view from the south-east, looking down
+ * at about 40°, framed so the whole floor fits the viewport. Pure and tested.
+ */
+export const CAMERA_FOV = 35;
+
+export const CAMERA_LIMITS = {
+ /** Polar angle from straight down: ~20° (near top-down) to ~72° (near eye level). */
+ minPolar: 0.35,
+ maxPolar: 1.25,
+ minDistance: 4,
+ maxDistance: 140,
+} as const;
+
+/** Look-down angle below the horizon and yaw east of south for the home view. */
+export const HOME_PITCH_RAD = (40 * Math.PI) / 180;
+export const HOME_YAW_RAD = (38 * Math.PI) / 180;
+
+export interface Bounds { minX: number; maxX: number; minZ: number; maxZ: number }
+export interface CameraPose { position: [number, number, number]; target: [number, number, number] }
+
+/** Distance that fits a floor of this footprint into a viewport of this aspect. */
+export function fitDistance(bounds: Bounds, aspect: number, fovDeg = CAMERA_FOV): number {
+ const width = bounds.maxX - bounds.minX;
+ const depth = bounds.maxZ - bounds.minZ;
+ // Seen diagonally, the floor's screen width is roughly its diagonal; its
+ // screen height is the diagonal foreshortened by the look-down angle.
+ const diagonal = Math.hypot(width, depth);
+ const vHalf = ((fovDeg * Math.PI) / 180) / 2;
+ const hHalf = Math.atan(Math.tan(vHalf) * Math.max(0.3, aspect));
+ const needH = (diagonal * 0.5) / Math.tan(hHalf);
+ const needV = (diagonal * Math.sin(HOME_PITCH_RAD) * 0.5 + 1.5) / Math.tan(vHalf);
+ return Math.min(CAMERA_LIMITS.maxDistance, Math.max(CAMERA_LIMITS.minDistance, Math.max(needH, needV) * 0.62));
+}
+
+/** Smallest area the home view frames, so a lone agent still shows its neighbourhood. */
+const MIN_FOCUS_W = 18;
+const MIN_FOCUS_D = 14;
+
+/** Pad the occupied area to a readable neighbourhood around it. */
+export function focusBounds(points: readonly { x: number; z: number }[]): Bounds | null {
+ if (points.length === 0) return null;
+ const xs = points.map((p) => p.x), zs = points.map((p) => p.z);
+ const cx = (Math.min(...xs) + Math.max(...xs)) / 2, cz = (Math.min(...zs) + Math.max(...zs)) / 2;
+ const w = Math.max(MIN_FOCUS_W, Math.max(...xs) - Math.min(...xs) + 6);
+ const d = Math.max(MIN_FOCUS_D, Math.max(...zs) - Math.min(...zs) + 6);
+ return { minX: cx - w / 2, maxX: cx + w / 2, minZ: cz - d / 2, maxZ: cz + d / 2 };
+}
+
+/** Home view: frame where the agents sit, or the whole floor when nobody does. */
+export function cameraHome(bounds: Bounds, aspect: number, focus: Bounds | null = null): CameraPose {
+ const frame = focus ?? bounds;
+ const target: [number, number, number] = [(frame.minX + frame.maxX) / 2, 0, (frame.minZ + frame.maxZ) / 2];
+ const distance = fitDistance(frame, aspect);
+ const horizontal = Math.cos(HOME_PITCH_RAD) * distance;
+ return {
+ target,
+ position: [
+ target[0] + Math.sin(HOME_YAW_RAD) * horizontal,
+ Math.sin(HOME_PITCH_RAD) * distance,
+ target[2] + Math.cos(HOME_YAW_RAD) * horizontal,
+ ],
+ };
+}
diff --git a/jarvis/ui/web/frontend/src/components/society/office/officeLayout.test.ts b/jarvis/ui/web/frontend/src/components/society/office/officeLayout.test.ts
new file mode 100644
index 0000000000..28d61770b1
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/society/office/officeLayout.test.ts
@@ -0,0 +1,83 @@
+import { describe, expect, it } from "vitest";
+import { allDesks, buildOfficeLayout, countStates, departmentKey, groupDepartments, MAX_DEPARTMENTS, MIN_DEPARTMENTS, type OfficeAgentInput } from "./officeLayout";
+import { cameraHome, fitDistance, focusBounds } from "./officeCamera";
+
+const agent = (id: string, provider: string, extra: Partial<OfficeAgentInput> = {}): OfficeAgentInput => ({
+ agentId: id, name: id, tier: "specialist", providerLabel: provider, state: "idle", createdMs: Number(id.replace(/\D/g, "")) || 0, ...extra,
+});
+
+describe("office layout", () => {
+ it("groups agents by provider family and falls back to Jarvis", () => {
+ expect(departmentKey({ providerLabel: " " })).toBe("Jarvis");
+ const groups = groupDepartments([agent("a1", "codex"), agent("a2", ""), agent("a3", "codex")]);
+ expect(groups.map((g) => g.label)).toEqual(["Codex", "Jarvis"]);
+ expect(buildOfficeLayout([agent("a1", "codex")]).departments.map((d) => d.label)).toEqual(["Codex", "", "", ""]);
+ });
+
+ it("gives every staff agent exactly one desk and the lead its own office", () => {
+ const roster = [agent("a1", "Codex"), agent("a2", "Claude Code"), agent("a3", "Codex"), agent("a4", "", { tier: "lead" })];
+ const layout = buildOfficeLayout(roster);
+ const seated = allDesks(layout).map((d) => d.agentId).filter(Boolean);
+ expect(new Set(seated)).toEqual(new Set(["a1", "a2", "a3", "a4"]));
+ expect(seated).toHaveLength(4);
+ expect(layout.lead.desks[0].agentId).toBe("a4");
+ });
+
+ it("keeps seating stable when run state changes or the roster is reordered", () => {
+ const roster = [agent("a1", "Codex"), agent("a2", "Codex"), agent("a3", "Gemini")];
+ const before = allDesks(buildOfficeLayout(roster)).map((d) => `${d.id}=${d.agentId}`);
+ const after = allDesks(buildOfficeLayout([...roster].reverse().map((a) => ({ ...a, state: "working" as const }))))
+ .map((d) => `${d.id}=${d.agentId}`);
+ expect(after).toEqual(before);
+ });
+
+ it("folds surplus providers into one department and never overlaps departments", () => {
+ const roster = Array.from({ length: 10 }, (_, i) => agent(`a${i}`, `P${i}`));
+ const layout = buildOfficeLayout(roster);
+ expect(layout.departments).toHaveLength(MAX_DEPARTMENTS);
+ expect(layout.departments.at(-1)?.label).toBe("Other");
+ for (const a of layout.departments) for (const b of layout.departments) {
+ if (a === b) continue;
+ const overlap = a.minX < b.maxX && b.minX < a.maxX && a.minZ < b.maxZ && b.minZ < a.maxZ;
+ expect(overlap).toBe(false);
+ }
+ for (const desk of allDesks(layout)) {
+ expect(desk.x).toBeGreaterThan(layout.bounds.minX);
+ expect(desk.x).toBeLessThan(layout.bounds.maxX);
+ expect(desk.z).toBeGreaterThan(layout.bounds.minZ);
+ expect(desk.z).toBeLessThan(layout.bounds.maxZ);
+ }
+ });
+
+ it("builds a furnished floor for an empty roster", () => {
+ const layout = buildOfficeLayout([]);
+ expect(layout.departments).toHaveLength(MIN_DEPARTMENTS);
+ expect(layout.departments.every((d) => d.label === "" && d.desks.length > 0)).toBe(true);
+ });
+
+ it("counts states", () => {
+ expect(countStates([{ state: "working" }, { state: "idle" }, { state: "working" }])).toEqual({ working: 2, idle: 1, waiting: 0, paused: 0 });
+ });
+});
+
+describe("office camera", () => {
+ const bounds = { minX: -12, maxX: 12, minZ: -15, maxZ: 15 };
+ it("looks at the floor centre from the south-east, above it", () => {
+ const pose = cameraHome(bounds, 16 / 9);
+ expect(pose.target).toEqual([0, 0, 0]);
+ expect(pose.position[0]).toBeGreaterThan(0);
+ expect(pose.position[1]).toBeGreaterThan(0);
+ expect(pose.position[2]).toBeGreaterThan(0);
+ });
+ it("backs off further for a narrow viewport and a bigger floor", () => {
+ expect(fitDistance(bounds, 0.6)).toBeGreaterThan(fitDistance(bounds, 2));
+ expect(fitDistance({ minX: -30, maxX: 30, minZ: -30, maxZ: 30 }, 1.6)).toBeGreaterThan(fitDistance(bounds, 1.6));
+ });
+ it("frames the occupied desks, padded to a readable neighbourhood", () => {
+ expect(focusBounds([])).toBeNull();
+ const focus = focusBounds([{ x: 10, z: -4 }])!;
+ expect((focus.minX + focus.maxX) / 2).toBe(10);
+ expect(focus.maxX - focus.minX).toBeGreaterThanOrEqual(18);
+ expect(cameraHome(bounds, 1.6, focus).target).toEqual([10, 0, -4]);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/society/office/officeLayout.ts b/jarvis/ui/web/frontend/src/components/society/office/officeLayout.ts
new file mode 100644
index 0000000000..e0dfded6a6
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/society/office/officeLayout.ts
@@ -0,0 +1,216 @@
+/**
+ * The office floor as data: departments, desk slots and who sits where.
+ *
+ * Pure and deterministic — the same roster always produces the same seating,
+ * so an agent never "moves desks" on a refetch. Units are metres, +x east,
+ * +z south, origin at the floor centre. The camera looks from the south-east.
+ */
+import type { AgentRunState, AgentTier } from "../data";
+
+export interface OfficeAgentInput {
+ agentId: string;
+ name: string;
+ tier: AgentTier;
+ providerLabel: string;
+ state: AgentRunState;
+ createdMs: number;
+}
+
+export type Facing = "north" | "south";
+
+export interface DeskSlot {
+ id: string;
+ /** Desk centre on the floor. */
+ x: number;
+ z: number;
+ /** The direction the seated agent looks (towards its monitor). */
+ facing: Facing;
+ agentId: string | null;
+}
+
+export interface Department {
+ id: string;
+ /** Provider family shown on the sign; "" for a spare open-space department. */
+ label: string;
+ /** Floor rectangle of the department's carpet. */
+ minX: number;
+ maxX: number;
+ minZ: number;
+ maxZ: number;
+ desks: DeskSlot[];
+ /** Carpet tint index into the palette's department colours. */
+ tint: number;
+}
+
+export interface LeadOffice {
+ minX: number;
+ maxX: number;
+ minZ: number;
+ maxZ: number;
+ desks: DeskSlot[];
+}
+
+export interface OfficeLayout {
+ departments: Department[];
+ lead: LeadOffice;
+ lounge: { minX: number; maxX: number; minZ: number; maxZ: number };
+ /** The whole walkable floor, railing included. */
+ bounds: { minX: number; maxX: number; minZ: number; maxZ: number };
+}
+
+/** Desk pitch along a row and the depth of one bench (two rows back to back plus chairs). */
+export const DESK_PITCH_X = 1.7;
+export const BENCH_DEPTH_Z = 4.2;
+/** Half the gap between the two monitors of a back-to-back pair. */
+export const DESK_HALF_GAP = 0.45;
+export const DESKS_PER_ROW = 4;
+const SEATS_PER_BENCH = DESKS_PER_ROW * 2;
+const MIN_BENCHES = 1;
+const MAX_BENCHES = 4;
+const DEPT_MARGIN_X = 1.1;
+const DEPT_HEADER_Z = 1.8;
+const DEPT_FOOTER_Z = 0.8;
+const AISLE = 3.2;
+const EDGE = 1.6;
+const LOUNGE_DEPTH = 6;
+const LEAD_DEPTH = 6;
+const COLUMNS = 2;
+/** The floor always shows at least this many departments; spare ones are open space with free desks. */
+export const MIN_DEPARTMENTS = 4;
+/** More departments than this fold into the last one — the floor stays one screen. */
+export const MAX_DEPARTMENTS = 6;
+export const MAX_SEATED = MAX_DEPARTMENTS * MAX_BENCHES * SEATS_PER_BENCH;
+
+/** The department an agent works in: its provider family, or Jarvis' own brain. */
+export function departmentKey(agent: Pick<OfficeAgentInput, "providerLabel">): string {
+ const label = agent.providerLabel.trim();
+ return label.length > 0 ? label.charAt(0).toUpperCase() + label.slice(1) : "Jarvis";
+}
+
+function byArrival(a: OfficeAgentInput, b: OfficeAgentInput): number {
+ return a.createdMs - b.createdMs || a.agentId.localeCompare(b.agentId);
+}
+
+/** Group staff (non-lead) agents into at most MAX_DEPARTMENTS stable departments. */
+export function groupDepartments(agents: readonly OfficeAgentInput[]): { label: string; members: OfficeAgentInput[] }[] {
+ const groups = new Map<string, OfficeAgentInput[]>();
+ for (const agent of agents) {
+ if (agent.tier === "lead") continue;
+ const key = departmentKey(agent);
+ const list = groups.get(key) ?? [];
+ list.push(agent);
+ groups.set(key, list);
+ }
+ const ordered = [...groups.entries()]
+ .map(([label, members]) => ({ label, members: [...members].sort(byArrival) }))
+ .sort((a, b) => b.members.length - a.members.length || a.label.localeCompare(b.label));
+ if (ordered.length === 0) return [{ label: "Jarvis", members: [] }];
+ if (ordered.length <= MAX_DEPARTMENTS) return ordered;
+ const kept = ordered.slice(0, MAX_DEPARTMENTS - 1);
+ const rest = ordered.slice(MAX_DEPARTMENTS - 1).flatMap((g) => g.members).sort(byArrival);
+ return [...kept, { label: "Other", members: rest }];
+}
+
+function benchCount(members: number): number {
+ return Math.min(MAX_BENCHES, Math.max(MIN_BENCHES, Math.ceil(members / SEATS_PER_BENCH)));
+}
+
+function deptWidth(): number {
+ return DESKS_PER_ROW * DESK_PITCH_X + DEPT_MARGIN_X * 2;
+}
+
+function deptDepth(benches: number): number {
+ return DEPT_HEADER_Z + benches * BENCH_DEPTH_Z + DEPT_FOOTER_Z;
+}
+
+/** Desk slots of one department, seated in arrival order: bench by bench, front row first. */
+function layoutDesks(deptId: string, minX: number, minZ: number, benches: number, members: OfficeAgentInput[]): DeskSlot[] {
+ const desks: DeskSlot[] = [];
+ let seat = 0;
+ for (let bench = 0; bench < benches; bench += 1) {
+ const centreZ = minZ + DEPT_HEADER_Z + bench * BENCH_DEPTH_Z + BENCH_DEPTH_Z / 2;
+ for (const facing of ["north", "south"] as const) {
+ // A north-facing agent sits on the south side of the pair, looking at its monitor.
+ const z = facing === "north" ? centreZ + DESK_HALF_GAP : centreZ - DESK_HALF_GAP;
+ for (let col = 0; col < DESKS_PER_ROW; col += 1) {
+ const x = minX + DEPT_MARGIN_X + DESK_PITCH_X * (col + 0.5);
+ desks.push({ id: `${deptId}:${bench}:${facing}:${col}`, x, z, facing, agentId: members[seat]?.agentId ?? null });
+ seat += 1;
+ }
+ }
+ }
+ return desks;
+}
+
+/** Build the floor for a roster. Seating is stable for an unchanged roster. */
+export function buildOfficeLayout(agents: readonly OfficeAgentInput[]): OfficeLayout {
+ const groups: { label: string; members: OfficeAgentInput[] }[] = groupDepartments(agents);
+ if (groups.length === 1 && groups[0].members.length === 0) groups.length = 0;
+ while (groups.length < MIN_DEPARTMENTS) groups.push({ label: "", members: [] });
+ const width = deptWidth();
+ const rows = Math.ceil(groups.length / COLUMNS);
+ const columns = Math.min(COLUMNS, groups.length);
+ const totalWidth = columns * width + (columns - 1) * AISLE;
+ const minX = -Math.max(totalWidth, 2 * width + AISLE) / 2;
+
+ // Row depth is the deepest department in that row, so rows line up.
+ const rowDepths: number[] = [];
+ for (let row = 0; row < rows; row += 1) {
+ const inRow = groups.slice(row * COLUMNS, row * COLUMNS + COLUMNS);
+ rowDepths.push(Math.max(...inRow.map((g) => deptDepth(benchCount(g.members.length)))));
+ }
+ const floorDepth = LEAD_DEPTH + AISLE + rowDepths.reduce((s, d) => s + d, 0) + (rows - 1) * AISLE + AISLE + LOUNGE_DEPTH;
+ const topZ = -floorDepth / 2;
+ const floorWidth = Math.max(totalWidth, 2 * width + AISLE);
+
+ const leadAgents = agents.filter((a) => a.tier === "lead").sort(byArrival).slice(0, 2);
+ const leadWidth = width;
+ const lead: LeadOffice = {
+ minX, maxX: minX + leadWidth, minZ: topZ, maxZ: topZ + LEAD_DEPTH,
+ desks: [0, 1].map((i) => ({
+ id: `lead:${i}`,
+ x: minX + leadWidth * (i === 0 ? 0.35 : 0.72),
+ z: topZ + LEAD_DEPTH * 0.45,
+ facing: "south" as const,
+ agentId: leadAgents[i]?.agentId ?? null,
+ })),
+ };
+
+ const departments: Department[] = [];
+ let z = topZ + LEAD_DEPTH + AISLE;
+ for (let row = 0; row < rows; row += 1) {
+ for (let col = 0; col < COLUMNS; col += 1) {
+ const index = row * COLUMNS + col;
+ const group = groups[index];
+ if (!group) continue;
+ const benches = benchCount(group.members.length);
+ const dMinX = minX + col * (width + AISLE);
+ const id = `dept-${index}`;
+ departments.push({
+ id, label: group.label, tint: index,
+ minX: dMinX, maxX: dMinX + width, minZ: z, maxZ: z + deptDepth(benches),
+ desks: layoutDesks(id, dMinX, z, benches, group.members.slice(0, benches * SEATS_PER_BENCH)),
+ });
+ }
+ z += rowDepths[row] + AISLE;
+ }
+
+ const lounge = { minX, maxX: minX + floorWidth, minZ: z, maxZ: z + LOUNGE_DEPTH };
+ return {
+ departments, lead, lounge,
+ bounds: { minX: minX - EDGE, maxX: minX + floorWidth + EDGE, minZ: topZ - EDGE, maxZ: lounge.maxZ + EDGE },
+ };
+}
+
+/** Every desk on the floor, lead office first. */
+export function allDesks(layout: OfficeLayout): DeskSlot[] {
+ return [...layout.lead.desks, ...layout.departments.flatMap((d) => d.desks)];
+}
+
+export interface StatusCounts { working: number; idle: number; waiting: number; paused: number }
+
+export function countStates(agents: readonly Pick<OfficeAgentInput, "state">[]): StatusCounts {
+ const counts: StatusCounts = { working: 0, idle: 0, waiting: 0, paused: 0 };
+ for (const agent of agents) counts[agent.state] += 1;
+ return counts;
+}
diff --git a/jarvis/ui/web/frontend/src/components/society/office/officePalette.ts b/jarvis/ui/web/frontend/src/components/society/office/officePalette.ts
new file mode 100644
index 0000000000..86d05c6a87
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/society/office/officePalette.ts
@@ -0,0 +1,40 @@
+/**
+ * The office's own colours ("cosy toy office", docs/agent-society/office-map.md §2).
+ * Like the earlier worlds, nothing inside the canvas reads a theme token: the
+ * scene is a lit diorama that looks the same in light and dark mode.
+ */
+export const OFFICE = {
+ space: "#0b1024",
+ slab: "#3a3f4b",
+ slabEdge: "#2b2f38",
+ wood: "#b98a5e",
+ woodDark: "#8a6240",
+ walkway: "#c9a27a",
+ deskTop: "#e8d3b0",
+ deskBody: "#f2f0ec",
+ deskLeg: "#d9d6cf",
+ chair: "#2c2f36",
+ chairSeat: "#3b3f48",
+ monitor: "#23262d",
+ keyboard: "#3a3d44",
+ railing: "#b7bcc4",
+ glass: "#bfe3ff",
+ wallWhite: "#f1efe9",
+ signBoard: "#3d2c22",
+ signText: "#fff7ec",
+ couch: "#2f3542",
+ couchCushion: "#3d4556",
+ plantPot: "#f4f1ea",
+ leaf: "#5fa35a",
+ leafDark: "#3f7f45",
+ trunk: "#6b4a2e",
+ book: ["#c8553d", "#f2a541", "#4f7cac", "#5e9c76", "#8d6cab"],
+ rug: "#d8c8ae",
+ ringWorking: "#4ade80",
+ ringIdle: "#e8ecf2",
+ ringWaiting: "#fbbf24",
+ ringPaused: "#94a3b8",
+} as const;
+
+/** Carpet tints per department — soft, desaturated, readable next to wood. */
+export const DEPARTMENT_TINTS = ["#9aa6b8", "#a9b59a", "#b8a39a", "#a39ab8", "#9ab5b1", "#b8b19a"] as const;
diff --git a/jarvis/ui/web/frontend/src/components/society/office/screenTextures.ts b/jarvis/ui/web/frontend/src/components/society/office/screenTextures.ts
new file mode 100644
index 0000000000..540bd7cdb9
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/society/office/screenTextures.ts
@@ -0,0 +1,67 @@
+/**
+ * Monitor faces, drawn once on a 2D canvas and shared by every desk.
+ *
+ * The screen tells the agent's state at a glance, like the status pill:
+ * code lines while working, a friendly face while idle, an amber prompt while
+ * waiting for the person, a dark glass when paused or when the desk is empty.
+ */
+import { CanvasTexture, SRGBColorSpace, type Texture } from "three";
+import type { AgentRunState } from "../data";
+
+export type ScreenFace = AgentRunState | "empty";
+
+const cache = new Map<ScreenFace, Texture | null>();
+
+function draw(face: ScreenFace, ctx: CanvasRenderingContext2D, w: number, h: number): void {
+ ctx.fillStyle = face === "paused" || face === "empty" ? "#15181e" : face === "waiting" ? "#2a2413" : "#1b2a44";
+ ctx.fillRect(0, 0, w, h);
+ if (face === "working") {
+ const colours = ["#7dd3fc", "#a7f3d0", "#fcd34d", "#f9a8d4", "#c4b5fd"];
+ for (let line = 0; line < 9; line += 1) {
+ const indent = [0, 1, 1, 2, 2, 1, 0, 1, 2][line] * 10;
+ const length = 30 + ((line * 37) % 60);
+ ctx.fillStyle = colours[line % colours.length];
+ ctx.fillRect(10 + indent, 9 + line * 12, length, 5);
+ }
+ } else if (face === "idle") {
+ // The friendly "^ ^" face of an idle machine.
+ ctx.strokeStyle = "#9cc8ff";
+ ctx.lineWidth = 6;
+ ctx.lineCap = "round";
+ for (const cx of [w * 0.36, w * 0.64]) {
+ ctx.beginPath();
+ ctx.moveTo(cx - 9, h * 0.48);
+ ctx.lineTo(cx, h * 0.38);
+ ctx.lineTo(cx + 9, h * 0.48);
+ ctx.stroke();
+ }
+ ctx.beginPath();
+ ctx.arc(w / 2, h * 0.58, 12, 0.15 * Math.PI, 0.85 * Math.PI);
+ ctx.stroke();
+ } else if (face === "waiting") {
+ ctx.fillStyle = "#fbbf24";
+ for (const dx of [-18, 0, 18]) {
+ ctx.beginPath();
+ ctx.arc(w / 2 + dx, h / 2, 5, 0, Math.PI * 2);
+ ctx.fill();
+ }
+ }
+}
+
+/** The shared texture for a face; null where no 2D canvas exists (tests, bare hosts). */
+export function screenTexture(face: ScreenFace): Texture | null {
+ if (cache.has(face)) return cache.get(face) ?? null;
+ let texture: Texture | null = null;
+ const canvas = typeof document !== "undefined" ? document.createElement("canvas") : null;
+ const ctx = canvas?.getContext("2d") ?? null;
+ if (canvas && ctx) {
+ canvas.width = 128;
+ canvas.height = 128;
+ draw(face, ctx, canvas.width, canvas.height);
+ const made = new CanvasTexture(canvas);
+ made.colorSpace = SRGBColorSpace;
+ texture = made;
+ }
+ cache.set(face, texture);
+ return texture;
+}
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 bd867cba80..28d80ab1e3 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/society/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/de.json
@@ -718,6 +718,27 @@
"cloud": "Wolke",
"drop": "Tropfen"
}
+ },
+ "office": {
+ "title": "Agenten-Büro",
+ "subtitle": "{0} Agenten im Büro",
+ "viewport": "Karte des Agenten-Büros",
+ "loading": "Das Büro wird eingerichtet…",
+ "no_graphics": "3D-Darstellung ist hier nicht verfügbar. Den Status aller Agenten siehst du weiterhin in der Agentenliste.",
+ "count_working": "{0} arbeiten",
+ "count_waiting": "{0} warten",
+ "count_idle": "{0} frei",
+ "state_working": "Arbeitet",
+ "state_idle": "Frei",
+ "state_waiting": "Wartet auf dich",
+ "state_paused": "Pausiert",
+ "open_agent": "{0} öffnen",
+ "overview": "Übersicht",
+ "ledger": "Agentenliste",
+ "help": "Ziehen zum Drehen · Rechts ziehen zum Verschieben · Scrollen zum Zoomen · Agent anklicken zum Öffnen",
+ "sample": "Beispiel-Agenten – das Backend ist noch nicht erreichbar.",
+ "overflow": "Nur die ersten {0} Agenten haben einen Schreibtisch; die Liste zeigt alle.",
+ "open_space": "Open Space"
}
}
}
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 5c8edd6b90..483247418a 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/society/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/en.json
@@ -718,6 +718,27 @@
"cloud": "Cloud",
"drop": "Drop"
}
+ },
+ "office": {
+ "title": "Agent office",
+ "subtitle": "{0} agents on the floor",
+ "viewport": "Agent office map",
+ "loading": "Setting up the office…",
+ "no_graphics": "3D rendering is unavailable here. Every agent's status stays available in the agents list.",
+ "count_working": "{0} working",
+ "count_waiting": "{0} waiting",
+ "count_idle": "{0} idle",
+ "state_working": "Working",
+ "state_idle": "Idle",
+ "state_waiting": "Waiting for you",
+ "state_paused": "Paused",
+ "open_agent": "Open {0}",
+ "overview": "Overview",
+ "ledger": "Agents list",
+ "help": "Drag to rotate · Right-drag to pan · Scroll to zoom · Click an agent to open it",
+ "sample": "Sample agents — the backend is not reachable yet.",
+ "overflow": "Only the first {0} agents have a desk; the list shows everyone.",
+ "open_space": "Open space"
}
}
}
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 f310f30b38..63e958e256 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/society/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/es.json
@@ -718,6 +718,27 @@
"cloud": "Nube",
"drop": "Gota"
}
+ },
+ "office": {
+ "title": "Oficina de agentes",
+ "subtitle": "{0} agentes en la oficina",
+ "viewport": "Mapa de la oficina de agentes",
+ "loading": "Preparando la oficina…",
+ "no_graphics": "El renderizado 3D no está disponible aquí. El estado de cada agente sigue en la lista de agentes.",
+ "count_working": "{0} trabajando",
+ "count_waiting": "{0} esperando",
+ "count_idle": "{0} libres",
+ "state_working": "Trabajando",
+ "state_idle": "Libre",
+ "state_waiting": "Te espera",
+ "state_paused": "En pausa",
+ "open_agent": "Abrir {0}",
+ "overview": "Vista general",
+ "ledger": "Lista de agentes",
+ "help": "Arrastra para girar · Clic derecho para desplazar · Rueda para zoom · Clic en un agente para abrirlo",
+ "sample": "Agentes de ejemplo: el backend aún no está disponible.",
+ "overflow": "Solo los primeros {0} agentes tienen escritorio; la lista muestra a todos.",
+ "open_space": "Espacio abierto"
}
}
}
diff --git a/jarvis/ui/web/frontend/src/views/JarvisAgentsView.test.tsx b/jarvis/ui/web/frontend/src/views/JarvisAgentsView.test.tsx
index 3d8ab4df6e..79b76cf8f2 100644
--- a/jarvis/ui/web/frontend/src/views/JarvisAgentsView.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/JarvisAgentsView.test.tsx
@@ -4,25 +4,24 @@ import { JarvisAgentsView } from "./JarvisAgentsView";
vi.mock("@/i18n", () => ({ useLocaleChunk: () => true }));
vi.mock("@/components/society/world/WorldStage", () => ({ WorldStage: () => { throw new Error("Legacy world must not mount"); } }));
-vi.mock("@/components/society/mars/MarsWorldStage", () => ({ MarsWorldStage: ({ onOpenLedger, onOpenStation, stationPanel }: any) => <div data-testid="mars-map"><button onClick={onOpenLedger}>Open agents</button><button onClick={onOpenStation}>Open station</button>{stationPanel}</div> }));
-vi.mock("@/components/society/mars/MarsStationPanel", () => ({ MarsStationPanel: ({ onClose }: any) => <aside aria-label="Mars station"><button onClick={onClose}>Close station</button></aside> }));
+vi.mock("@/components/society/mars/MarsWorldStage", () => ({ MarsWorldStage: () => { throw new Error("Mars must not mount as the map"); } }));
+vi.mock("@/components/society/office/OfficeStage", () => ({ OfficeStage: ({ onOpenLedger, onSelectAgent }: any) => <div data-testid="office-map"><button onClick={onOpenLedger}>Open agents</button><button onClick={() => onSelectAgent("a1")}>Agent a1</button></div> }));
const initialUrl = window.location.href;
afterEach(() => { cleanup(); window.history.replaceState(null, "", initialUrl); });
-it.each(["?view=agents", "?view=agents&world=legacy", "?view=agents&world=mars"])("uses only Mars in the normal app for %s", async (url) => {
+it.each(["?view=agents", "?view=agents&world=legacy", "?view=agents&world=mars"])("mounts only the office for %s", async (url) => {
window.history.replaceState(null, "", url);
const openAgents = vi.fn();
render(<JarvisAgentsView onOpenAgents={openAgents} />);
- expect(await screen.findByTestId("mars-map")).toBeTruthy();
+ expect(await screen.findByTestId("office-map")).toBeTruthy();
expect(screen.queryByRole("button", { name: /previous|preview/i })).toBeNull();
fireEvent.click(screen.getByText("Open agents"));
expect(openAgents).toHaveBeenCalledOnce();
});
-it("keeps the station usable within the replacement map", async () => {
- render(<JarvisAgentsView onOpenAgents={() => undefined} />);
- fireEvent.click(await screen.findByText("Open station"));
- expect(await screen.findByRole("complementary", { name: "Mars station" })).toBeTruthy();
- fireEvent.click(screen.getByText("Close station"));
- expect(screen.queryByRole("complementary", { name: "Mars station" })).toBeNull();
+it("forwards an agent picked in the office", async () => {
+ const onSelect = vi.fn();
+ render(<JarvisAgentsView onOpenAgents={() => undefined} onSelectAgent={onSelect} />);
+ fireEvent.click(await screen.findByText("Agent a1"));
+ expect(onSelect).toHaveBeenCalledWith("a1");
});
diff --git a/jarvis/ui/web/frontend/src/views/JarvisAgentsView.tsx b/jarvis/ui/web/frontend/src/views/JarvisAgentsView.tsx
index 3bc891bc8b..4a728e001a 100644
--- a/jarvis/ui/web/frontend/src/views/JarvisAgentsView.tsx
+++ b/jarvis/ui/web/frontend/src/views/JarvisAgentsView.tsx
@@ -1,10 +1,9 @@
/** Lazy map surface; the parent keeps the existing Agents workspace mounted. */
-import { Suspense, lazy, useCallback, useState } from "react";
+import { Suspense, lazy } from "react";
import { useLocaleChunk } from "@/i18n";
import type { PlaceId } from "@/components/society/world/islandLayout";
-const MarsWorldStage = lazy(() => import("@/components/society/mars/MarsWorldStage").then((m) => ({ default: m.MarsWorldStage })));
-const MarsStationPanel = lazy(() => import("@/components/society/mars/MarsStationPanel").then((m) => ({ default: m.MarsStationPanel })));
+const OfficeStage = lazy(() => import("@/components/society/office/OfficeStage").then((m) => ({ default: m.OfficeStage })));
export interface JarvisAgentsViewProps {
onSelectAgent?: (agentId: string | null) => void;
@@ -14,16 +13,11 @@ export interface JarvisAgentsViewProps {
export function JarvisAgentsView({ onSelectAgent, onOpenAgents }: JarvisAgentsViewProps) {
const ready = useLocaleChunk("society");
- const [stationOpen, setStationOpen] = useState(false);
- const openStation = useCallback(() => setStationOpen(true), []);
if (!ready) return null;
return (
<div className="h-full min-h-0">
<Suspense fallback={<div className="h-full w-full animate-pulse bg-secondary" aria-hidden />}>
- <MarsWorldStage onOpenLedger={onOpenAgents}
- onSelectAgent={onSelectAgent} onOpenStation={openStation}
- stationPanel={stationOpen ? <MarsStationPanel onClose={() => setStationOpen(false)} onOpenAgent={onSelectAgent} /> : undefined}
- />
+ <OfficeStage onOpenLedger={onOpenAgents} onSelectAgent={onSelectAgent} />
</Suspense>
</div>
);