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
fix(ultrawiki): let a click land anywhere on the topic it points at
Ruben Lütke5eb452d9a672
diff --git a/jarvis/ui/web/frontend/src/components/ultrawiki/EntityGraph.test.tsx b/jarvis/ui/web/frontend/src/components/ultrawiki/EntityGraph.test.tsxindex 02b47a1293..de4a5f1cb8 100644--- a/jarvis/ui/web/frontend/src/components/ultrawiki/EntityGraph.test.tsx+++ b/jarvis/ui/web/frontend/src/components/ultrawiki/EntityGraph.test.tsx@@ -43,6 +43,39 @@ vi.mock("react-force-graph-2d", async () => {};});+/** A canvas that remembers nothing but the circles it was asked to draw. */+function fakeCanvas(): { ctx: CanvasRenderingContext2D; radii: number[] } {+ const radii: number[] = [];+ const ctx = {+ fillStyle: "",+ strokeStyle: "",+ lineWidth: 0,+ font: "",+ textAlign: "left",+ textBaseline: "top",+ beginPath: () => {},+ arc: (_x: number, _y: number, radius: number) => {+ radii.push(radius);+ },+ fill: () => {},+ stroke: () => {},+ fillText: () => {},+ };+ return { ctx: ctx as unknown as CanvasRenderingContext2D, radii };+}++type NodePaint = (+ node: Record<string, unknown>,+ ctx: CanvasRenderingContext2D,+ scale: number,+) => void;+type PointerPaint = (+ node: Record<string, unknown>,+ colour: string,+ ctx: CanvasRenderingContext2D,+ scale: number,+) => void;+const PAYLOAD = {ok: true,nodes: [@@ -136,6 +169,40 @@ it("reports the topic behind a clicked node", async () => {expect(onSelect).toHaveBeenCalledWith("tahiti");});+it("takes a click anywhere on the dot, not just in its core", async () => {+ // The regression this pins: the renderer derives its hit area from+ // `nodeVal` (radius = sqrt(val) * nodeRelSize), never from the circle+ // nodeCanvasObject actually draws. Left to itself the fattest topic+ // answered only within sqrt(12) of its 12 units — 8 % of the target the+ // user aims at — so most clicks landed on nothing. The hit area has to be+ // painted by hand, and it may never be smaller than what is on screen.+ installFetch();+ renderGraph();++ await waitFor(() => expect(forceGraphProps.length).toBeGreaterThan(0));+ const props = forceGraphProps.at(-1) as Record<string, unknown>;+ const graphData = props.graphData as {+ nodes: Array<{ id: string; radius: number; colour: string }>;+ };+ // The biggest node is where the mismatch hurts most, so measure that one.+ const biggest = graphData.nodes.reduce((peak, node) =>+ node.radius > peak.radius ? node : peak,+ );+ const node = { ...biggest, x: 0, y: 0 } as unknown as Record<string, unknown>;++ const drawn = fakeCanvas();+ (props.nodeCanvasObject as NodePaint)(node, drawn.ctx, 1);++ const target = fakeCanvas();+ const paintHitArea = props.nodePointerAreaPaint as PointerPaint | undefined;+ expect(typeof paintHitArea).toBe("function");+ paintHitArea!(node, "#010203", target.ctx, 1);++ expect(Math.max(...target.radii)).toBeGreaterThanOrEqual(+ Math.max(...drawn.radii),+ );+});+it("moves the floor when the slider moves", async () => {installFetch();const onMinMentionsChange = vi.fn();diff --git a/jarvis/ui/web/frontend/src/components/ultrawiki/EntityGraph.tsx b/jarvis/ui/web/frontend/src/components/ultrawiki/EntityGraph.tsxindex 4d0c43629c..a613757d61 100644--- a/jarvis/ui/web/frontend/src/components/ultrawiki/EntityGraph.tsx+++ b/jarvis/ui/web/frontend/src/components/ultrawiki/EntityGraph.tsx@@ -53,6 +53,16 @@ interface RenderEdge {/** Floors the slider offers — 1 is always reachable, so nothing is hidden for good. */const FLOORS = [1, 2, 3, 5, 8] as const;+/**+ * Slack around a node's hit area, in graph units.+ *+ * A topic is a small target on a crowded map and the pointer is never exactly+ * where the eye is. A rim slightly wider than the dot costs nothing — the+ * nodes it could steal from are further away than this — and it is the+ * difference between "I clicked it" and "I clicked next to it".+ */+const POINTER_PAD = 2;+export function EntityGraph({minMentions,onMinMentionsChange,@@ -217,6 +227,22 @@ export function EntityGraph({onNodeClick={(node) => {if (node?.id !== undefined) onSelect(String(node.id));}}+ // Which pixels belong to which node is decided on a second,+ // invisible canvas the renderer paints in per-node id colours and+ // then samples under the pointer. It does NOT know what+ // nodeCanvasObject drew there: left alone it stamps its own circle+ // of sqrt(nodeVal) * nodeRelSize, so a dot drawn at radius 12+ // answered only within 3.5 — barely 8 % of the area a user aims+ // at, and clicking the biggest topics did nothing at all. Painting+ // the hit area ourselves is what keeps the target and the drawing+ // the same shape.+ nodePointerAreaPaint={(node, colour, ctx) => {+ if (node.x === undefined || node.y === undefined) return;+ ctx.fillStyle = colour;+ ctx.beginPath();+ ctx.arc(node.x, node.y, node.radius + POINTER_PAD, 0, 2 * Math.PI);+ ctx.fill();+ }}nodeCanvasObjectMode={() => "after"}nodeCanvasObject={(node, ctx, scale) => {if (node.x === undefined || node.y === undefined) return;