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(wiki): make the memory maps worth looking at, and stop asking which mode
Ruben Lütke79f300e76386
diff --git a/jarvis/ui/web/frontend/src/components/ultrawiki/EntityGraph3D.tsx b/jarvis/ui/web/frontend/src/components/ultrawiki/EntityGraph3D.tsxindex 6fc608bbd4..7dbaae169e 100644--- a/jarvis/ui/web/frontend/src/components/ultrawiki/EntityGraph3D.tsx+++ b/jarvis/ui/web/frontend/src/components/ultrawiki/EntityGraph3D.tsx@@ -18,6 +18,7 @@import {useCallback,useEffect,+ useMemo,useRef,useState,type RefObject,@@ -28,6 +29,7 @@ import type { Object3D } from "three";import SpriteText from "three-spritetext";import { CENTRING_STRENGTH, createCentringForce } from "@/lib/graphForces";+import { endpointId as endpointKey } from "@/lib/wikiGraph";import type { Vec3 } from "@/lib/graphCamera";import { useGraphOrbit, type GraphCameraApi } from "@/hooks/useGraphOrbit";@@ -56,11 +58,47 @@ export interface ExploreRenderEdge {* the one that carries over, and it is the one that mattered: the topics that* hold the network together stay named, the long tail stays quiet.*/-const LABEL_RADIUS_FLOOR = 8;+const LABEL_RADIUS_FLOOR = 6;/** How much larger the selected topic draws, so it is findable at a glance. */const SELECTED_SCALE = 1.4;+/**+ * How much of the flat map's dot radius a sphere keeps.+ *+ * This number is the difference between a map and a bag of marbles, and the+ * arithmetic is worth writing down. What the eye sees is the PROJECTION: N+ * discs of radius r inside a cloud of radius R cover N·r²/R² of the frame.+ * At the flat map's radii (up to 12) with 250 topics in a cloud about 200+ * across, that is ninety per cent — a solid yellow wall with the network+ * hidden somewhere behind it. Every edge, every cluster, every gap was drawn+ * and then painted over.+ *+ * At 0.5 the same scene covers a few per cent and the structure is back. The+ * ORDER is untouched — a topic mentioned a hundred times is still visibly+ * bigger than one mentioned twice — which is the part that carries meaning.+ */+const SPHERE_SCALE = 0.5;++/**+ * The colour the scene clears to.+ *+ * Not transparent, and not by choice: once a post-processing pass is on the+ * composer the renderer clears opaque, so anything painted behind the canvas+ * in CSS is never seen again. A near-black with a blue cast does the same job+ * from inside — the frame reads as depth rather than as a switched-off screen,+ * and the warm nodes have something cold to sit against. The CSS layer stays+ * as the fallback for a machine where the bloom pass fails to load.+ */+const SPACE_COLOUR = "#05070d";++/** Focus colours: everything unrelated to what you point at recedes. */+const LINK_REST = "rgba(255, 214, 10, 0.16)";+const LINK_FOCUS = "#ffe680";+const LINK_FADED = "rgba(255, 214, 10, 0.03)";+const NODE_FADED = "#3a352a";+const PARTICLE_COLOUR = "#fff3c4";+export interface EntityGraph3DProps {graphData: { nodes: ExploreRenderNode[]; links: ExploreRenderEdge[] };width: number;@@ -85,6 +123,49 @@ export function EntityGraph3D({const selectedRef = useRef(selectedKey);selectedRef.current = selectedKey;+ // Pointing at a topic dims everything it never shared a moment with. On a+ // map this crowded that is not decoration — it is the only way to read one+ // topic's world out of a few hundred overlapping ones.+ const [hoverId, setHoverId] = useState<string | null>(null);+ const neighbours = useMemo(() => {+ const map = new Map<string, Set<string>>();+ const add = (from: string, to: string) => {+ const set = map.get(from) ?? new Set<string>();+ set.add(to);+ map.set(from, set);+ };+ for (const link of graphData.links) {+ const source = endpointKey(link.source);+ const target = endpointKey(link.target);+ if (!source || !target) continue;+ add(source, target);+ add(target, source);+ }+ return map;+ }, [graphData.links]);++ const isNearHover = useCallback(+ (id: string): boolean =>+ hoverId === null ||+ id === hoverId ||+ (neighbours.get(hoverId)?.has(id) ?? false),+ [hoverId, neighbours],+ );++ const touchesHover = useCallback(+ (link: ExploreRenderEdge): boolean =>+ hoverId !== null &&+ (endpointKey(link.source) === hoverId || endpointKey(link.target) === hoverId),+ [hoverId],+ );++ const handleNodeHover = useCallback(+ (node: NodeObject<ExploreRenderNode> | null) => {+ setHoverId(node ? String(node.id ?? "") : null);+ },+ [],+ );+// Forces are set once per data generation, never per tick: d3's setters walk// every node and every link, so per-frame calls are a tax on the simulation.const forcesConfiguredRef = useRef(false);@@ -106,15 +187,16 @@ export function EntityGraph3D({const anyRef = ref as any;const charge = anyRef.d3Force?.("charge");if (charge && typeof charge.strength === "function") {- charge.strength(-380);- // Bounded reach: past this distance a node is already outside the map- // and pushing it further only costs the camera its framing.- if (typeof charge.distanceMax === "function") charge.distanceMax(220);+ charge.strength(-650);+ // Wide enough to reach across a crowd of a few hundred topics. Capping+ // it below the cloud's own width means the outer nodes stop feeling any+ // push at all, and the crowd never opens up.+ if (typeof charge.distanceMax === "function") charge.distanceMax(420);}const link = anyRef.d3Force?.("link");if (link && typeof link.distance === "function") {- link.distance(75);- if (typeof link.strength === "function") link.strength(0.14);+ link.distance(110);+ if (typeof link.strength === "function") link.strength(0.1);}// A topic mentioned once, sharing a moment with nothing, has no link to// hold it. Without this it drifts out of the world and takes the camera@@ -136,25 +218,42 @@ export function EntityGraph3D({frameSignal,});+ /*+ * Framing has to be repeated, not done once.+ *+ * The camera is placed from where the nodes ARE, and for the first few+ * seconds after new data they are still flying apart. Frame once, too early,+ * and the camera is parked at the radius of a cloud that has since grown+ * around it — which is how the map ended up being viewed from the inside.+ * A short schedule costs nothing (each pass is one loop over the nodes) and+ * removes the entire class of "it depends when you looked".+ *+ * The window size is a dependency for the same reason: going full-window+ * changes the aspect ratio the distance was computed against.+ */useEffect(() => {if (graphData.nodes.length === 0) return;reframe();- // Backstop for a simulation that never reports a stop.- const timer = window.setTimeout(reframe, 2600);- return () => window.clearTimeout(timer);- }, [graphData, reframe]);+ const timers = [900, 2600, 5000, 8000].map((delay) =>+ window.setTimeout(reframe, delay),+ );+ return () => timers.forEach(window.clearTimeout);+ }, [graphData, reframe, width, height]);const nodeVal = useCallback((node: NodeObject<ExploreRenderNode>): number => {- const base = (node as ExploreRenderNode).radius;+ const base = (node as ExploreRenderNode).radius * SPHERE_SCALE;const radius = node.id === selectedRef.current ? base * SELECTED_SCALE : base;// Cubed, because the renderer takes the cube root to get a sphere radius —- // this is what makes the sphere exactly as wide as the flat map's dot.+ // so this is exactly `radius` in graph units.return radius ** 3;}, []);const nodeColor = useCallback(- (node: NodeObject<ExploreRenderNode>) => (node as ExploreRenderNode).colour,- [],+ (node: NodeObject<ExploreRenderNode>) => {+ const topic = node as ExploreRenderNode;+ return isNearHover(String(node.id ?? "")) ? topic.colour : NODE_FADED;+ },+ [isNearHover],);const nodeLabel = useCallback(@@ -175,9 +274,12 @@ export function EntityGraph3D({// Sized against the layout's spread, not the screen: the camera frames// the whole network, so a fixed pixel size would shrink into nothing on// a big corpus.- sprite.textHeight = selected ? 6 : 4.5;- const radius = selected ? topic.radius * SELECTED_SCALE : topic.radius;- sprite.position.set(0, -(radius + 2.5), 0);+ // Big, because the cloud is: a few hundred topics spread over a couple+ // of thousand graph units means a label of six units is a smudge.+ sprite.textHeight = selected ? 22 : 16;+ const radius =+ (selected ? topic.radius * SELECTED_SCALE : topic.radius) * SPHERE_SCALE;+ sprite.position.set(0, -(radius + 4), 0);return sprite;},[],@@ -191,26 +293,80 @@ export function EntityGraph3D({);const linkWidth = useCallback(- (link: ExploreRenderEdge) => Math.min(0.2 + (link.weight ?? 1) * 0.08, 1.2),- [],+ (link: ExploreRenderEdge) =>+ touchesHover(link)+ ? 1.6+ : Math.min(0.2 + (link.weight ?? 1) * 0.08, 1.2),+ [touchesHover],);+ const linkColor = useCallback(+ (link: ExploreRenderEdge) => {+ if (hoverId === null) return LINK_REST;+ return touchesHover(link) ? LINK_FOCUS : LINK_FADED;+ },+ [hoverId, touchesHover],+ );++ // Only the hovered topic's world lights up. Nothing travels at rest here:+ // a co-occurrence network has thousands of edges, and a light on each of+ // them is a frame budget spent on confetti.+ const linkParticles = useCallback(+ (link: ExploreRenderEdge) => (touchesHover(link) ? 3 : 0),+ [touchesHover],+ );++ /**+ * The glow — the single change that turns a field of flat discs into+ * something with light in it. One post-processing pass on the composer the+ * renderer already exposes; the threshold sits below the warm end of the+ * recency ramp so recent topics bloom and old ones stay quiet, which makes+ * the encoding easier to read rather than harder.+ */+ useEffect(() => {+ let cancelled = false;+ let installed: { dispose?: () => void } | null = null;+ void (async () => {+ const [{ UnrealBloomPass }, { Vector2 }] = await Promise.all([+ import("three/examples/jsm/postprocessing/UnrealBloomPass.js"),+ import("three"),+ ]);+ const composer = graphRef.current?.postProcessingComposer?.();+ if (cancelled || !composer) return;+ const pass = new UnrealBloomPass(+ new Vector2(Math.max(width, 1), Math.max(height, 1)),+ 0.9,+ 0.8,+ 0.16,+ );+ composer.addPass(pass);+ installed = pass;+ })();+ return () => {+ cancelled = true;+ installed?.dispose?.();+ };+ // Once per mount: the pass follows the composer's own resizes, so re-adding+ // it per resize would only stack passes.+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, []);+return (// The wrapper is what the camera work listens on to know the user has// taken the wheel; the renderer paints into its own canvas inside it.- <div ref={hostRef} className="h-full w-full">+ <div ref={hostRef} className="wiki-space relative h-full w-full"><ForceGraph3D<ExploreRenderNode, ExploreRenderEdge>ref={graphRef}graphData={graphData}width={width || undefined}height={height || undefined}- backgroundColor="rgba(0,0,0,0)"+ backgroundColor={SPACE_COLOUR}nodeId="id"nodeRelSize={1}nodeVal={nodeVal}nodeColor={nodeColor}nodeLabel={nodeLabel}- nodeOpacity={0.9}+ nodeOpacity={0.92}nodeResolution={10}// A falsy return means "no extra object, just draw the sphere" — the// documented behaviour — but the typings insist on an Object3D. The cast@@ -223,18 +379,31 @@ export function EntityGraph3D({) => Object3D}nodeThreeObjectExtend- linkColor={() => "rgba(255, 214, 10, 0.28)"}- linkOpacity={0.22}+ linkColor={linkColor}+ linkOpacity={0.5}linkWidth={linkWidth}+ linkDirectionalParticles={linkParticles}+ linkDirectionalParticleSpeed={0.005}+ linkDirectionalParticleWidth={1.4}+ linkDirectionalParticleColor={() => PARTICLE_COLOUR}onNodeClick={handleNodeClick}+ onNodeHover={handleNodeHover}controlType="orbit"// English-only overlay baked into the library; this app ships in three// languages, and the switch's tooltip explains how to steer.showNavInfo={false}- cooldownTicks={80}+ // Long enough for a few hundred topics to actually finish spreading.+ // At 80 the simulation was called done while the cloud was still+ // opening, which froze the layout half-formed AND handed the camera a+ // radius that stopped being true a second later.+ cooldownTicks={220}onEngineTick={configureForces}onEngineStop={reframe}/>+ <div+ className="wiki-space-vignette pointer-events-none absolute inset-0"+ aria-hidden+ /></div>);}diff --git a/jarvis/ui/web/frontend/src/components/wiki/WikiGraph.tsx b/jarvis/ui/web/frontend/src/components/wiki/WikiGraph.tsxindex 43516dd374..8e30b8ffd2 100644--- a/jarvis/ui/web/frontend/src/components/wiki/WikiGraph.tsx+++ b/jarvis/ui/web/frontend/src/components/wiki/WikiGraph.tsx@@ -31,6 +31,7 @@ import {BROKEN_EDGE_COLOUR,clampCenterToView,NODE_COLOUR,+ endpointId,nodeSizeScore,sizeChanged,toGraphData,@@ -66,17 +67,6 @@ async function fetchGraph(): Promise<WikiGraphPayload> {return res.json();}-function endpointId(endpoint: unknown): string {- if (typeof endpoint === "string" || typeof endpoint === "number") {- return String(endpoint);- }- if (endpoint && typeof endpoint === "object" && "id" in endpoint) {- const id = (endpoint as { id?: unknown }).id;- return typeof id === "string" || typeof id === "number" ? String(id) : "";- }- return "";-}-function escapeTooltipText(value: string): string {return value.replace(/&/g, "&")diff --git a/jarvis/ui/web/frontend/src/components/wiki/WikiGraph3D.tsx b/jarvis/ui/web/frontend/src/components/wiki/WikiGraph3D.tsxindex 62a9ca18e5..59b91c742c 100644--- a/jarvis/ui/web/frontend/src/components/wiki/WikiGraph3D.tsx+++ b/jarvis/ui/web/frontend/src/components/wiki/WikiGraph3D.tsx@@ -35,6 +35,7 @@ import SpriteText from "three-spritetext";import {BROKEN_EDGE_COLOUR,NODE_COLOUR,+ endpointId,nodeSizeScore,type RenderEdge,type RenderNode,@@ -55,6 +56,36 @@ const LABEL_ALL_BELOW = 220;/** A hub, once the scene is too crowded to label everything. */const HUB_BACKLINKS = 2;+/**+ * How many links carry a travelling light at rest.+ *+ * The particles are what make the map look alive rather than photographed,+ * but each one is geometry the GPU draws every frame, and a vault with a+ * thousand wikilinks would spend the whole frame budget on decoration. So they+ * go to the busiest links — the ones that carry the structure — and the rest+ * stay quiet until you hover them.+ */+const AMBIENT_PARTICLE_LINKS = 90;++/** Colours for the focus state. Everything not near the pointer recedes. */+const LINK_REST = "rgba(106, 169, 255, 0.5)";+const LINK_FOCUS = "#9ecbff";+const LINK_FADED = "rgba(106, 169, 255, 0.06)";+const NODE_FADED = "#2c3340";+const PARTICLE_COLOUR = "#cfe4ff";++/**+ * The colour the scene clears to.+ *+ * Not transparent, and not by choice: once a post-processing pass is on the+ * composer the renderer clears opaque, so anything painted behind the canvas+ * in CSS is never seen again. A near-black with a blue cast does the same job+ * from inside — the frame reads as depth rather than as a switched-off screen.+ * The CSS layer stays as the fallback for a machine where the bloom pass fails+ * to load.+ */+const SPACE_COLOUR = "#05070d";+export interface WikiGraph3DProps {graphData: { nodes: RenderNode[]; links: RenderEdge[] };width: number;@@ -91,6 +122,61 @@ export function WikiGraph3D({const labelEverything = graphData.nodes.length <= LABEL_ALL_BELOW;+ // Pointing at a node dims everything it has nothing to do with. On a network+ // this dense that is not a flourish — it is the only way to read a single+ // page's neighbourhood out of a thousand crossing lines.+ const [hoverId, setHoverId] = useState<string | null>(null);+ const neighbours = useMemo(() => {+ const map = new Map<string, Set<string>>();+ const add = (from: string, to: string) => {+ const set = map.get(from) ?? new Set<string>();+ set.add(to);+ map.set(from, set);+ };+ for (const link of graphData.links) {+ const source = endpointId(link.source);+ const target = endpointId(link.target);+ if (!source || !target) continue;+ add(source, target);+ add(target, source);+ }+ return map;+ }, [graphData.links]);++ const isNearHover = useCallback(+ (id: string): boolean =>+ hoverId === null ||+ id === hoverId ||+ (neighbours.get(hoverId)?.has(id) ?? false),+ [hoverId, neighbours],+ );++ const touchesHover = useCallback(+ (link: RenderEdge): boolean =>+ hoverId !== null &&+ (endpointId(link.source) === hoverId || endpointId(link.target) === hoverId),+ [hoverId],+ );++ // The links that carry a travelling light while nothing is hovered: the+ // busiest ones, capped, so the effect scales to a vault of any size.+ const ambientParticleLinks = useMemo(() => {+ const weight = new Map<string, number>();+ for (const node of graphData.nodes) {+ weight.set(node.id, node.backlinkCount ?? 0);+ }+ return new Set(+ [...graphData.links]+ .filter((link) => !link.broken)+ .sort(+ (a, b) =>+ (weight.get(endpointId(b.target)) ?? 0) -+ (weight.get(endpointId(a.target)) ?? 0),+ )+ .slice(0, AMBIENT_PARTICLE_LINKS),+ );+ }, [graphData]);+// Forces are set once per data generation, never per tick — d3's setters// re-initialise the force over every node and every link, so calling them// per frame is an O(n) tax on the simulation. Same discipline as the flat@@ -153,14 +239,23 @@ export function WikiGraph3D({frameSignal,});- // The host asked for a reset, or the data changed under us.+ /*+ * The host asked for a reset, or the data changed under us — and framing has+ * to be repeated rather than done once. The camera is placed from where the+ * nodes ARE, and for the first few seconds after new data they are still+ * flying apart; framing once, too early, parks the camera at the radius of a+ * cloud that then grows around it. The window size is a dependency for the+ * same reason: going full-window changes the aspect ratio the distance was+ * computed against.+ */useEffect(() => {if (graphData.nodes.length === 0) return;reframe();- // A simulation that never reports a stop still gets framed.- const timer = window.setTimeout(reframe, 2600);- return () => window.clearTimeout(timer);- }, [graphData, resetSignal, reframe]);+ const timers = [900, 2600, 5000, 8000].map((delay) =>+ window.setTimeout(reframe, delay),+ );+ return () => timers.forEach(window.clearTimeout);+ }, [graphData, resetSignal, reframe, width, height]);const handleNodeClick = useCallback((node: NodeObject<RenderNode>): void => {@@ -182,11 +277,57 @@ export function WikiGraph3D({}, []);const nodeColor = useCallback(- (node: NodeObject<RenderNode>) =>- (node as RenderNode).colour ?? NODE_COLOUR.entity ?? "#8b95a7",- [],+ (node: NodeObject<RenderNode>) => {+ const own = (node as RenderNode).colour ?? NODE_COLOUR.entity ?? "#8b95a7";+ return isNearHover(String(node.id ?? "")) ? own : NODE_FADED;+ },+ [isNearHover],);+ /**+ * The glow.+ *+ * A force graph drawn as flat-shaded spheres reads as a diagram. The same+ * graph with the bright parts bleeding light reads as something with depth+ * and mass — and it costs one post-processing pass, because the renderer+ * already hands out its composer. The threshold is low so the node colours+ * themselves bloom, and the strength stays under the point where labels turn+ * into smears.+ *+ * Loaded on demand: the pass is part of three.js's addons, and this whole+ * component is already behind a lazy import, so a flat-map reader never+ * downloads a line of it.+ */+ useEffect(() => {+ let cancelled = false;+ let installed: { dispose?: () => void } | null = null;+ void (async () => {+ const [{ UnrealBloomPass }, { Vector2 }] = await Promise.all([+ import("three/examples/jsm/postprocessing/UnrealBloomPass.js"),+ import("three"),+ ]);+ const composer = graphRef.current?.postProcessingComposer?.();+ if (cancelled || !composer) return;+ const pass = new UnrealBloomPass(+ new Vector2(Math.max(width, 1), Math.max(height, 1)),+ // strength, radius, threshold+ 1.15,+ 0.85,+ 0.08,+ );+ composer.addPass(pass);+ installed = pass;+ })();+ return () => {+ cancelled = true;+ installed?.dispose?.();+ };+ // Deliberately once per mount: the pass reads the canvas size from the+ // composer on every resize itself, so re-adding it per resize would only+ // stack passes.+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, []);+const nodeThreeObject = useCallback((node: NodeObject<RenderNode>): SpriteText | null => {const rendered = node as RenderNode;@@ -213,11 +354,36 @@ export function WikiGraph3D({);const linkColor = useCallback(- (link: RenderEdge) =>- link.broken ? BROKEN_EDGE_COLOUR : "rgba(106, 169, 255, 0.55)",- [],+ (link: RenderEdge) => {+ if (hoverId !== null) {+ if (!touchesHover(link)) return LINK_FADED;+ return link.broken ? BROKEN_EDGE_COLOUR : LINK_FOCUS;+ }+ return link.broken ? BROKEN_EDGE_COLOUR : LINK_REST;+ },+ [hoverId, touchesHover],+ );++ const linkWidth = useCallback(+ (link: RenderEdge) => (touchesHover(link) ? 1.4 : 0.4),+ [touchesHover],);+ // Light travelling from source to target: direction you can read at a+ // glance, and the thing that makes the map look like it is running rather+ // than sitting there. Hovering floods the neighbourhood with it.+ const linkParticles = useCallback(+ (link: RenderEdge) => {+ if (hoverId !== null) return touchesHover(link) ? 4 : 0;+ return ambientParticleLinks.has(link) ? 2 : 0;+ },+ [ambientParticleLinks, hoverId, touchesHover],+ );++ const handleNodeHover = useCallback((node: NodeObject<RenderNode> | null) => {+ setHoverId(node ? String(node.id ?? "") : null);+ }, []);+// An unresolved link points at a page that does not exist, so an arrowhead// claiming a destination would be the wrong story; the rose colour carries// it instead — the same signal the flat map's dashes carry.@@ -235,14 +401,15 @@ export function WikiGraph3D({return (// The renderer paints into its own canvas; this wrapper is what the camera- // work listens on to know the user has taken the wheel.- <div ref={hostRef} className="h-full w-full">+ // work listens on to know the user has taken the wheel, and what carries+ // the space the network floats in (see .wiki-space in index.css).+ <div ref={hostRef} className="wiki-space relative h-full w-full"><ForceGraph3D<RenderNode, RenderEdge>ref={graphRef}graphData={data}width={width}height={height}- backgroundColor="rgba(0,0,0,0)"+ backgroundColor={SPACE_COLOUR}nodeId="id"nodeLabel={nodeLabel}nodeRelSize={NODE_REL_SIZE}@@ -261,12 +428,17 @@ export function WikiGraph3D({nodeThreeObjectExtendlinkLabel={linkLabel}linkColor={linkColor}- linkOpacity={0.5}- linkWidth={0.4}+ linkOpacity={0.6}+ linkWidth={linkWidth}linkDirectionalArrowLength={linkArrowLength}linkDirectionalArrowRelPos={0.85}linkDirectionalArrowColor={linkArrowColor}+ linkDirectionalParticles={linkParticles}+ linkDirectionalParticleSpeed={0.006}+ linkDirectionalParticleWidth={1.3}+ linkDirectionalParticleColor={() => PARTICLE_COLOUR}onNodeClick={handleNodeClick}+ onNodeHover={handleNodeHover}// Drag to rotate, wheel to zoom, right-drag to pan — the mapping people// already know from every other 3D viewer.controlType="orbit"@@ -281,6 +453,10 @@ export function WikiGraph3D({onEngineTick={configureForces}onEngineStop={reframe}/>+ <div+ className="wiki-space-vignette pointer-events-none absolute inset-0"+ aria-hidden+ /></div>);}diff --git a/jarvis/ui/web/frontend/src/index.css b/jarvis/ui/web/frontend/src/index.cssindex db4458fb4c..953b1eb393 100644--- a/jarvis/ui/web/frontend/src/index.css+++ b/jarvis/ui/web/frontend/src/index.css@@ -988,6 +988,43 @@);}+ /*+ * The space the 3D memory map floats in.+ *+ * The WebGL canvas is transparent on purpose, so everything behind it is+ * plain CSS: no textures to download, no extra draw calls, nothing for the+ * GPU to carry. Three layers, and each one earns its place —+ *+ * - a deep blue-black wash off centre, so the frame is a volume rather+ * than a flat black rectangle;+ * - two very faint dot fields at different sizes, which is what gives the+ * orbiting network something to move AGAINST. Without them a slow+ * rotation is nearly invisible: the nodes shift, but with no fixed+ * reference the eye reads it as drift rather than depth.+ * - a vignette that pulls the attention back to the middle.+ */+ .wiki-space {+ background-color: #05070c;+ background-image:+ radial-gradient(+ ellipse 120% 90% at 50% 42%,+ rgba(40, 78, 140, 0.22) 0%,+ rgba(14, 24, 44, 0.5) 45%,+ transparent 78%+ ),+ radial-gradient(circle at 18% 24%, rgba(255, 255, 255, 0.5) 0.6px, transparent 0.7px),+ radial-gradient(circle at 72% 68%, rgba(255, 255, 255, 0.35) 0.5px, transparent 0.6px);+ background-size: 100% 100%, 190px 190px, 97px 97px;+ }++ .wiki-space-vignette {+ background: radial-gradient(+ ellipse at 50% 50%,+ transparent 38%,+ rgba(0, 0, 0, 0.62) 100%+ );+ }+/* The floating control pills over the stage (floor slider, legend, counts).Glass rather than a solid card: the map has to stay visible underneath,or the controls become a second letterbox. */diff --git a/jarvis/ui/web/frontend/src/lib/wikiGraph.ts b/jarvis/ui/web/frontend/src/lib/wikiGraph.tsindex e5847498b0..99342b0db0 100644--- a/jarvis/ui/web/frontend/src/lib/wikiGraph.ts+++ b/jarvis/ui/web/frontend/src/lib/wikiGraph.ts@@ -199,6 +199,25 @@ export function nodeRadius(backlinkCount: number): number {return Math.max(8, Math.min(24, 8 + backlinkCount * 2));}+/**+ * The id at one end of a link.+ *+ * Links arrive from the API as plain id strings and are REPLACED in place by+ * the renderer with references to the node objects themselves once the+ * simulation ingests them. Any code that reads an endpoint therefore has to+ * cope with both shapes, and every renderer needs it — hence one definition.+ */+export function endpointId(endpoint: unknown): string {+ if (typeof endpoint === "string" || typeof endpoint === "number") {+ return String(endpoint);+ }+ if (endpoint && typeof endpoint === "object" && "id" in endpoint) {+ const id = (endpoint as { id?: unknown }).id;+ return typeof id === "string" || typeof id === "number" ? String(id) : "";+ }+ return "";+}+/*** How big a node draws, relative to its peers — the shared size encoding for* BOTH the flat map and the 3D one.diff --git a/jarvis/ui/web/frontend/src/views/WikiView.mode-memory.test.tsx b/jarvis/ui/web/frontend/src/views/WikiView.mode-memory.test.tsxnew file mode 100644index 0000000000..03d497d513--- /dev/null+++ b/jarvis/ui/web/frontend/src/views/WikiView.mode-memory.test.tsx@@ -0,0 +1,154 @@+/**+ * "Checking which wiki mode is active…" must not be the first thing the Wiki+ * tab shows every single time.+ *+ * The probe is honest — the section genuinely does not know which body it owns+ * until the backend answers — but the answer only changes when somebody flips+ * the mode switch, while this component remounts on every navigation away and+ * back. So the wait was being paid over and over for a fact that had not+ * moved. Remembering the last confirmed answer per machine removes the wait+ * without inventing anything: the live probe still overwrites it the moment it+ * disagrees.+ */+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { cleanup, render, screen, waitFor } from "@testing-library/react";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";++import { WikiView } from "@/views/WikiView";+import type { WikiTreeResponse } from "@/lib/wikiApi";++const ULTRA_MODE_KEY = "jarvis.wiki.lastUltraMode";++vi.mock("@/hooks/useWikiLive", () => ({+ useWikiLive: () => ({ connected: true, lastEventAt: null }),+}));++vi.mock("@/views/ultrawiki/UltraWikiPanel", () => ({+ UltraWikiPanel: () => <div data-testid="ultrawiki-panel-stub" />,+}));++vi.mock("@/components/wiki/WikiGraph", () => ({+ WikiGraph: () => <div data-testid="wiki-graph-stub" />,+}));++const EMPTY_TREE: WikiTreeResponse = {+ ok: true,+ vault_root: "wiki/obsidian-vault",+ folders: [],+ stats: { total_pages: 3, total_links: 4, last_curator_run: null },+};++/**+ * A backend that never answers the mode probe — the few seconds after a+ * restart, and the case the memory exists for.+ */+function installSilentStatus() {+ vi.stubGlobal(+ "fetch",+ vi.fn(async (input: unknown) => {+ const url = String(input);+ if (url.includes("/api/ultrawiki/status")) {+ return new Response("null", {+ status: 200,+ headers: { "content-type": "application/json" },+ });+ }+ if (url.includes("/api/wiki/tree")) {+ return new Response(JSON.stringify(EMPTY_TREE), {+ status: 200,+ headers: { "content-type": "application/json" },+ });+ }+ return new Response("{}", {+ status: 200,+ headers: { "content-type": "application/json" },+ });+ }),+ );+}++function renderWiki() {+ const client = new QueryClient({+ defaultOptions: { queries: { retry: false, gcTime: 0, staleTime: 0 } },+ });+ return render(+ <QueryClientProvider client={client}>+ <WikiView />+ </QueryClientProvider>,+ );+}++beforeEach(() => {+ window.localStorage.removeItem(ULTRA_MODE_KEY);+});++afterEach(() => {+ cleanup();+ vi.unstubAllGlobals();+ vi.restoreAllMocks();+ window.localStorage.removeItem(ULTRA_MODE_KEY);+});++describe("WikiView — remembering which mode this machine runs", () => {+ it("still waits on a genuinely first-ever visit", async () => {+ installSilentStatus();+ renderWiki();++ expect(await screen.findByTestId("wiki-mode-probe")).toBeDefined();+ expect(screen.queryByTestId("ultrawiki-panel-stub")).toBeNull();+ });++ it("renders Ultra straight away when this machine ran Ultra last time", async () => {+ window.localStorage.setItem(ULTRA_MODE_KEY, "ultra");+ installSilentStatus();+ renderWiki();++ expect(await screen.findByTestId("ultrawiki-panel-stub")).toBeDefined();+ expect(screen.queryByTestId("wiki-mode-probe")).toBeNull();+ });++ it("renders the normal wiki straight away when that is what ran last", async () => {+ window.localStorage.setItem(ULTRA_MODE_KEY, "normal");+ installSilentStatus();+ renderWiki();++ await waitFor(() => {+ expect(screen.queryByTestId("wiki-mode-probe")).toBeNull();+ });+ expect(screen.queryByTestId("ultrawiki-panel-stub")).toBeNull();+ expect(screen.getByTestId("wiki-workspace")).toBeDefined();+ });++ it("lets the backend overrule the memory", async () => {+ window.localStorage.setItem(ULTRA_MODE_KEY, "normal");+ vi.stubGlobal(+ "fetch",+ vi.fn(async (input: unknown) => {+ const url = String(input);+ if (url.includes("/api/ultrawiki/status")) {+ return new Response(JSON.stringify({ enabled: true, sources: [] }), {+ status: 200,+ headers: { "content-type": "application/json" },+ });+ }+ if (url.includes("/api/wiki/tree")) {+ return new Response(JSON.stringify(EMPTY_TREE), {+ status: 200,+ headers: { "content-type": "application/json" },+ });+ }+ return new Response("{}", {+ status: 200,+ headers: { "content-type": "application/json" },+ });+ }),+ );+ renderWiki();++ expect(await screen.findByTestId("ultrawiki-panel-stub")).toBeDefined();+ // ...and the corrected answer is what the next visit starts from.+ await waitFor(() => {+ expect(window.localStorage.getItem(ULTRA_MODE_KEY)).toBe("ultra");+ });+ });+});diff --git a/jarvis/ui/web/frontend/src/views/WikiView.tsx b/jarvis/ui/web/frontend/src/views/WikiView.tsxindex 2dd3fd07c6..10183a2a7b 100644--- a/jarvis/ui/web/frontend/src/views/WikiView.tsx+++ b/jarvis/ui/web/frontend/src/views/WikiView.tsx@@ -68,6 +68,34 @@ const UltraWikiPanel = lazy(() =>type CentreTab = "graph" | "page";+/**+ * Which wiki mode this machine saw last.+ *+ * A per-machine memory of a backend fact, kept for exactly one reason: to+ * render the right body immediately instead of a spinner. It is never the+ * authority — `GET /api/ultrawiki/status` is, and overwrites this the moment+ * it answers.+ */+const ULTRA_MODE_KEY = "jarvis.wiki.lastUltraMode";++function recallUltraMode(): boolean | null {+ try {+ const raw = window.localStorage.getItem(ULTRA_MODE_KEY);+ return raw === "ultra" ? true : raw === "normal" ? false : null;+ } catch {+ // Private mode / storage disabled — fall back to asking, as before.+ return null;+ }+}++function rememberUltraMode(enabled: boolean): void {+ try {+ window.localStorage.setItem(ULTRA_MODE_KEY, enabled ? "ultra" : "normal");+ } catch {+ // Losing the shortcut only costs one probe on the next visit.+ }+}+interface WikiToast {message: string;id: number;@@ -129,12 +157,26 @@ export function WikiView(): JSX.Element {const [lastKnownUltra, setLastKnownUltra] = useState<UltraWikiStatus | null>(null,);+ // ...and the last confirmed answer from a PREVIOUS visit, which is what+ // stops "Checking which wiki mode is active…" from being the first thing+ // the Wiki tab shows every single time. The probe is a few hundred+ // milliseconds on a warm backend and several seconds on a cold one, and+ // this component remounts on every navigation away and back — so without a+ // memory the wait was paid again and again for an answer that has not+ // changed since the mode was last switched. Remembering it is a claim we+ // can stand behind (it was true a moment ago) and the live probe still+ // corrects it the instant it disagrees.+ const [rememberedUltra, setRememberedUltra] = useState<boolean | null>(+ recallUltraMode,+ );const [unansweredProbes, setUnansweredProbes] = useState(0);const ultraProbe = ultraStatusQuery.data;const ultraProbeAt = ultraStatusQuery.dataUpdatedAt;useEffect(() => {if (ultraProbe) {setLastKnownUltra(ultraProbe);+ setRememberedUltra(ultraProbe.enabled);+ rememberUltraMode(ultraProbe.enabled);setUnansweredProbes(0);} else if (ultraProbeAt > 0) {setUnansweredProbes((n) => n + 1);@@ -142,8 +184,9 @@ export function WikiView(): JSX.Element {}, [ultraProbe, ultraProbeAt]);const ultraStatus = ultraProbe ?? lastKnownUltra;- const ultraModeKnown = ultraStatus != null;- const ultraEnabled = ultraStatus?.enabled === true;+ // Only a genuinely first-ever visit has nothing to go on and has to wait.+ const ultraModeKnown = ultraStatus != null || rememberedUltra != null;+ const ultraEnabled = ultraStatus?.enabled ?? rememberedUltra ?? false;// When a slug is selected (via tree click, graph click, or wikilink),// automatically swap to the page tab.@@ -154,6 +197,18 @@ export function WikiView(): JSX.Element {}}, [selectedSlug]);+ // Escape leaves the full-window map. With the nav rail covered it is the+ // reflex people reach for first, and the Restore button in the tab bar is+ // the only other way out.+ useEffect(() => {+ if (!isGraphExpanded) return;+ const onKey = (event: KeyboardEvent) => {+ if (event.key === "Escape") setIsGraphExpanded(false);+ };+ window.addEventListener("keydown", onKey);+ return () => window.removeEventListener("keydown", onKey);+ }, [isGraphExpanded]);+// On the first visit to the Wiki tab, auto-open the Obsidian setup// walkthrough — but only if the user has never marked it as completed// AND the current status says action is required.@@ -352,7 +407,15 @@ export function WikiView(): JSX.Element {) : (<divid="wiki-workspace"- className="flex flex-1 min-h-0 overflow-hidden"+ className={cn(+ "flex flex-1 min-h-0 overflow-hidden",+ // Expanded means the whole window, not "the middle column, but+ // wider". The map is the one thing in this app that gets better+ // the more room it has, and leaving the nav rail, the header and+ // two status strips around it was most of why it never looked+ // like anything. Fixed to the viewport, above everything.+ isGraphExpanded && "fixed inset-0 z-50 bg-background",+ )}data-testid="wiki-workspace"data-graph-expanded={isGraphExpanded ? "true" : "false"}>