Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(agents): keep Map/Agents switch in caption on the island

rubenluetke10-beep6d2f29e84acb
diff --git a/jarvis/ui/web/frontend/src/components/society/world/WorldHud.tsx b/jarvis/ui/web/frontend/src/components/society/world/WorldHud.tsx
index c7f01e4ec1..26da3ac4e8 100644
--- a/jarvis/ui/web/frontend/src/components/society/world/WorldHud.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/world/WorldHud.tsx
@@ -1,10 +1,9 @@
/**
* The thin layer of DOM over the canvas: the population chip (top-left),
- * whatever the section hands in for the top-right corner (the World / Ledger
- * switch — app chrome, not world content), the controls hint, the zoom
- * buttons and the minimap (bottom-right).
+ * the controls hint, the zoom buttons and the minimap (bottom-right).
+ * The Map / Agents switch is app chrome and lives in the window caption —
+ * never in this HUD, where fullscreen would strand the user on the island.
*/
-import type { ReactNode } from "react";
import { Minus, Plus, RotateCcw, ScrollText } from "lucide-react";
import { fill, useT } from "@/i18n";
@@ -20,7 +19,6 @@ interface Props {
sample: boolean;
awake: boolean;
reducedMotion: boolean;
- topRight?: ReactNode;
/** The Quest Board button: how many quests are on the board and whether its drawer is open. */
questsOnBoard?: number;
questsOpen?: boolean;
@@ -32,7 +30,6 @@ export function WorldHud({
sample,
awake,
reducedMotion,
- topRight,
questsOnBoard = 0,
questsOpen = false,
onOpenQuests,
@@ -76,7 +73,6 @@ export function WorldHud({
{sample && <div className="sw-chip sw-chip-note">{t("society.world.sample_badge")}</div>}
{reducedMotion && <div className="sw-chip sw-chip-note">{t("society.world.reduced_motion_note")}</div>}
</div>
- {topRight ? <div className="sw-hud-topright">{topRight}</div> : null}
</div>
<div className="sw-hud-bottom">
<div className="sw-hint-row">
diff --git a/jarvis/ui/web/frontend/src/components/society/world/WorldStage.tsx b/jarvis/ui/web/frontend/src/components/society/world/WorldStage.tsx
index 1a7302272e..61b746e493 100644
--- a/jarvis/ui/web/frontend/src/components/society/world/WorldStage.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/world/WorldStage.tsx
@@ -18,7 +18,7 @@ import "@fontsource/pixelify-sans/500.css";
import "@fontsource/pixelify-sans/600.css";
import "./world.css";
-import { useCallback, useEffect, useRef, useState, type ReactNode } from "react";
+import { useCallback, useEffect, useRef, useState } from "react";
import { Canvas } from "@react-three/fiber";
import { useReducedMotion } from "framer-motion";
@@ -65,8 +65,6 @@ import { SKY } from "./worldPalette";
import { useWorldSettings } from "./worldSettings";
export interface WorldStageProps {
- /** App-chrome content for the HUD's top-right corner (the Map / Agents switch). */
- topRight?: ReactNode;
/** Where the fallback sends someone whose window cannot draw 3D. */
onOpenAgents: () => void;
/** A figure was clicked (or the selection cleared). The model card hooks in here. */
@@ -84,7 +82,7 @@ const CAMERA_START = cameraOffset();
/** Zoom step the island snaps to when it shows a newborn leaving the foundry. */
const SPAWN_ZOOM = 1;
-export function WorldStage({ topRight, onOpenAgents, onSelectAgent, onSelectPlace }: WorldStageProps) {
+export function WorldStage({ onOpenAgents, onSelectAgent, onSelectPlace }: WorldStageProps) {
const t = useT();
const ready = useLocaleChunk("society");
const hostRef = useRef<HTMLDivElement>(null);
@@ -239,7 +237,6 @@ export function WorldStage({ topRight, onOpenAgents, onSelectAgent, onSelectPlac
sample={sample}
awake={awake}
reducedMotion={reduced}
- topRight={topRight}
questsOnBoard={questsOnBoard}
questsOpen={questOpen}
onOpenQuests={() => {
diff --git a/jarvis/ui/web/frontend/src/views/JarvisAgentsView.tsx b/jarvis/ui/web/frontend/src/views/JarvisAgentsView.tsx
index 656064d4c4..560f3554d4 100644
--- a/jarvis/ui/web/frontend/src/views/JarvisAgentsView.tsx
+++ b/jarvis/ui/web/frontend/src/views/JarvisAgentsView.tsx
@@ -1,5 +1,5 @@
/** Lazy map surface for the Agents section. */
-import { Suspense, lazy, type ReactNode } from "react";
+import { Suspense, lazy } from "react";
import type { PlaceId } from "@/components/society/world/islandLayout";
const WorldStage = lazy(() =>
@@ -10,15 +10,13 @@ export interface JarvisAgentsViewProps {
onSelectAgent?: (agentId: string | null) => void;
onSelectPlace?: (place: PlaceId) => void;
onOpenAgents: () => void;
- /** App-chrome content floating over the canvas (the Map / Agents switch). */
- topRight?: ReactNode;
}
-export function JarvisAgentsView({ onSelectAgent, onSelectPlace, onOpenAgents, topRight }: JarvisAgentsViewProps) {
+export function JarvisAgentsView({ onSelectAgent, onSelectPlace, onOpenAgents }: JarvisAgentsViewProps) {
return (
<div className="h-full min-h-0">
<Suspense fallback={<div className="h-full w-full animate-pulse bg-secondary" aria-hidden />}>
- <WorldStage onOpenAgents={onOpenAgents} onSelectAgent={onSelectAgent} onSelectPlace={onSelectPlace} topRight={topRight} />
+ <WorldStage onOpenAgents={onOpenAgents} onSelectAgent={onSelectAgent} onSelectPlace={onSelectPlace} />
</Suspense>
</div>
);
diff --git a/jarvis/ui/web/frontend/src/views/society/SocietyView.test.tsx b/jarvis/ui/web/frontend/src/views/society/SocietyView.test.tsx
index 9041511efb..b231fe1333 100644
--- a/jarvis/ui/web/frontend/src/views/society/SocietyView.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/society/SocietyView.test.tsx
@@ -11,8 +11,8 @@ vi.mock("@/components/society/data", () => ({ useSocietyRoster: () => ({ data: {
{ agentId: "lead", name: "Lead", tier: "lead", state: "idle" },
{ agentId: "specialist", name: "Specialist", tier: "specialist", state: "idle" },
] }, isLoading: false }) }));
-vi.mock("@/views/JarvisAgentsView", () => ({ JarvisAgentsView: ({ onSelectAgent, onOpenAgents, topRight }: any) => (
- <div data-testid="map">{topRight}<button onClick={() => onSelectAgent("specialist")}>Map specialist</button><button onClick={onOpenAgents}>Map fallback</button></div>
+vi.mock("@/views/JarvisAgentsView", () => ({ JarvisAgentsView: ({ onSelectAgent, onOpenAgents }: any) => (
+ <div data-testid="map"><button onClick={() => onSelectAgent("specialist")}>Map specialist</button><button onClick={onOpenAgents}>Map fallback</button></div>
) }));
vi.mock("@/components/society/card/AgentCardOverlay", () => ({ AgentCardOverlay: ({ agent, embedded, onSelectAgent, onCreate, railHeader }: any) => (
<div data-testid="workspace" data-embedded={String(embedded)}>
@@ -77,22 +77,22 @@ it("opens map selections in Agents and keeps creation available", async () => {
});
-it("floats the Map/Agents switch without a second header bar", async () => {
+it("keeps the Map/Agents switch in the caption in both modes", async () => {
render(<SocietyView />);
- // Agents mode carries the switch in the window caption: no second bar, no
- // "Back to app" — the workspace expands straight under the caption.
+ // Agents mode: no second bar, no "Back to app" — the workspace expands
+ // straight under the caption, the switch rides centered in it.
expect(screen.queryByRole("button", { name: "settings_hub.back_to_app" })).toBeNull();
- const captionSwitch = screen.getByTestId("agents-mode-switch");
+ const captionSwitch = screen.getByTestId("mode-switch");
expect(within(captionSwitch).getByRole("tab", { name: "society.world.mode_map" })).toBeTruthy();
fireEvent.click(within(captionSwitch).getByRole("tab", { name: "society.world.mode_map" }));
- const map = await screen.findByTestId("map");
- // The switch rides along into the map HUD, so Map stays closable.
- expect(screen.queryByTestId("agents-mode-switch")).toBeNull();
+ await screen.findByTestId("map");
+ // Map mode takes the native window fullscreen: the switch stays in the
+ // caption instead of shrinking into the map HUD, so Agents stays reachable.
+ expect(screen.getByTestId("mode-switch")).toBeTruthy();
expect(screen.queryByRole("button", { name: "settings_hub.back_to_app" })).toBeNull();
- expect(within(map).getByRole("tab", { name: "society.roster.title" })).toBeTruthy();
- fireEvent.click(within(map).getByRole("tab", { name: "society.roster.title" }));
+ fireEvent.click(screen.getByRole("tab", { name: "society.roster.title" }));
expect(screen.queryByTestId("map")).toBeNull();
- expect(screen.getByTestId("agents-mode-switch")).toBeTruthy();
+ expect(screen.getByTestId("mode-switch")).toBeTruthy();
expect(screen.queryByRole("button", { name: "settings_hub.back_to_app" })).toBeNull();
});
@@ -101,7 +101,7 @@ it("navigates back through the window caption instead of a sections toggle", ()
expect(screen.queryByRole("button", { name: "society.world.toggle_sections" })).toBeNull();
expect(screen.queryByRole("button", { name: "settings_hub.back_to_app" })).toBeNull();
// The caption sidebar toggle (owned by TopBar) is the way back to the app.
- expect(screen.getByTestId("agents-mode-switch")).toBeTruthy();
+ expect(screen.getByTestId("mode-switch")).toBeTruthy();
});
it("requests fullscreen for Map and leaves it on Escape", async () => {
diff --git a/jarvis/ui/web/frontend/src/views/society/SocietyView.tsx b/jarvis/ui/web/frontend/src/views/society/SocietyView.tsx
index 9f0e86f79a..40da934d99 100644
--- a/jarvis/ui/web/frontend/src/views/society/SocietyView.tsx
+++ b/jarvis/ui/web/frontend/src/views/society/SocietyView.tsx
@@ -113,18 +113,20 @@ export function SocietyView() {
return (
<div className={mode === "world" ? "fixed inset-x-0 bottom-0 top-8 z-30 flex flex-col bg-background" : "flex h-full min-h-0 w-full flex-col"} data-testid="society-view">
<div className="flex min-h-0 min-w-0 flex-1 flex-col">
- {mode === "agents" && (
- <div className="pointer-events-none fixed inset-x-0 top-0 z-[130] flex h-8 items-center justify-center" data-testid="agents-mode-switch">
+ {/* Map mode takes the native window fullscreen, so the switch cannot
+ live inside the map HUD: it would shrink into the corner and strand
+ the user on the island. It rides in the window caption in BOTH
+ modes — one switch, always centered, always a way back. */}
+ <div className="pointer-events-none fixed inset-x-0 top-0 z-[130] flex h-8 items-center justify-center" data-testid="mode-switch">
<div className="pointer-events-auto">{modeSwitch}</div>
</div>
- )}
{fullscreenError && <p role="alert" className="bg-card px-4 py-2 text-sm text-destructive">{t("society.world.fullscreen_failed")}</p>}
{mode === "world" ? (
<div className="relative flex min-h-0 flex-1">
<div className="min-w-0 flex-1">
<CanvasActivity.Provider value={!openPlace && !creating}>
<Suspense fallback={null}>
- <JarvisAgentsBoard onSelectAgent={onIslandSelect} onSelectPlace={onIslandPlace} onOpenAgents={() => switchMode("agents")} topRight={modeSwitch} />
+ <JarvisAgentsBoard onSelectAgent={onIslandSelect} onSelectPlace={onIslandPlace} onOpenAgents={() => switchMode("agents")} />
</Suspense>
</CanvasActivity.Provider>
</div>