Skip to content

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

feat(wiki): the memory map turns around the user's own page, and shows its depth

Haraldc2386e53b400
diff --git a/jarvis/ui/web/frontend/src/components/deck/DeckWiki.tsx b/jarvis/ui/web/frontend/src/components/deck/DeckWiki.tsx
index b4b14c0d30..1538c87f64 100644
--- a/jarvis/ui/web/frontend/src/components/deck/DeckWiki.tsx
+++ b/jarvis/ui/web/frontend/src/components/deck/DeckWiki.tsx
@@ -53,12 +53,14 @@ async function fetchGraph(): Promise<WikiGraphPayload> {
function DeckWikiScene({
graphData,
highlightSlug,
+ pivotSlug,
resetSignal,
onNodeClick,
className,
}: {
graphData: { nodes: RenderNode[]; links: RenderEdge[] };
highlightSlug?: string;
+ pivotSlug?: string | null;
resetSignal: number;
onNodeClick: (slug: string) => void;
className?: string;
@@ -100,6 +102,7 @@ function DeckWikiScene({
width={size.w}
height={size.h}
highlightSlug={highlightSlug}
+ pivotSlug={pivotSlug}
onNodeClick={onNodeClick}
resetSignal={resetSignal}
nodeLabel={nodeLabel}
@@ -145,7 +148,11 @@ export function WikiCard({ className }: { className?: string }) {
const pages = tree.data?.stats?.total_pages ?? graphData.nodes.length;
const links = tree.data?.stats?.total_links ?? graphData.links.length;
- const highlightSlug = changes[0]?.slug;
+ // The pivot: the user's own page, as the route names it. Until something
+ // changes this session that page is also the one that glows, so the centre
+ // of the turn is recognisable as a page and not just a point in space.
+ const hub = graph.data?.hub ?? null;
+ const highlightSlug = changes[0]?.slug ?? hub ?? undefined;
const openPage = useCallback(
(slug: string) => {
@@ -198,6 +205,7 @@ export function WikiCard({ className }: { className?: string }) {
<DeckWikiScene
graphData={graphData}
highlightSlug={highlightSlug}
+ pivotSlug={hub}
resetSignal={resetTick}
onNodeClick={openPage}
/>
@@ -215,6 +223,7 @@ export function WikiCard({ className }: { className?: string }) {
<WikiExpanded
graphData={graphData}
highlightSlug={highlightSlug}
+ pivotSlug={hub}
pages={pages}
links={links}
recent={changes.map((c) => c.slug)}
@@ -242,6 +251,7 @@ export function WikiCard({ className }: { className?: string }) {
function WikiExpanded({
graphData,
highlightSlug,
+ pivotSlug,
pages,
links,
recent,
@@ -251,6 +261,7 @@ function WikiExpanded({
}: {
graphData: { nodes: RenderNode[]; links: RenderEdge[] };
highlightSlug?: string;
+ pivotSlug?: string | null;
pages: number;
links: number;
recent: string[];
@@ -298,6 +309,7 @@ function WikiExpanded({
<DeckWikiScene
graphData={graphData}
highlightSlug={highlightSlug}
+ pivotSlug={pivotSlug}
resetSignal={resetTick}
onNodeClick={onNodeClick}
/>
diff --git a/jarvis/ui/web/frontend/src/components/wiki/WikiGraph3D.tsx b/jarvis/ui/web/frontend/src/components/wiki/WikiGraph3D.tsx
index 0fdcb591c4..c52b4abd52 100644
--- a/jarvis/ui/web/frontend/src/components/wiki/WikiGraph3D.tsx
+++ b/jarvis/ui/web/frontend/src/components/wiki/WikiGraph3D.tsx
@@ -82,6 +82,12 @@ export interface WikiGraph3DProps {
width: number;
height: number;
highlightSlug?: string;
+ /**
+ * The page the ambient orbit turns around — the user's own entity page when
+ * the vault has one (`hub` in the graph payload). Absent, the camera turns
+ * around the network's middle as before.
+ */
+ pivotSlug?: string | null;
onNodeClick: (slug: string) => void;
/** Any change re-frames the camera; the host's Center button bumps it. */
resetSignal: number;
@@ -96,6 +102,7 @@ export function WikiGraph3D({
width,
height,
highlightSlug,
+ pivotSlug = null,
onNodeClick,
resetSignal,
nodeLabel,
@@ -223,10 +230,18 @@ export function WikiGraph3D({
const [frameSignal, setFrameSignal] = useState(0);
const reframe = useCallback(() => setFrameSignal((tick) => tick + 1), []);
+ // The live node object for the pivot: the simulation writes its position
+ // onto this very object, so handing it to the orbit lets the camera follow.
+ const pivotNode = useMemo(
+ () => (pivotSlug ? (graphData.nodes.find((n) => n.id === pivotSlug) ?? null) : null),
+ [graphData.nodes, pivotSlug],
+ );
+
useGraphOrbit({
graphRef: graphRef as RefObject<GraphCameraApi | undefined>,
hostRef,
nodes: graphData.nodes as Array<Partial<Vec3>>,
+ pivot: pivotNode as Partial<Vec3> | null,
frameSignal,
});
diff --git a/jarvis/ui/web/frontend/src/hooks/useGraphOrbit.ts b/jarvis/ui/web/frontend/src/hooks/useGraphOrbit.ts
index bc05e48b3a..a0089f9204 100644
--- a/jarvis/ui/web/frontend/src/hooks/useGraphOrbit.ts
+++ b/jarvis/ui/web/frontend/src/hooks/useGraphOrbit.ts
@@ -1,15 +1,18 @@
/**
- * The camera work for the 3D memory maps: fill the frame, then keep moving.
+ * The camera work for the 3D memory maps: fill the frame, then keep turning.
*
* Two jobs, one owner, because they are the same state. Framing decides where
* the middle of the network is and how far back to stand; the drift walks the
* camera around that same point. Split across two places they fight — the
* drift keeps restoring an angle the fit just changed.
*
- * The motion is deliberately slow: a full turn takes well over a minute, with
- * a slight rise and fall on top so the network reads as a solid object in
- * space rather than a flat picture that happens to spin. It is ambient, not
- * animation — you should be able to read a label while it moves.
+ * The motion is ONE thing: a steady clockwise turn around a fixed pivot, seen
+ * from a raised camera so the turn reads as a rotation about a point rather
+ * than nodes sliding sideways (maintainer decision 2026-08-18: "always
+ * rotates around a fixed point, clockwise"). No rise and fall on top — a
+ * bobbing camera made the pivot itself look like it was drifting. It is
+ * still ambient, not animation: a full turn takes well over a minute, and
+ * you can read a label while it moves.
*
* Three things stop it, and all three matter:
* - The user touching the map. Nothing is more irritating than a view that
@@ -24,10 +27,12 @@
import { useCallback, useEffect, useRef, type RefObject } from "react";
import {
+ framingAround,
framingFor,
orbitDistance,
orbitFrom,
orbitPoint,
+ stepAzimuth,
type Orbit,
type Vec3,
} from "@/lib/graphCamera";
@@ -45,12 +50,26 @@ export interface GraphCameraApi {
/** One full revolution. Long enough to read while it happens. */
const REVOLUTION_MS = 96_000;
-/** The rise and fall on top of the rotation. */
-const SWAY_PERIOD_MS = 19_000;
-const SWAY_RADIANS = 0.11;
+/**
+ * Resting height above the network's own plane, radians.
+ *
+ * Lower than it used to be (was 1.0 ≈ 57°, a near top-down view that made the
+ * map read as a flat disc turning). At ≈ 30° the camera looks THROUGH the
+ * network: pages on the near side sweep past large, pages on the far side
+ * pass behind the pivot small, and the whole thing reads as a volume in space
+ * — what the maintainer asked for on 2026-08-18. Still high enough that the
+ * turn is unmistakably a rotation about the pivot rather than a tilt.
+ */
+const BASE_ELEVATION = 0.52;
-/** Resting height above the network's own plane — a slight look down. */
-const BASE_ELEVATION = 0.24;
+/**
+ * The camera also rises and falls as it goes round — a slow nod on top of the
+ * turn, so the same page is not always the one in front and the parallax
+ * changes from pass to pass. Its period is deliberately NOT a divisor of the
+ * revolution: the view never repeats exactly.
+ */
+const ELEVATION_SWING = 0.28;
+const SWING_MS = 61_000;
/** How long after the user's last touch the drift picks back up. */
const RESUME_AFTER_MS = 3_500;
@@ -64,6 +83,13 @@ export interface GraphOrbitOptions {
hostRef: RefObject<HTMLElement | null>;
/** Live node array; the simulation writes x/y/z onto these objects. */
nodes: readonly Partial<Vec3>[];
+ /**
+ * The node to turn around, when the map has one — the user's own page. The
+ * simulation keeps moving it, so the object is read fresh every frame and
+ * the camera follows; absent, the orbit turns around the network's trimmed
+ * mean as before.
+ */
+ pivot?: Partial<Vec3> | null;
/** Bump to re-frame: new data, a settled layout, the Center button. */
frameSignal: number;
}
@@ -72,6 +98,7 @@ export function useGraphOrbit({
graphRef,
hostRef,
nodes,
+ pivot = null,
frameSignal,
}: GraphOrbitOptions): void {
const centreRef = useRef<Vec3>({ x: 0, y: 0, z: 0 });
@@ -80,21 +107,26 @@ export function useGraphOrbit({
azimuth: 0,
elevation: BASE_ELEVATION,
});
- // Phase of the sway, kept separately so pausing does not make the camera
- // jump when it resumes at a different point in the cycle.
- const swayRef = useRef(0);
const pausedUntilRef = useRef(0);
const resyncRef = useRef(false);
// Read once per mount rather than per frame; the array identity changes on
// every data generation but the objects inside are the live ones.
const nodesRef = useRef(nodes);
nodesRef.current = nodes;
+ const pivotRef = useRef(pivot);
+ pivotRef.current = pivot;
+ /** Where the elevation swing is in its cycle; advanced by the drift. */
+ const swingPhaseRef = useRef(0);
+ /** The height the swing oscillates around — ours, or the user's after a drag. */
+ const baseElevationRef = useRef(BASE_ELEVATION);
/** Point the camera at the middle of the network, far enough back to see it. */
const frame = useCallback((transitionMs = 700): void => {
const graph = graphRef.current;
if (!graph) return;
- const framing = framingFor(nodesRef.current, 0.95);
+ const framing = pivotRef.current
+ ? framingAround(pivotRef.current, nodesRef.current, 0.95)
+ : framingFor(nodesRef.current, 0.95);
if (!framing) return;
const camera = graph.camera();
@@ -110,6 +142,7 @@ export function useGraphOrbit({
const current = camera?.position
? orbitFrom(framing.centre, camera.position)
: null;
+ baseElevationRef.current = BASE_ELEVATION;
orbitRef.current = {
distance,
azimuth: current?.azimuth ?? 0,
@@ -183,37 +216,49 @@ export function useGraphOrbit({
if (!graph || orbitRef.current.distance === 0) return;
if (resyncRef.current) {
- // Carry on from wherever the user left the camera — including how far
- // out they zoomed — instead of yanking it back to our own angle. The
- // sway is subtracted back out so the stored elevation stays the
- // RESTING one; keeping the swayed value would let each pause ratchet
- // the camera a little further up or down.
+ // Carry on from wherever the user left the camera — their angle,
+ // their height, how far out they zoomed — instead of yanking it back
+ // to our own. The pivot stays ours: the turn continues around the
+ // same point, just from where they parked the view.
const camera = graph.camera();
if (camera?.position) {
const seen = orbitFrom(centreRef.current, camera.position);
if (seen.distance > 0) {
- orbitRef.current = {
- ...seen,
- elevation: seen.elevation - Math.sin(swayRef.current) * SWAY_RADIANS,
- };
+ orbitRef.current = seen;
+ baseElevationRef.current = seen.elevation;
}
}
resyncRef.current = false;
}
+ // The pivot node keeps moving while the layout settles (and again after
+ // new data); following it each frame is what makes the turn stay
+ // centred on the page rather than on where it was when we framed.
+ const pivotNode = pivotRef.current;
+ if (pivotNode && Number.isFinite(pivotNode.x)) {
+ centreRef.current = {
+ x: pivotNode.x ?? 0,
+ y: pivotNode.y ?? 0,
+ z: pivotNode.z ?? 0,
+ };
+ }
+
const orbit = orbitRef.current;
- orbit.azimuth -= (elapsed / REVOLUTION_MS) * Math.PI * 2;
- swayRef.current += (elapsed / SWAY_PERIOD_MS) * Math.PI * 2;
- const elevation = orbit.elevation + Math.sin(swayRef.current) * SWAY_RADIANS;
-
- graph.cameraPosition(
- orbitPoint(centreRef.current, { ...orbit, elevation }),
- centreRef.current,
- 0,
+ orbit.azimuth = stepAzimuth(orbit.azimuth, elapsed, REVOLUTION_MS);
+ swingPhaseRef.current += (elapsed / SWING_MS) * Math.PI * 2;
+ orbit.elevation = clampElevation(
+ baseElevationRef.current + Math.sin(swingPhaseRef.current) * ELEVATION_SWING,
);
+
+ graph.cameraPosition(orbitPoint(centreRef.current, orbit), centreRef.current, 0);
};
raf = window.requestAnimationFrame(step);
return () => window.cancelAnimationFrame(raf);
}, [graphRef]);
}
+
+/** Keep the nod inside a range where "up" stays up and the pivot stays framed. */
+function clampElevation(value: number): number {
+ return Math.min(1.25, Math.max(0.12, value));
+}
diff --git a/jarvis/ui/web/frontend/src/lib/graphCamera.test.ts b/jarvis/ui/web/frontend/src/lib/graphCamera.test.ts
index 43772c6c5b..2a04c5a795 100644
--- a/jarvis/ui/web/frontend/src/lib/graphCamera.test.ts
+++ b/jarvis/ui/web/frontend/src/lib/graphCamera.test.ts
@@ -9,10 +9,14 @@
import { describe, expect, it } from "vitest";
import {
+ framingAround,
+ ORBIT_DIRECTION,
framingFor,
orbitDistance,
orbitFrom,
orbitPoint,
+ projectToScreen,
+ stepAzimuth,
} from "@/lib/graphCamera";
/** A ball of nodes around a known centre, plus optional outliers. */
@@ -41,6 +45,19 @@ describe("framingFor", () => {
expect(framing!.radius).toBeCloseTo(50, 5);
});
+ it("keeps the pivot inside the cluster when one page drifted away", () => {
+ // Nine pages, one of them linked to nothing and far off — a small vault
+ // on its first day. The plain average would sit halfway out to the stray
+ // and the readable cluster would swing around empty space.
+ const nodes = [...cluster(8, 30), { x: 900, y: 0, z: 0 }];
+ const framing = framingFor(nodes, 0.95)!;
+ expect(Math.abs(framing.centre.x)).toBeLessThan(5);
+ expect(Math.abs(framing.centre.z)).toBeLessThan(5);
+ // …and with nine nodes the 95th percentile still covers all of them, so
+ // the stray stays in the picture, orbiting at the edge.
+ expect(framing.radius).toBeGreaterThan(800);
+ });
+
it("does not let one stray node blow the radius up", () => {
const nodes = [...cluster(40, 50), { x: 4000, y: 0, z: 0 }];
const framing = framingFor(nodes, 0.95)!;
@@ -67,6 +84,33 @@ describe("framingFor", () => {
});
});
+describe("framingAround", () => {
+ it("turns around the page it was given, not the middle of the cloud", () => {
+ // A hub off to one side of a cluster: the trimmed mean sits in the
+ // cluster, the pivot sits on the hub.
+ const hub = { x: 100, y: 0, z: 0 };
+ const others = cluster(12, 30, { x: -40, y: 0, z: 0 });
+ const framing = framingAround(hub, [hub, ...others], 0.95);
+ expect(framing).not.toBeNull();
+ expect(framing!.centre).toEqual(hub);
+ const mean = framingFor([hub, ...others], 0.95)!.centre;
+ expect(Math.abs(mean.x - hub.x)).toBeGreaterThan(50);
+ });
+
+ it("measures the radius from the pivot so the network around it stays framed", () => {
+ const hub = { x: 0, y: 0, z: 0 };
+ const points = [hub, ...cluster(20, 50)];
+ const framing = framingAround(hub, points, 1)!;
+ expect(framing.radius).toBeCloseTo(50, 5);
+ });
+
+ it("reads missing pivot coordinates as the origin and has nothing to frame without nodes", () => {
+ expect(framingAround({}, [])).toBeNull();
+ const framing = framingAround({}, [{ x: 10, y: 0, z: 0 }], 1)!;
+ expect(framing.centre).toEqual({ x: 0, y: 0, z: 0 });
+ });
+});
+
describe("orbitDistance", () => {
it("stands further back for a bigger network", () => {
const near = orbitDistance(50, 50, 1.6);
@@ -125,3 +169,47 @@ describe("orbitPoint / orbitFrom", () => {
expect(Number.isFinite(orbit.elevation)).toBe(true);
});
});
+
+describe("the ambient drift", () => {
+ it("turns the network clockwise on the screen around the pivot", () => {
+ // A node on the network's plane, watched from the drifting camera: its
+ // screen angle must DECREASE (clockwise, the way a clock hand goes) step
+ // after step, whatever the elevation the camera happens to be at.
+ const centre = { x: 0, y: 0, z: 0 };
+ const node = { x: 40, y: 0, z: 0 };
+ for (const elevation of [0.3, 1.0, 1.4]) {
+ let azimuth = 0.7;
+ let previous = Number.NaN;
+ for (let step = 0; step < 12; step++) {
+ const eye = orbitPoint(centre, { distance: 300, azimuth, elevation });
+ const { x, y } = projectToScreen(eye, centre, node);
+ const angle = Math.atan2(y, x);
+ if (!Number.isNaN(previous)) {
+ let delta = angle - previous;
+ if (delta > Math.PI) delta -= Math.PI * 2;
+ if (delta < -Math.PI) delta += Math.PI * 2;
+ expect(delta, `elevation ${elevation}, step ${step}`).toBeLessThan(0);
+ }
+ previous = angle;
+ azimuth = stepAzimuth(azimuth, 4_000, 96_000);
+ }
+ }
+ });
+
+ it("completes exactly one revolution per revolution period", () => {
+ const azimuth = stepAzimuth(0.5, 96_000, 96_000);
+ expect(azimuth).toBeCloseTo(0.5 + ORBIT_DIRECTION * Math.PI * 2, 9);
+ });
+
+ it("keeps the camera exactly as far from the pivot as it turns", () => {
+ // The pivot is fixed and so is the distance: nothing about the drift
+ // moves the point the network turns around.
+ const centre = { x: 5, y: -2, z: 9 };
+ let azimuth = 0;
+ for (let step = 0; step < 30; step++) {
+ azimuth = stepAzimuth(azimuth, 3_000, 96_000);
+ const eye = orbitPoint(centre, { distance: 120, azimuth, elevation: 1.0 });
+ expect(Math.hypot(eye.x - centre.x, eye.y - centre.y, eye.z - centre.z)).toBeCloseTo(120, 6);
+ }
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/lib/graphCamera.ts b/jarvis/ui/web/frontend/src/lib/graphCamera.ts
index 2b2fdd892d..1de6076fa3 100644
--- a/jarvis/ui/web/frontend/src/lib/graphCamera.ts
+++ b/jarvis/ui/web/frontend/src/lib/graphCamera.ts
@@ -42,15 +42,51 @@ function coordinate(value: number | undefined): number {
return Number.isFinite(value) ? (value as number) : 0;
}
+/**
+ * A node farther from the plain average than this many median distances is
+ * a stray and has no say in where the pivot is. A ring, a ball, a spread-out
+ * cluster all sit within it whole; only a page that drifted off alone falls
+ * outside.
+ */
+const PIVOT_REACH = 1.5;
+
+function meanOf(points: readonly Partial<Vec3>[]): Vec3 {
+ let sx = 0;
+ let sy = 0;
+ let sz = 0;
+ for (const point of points) {
+ sx += coordinate(point.x);
+ sy += coordinate(point.y);
+ sz += coordinate(point.z);
+ }
+ const n = Math.max(1, points.length);
+ return { x: sx / n, y: sy / n, z: sz / n };
+}
+
+function distanceFrom(centre: Vec3, point: Partial<Vec3>): number {
+ const dx = coordinate(point.x) - centre.x;
+ const dy = coordinate(point.y) - centre.y;
+ const dz = coordinate(point.z) - centre.z;
+ return Math.sqrt(dx * dx + dy * dy + dz * dz);
+}
+
/**
* The middle of the network and a radius that covers the bulk of it.
*
- * The radius is a PERCENTILE, not a maximum, and that is the whole point. A
- * vault is allowed to contain a page nothing links to; it drifts to the edge
- * of the layout, and framing it along with everything else is what left the
+ * The middle is a TRIMMED mean: the plain average first, then the average of
+ * the nodes within reach of it. On a small vault one page nothing links to
+ * sits a long way from the rest, and the plain average lands halfway between
+ * the two — the camera then circles a point in empty space and the readable
+ * cluster swings around it like a bucket on a rope. Averaging again without
+ * the stray puts the pivot inside the cluster, so the cluster turns in place
+ * and the stray page orbits at the edge, which is what a person means by
+ * "rotates around a fixed point".
+ *
+ * The radius is a PERCENTILE, not a maximum, and that is the other half of
+ * the point. Framing the stray along with everything else is what left the
* readable part of the map occupying a fifth of the screen. Taking the 95th
- * percentile means the network fills the frame and the handful of outliers sit
- * just past the edge — where a slowly orbiting camera brings them back into
+ * percentile means the network fills the frame and the handful of outliers
+ * sit just past the edge — where the orbiting camera brings them back into
* view anyway, and where a scroll wheel finds them immediately.
*
* @param points node positions as the simulation last left them
@@ -63,27 +99,15 @@ export function framingFor(
): Framing | null {
if (points.length === 0) return null;
- let sx = 0;
- let sy = 0;
- let sz = 0;
- for (const point of points) {
- sx += coordinate(point.x);
- sy += coordinate(point.y);
- sz += coordinate(point.z);
- }
- const centre: Vec3 = {
- x: sx / points.length,
- y: sy / points.length,
- z: sz / points.length,
- };
+ const rough = meanOf(points);
+ const roughDistances = points.map((point) => distanceFrom(rough, point)).sort((a, b) => a - b);
+ const median = roughDistances[Math.floor(roughDistances.length / 2)];
+ const reach = median * PIVOT_REACH;
+ const near = points.filter((point) => distanceFrom(rough, point) <= reach);
+ const centre = meanOf(near.length > 0 ? near : points);
const distances = points
- .map((point) => {
- const dx = coordinate(point.x) - centre.x;
- const dy = coordinate(point.y) - centre.y;
- const dz = coordinate(point.z) - centre.z;
- return Math.sqrt(dx * dx + dy * dy + dz * dz);
- })
+ .map((point) => distanceFrom(centre, point))
.sort((a, b) => a - b);
const share = Math.min(Math.max(percentile, 0), 1);
@@ -94,6 +118,41 @@ export function framingFor(
return { centre, radius: Math.max(distances[index], MIN_RADIUS) };
}
+/**
+ * Framing around a point the caller CHOSE — the user's own page, say — rather
+ * than around the trimmed mean.
+ *
+ * The maintainer's "main wiki point" (2026-08-18): the vault names one page for
+ * the person Jarvis serves and the map should turn around it, so the pages that
+ * cluster near it stay near the middle of the screen while everything else
+ * sweeps past. Same percentile radius as `framingFor`, measured from the pivot,
+ * so a hub that sits off-centre in the cloud still gets a frame that covers
+ * the bulk of the network around it.
+ *
+ * @param pivot the point to turn around (missing coordinates read as 0)
+ */
+export function framingAround(
+ pivot: Partial<Vec3>,
+ points: readonly Partial<Vec3>[],
+ percentile = 0.95,
+): Framing | null {
+ if (points.length === 0) return null;
+ const centre = {
+ x: coordinate(pivot.x),
+ y: coordinate(pivot.y),
+ z: coordinate(pivot.z),
+ };
+ const distances = points
+ .map((point) => distanceFrom(centre, point))
+ .sort((a, b) => a - b);
+ const share = Math.min(Math.max(percentile, 0), 1);
+ const index = Math.min(
+ distances.length - 1,
+ Math.max(0, Math.ceil(share * distances.length) - 1),
+ );
+ return { centre, radius: Math.max(distances[index], MIN_RADIUS) };
+}
+
/**
* How far back the camera has to stand for a sphere of `radius` to fill
* `fill` of the frame.
@@ -153,3 +212,48 @@ export function orbitFrom(centre: Vec3, position: Vec3): Orbit {
elevation: Math.asin(Math.min(Math.max(dy / distance, -1), 1)),
};
}
+
+/**
+ * Sign of the azimuth change per step of the ambient drift.
+ *
+ * With Y up and the camera looking down at the network, a DECREASING azimuth
+ * moves the camera anticlockwise around the pivot as seen from above, so the
+ * network turns clockwise on the screen — the direction of a clock hand,
+ * which is what the maintainer asked for. `graphCamera.test.ts` projects a
+ * node through a look-at camera to pin exactly that, so a sign flip here or
+ * in `orbitPoint` fails a test rather than quietly reversing the map.
+ */
+export const ORBIT_DIRECTION = -1;
+
+/** The next azimuth of the ambient drift after `elapsedMs`. */
+export function stepAzimuth(azimuth: number, elapsedMs: number, revolutionMs: number): number {
+ return azimuth + ORBIT_DIRECTION * (elapsedMs / revolutionMs) * Math.PI * 2;
+}
+
+/**
+ * Where a point lands on the screen of a camera at `eye` looking at `centre`
+ * with Y up — the same construction as three.js's `lookAt`. Pure arithmetic
+ * so the direction of the drift can be tested without a GPU: `x` grows to the
+ * right, `y` grows upwards.
+ */
+export function projectToScreen(eye: Vec3, centre: Vec3, point: Vec3): { x: number; y: number } {
+ const back = normalise({ x: eye.x - centre.x, y: eye.y - centre.y, z: eye.z - centre.z });
+ const up = { x: 0, y: 1, z: 0 };
+ const right = normalise(cross(up, back));
+ const screenUp = cross(back, right);
+ const rel = { x: point.x - eye.x, y: point.y - eye.y, z: point.z - eye.z };
+ return { x: dot(rel, right), y: dot(rel, screenUp) };
+}
+
+function cross(a: Vec3, b: Vec3): Vec3 {
+ return { x: a.y * b.z - a.z * b.y, y: a.z * b.x - a.x * b.z, z: a.x * b.y - a.y * b.x };
+}
+
+function dot(a: Vec3, b: Vec3): number {
+ return a.x * b.x + a.y * b.y + a.z * b.z;
+}
+
+function normalise(v: Vec3): Vec3 {
+ const length = Math.sqrt(dot(v, v)) || 1;
+ return { x: v.x / length, y: v.y / length, z: v.z / length };
+}
diff --git a/jarvis/ui/web/frontend/src/lib/wikiGraph.ts b/jarvis/ui/web/frontend/src/lib/wikiGraph.ts
index 99342b0db0..c4b8038f2b 100644
--- a/jarvis/ui/web/frontend/src/lib/wikiGraph.ts
+++ b/jarvis/ui/web/frontend/src/lib/wikiGraph.ts
@@ -37,6 +37,12 @@ export interface WikiGraphPayload {
nodes: WikiGraphNode[];
edges: WikiGraphEdge[];
broken: WikiGraphBrokenLink[];
+ /**
+ * The page the memory map turns around — the user's own entity page, as
+ * the route names it (null when the vault has no such page yet). Absent on
+ * an older backend, which is why the type allows it to be missing.
+ */
+ hub?: string | null;
}
/**
diff --git a/jarvis/ui/web/wiki_routes.py b/jarvis/ui/web/wiki_routes.py
index ea74128041..9905a2e614 100644
--- a/jarvis/ui/web/wiki_routes.py
+++ b/jarvis/ui/web/wiki_routes.py
@@ -54,6 +54,7 @@ from jarvis.memory.wiki.integration import (
get_running_curator,
)
from jarvis.memory.wiki.page import parse_markdown
+from jarvis.memory.wiki.prompt import resolve_user_entity_slug
from jarvis.memory.wiki.protocols import WikiPage
from jarvis.memory.wiki.search import VaultSearch
from jarvis.memory.wiki.telemetry import telemetry as _telemetry
@@ -180,6 +181,26 @@ def _display_title(page: WikiPage) -> str:
return _human_title_from_slug(page.slug)
+def _hub_slug(request: Request, known_slugs: set[str]) -> str | None:
+ """The page the memory map turns around: the user's own entity page.
+
+ The vault names ONE page for the person Jarvis serves
+ (``[memory.wiki.session_rollup].user_entity_slug``, ``"user"`` when unset)
+ and the consolidator hangs new knowledge off it. That is the natural pivot
+ for the map's orbit — the maintainer's "main wiki point" (2026-08-18) —
+ so the graph route states it rather than leaving the client to guess a
+ hub from link counts. ``None`` when that page does not exist yet.
+ """
+ config = getattr(request.app.state, "config", None)
+ configured = ""
+ try:
+ configured = getattr(config.memory.wiki.session_rollup, "user_entity_slug", "")
+ except AttributeError:
+ configured = ""
+ slug = resolve_user_entity_slug(configured)
+ return slug if slug in known_slugs else None
+
+
def _kind_of(page: WikiPage) -> str:
"""Schema kind (entity/concept/project/session/meta) of a page."""
return page.page_type or "meta"
@@ -618,6 +639,8 @@ async def get_graph(request: Request) -> dict[str, Any]:
"nodes": nodes,
"edges": edges,
"broken": broken,
+ # The pivot of the memory map — see ``_hub_slug``.
+ "hub": _hub_slug(request, known_slugs),
}
diff --git a/tests/unit/ui/web/test_wiki_routes.py b/tests/unit/ui/web/test_wiki_routes.py
index 5821c2de00..5274fc6fc1 100644
--- a/tests/unit/ui/web/test_wiki_routes.py
+++ b/tests/unit/ui/web/test_wiki_routes.py
@@ -371,6 +371,27 @@ def test_graph_with_linked_pages_produces_nodes_and_edges(populated_vault: Path)
assert edge["context"] != ""
+def test_graph_names_the_hub_when_the_user_page_exists(populated_vault: Path) -> None:
+ """The map turns around the user's own entity page — the route says which."""
+ app = _make_app(populated_vault)
+ app.state.config.memory.wiki = SimpleNamespace(
+ session_rollup=SimpleNamespace(user_entity_slug="example-user"),
+ )
+ with TestClient(app) as client:
+ body = client.get("/api/wiki/graph").json()
+ assert body["hub"] == "example-user"
+
+
+def test_graph_hub_is_null_when_no_such_page_and_without_config(populated_vault: Path) -> None:
+ # No [memory.wiki.session_rollup] at all: resolves to "user", which this
+ # vault does not have — so no hub, and no guess.
+ app = _make_app(populated_vault)
+ with TestClient(app) as client:
+ body = client.get("/api/wiki/graph").json()
+ assert body["ok"] is True
+ assert body["hub"] is None
+
+
def test_graph_with_broken_wikilink_lists_it_in_broken_bucket(tmp_path: Path) -> None:
vault = tmp_path / "vault"
_write_page(