Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(society): the Quest Board monument in the market square, with its live drawer
rubenluetke10-beep6d1829f6ef02
diff --git a/jarvis/ui/web/frontend/src/components/society/world/QuestBoardDrawer.tsx b/jarvis/ui/web/frontend/src/components/society/world/QuestBoardDrawer.tsxnew file mode 100644index 0000000000..3013091d52--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/society/world/QuestBoardDrawer.tsx@@ -0,0 +1,277 @@+/**+ * What a click on the Quest Board opens: a composer to post a quest and the+ * board itself — what is being worked on, what waits, what is done — as a+ * drawer over the island (one-viewer doctrine: the world keeps living behind+ * it). The list is live: every change on the backend arrives as a push and+ * re-reads it within a second. The drawer is app chrome, so it wears the+ * theme tokens; only the state dots echo the monument's scroll colours.+ */+import { useEffect, useMemo, useState, type FormEvent } from "react";+import { ExternalLink, RotateCcw, X } from "lucide-react";++import { fill, useT } from "@/i18n";+import type { QuestState, SocietyQuestRow } from "@/lib/societyApi";+import { cn } from "@/lib/utils";+import { useEventStore } from "@/store/events";++import { useSocietyRoster } from "../data";+import { ageOf, groupQuests, takerKind, type QuestGroup } from "./questBoard";+import { useCancelQuest, usePostQuest, useRetryQuest, useSocietyQuests } from "./questsData";++const STATE_DOT: Record<QuestState, string> = {+ open: "#c9c2b2",+ assigned: "#ffb703",+ running: "#4cc9f0",+ done: "#06d6a0",+ failed: "#ff6f61",+ cancelled: "#8b8f9c",+};++const GROUPS: ReadonlyArray<{ key: QuestGroup; labelKey: string }> = [+ { key: "active", labelKey: "quest_group_active" },+ { key: "done", labelKey: "quest_group_done" },+ { key: "failed", labelKey: "quest_group_failed" },+ { key: "cancelled", labelKey: "quest_group_cancelled" },+];++function useNow(tickMs = 30_000): number {+ const [now, setNow] = useState(() => Date.now());+ useEffect(() => {+ const id = window.setInterval(() => setNow(Date.now()), tickMs);+ return () => window.clearInterval(id);+ }, [tickMs]);+ return now;+}++function QuestRow({+ row,+ agentName,+ agentColor,+ now,+}: {+ row: SocietyQuestRow;+ agentName: string | null;+ agentColor: string | null;+ now: number;+}) {+ const t = useT();+ const [open, setOpen] = useState(false);+ const cancel = useCancelQuest();+ const retry = useRetryQuest();+ const age = ageOf(row.done_ms ?? row.created_ms, now);+ const ageText =+ age.unit === "now" ? t("society.world.quest_age_now") : fill(t(`society.world.quest_age_${age.unit}`), { n: age.n });+ const kind = takerKind(row);+ const takerText =+ kind === "none"+ ? t("society.world.quest_no_taker")+ : fill(t(kind === "forged" ? "society.world.quest_forged" : "society.world.quest_taken_by"), {+ agent: agentName ?? row.agent_id ?? "",+ });+ const active = row.state === "open" || row.state === "assigned" || row.state === "running";+ const retryable = row.state === "failed" || row.state === "open";+ const handoff = row.result?.done || row.result?.text || "";+ const refusal = row.result?.status === "vetoed" ? row.result.reason || row.result.text || "" : "";++ return (+ <li className="rounded-md border border-border bg-background/60">+ <button+ type="button"+ onClick={() => setOpen((v) => !v)}+ className="flex w-full items-start gap-2.5 px-3 py-2 text-left"+ aria-expanded={open}+ >+ <span+ className={cn("mt-1.5 inline-block h-2.5 w-2.5 shrink-0 rounded-full", row.state === "running" && "animate-pulse")}+ style={{ background: STATE_DOT[row.state] }}+ aria-hidden+ />+ <span className="min-w-0 flex-1">+ <span className="block truncate text-sm font-medium text-foreground">{row.title}</span>+ <span className="mt-0.5 flex items-center gap-1.5 text-xs text-muted-foreground">+ {agentColor && <span className="inline-block h-2 w-2 rounded-sm" style={{ background: agentColor }} aria-hidden />}+ <span className="truncate">{takerText}</span>+ <span aria-hidden>·</span>+ <span className="shrink-0">{t(`society.world.quest_state.${row.state}`)}</span>+ <span aria-hidden>·</span>+ <span className="shrink-0 tabular-nums">{ageText}</span>+ </span>+ </span>+ </button>+ {open && (+ <div className="space-y-2 border-t border-border px-3 py-2 text-sm">+ <p className="whitespace-pre-wrap text-foreground">{row.text}</p>+ {handoff && (+ <div>+ <div className="text-xs font-medium uppercase tracking-wide text-muted-foreground">+ {t("society.world.quest_result_label")}+ </div>+ <p className="whitespace-pre-wrap text-foreground">{handoff}</p>+ </div>+ )}+ {row.result?.open && row.result.open.length > 0 && (+ <div>+ <div className="text-xs font-medium uppercase tracking-wide text-muted-foreground">+ {t("society.world.quest_open_label")}+ </div>+ <ul className="list-disc pl-4 text-foreground">+ {row.result.open.map((item) => (+ <li key={item}>{item}</li>+ ))}+ </ul>+ </div>+ )}+ {refusal && <p className="text-destructive">{fill(t("society.world.quest_refused"), { reason: refusal })}</p>}+ <div className="flex gap-2 pt-1">+ {active && (+ <button+ type="button"+ disabled={cancel.isPending}+ onClick={() => cancel.mutate([row.quest_id])}+ className="inline-flex h-7 items-center gap-1.5 rounded-md bg-secondary px-2.5 text-xs font-medium text-foreground hover:bg-muted disabled:opacity-50"+ >+ <X size={12} />+ {t("society.world.quest_cancel")}+ </button>+ )}+ {retryable && (+ <button+ type="button"+ disabled={retry.isPending}+ onClick={() => retry.mutate([row.quest_id])}+ className="inline-flex h-7 items-center gap-1.5 rounded-md bg-secondary px-2.5 text-xs font-medium text-foreground hover:bg-muted disabled:opacity-50"+ >+ <RotateCcw size={12} />+ {t("society.world.quest_retry")}+ </button>+ )}+ </div>+ {(cancel.isError || retry.isError) && (+ <p className="text-xs text-destructive">{String(cancel.error ?? retry.error)}</p>+ )}+ </div>+ )}+ </li>+ );+}++export function QuestBoardDrawer({ onClose }: { onClose: () => void }) {+ const t = useT();+ const setActiveSection = useEventStore((s) => s.setActiveSection);+ const quests = useSocietyQuests();+ const roster = useSocietyRoster();+ const post = usePostQuest();+ const [text, setText] = useState("");+ const now = useNow();++ useEffect(() => {+ const onKey = (e: KeyboardEvent) => {+ if (e.key === "Escape") onClose();+ };+ window.addEventListener("keydown", onKey);+ return () => window.removeEventListener("keydown", onKey);+ }, [onClose]);++ const agents = useMemo(() => {+ const byId = new Map<string, { name: string; color: string }>();+ for (const a of roster.data?.agents ?? []) byId.set(a.agentId, { name: a.name, color: a.palette.accent });+ return byId;+ }, [roster.data]);++ const groups = useMemo(() => groupQuests(quests.data ?? []), [quests.data]);+ const total = quests.data?.length ?? 0;++ const submit = (e: FormEvent) => {+ e.preventDefault();+ const clean = text.trim();+ if (!clean || post.isPending) return;+ post.mutate([clean, ""], { onSuccess: () => setText("") });+ };++ return (+ <aside+ className="absolute inset-y-3 right-3 z-30 flex w-[360px] max-w-[85%] flex-col overflow-hidden rounded-lg border border-border bg-popover text-foreground shadow-float"+ role="dialog"+ aria-label={t("society.world.drawer_quests_title")}+ >+ <header className="flex items-start justify-between gap-3 border-b border-border px-4 py-3">+ <div className="min-w-0">+ <h2 className="font-display text-base font-semibold tracking-tight">{t("society.world.drawer_quests_title")}</h2>+ <p className="mt-0.5 text-xs text-muted-foreground">{t("society.world.drawer_quests_hint")}</p>+ </div>+ <button+ type="button"+ onClick={onClose}+ aria-label={t("society.world.quest_close")}+ className="rounded-md p-1 text-muted-foreground hover:bg-muted hover:text-foreground"+ >+ <X size={16} />+ </button>+ </header>+ <form onSubmit={submit} className="border-b border-border px-4 py-3">+ <label htmlFor="sw-quest-text" className="sr-only">+ {t("society.world.quest_post")}+ </label>+ <textarea+ id="sw-quest-text"+ value={text}+ onChange={(e) => setText(e.target.value)}+ onKeyDown={(e) => {+ if ((e.metaKey || e.ctrlKey) && e.key === "Enter") submit(e);+ }}+ rows={3}+ placeholder={t("society.world.quest_compose_placeholder")}+ className="w-full resize-none rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"+ />+ <div className="mt-2 flex items-center justify-between gap-2">+ <span className="text-xs text-muted-foreground">{t("society.world.quest_compose_hint")}</span>+ <button+ type="submit"+ disabled={!text.trim() || post.isPending}+ className="inline-flex h-8 items-center rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50"+ >+ {post.isPending ? t("society.world.quest_posting") : t("society.world.quest_post")}+ </button>+ </div>+ {post.isError && <p className="mt-1.5 text-xs text-destructive">{String(post.error)}</p>}+ </form>+ <div className="min-h-0 flex-1 overflow-y-auto px-4 py-3">+ {quests.isLoading && <p className="text-sm text-muted-foreground">{t("society.world.quest_loading")}</p>}+ {quests.isError && <p className="text-sm text-destructive">{String(quests.error)}</p>}+ {quests.data && total === 0 && <p className="text-sm text-muted-foreground">{t("society.world.quest_empty")}</p>}+ {GROUPS.filter((g) => groups[g.key].length > 0).map((g) => (+ <section key={g.key} className="mb-4">+ <h3 className="mb-1.5 flex items-center gap-2 text-xs font-medium uppercase tracking-wide text-muted-foreground">+ {t(`society.world.${g.labelKey}`)}+ <span className="tabular-nums">{groups[g.key].length}</span>+ </h3>+ <ul className="space-y-1.5">+ {groups[g.key].map((row) => {+ const agent = row.agent_id ? agents.get(row.agent_id) : undefined;+ return (+ <QuestRow+ key={row.quest_id}+ row={row}+ agentName={agent?.name ?? null}+ agentColor={agent?.color ?? null}+ now={now}+ />+ );+ })}+ </ul>+ </section>+ ))}+ </div>+ <footer className="border-t border-border px-4 py-3">+ <button+ type="button"+ onClick={() => setActiveSection("agents")}+ className="inline-flex h-8 items-center gap-2 rounded-md bg-secondary px-3 text-sm font-medium text-foreground hover:bg-muted"+ >+ <ExternalLink size={14} />+ {t("society.world.quest_open_ledger")}+ </button>+ </footer>+ </aside>+ );+}diff --git a/jarvis/ui/web/frontend/src/components/society/world/QuestMonument.tsx b/jarvis/ui/web/frontend/src/components/society/world/QuestMonument.tsxnew file mode 100644index 0000000000..417e3eb39f--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/society/world/QuestMonument.tsx@@ -0,0 +1,189 @@+/**+ * The Quest Board — the monument in the middle of the market square, where+ * the big tree used to stand. A stepped stone plinth, a tall pale obelisk+ * with a slowly turning rune band and a crystal that breathes on top, three+ * notice boards around it, and one floating scroll per quest on the board:+ * amber while it waits for a taker, blue while an agent works it. Click it+ * and the stage opens the Quest Board drawer.+ *+ * Everything is primitives from `worldMaterials.ts`; the quests come from+ * `questsData.ts` and arrive within a second of a change (SocietyQuestChanged).+ */+import { useEffect, useMemo, useRef, useState } from "react";+import { useFrame, useThree, type ThreeEvent } from "@react-three/fiber";+import { Group, Mesh } from "three";++import type { SocietyQuestRow } from "@/lib/societyApi";++import { useCameraStore } from "./cameraStore";+import { buildIsland, groundY } from "./islandLayout";+import { Block, useKit, type Kit } from "./WorldKit";+import { PAL } from "./worldMaterials";+import { boardScrolls } from "./questBoard";+import { useSocietyQuests } from "./questsData";++/** Radius of the hover/selection ring under the monument, in metres. */+const RING_R = 6.4;+/** Where the floating scrolls orbit, in metres from the obelisk. */+const SCROLL_R = 3.4;++const SCROLL_COLOR: Record<SocietyQuestRow["state"], string> = {+ open: PAL.wall,+ assigned: PAL.beacon,+ running: PAL.glass,+ done: PAL.wall,+ failed: PAL.wall,+ cancelled: PAL.wall,+};++function NoticeBoard({ kit, angle, lit }: { kit: Kit; angle: number; lit: boolean }) {+ const r = 5.6;+ const x = Math.sin(angle) * r;+ const z = Math.cos(angle) * r;+ return (+ <group position={[x, 0, z]} rotation={[0, angle, 0]}>+ {/* two posts */}+ <Block kit={kit} at={[-1.1, 1.1, 0]} size={[0.22, 2.2, 0.22]} color={PAL.woodDark} />+ <Block kit={kit} at={[1.1, 1.1, 0]} size={[0.22, 2.2, 0.22]} color={PAL.woodDark} />+ {/* the board and its parchment */}+ <Block kit={kit} at={[0, 1.55, 0]} size={[2.7, 1.5, 0.14]} color={PAL.wood} />+ <Block kit={kit} at={[0, 1.55, 0.1]} size={[2.3, 1.15, 0.05]} color={PAL.wall} />+ {/* three lines of "writing" */}+ {[0.3, 0, -0.3].map((dy) => (+ <Block key={dy} kit={kit} at={[-0.15, 1.55 + dy, 0.14]} size={[1.5 - Math.abs(dy), 0.08, 0.02]} color={PAL.trim} />+ ))}+ {/* a little roof that glows when the board carries a quest */}+ <Block kit={kit} at={[0, 2.42, 0.15]} size={[3.0, 0.14, 0.9]} color={PAL.wood} />+ <Block kit={kit} at={[0, 2.32, 0.55]} size={[2.6, 0.06, 0.12]} color={lit ? PAL.beacon : PAL.trim} glow={lit} />+ </group>+ );+}++function Scroll({+ kit,+ index,+ total,+ color,+ paused,+}: {+ kit: Kit;+ index: number;+ total: number;+ color: string;+ paused: boolean;+}) {+ const ref = useRef<Group>(null);+ const phase = (index / Math.max(1, total)) * Math.PI * 2;+ useFrame(({ clock }) => {+ if (!ref.current || paused) return;+ const t = clock.getElapsedTime();+ const a = phase + t * 0.25;+ ref.current.position.set(Math.sin(a) * SCROLL_R, 4.6 + Math.sin(t * 1.6 + phase) * 0.25, Math.cos(a) * SCROLL_R);+ ref.current.rotation.y = -a + Math.PI / 2;+ });+ return (+ <group ref={ref} position={[Math.sin(phase) * SCROLL_R, 4.6, Math.cos(phase) * SCROLL_R]}>+ {/* a rolled scroll: parchment tube with two wooden knobs and a coloured seal */}+ <mesh geometry={kit.g.cylinder} material={kit.m.lit(PAL.wall)} rotation={[0, 0, Math.PI / 2]} scale={[0.34, 1.1, 0.34]} />+ <mesh geometry={kit.g.cylinder} material={kit.m.lit(PAL.woodDark)} rotation={[0, 0, Math.PI / 2]} position={[0.62, 0, 0]} scale={[0.16, 0.16, 0.16]} />+ <mesh geometry={kit.g.cylinder} material={kit.m.lit(PAL.woodDark)} rotation={[0, 0, Math.PI / 2]} position={[-0.62, 0, 0]} scale={[0.16, 0.16, 0.16]} />+ <mesh geometry={kit.g.sphere} material={kit.m.glow(color)} position={[0, 0, 0.2]} scale={0.22} />+ </group>+ );+}++export function QuestMonument({+ paused,+ onClick,+ selected,+}: {+ paused: boolean;+ /** The monument was clicked — the stage opens the Quest Board. */+ onClick?: () => void;+ selected?: boolean;+}) {+ const kit = useKit();+ const gl = useThree((s) => s.gl);+ const [hover, setHover] = useState(false);+ const band = useRef<Mesh>(null);+ const crystal = useRef<Mesh>(null);+ const quests = useSocietyQuests();+ const scrolls = useMemo(() => boardScrolls(quests.data ?? []), [quests.data]);+ const working = scrolls.some((q) => q.state === "running");++ const { map } = buildIsland();+ const y = groundY(map, 1, 1);++ useFrame(({ clock }) => {+ if (paused) return;+ const t = clock.getElapsedTime();+ if (band.current) band.current.rotation.y = t * 0.35;+ if (crystal.current) {+ const pulse = 1 + Math.sin(t * (working ? 3.2 : 1.4)) * 0.08;+ crystal.current.scale.setScalar(0.9 * pulse);+ crystal.current.rotation.y = t * 0.8;+ }+ });++ useEffect(() => {+ if (!onClick) return;+ gl.domElement.style.cursor = hover ? "pointer" : "";+ return () => {+ gl.domElement.style.cursor = "";+ };+ }, [hover, gl, onClick]);++ const click = (e: ThreeEvent<MouseEvent>) => {+ if (!onClick) return;+ e.stopPropagation();+ if (useCameraStore.getState().dragging) return;+ onClick();+ };++ const lit = scrolls.length > 0;++ return (+ <group+ position={[0, y, 0]}+ onClick={click}+ onPointerOver={(e) => {+ e.stopPropagation();+ setHover(true);+ }}+ onPointerOut={() => setHover(false)}+ >+ {/* stepped stone plinth */}+ <mesh geometry={kit.g.cylinder} material={kit.m.lit(PAL.trim)} position={[0, 0.2, 0]} scale={[8.4, 0.4, 8.4]} />+ <mesh geometry={kit.g.cylinder} material={kit.m.lit(PAL.wallShade)} position={[0, 0.55, 0]} scale={[6.4, 0.3, 6.4]} />+ <mesh geometry={kit.g.cylinder} material={kit.m.lit(PAL.trim)} position={[0, 0.85, 0]} scale={[4.6, 0.3, 4.6]} />+ {/* the obelisk: a tapering pale shaft on a dark foot, capped by a copper pyramid */}+ <Block kit={kit} at={[0, 1.5, 0]} size={[2.6, 1.0, 2.6]} color={PAL.solar} />+ <mesh geometry={kit.g.cone} material={kit.m.lit(PAL.wall)} position={[0, 6.0, 0]} scale={[2.6, 9.0, 2.6]} />+ <mesh geometry={kit.g.cone} material={kit.m.lit(PAL.hubAccent)} position={[0, 10.9, 0]} scale={[1.05, 1.4, 1.05]} />+ {/* rune band: a turning glowing ring around the shaft */}+ <mesh ref={band} geometry={kit.g.ring} material={kit.m.glow(lit ? PAL.beacon : PAL.hubGlass)} position={[0, 3.6, 0]} rotation={[Math.PI / 2, 0, 0]} scale={[3.6, 3.6, 1.6]} />+ {/* four glowing rune slots on the shaft faces */}+ {[0, Math.PI / 2, Math.PI, -Math.PI / 2].map((a) => (+ <group key={a} rotation={[0, a, 0]}>+ <Block kit={kit} at={[0, 5.2, 1.0]} size={[0.5, 2.2, 0.06]} color={working ? PAL.glass : PAL.beacon} glow />+ </group>+ ))}+ {/* the crystal that breathes on top */}+ <mesh ref={crystal} geometry={kit.g.blob} material={kit.m.glow(working ? PAL.glassEmissive : PAL.beaconCore)} position={[0, 12.3, 0]} scale={0.9} />+ {/* three notice boards facing outward */}+ {[0, (Math.PI * 2) / 3, (Math.PI * 4) / 3].map((a, i) => (+ <NoticeBoard key={a} kit={kit} angle={a + Math.PI / 6} lit={lit && i < scrolls.length} />+ ))}+ {/* one scroll per quest on the board */}+ {scrolls.map((q, i) => (+ <Scroll key={q.quest_id} kit={kit} index={i} total={scrolls.length} color={SCROLL_COLOR[q.state]} paused={paused} />+ ))}+ {(hover || selected) && (+ <mesh position={[0, 0.06, 0]} rotation={[-Math.PI / 2, 0, 0]}>+ <ringGeometry args={[RING_R - 0.3, RING_R + 0.3, 48]} />+ <meshBasicMaterial color={selected ? "#ffd166" : "#fffaf0"} transparent opacity={0.85} />+ </mesh>+ )}+ </group>+ );+}diff --git a/jarvis/ui/web/frontend/src/components/society/world/Village.tsx b/jarvis/ui/web/frontend/src/components/society/world/Village.tsxindex 45834c935c..34840fc15f 100644--- a/jarvis/ui/web/frontend/src/components/society/world/Village.tsx+++ b/jarvis/ui/web/frontend/src/components/society/world/Village.tsx@@ -1,7 +1,7 @@/*** The market district: twelve solarpunk houses in a ring around the open- * square, the lead agent's hub at its head, the big tree with the round table- * in the middle, the hedge ring with its four gates, and the lamps.+ * square, the lead agent's hub at its head, the Quest Board monument with the+ * long table in the middle, the hedge ring with its four gates, and the lamps.** Everything is primitives from `worldMaterials.ts` — no asset files. The* building language (docs/agent-society/world-art-direction.md §4): white@@ -12,6 +12,7 @@ import { useFrame } from "@react-three/fiber";import { Color, InstancedMesh, Mesh, Object3D } from "three";import { buildIsland, groundY, type HousePlot, type Post } from "./islandLayout";+import { QuestMonument } from "./QuestMonument";import { Block, useKit, type Kit } from "./WorldKit";import { PAL } from "./worldMaterials";@@ -107,19 +108,25 @@ function Hub({ kit, paused }: { kit: Kit; paused: boolean }) {);}-/** The big tree in the middle of the square, the ring bench and the long table. */-function SquareCentre({ kit }: { kit: Kit }) {+/** The Quest Board in the middle of the square, the ring bench and the long table. */+function SquareCentre({+ kit,+ paused,+ onQuestClick,+ questOpen,+}: {+ kit: Kit;+ paused: boolean;+ onQuestClick?: () => void;+ questOpen?: boolean;+}) {const { map } = buildIsland();const y = groundY(map, 1, 1);return (<group position={[0, y, 0]}>- <mesh geometry={kit.g.cylinder} material={kit.m.lit(PAL.trunk)} position={[0, 2.6, 0]} scale={[1.8, 5.2, 1.8]} />- <mesh geometry={kit.g.blob} material={kit.m.lit(PAL.bigCanopy)} position={[0, 6.4, 0]} scale={[9.5, 6.5, 9.5]} />- <mesh geometry={kit.g.blob} material={kit.m.lit(PAL.bigCanopyLight)} position={[2.4, 7.8, 1.2]} scale={[5.5, 4.5, 5.5]} />- <mesh geometry={kit.g.blob} material={kit.m.lit(PAL.bigCanopy)} position={[-2.8, 7.4, -1.6]} scale={[5, 4, 5]} />- <mesh geometry={kit.g.blob} material={kit.m.lit(PAL.bigCanopyLight)} position={[0.4, 9.6, -0.6]} scale={[4.2, 3.4, 4.2]} />- {/* ring bench */}- <mesh geometry={kit.g.ring} material={kit.m.lit(PAL.bench)} position={[0, 0.45, 0]} rotation={[Math.PI / 2, 0, 0]} scale={[7.4, 7.4, 4]} />+ <QuestMonument paused={paused} onClick={onQuestClick} selected={questOpen} />+ {/* ring bench around the monument's plinth */}+ <mesh geometry={kit.g.ring} material={kit.m.lit(PAL.bench)} position={[0, 0.45, 0]} rotation={[Math.PI / 2, 0, 0]} scale={[10.2, 10.2, 4]} />{/* the long table on the south side, where everyone gathers */}<Block kit={kit} at={[0, 0.85, 8.5]} size={[10, 0.2, 1.8]} color={PAL.tableWood} /><Block kit={kit} at={[-4, 0.4, 8.5]} size={[0.4, 0.8, 1.4]} color={PAL.woodDark} />@@ -175,7 +182,16 @@ function Lamps({ kit, posts }: { kit: Kit; posts: Post[] }) {);}-export function Village({ paused }: { paused: boolean }) {+export function Village({+ paused,+ onQuestClick,+ questOpen,+}: {+ paused: boolean;+ /** The Quest Board monument was clicked — the stage opens its drawer. */+ onQuestClick?: () => void;+ questOpen?: boolean;+}) {const kit = useKit();const { content } = buildIsland();return (@@ -184,7 +200,7 @@ export function Village({ paused }: { paused: boolean }) {<House key={i} kit={kit} plot={plot} />))}<Hub kit={kit} paused={paused} />- <SquareCentre kit={kit} />+ <SquareCentre kit={kit} paused={paused} onQuestClick={onQuestClick} questOpen={questOpen} /><Hedges kit={kit} posts={content.hedges} /><Lamps kit={kit} posts={content.lamps} /></group>diff --git a/jarvis/ui/web/frontend/src/components/society/world/WorldStage.tsx b/jarvis/ui/web/frontend/src/components/society/world/WorldStage.tsxindex 3d119d0ed9..d5b98b94d7 100644--- a/jarvis/ui/web/frontend/src/components/society/world/WorldStage.tsx+++ b/jarvis/ui/web/frontend/src/components/society/world/WorldStage.tsx@@ -32,6 +32,7 @@ import { Clouds } from "./Clouds";import { Landmarks } from "./Landmarks";import { PlaceLabels } from "./PlaceLabels";import { HubDrawer } from "./HubDrawer";+import { QuestBoardDrawer } from "./QuestBoardDrawer";import { Shadowed } from "./Shadowed";import { SunRig } from "./SunRig";import { Terrain, Water } from "./Terrain";@@ -79,6 +80,7 @@ export function WorldStage({ topRight, onOpenLedger, onSelectAgent }: WorldStageconst sample = roster.data?.sample ?? true;const [selected, setSelected] = useState<string | null>(null);const [openHub, setOpenHub] = useState<KitPlace | null>(null);+ const [questOpen, setQuestOpen] = useState(false);useWorldControls(hostRef, webgl);@@ -142,10 +144,18 @@ export function WorldStage({ topRight, onOpenLedger, onSelectAgent }: WorldStage<Terrain /><Water paused={reduced} /><Shadowed>- <Village paused={reduced} />+ <Village+ paused={reduced}+ questOpen={questOpen}+ onQuestClick={() => {+ setOpenHub(null);+ setQuestOpen((cur) => !cur);+ }}+ /><Landmarkspaused={reduced}onHubClick={(p) => {+ setQuestOpen(false);const hub = asHub(p);if (hub) setOpenHub((cur) => (cur === hub ? null : hub));}}@@ -165,6 +175,7 @@ export function WorldStage({ topRight, onOpenLedger, onSelectAgent }: WorldStage<WorldHud agents={agents} sample={sample} awake={awake} reducedMotion={reduced} topRight={topRight} />)}{ready && openHub && <HubDrawer hub={openHub} onClose={() => setOpenHub(null)} />}+ {ready && questOpen && <QuestBoardDrawer onClose={() => setQuestOpen(false)} />}</div>);}diff --git a/jarvis/ui/web/frontend/src/components/society/world/questBoard.test.ts b/jarvis/ui/web/frontend/src/components/society/world/questBoard.test.tsnew file mode 100644index 0000000000..97f3ae2ace--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/society/world/questBoard.test.ts@@ -0,0 +1,68 @@+import { describe, expect, it } from "vitest";++import type { SocietyQuestRow } from "@/lib/societyApi";++import { ageOf, boardScrolls, groupQuests, takerKind } from "./questBoard";++function row(partial: Partial<SocietyQuestRow> & Pick<SocietyQuestRow, "quest_id" | "state">): SocietyQuestRow {+ return {+ title: partial.quest_id,+ text: partial.quest_id,+ created_by: "user",+ agent_id: null,+ trace_id: `quest:${partial.quest_id}`,+ assign_event_id: null,+ run_id: "",+ routing: {},+ result: {},+ created_ms: 0,+ updated_ms: 0,+ done_ms: null,+ ...partial,+ };+}++describe("questBoard", () => {+ it("groups active first, running before assigned before open, newest first within a state", () => {+ const rows = [+ row({ quest_id: "a", state: "open", created_ms: 1 }),+ row({ quest_id: "b", state: "running", created_ms: 2 }),+ row({ quest_id: "c", state: "assigned", created_ms: 3 }),+ row({ quest_id: "d", state: "running", created_ms: 4 }),+ row({ quest_id: "e", state: "done", created_ms: 5, done_ms: 50 }),+ row({ quest_id: "f", state: "done", created_ms: 6, done_ms: 60 }),+ row({ quest_id: "g", state: "failed", created_ms: 7 }),+ row({ quest_id: "h", state: "cancelled", created_ms: 8 }),+ ];+ const g = groupQuests(rows);+ expect(g.active.map((r) => r.quest_id)).toEqual(["d", "b", "c", "a"]);+ expect(g.done.map((r) => r.quest_id)).toEqual(["f", "e"]);+ expect(g.failed.map((r) => r.quest_id)).toEqual(["g"]);+ expect(g.cancelled.map((r) => r.quest_id)).toEqual(["h"]);+ });++ it("puts only active quests on the monument, oldest first, capped", () => {+ const rows = Array.from({ length: 12 }, (_, i) =>+ row({ quest_id: `q${i}`, state: i % 4 === 0 ? "done" : "open", created_ms: 100 - i }),+ );+ const scrolls = boardScrolls(rows, 5);+ expect(scrolls).toHaveLength(5);+ expect(scrolls.every((r) => r.state === "open")).toBe(true);+ expect(scrolls[0].created_ms).toBeLessThan(scrolls[4].created_ms);+ });++ it("ages coarsely", () => {+ expect(ageOf(1000, 1000 + 30_000)).toEqual({ unit: "now", n: 0 });+ expect(ageOf(0, 5 * 60_000)).toEqual({ unit: "min", n: 5 });+ expect(ageOf(0, 3 * 3_600_000)).toEqual({ unit: "h", n: 3 });+ expect(ageOf(0, 72 * 3_600_000)).toEqual({ unit: "d", n: 3 });+ });++ it("names the taker kind from the routing record", () => {+ expect(takerKind(row({ quest_id: "x", state: "open" }))).toBe("none");+ expect(takerKind(row({ quest_id: "x", state: "running", agent_id: "mailbox" }))).toBe("taken");+ expect(takerKind(row({ quest_id: "x", state: "running", agent_id: "mailbox", routing: { forged: true } }))).toBe(+ "forged",+ );+ });+});diff --git a/jarvis/ui/web/frontend/src/components/society/world/questBoard.ts b/jarvis/ui/web/frontend/src/components/society/world/questBoard.tsnew file mode 100644index 0000000000..6b053c6d90--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/society/world/questBoard.ts@@ -0,0 +1,56 @@+/**+ * The Quest Board's pure helpers — grouping, ordering and ages, kept out of+ * the drawer so `questBoard.test.ts` pins them without React or a canvas.+ */+import type { QuestState, SocietyQuestRow } from "@/lib/societyApi";++/** States a quest can still move out of — what the board shows first. */+export const ACTIVE_STATES: ReadonlySet<QuestState> = new Set(["open", "assigned", "running"]);++export type QuestGroup = "active" | "done" | "failed" | "cancelled";++export function groupOf(state: QuestState): QuestGroup {+ if (ACTIVE_STATES.has(state)) return "active";+ if (state === "done") return "done";+ if (state === "failed") return "failed";+ return "cancelled";+}++/** Display order: active first (running before assigned before open, newest first), then the rest newest first. */+export function groupQuests(rows: readonly SocietyQuestRow[]): Record<QuestGroup, SocietyQuestRow[]> {+ const out: Record<QuestGroup, SocietyQuestRow[]> = { active: [], done: [], failed: [], cancelled: [] };+ for (const row of rows) out[groupOf(row.state)].push(row);+ const rank: Record<QuestState, number> = { running: 0, assigned: 1, open: 2, done: 3, failed: 3, cancelled: 3 };+ out.active.sort((a, b) => rank[a.state] - rank[b.state] || b.created_ms - a.created_ms);+ for (const key of ["done", "failed", "cancelled"] as const) {+ out[key].sort((a, b) => (b.done_ms ?? b.updated_ms) - (a.done_ms ?? a.updated_ms));+ }+ return out;+}++/** Quests the monument shows as floating scrolls: the active ones, oldest first, capped. */+export function boardScrolls(rows: readonly SocietyQuestRow[], cap = 8): SocietyQuestRow[] {+ return rows+ .filter((r) => ACTIVE_STATES.has(r.state))+ .sort((a, b) => a.created_ms - b.created_ms)+ .slice(0, cap);+}++export type AgeUnit = "now" | "min" | "h" | "d";++/** A coarse age for a row: the unit and the count, for the locale to word. */+export function ageOf(fromMs: number, nowMs: number): { unit: AgeUnit; n: number } {+ const s = Math.max(0, Math.floor((nowMs - fromMs) / 1000));+ if (s < 60) return { unit: "now", n: 0 };+ const m = Math.floor(s / 60);+ if (m < 60) return { unit: "min", n: m };+ const h = Math.floor(m / 60);+ if (h < 48) return { unit: "h", n: h };+ return { unit: "d", n: Math.floor(h / 24) };+}++/** The routing line's shape: who took it and whether it was forged for this quest. */+export function takerKind(row: SocietyQuestRow): "forged" | "taken" | "none" {+ if (!row.agent_id) return "none";+ return row.routing?.forged ? "forged" : "taken";+}diff --git a/jarvis/ui/web/frontend/src/components/society/world/questsData.ts b/jarvis/ui/web/frontend/src/components/society/world/questsData.tsnew file mode 100644index 0000000000..af03aacc59--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/society/world/questsData.ts@@ -0,0 +1,76 @@+/**+ * The Quest Board's data seam: the list from `/api/society/quests`, kept+ * live by the `SocietyQuestChanged` push the WebSocket forwards (every+ * change re-reads within a second) with a slow poll as the safety net, and+ * the three mutations — post, cancel, retry — each of which invalidates the+ * list AND the roster, because a quest may have forged a new agent.+ */+import { useEffect } from "react";+import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";++import {+ cancelSocietyQuest,+ fetchSocietyQuests,+ postSocietyQuest,+ retrySocietyQuest,+ type SocietyQuestRow,+} from "@/lib/societyApi";+import { useEventStore } from "@/store/events";++export const QUESTS_QUERY_KEY = ["society", "quests"] as const;+/** The roster's key as `components/society/data.ts` spells it. */+const ROSTER_QUERY_KEY = ["society", "roster"] as const;++/** Bus event names that mean "the board changed" (jarvis/core/events.py). */+const QUEST_EVENTS = new Set(["SocietyQuestChanged"]);++export function useSocietyQuests(enabled = true) {+ const client = useQueryClient();+ const query = useQuery({+ queryKey: QUESTS_QUERY_KEY,+ queryFn: fetchSocietyQuests,+ enabled,+ staleTime: 2_000,+ refetchInterval: 10_000,+ });+ useEffect(() => {+ if (!enabled) return;+ let lastId: string | null = useEventStore.getState().events[0]?.id ?? null;+ return useEventStore.subscribe((state) => {+ const top = state.events[0];+ if (!top || top.id === lastId) return;+ lastId = top.id;+ if (!QUEST_EVENTS.has(top.name)) return;+ void client.invalidateQueries({ queryKey: QUESTS_QUERY_KEY });+ const payload = top.payload as { previous?: string } | undefined;+ // A quest that just left "open" may have forged its taker: refresh the roster.+ if (payload?.previous === "open") void client.invalidateQueries({ queryKey: ROSTER_QUERY_KEY });+ });+ }, [client, enabled]);+ return query;+}++function useQuestMutation<TArgs extends unknown[]>(fn: (...args: TArgs) => Promise<SocietyQuestRow>) {+ const client = useQueryClient();+ return useMutation({+ mutationFn: (args: TArgs) => fn(...args),+ onSuccess: async () => {+ await Promise.all([+ client.invalidateQueries({ queryKey: QUESTS_QUERY_KEY }),+ client.invalidateQueries({ queryKey: ROSTER_QUERY_KEY }),+ ]);+ },+ });+}++export function usePostQuest() {+ return useQuestMutation<[text: string, title: string]>((text, title) => postSocietyQuest(text, title));+}++export function useCancelQuest() {+ return useQuestMutation((questId: string) => cancelSocietyQuest(questId));+}++export function useRetryQuest() {+ return useQuestMutation((questId: string) => retrySocietyQuest(questId));+}diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex 52cad7c9b9..1fdfd73f2d 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -5143,7 +5143,42 @@"zoom_out": "Verkleinern","webgl_missing_title": "Die Insel braucht WebGL","webgl_missing_body": "Dieses Fenster kann gerade kein 3D zeichnen. Das Register zeigt dieselben Agenten als Tabelle.",- "open_ledger": "Register öffnen"+ "open_ledger": "Register öffnen",+ "place_quests": "Questtafel",+ "drawer_quests_title": "Questtafel",+ "drawer_quests_hint": "Gib einen Auftrag auf. Der passende Agent übernimmt ihn – passt niemand, schmiedet die Foundry einen.",+ "quest_compose_placeholder": "Was soll erledigt werden? Zum Beispiel: die fünf wichtigsten Mails von heute",+ "quest_compose_hint": "Strg+Enter schickt ab",+ "quest_post": "Quest aufgeben",+ "quest_posting": "Wird aufgegeben…",+ "quest_group_active": "Auf der Tafel",+ "quest_group_done": "Erledigt",+ "quest_group_failed": "Gescheitert",+ "quest_group_cancelled": "Abgebrochen",+ "quest_empty": "Noch keine Quests. Gib die erste auf.",+ "quest_state": {+ "open": "wartet auf jemanden",+ "assigned": "zugeteilt",+ "running": "in Arbeit",+ "done": "erledigt",+ "failed": "gescheitert",+ "cancelled": "abgebrochen"+ },+ "quest_taken_by": "{agent} hat sie übernommen",+ "quest_forged": "{agent} wurde dafür geschmiedet",+ "quest_no_taker": "Noch niemand konnte sie übernehmen",+ "quest_cancel": "Abbrechen",+ "quest_retry": "Erneut versuchen",+ "quest_result_label": "Übergabe",+ "quest_open_label": "Noch offen",+ "quest_refused": "Abgelehnt: {reason}",+ "quest_age_now": "gerade eben",+ "quest_age_min": "vor {n} Min.",+ "quest_age_h": "vor {n} Std.",+ "quest_age_d": "vor {n} Tagen",+ "quest_close": "Schließen",+ "quest_loading": "Tafel wird gelesen…",+ "quest_open_ledger": "Agenten-Register öffnen"},"style": {"modern": "Modern",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex eea924e205..bc51d30854 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -5143,7 +5143,42 @@"zoom_out": "Zoom out","webgl_missing_title": "The island needs WebGL","webgl_missing_body": "This window cannot draw 3D right now. The ledger shows the same agents as a table.",- "open_ledger": "Open the ledger"+ "open_ledger": "Open the ledger",+ "place_quests": "Quest Board",+ "drawer_quests_title": "Quest Board",+ "drawer_quests_hint": "Post a job. The agent who fits takes it — when nobody fits, the Foundry forges one.",+ "quest_compose_placeholder": "What should be done? For example: the five most important mails of today",+ "quest_compose_hint": "Ctrl+Enter posts",+ "quest_post": "Post quest",+ "quest_posting": "Posting…",+ "quest_group_active": "On the board",+ "quest_group_done": "Completed",+ "quest_group_failed": "Failed",+ "quest_group_cancelled": "Cancelled",+ "quest_empty": "No quests yet. Post the first one.",+ "quest_state": {+ "open": "waiting for a taker",+ "assigned": "assigned",+ "running": "in progress",+ "done": "done",+ "failed": "failed",+ "cancelled": "cancelled"+ },+ "quest_taken_by": "{agent} took it",+ "quest_forged": "{agent} was forged for it",+ "quest_no_taker": "Nobody could take it yet",+ "quest_cancel": "Cancel",+ "quest_retry": "Retry",+ "quest_result_label": "Handoff",+ "quest_open_label": "Still open",+ "quest_refused": "Refused: {reason}",+ "quest_age_now": "just now",+ "quest_age_min": "{n} min ago",+ "quest_age_h": "{n} h ago",+ "quest_age_d": "{n} d ago",+ "quest_close": "Close",+ "quest_loading": "Reading the board…",+ "quest_open_ledger": "Open the agents ledger"},"style": {"modern": "Modern",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex 1d8f4e3b3a..e958841941 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -5143,7 +5143,42 @@"zoom_out": "Alejar","webgl_missing_title": "La isla necesita WebGL","webgl_missing_body": "Esta ventana no puede dibujar 3D ahora. El registro muestra los mismos agentes como tabla.",- "open_ledger": "Abrir el registro"+ "open_ledger": "Abrir el registro",+ "place_quests": "Tablón de misiones",+ "drawer_quests_title": "Tablón de misiones",+ "drawer_quests_hint": "Publica un encargo. El agente adecuado lo toma; si nadie encaja, la Fundición forja uno.",+ "quest_compose_placeholder": "¿Qué hay que hacer? Por ejemplo: los cinco correos más importantes de hoy",+ "quest_compose_hint": "Ctrl+Intro publica",+ "quest_post": "Publicar misión",+ "quest_posting": "Publicando…",+ "quest_group_active": "En el tablón",+ "quest_group_done": "Completadas",+ "quest_group_failed": "Fallidas",+ "quest_group_cancelled": "Canceladas",+ "quest_empty": "Aún no hay misiones. Publica la primera.",+ "quest_state": {+ "open": "espera a alguien",+ "assigned": "asignada",+ "running": "en curso",+ "done": "hecha",+ "failed": "fallida",+ "cancelled": "cancelada"+ },+ "quest_taken_by": "{agent} la tomó",+ "quest_forged": "{agent} fue forjado para ella",+ "quest_no_taker": "Nadie ha podido tomarla aún",+ "quest_cancel": "Cancelar",+ "quest_retry": "Reintentar",+ "quest_result_label": "Entrega",+ "quest_open_label": "Pendiente",+ "quest_refused": "Rechazada: {reason}",+ "quest_age_now": "ahora mismo",+ "quest_age_min": "hace {n} min",+ "quest_age_h": "hace {n} h",+ "quest_age_d": "hace {n} d",+ "quest_close": "Cerrar",+ "quest_loading": "Leyendo el tablón…",+ "quest_open_ledger": "Abrir el registro de agentes"},"style": {"modern": "Moderno",diff --git a/jarvis/ui/web/frontend/src/lib/societyApi.ts b/jarvis/ui/web/frontend/src/lib/societyApi.tsindex c9a6e4ec0b..71107380ba 100644--- a/jarvis/ui/web/frontend/src/lib/societyApi.ts+++ b/jarvis/ui/web/frontend/src/lib/societyApi.ts@@ -151,3 +151,80 @@ export interface SocietyAgentRow {stats: { runs: number; total_cost_usd: number; last_active_ms: number | null };run_state?: RunState;}++/** One quest as GET /api/society/quests returns it (jarvis/society/quests.py). */+export interface SocietyQuestRow {+ quest_id: string;+ title: string;+ text: string;+ state: QuestState;+ created_by: string;+ /** The taker, once routed; null while nobody could take it. */+ agent_id: string | null;+ trace_id: string;+ assign_event_id: string | null;+ run_id: string;+ /** How the taker was chosen: reason ("focus-match" | "keyword-match" | "generalist" |+ * "orchestrator" | "forged:<capability>"), score, focus, forged. */+ routing: { reason?: string; score?: number; focus?: string[]; forged?: boolean; agent_id?: string };+ /** The handoff (status, done, output, open, text) or the typed refusal (reason, retry). */+ result: {+ status?: string;+ done?: string;+ output?: string[];+ open?: string[];+ text?: string;+ reason?: string;+ retry?: string;+ };+ created_ms: number;+ updated_ms: number;+ done_ms: number | null;+}++async function questJson<T>(url: string, init?: RequestInit): Promise<T> {+ const res = await fetch(url, init);+ if (!res.ok) {+ let detail = `HTTP ${res.status}`;+ try {+ const body = (await res.json()) as { detail?: unknown };+ if (typeof body.detail === "string") detail = body.detail;+ else if (body.detail && typeof body.detail === "object" && "detail" in body.detail)+ detail = String((body.detail as { detail: unknown }).detail);+ } catch {+ /* not JSON */+ }+ throw new Error(detail);+ }+ return (await res.json()) as T;+}++export async function fetchSocietyQuests(): Promise<SocietyQuestRow[]> {+ const body = await questJson<{ quests?: SocietyQuestRow[] }>("/api/society/quests");+ return Array.isArray(body.quests) ? body.quests : [];+}++export async function postSocietyQuest(text: string, title = ""): Promise<SocietyQuestRow> {+ const body = await questJson<{ quest: SocietyQuestRow }>("/api/society/quests", {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({ text, title }),+ });+ return body.quest;+}++export async function cancelSocietyQuest(questId: string): Promise<SocietyQuestRow> {+ const body = await questJson<{ quest: SocietyQuestRow }>(+ `/api/society/quests/${encodeURIComponent(questId)}/cancel`,+ { method: "POST" },+ );+ return body.quest;+}++export async function retrySocietyQuest(questId: string): Promise<SocietyQuestRow> {+ const body = await questJson<{ quest: SocietyQuestRow }>(+ `/api/society/quests/${encodeURIComponent(questId)}/retry`,+ { method: "POST" },+ );+ return body.quest;+}