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: float Map/Agents switch over canvas, slim Agents header

rubenluetke10-beep55789448f291
diff --git a/jarvis/ui/web/frontend/src/views/JarvisAgentsView.tsx b/jarvis/ui/web/frontend/src/views/JarvisAgentsView.tsx
index 560f3554d4..656064d4c4 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 } from "react";
+import { Suspense, lazy, type ReactNode } from "react";
import type { PlaceId } from "@/components/society/world/islandLayout";
const WorldStage = lazy(() =>
@@ -10,13 +10,15 @@ 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 }: JarvisAgentsViewProps) {
+export function JarvisAgentsView({ onSelectAgent, onSelectPlace, onOpenAgents, topRight }: 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} />
+ <WorldStage onOpenAgents={onOpenAgents} onSelectAgent={onSelectAgent} onSelectPlace={onSelectPlace} topRight={topRight} />
</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 d840652eb5..b782afac08 100644
--- a/jarvis/ui/web/frontend/src/views/society/SocietyView.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/society/SocietyView.test.tsx
@@ -1,6 +1,5 @@
-import { cleanup, fireEvent, render, screen } from "@testing-library/react";
+import { cleanup, fireEvent, render, screen, within } from "@testing-library/react";
import { afterEach, expect, it, vi } from "vitest";
-import { useSocietyShell } from "@/store/societyShell";
import { setMapFullscreen } from "@/lib/mapFullscreen";
import { LAST_AGENT_STORAGE_KEY } from "./lastAgent";
import { SocietyView } from "./SocietyView";
@@ -12,11 +11,12 @@ 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 }: any) => (
- <div data-testid="map"><button onClick={() => onSelectAgent("specialist")}>Map specialist</button><button onClick={onOpenAgents}>Map fallback</button></div>
+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("@/components/society/card/AgentCardOverlay", () => ({ AgentCardOverlay: ({ agent, embedded, onSelectAgent, onCreate }: any) => (
+vi.mock("@/components/society/card/AgentCardOverlay", () => ({ AgentCardOverlay: ({ agent, embedded, onSelectAgent, onCreate, railHeader }: any) => (
<div data-testid="workspace" data-embedded={String(embedded)}>
+ {railHeader}
<span>{agent.name}</span><input aria-label="Draft" />
<button onClick={() => onSelectAgent("specialist")}>Select specialist</button>
<button onClick={onCreate}>Create agent</button>
@@ -77,13 +77,24 @@ it("opens map selections in Agents and keeps creation available", async () => {
});
-it("starts with sections hidden and toggles them independently of the agent roster", () => {
+it("floats the Map/Agents switch over the map instead of a second header bar", async () => {
render(<SocietyView />);
- expect(useSocietyShell.getState().navigationOpen).toBe(false);
- fireEvent.click(screen.getByRole("button", { name: "society.world.toggle_sections" }));
- expect(useSocietyShell.getState().navigationOpen).toBe(true);
- fireEvent.click(screen.getByRole("button", { name: "society.world.toggle_sections" }));
- expect(useSocietyShell.getState().navigationOpen).toBe(false);
+ fireEvent.click(screen.getByRole("tab", { name: "society.world.mode_map" }));
+ const map = await screen.findByTestId("map");
+ // The section header bar (with "Back to app") is gone in Map mode: the
+ // canvas starts directly under the window caption.
+ expect(screen.queryByRole("button", { name: "settings_hub.back_to_app" })).toBeNull();
+ // The switch itself rides along into the map HUD, so Map stays closable.
+ expect(within(map).getByRole("tab", { name: "society.roster.title" })).toBeTruthy();
+ fireEvent.click(within(map).getByRole("tab", { name: "society.roster.title" }));
+ expect(screen.queryByTestId("map")).toBeNull();
+ expect(screen.getByRole("button", { name: "settings_hub.back_to_app" })).toBeTruthy();
+});
+
+it("offers a way back to the app instead of a sections toggle", () => {
+ render(<SocietyView />);
+ expect(screen.queryByRole("button", { name: "society.world.toggle_sections" })).toBeNull();
+ expect(screen.getByRole("button", { name: "settings_hub.back_to_app" })).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 dfac0df801..2c0a48f0c5 100644
--- a/jarvis/ui/web/frontend/src/views/society/SocietyView.tsx
+++ b/jarvis/ui/web/frontend/src/views/society/SocietyView.tsx
@@ -109,7 +109,7 @@ export function SocietyView() {
}, []);
const modeSwitch = (
- <div role="tablist" aria-label={t("society.world.mode_label")} className="flex items-center gap-0.5 rounded-md border border-border/60 p-0.5">
+ <div role="tablist" aria-label={t("society.world.mode_label")} className="flex items-center gap-0.5 rounded-md border border-border/60 bg-background/80 p-0.5 backdrop-blur-sm">
{(["world", "agents"] as const).map((value) => {
return <button key={value} type="button" role="tab" aria-selected={mode === value}
onClick={() => switchMode(value)}
@@ -123,17 +123,19 @@ 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="relative flex h-8 shrink-0 items-center px-2">
- {mode === "agents" && backToApp}
+ {backToApp}
<div className="absolute left-1/2 -translate-x-1/2">{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")} />
+ <JarvisAgentsBoard onSelectAgent={onIslandSelect} onSelectPlace={onIslandPlace} onOpenAgents={() => switchMode("agents")} topRight={modeSwitch} />
</Suspense>
</CanvasActivity.Provider>
</div>