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(wiki): readable memory map, collision-free labels and a narrow-window layout
rubenluetke10-beepb940954f9cfb
diff --git a/jarvis/ui/web/frontend/src/components/wiki/WikiGraph.tsx b/jarvis/ui/web/frontend/src/components/wiki/WikiGraph.tsxindex e397875752..b9446c83bc 100644--- a/jarvis/ui/web/frontend/src/components/wiki/WikiGraph.tsx+++ b/jarvis/ui/web/frontend/src/components/wiki/WikiGraph.tsx@@ -178,6 +178,26 @@ function linkTouches(link: RenderEdge, slug: string): boolean {/** The canvas face of the brand typeface — the bundle names it "Inter Variable". */const CANVAS_FONT = "'Inter Variable', Inter, system-ui, sans-serif";+/** Pull of every page towards the middle; see the gravity force. */+const GRAVITY = 0.035;++/** A page with no links is pulled in harder, so it orbits instead of drifting off. */+const ORPHAN_GRAVITY = 0.16;++/** Drawn radius in graph units: big enough to see a leaf at a fitted zoom. */+function drawRadius(node: RenderNode, isActive: boolean): number {+ return nodeSizeScore(node.backlinkCount ?? 0, isActive) * 2.6;+}++/**+ * The radius a page is actually painted at: its graph size, but never+ * smaller on screen than a dot you can see and point at.+ */+function paintedRadius(node: RenderNode, isActive: boolean, isHub: boolean, globalScale: number): number {+ const floor = (isHub ? 6 : isActive ? 5 : 3.2) / Math.max(globalScale, 0.01);+ return Math.max(drawRadius(node, isActive), floor);+}+/** How many of the best-connected pages keep their label at any zoom. */const ALWAYS_LABELLED = 10;@@ -365,6 +385,8 @@ export function WikiGraph({ onNodeClick, highlightSlug }: WikiGraphProps): JSX.E}, [graphData]);const structureRef = useRef(structure);structureRef.current = structure;+ const graphDataRef = useRef(graphData);+ graphDataRef.current = graphData;const hubSlug = data?.hub ?? null;const hubRef = useRef(hubSlug);@@ -742,21 +764,21 @@ export function WikiGraph({ onNodeClick, highlightSlug }: WikiGraphProps): JSX.Eif (!ref) return;// eslint-disable-next-line @typescript-eslint/no-explicit-anyconst anyRef = ref as any;- // Repulsion: every pair pushes apart, reaching far enough (380 graph+ // Repulsion: every pair pushes apart, reaching far enough (460 graph// units) that the leaves of one hub keep clear of the next hub's, so the// vault settles into readable constellations instead of one knot.const chargeForce = anyRef.d3Force?.("charge");if (chargeForce && typeof chargeForce.strength === "function") {- chargeForce.strength(-150);+ chargeForce.strength(-210);if (typeof chargeForce.distanceMax === "function") {- chargeForce.distanceMax(380);+ chargeForce.distanceMax(460);}}// Links stay short so a page sits beside what it links to, and loose// enough that a hub with ninety links does not crush its leaves together.const linkForce = anyRef.d3Force?.("link");if (linkForce && typeof linkForce.distance === "function") {- linkForce.distance(48);+ linkForce.distance(56);if (typeof linkForce.strength === "function") {linkForce.strength(0.5);}@@ -771,6 +793,27 @@ export function WikiGraph({ onNodeClick, highlightSlug }: WikiGraphProps): JSX.Eif (centerForce && typeof centerForce.strength === "function") {centerForce.strength(0.08);}+ // Gentle gravity towards the middle. forceCenter only re-centres the+ // whole cloud; a page with no links feels nothing else, so the charge+ // alone pushed every orphan to the far edge and the camera had to zoom+ // out until the real network was a speck.+ let gravityNodes: Array<{ id?: string | number; x?: number; y?: number; vx?: number; vy?: number }> = [];+ const gravity = Object.assign(+ (alpha: number) => {+ const { degree } = structureRef.current;+ for (const node of gravityNodes) {+ const k = (degree.get(String(node.id ?? "")) ?? 0) > 0 ? GRAVITY : ORPHAN_GRAVITY;+ node.vx = (node.vx ?? 0) - (node.x ?? 0) * k * alpha;+ node.vy = (node.vy ?? 0) - (node.y ?? 0) * k * alpha;+ }+ },+ {+ initialize: (nodes: typeof gravityNodes) => {+ gravityNodes = nodes;+ },+ },+ );+ anyRef.d3Force?.("gravity", gravity);forcesConfiguredRef.current = true;}, []);@@ -812,6 +855,24 @@ export function WikiGraph({ onNodeClick, highlightSlug }: WikiGraphProps): JSX.Econst nodeCanvasObjectMode = useCallback(() => "replace" as const, []);+ // The hit area follows the drawn shape (plus a little slack), so a leaf is+ // as easy to hover as it is to see.+ const nodePointerAreaPaint = useCallback(+ (node: NodeObject<RenderNode>, colour: string, ctx: CanvasRenderingContext2D): void => {+ ctx.beginPath();+ ctx.arc(+ node.x ?? 0,+ node.y ?? 0,+ drawRadius(node as RenderNode, node.id === highlightRef.current) + 2.5,+ 0,+ Math.PI * 2,+ );+ ctx.fillStyle = colour;+ ctx.fill();+ },+ [],+ );+const nodeCanvasObject = useCallback((node: NodeObject<RenderNode>,@@ -822,7 +883,7 @@ export function WikiGraph({ onNodeClick, highlightSlug }: WikiGraphProps): JSX.Econst y = node.y ?? 0;const id = String(node.id ?? "");const palette = paletteRef.current;- const { neighbours, degree, labelled, groups, maxDegree } = structureRef.current;+ const { neighbours, degree, groups, maxDegree } = structureRef.current;const isActive = id === highlightRef.current;const isHover = id === hoverRef.current;const isHub = id === hubRef.current;@@ -833,7 +894,7 @@ export function WikiGraph({ onNodeClick, highlightSlug }: WikiGraphProps): JSX.Econst isBroken = (node as RenderNode).kind === "broken";const shape = isBroken ? "dot" : GROUP_SHAPE[group];// Match the nodeVal calculation so the hit area and the drawn shape agree.- const radius = sizeOf(node as RenderNode, isActive) * 2;+ const radius = paintedRadius(node as RenderNode, isActive, isHub, globalScale);// Ink weight follows connectedness: leaves are quiet, hubs read first.const weight = Math.min(1, (degree.get(id) ?? 0) / Math.max(4, maxDegree * 0.35));const alpha = inFocus ? 0.5 + weight * 0.5 : 0.12;@@ -877,41 +938,93 @@ export function WikiGraph({ onNodeClick, highlightSlug }: WikiGraphProps): JSX.Ectx.stroke();}- const showLabel =- inFocus &&- (isActive ||- isHover ||- isHub ||- (focus !== null && isNeighbour) ||- labelled.has(id) ||- globalScale >= LABEL_ALL_ZOOM);- const label = (node as RenderNode).title ?? id;- if (showLabel && label) {- const strong = isActive || isHover || isHub || labelled.has(id);- const fontSize = (strong ? 12 : 11) / globalScale;- ctx.font = `${strong ? 500 : 400} ${fontSize}px ${CANVAS_FONT}`;- ctx.textAlign = "center";- ctx.textBaseline = "top";- const ty = y + radius + 4 / globalScale;- // A halo in the room colour instead of a drop shadow: legible over- // crossing lines in both themes, and no glow.- ctx.lineJoin = "round";- ctx.lineWidth = 3.5 / globalScale;- ctx.strokeStyle = hsl(palette.room, 0.92);- ctx.strokeText(label, x, ty);- ctx.fillStyle =- isActive || isHover- ? hsl(palette.ink)- : strong- ? hsl(palette.ink, 0.88)- : hsl(palette.muted, 0.95);- ctx.fillText(label, x, ty);- }ctx.restore();},[],);+ /**+ * Labels are drawn after every shape, once per frame, most important first:+ * the open and hovered page, the user's own page, the hovered page's+ * neighbours, then by how connected a page is. A label that would collide+ * with one already placed is left out — a crowded hub shows the names that+ * matter instead of a pile of overprinted text. Zooming in makes room, so+ * more of them appear.+ */+ const drawLabels = useCallback((ctx: CanvasRenderingContext2D, globalScale: number): void => {+ const palette = paletteRef.current;+ const { neighbours, degree, labelled } = structureRef.current;+ const hover = hoverRef.current;+ const selected = highlightRef.current;+ const focus = focusOf(hover, selected);+ const focusNeighbours = focus !== null ? neighbours.get(focus) : undefined;++ type Candidate = { node: RenderNode; rank: number; text: string };+ const candidates: Candidate[] = [];+ for (const node of graphDataRef.current.nodes) {+ const id = String(node.id ?? "");+ const isActive = id === selected;+ const isHover = id === hover;+ const isHub = id === hubRef.current;+ const isNeighbour = focusNeighbours?.has(id) ?? false;+ const inFocus = focus === null || id === focus || isNeighbour;+ if (!inFocus) continue;+ let rank: number;+ if (isActive || isHover) rank = 0;+ else if (isHub) rank = 1;+ else if (isNeighbour) rank = 2;+ else if (labelled.has(id)) rank = 3;+ else if (globalScale >= LABEL_ALL_ZOOM) rank = 4;+ else continue;+ const text = node.title ?? id;+ if (text) candidates.push({ node, rank, text });+ }+ candidates.sort(+ (a, b) =>+ a.rank - b.rank ||+ (degree.get(String(b.node.id)) ?? 0) - (degree.get(String(a.node.id)) ?? 0),+ );++ const placed: Array<[number, number, number, number]> = [];+ const pad = 3 / globalScale;+ ctx.save();+ ctx.textAlign = "center";+ ctx.textBaseline = "top";+ ctx.lineJoin = "round";+ for (const { node, rank, text } of candidates) {+ const x = node.x ?? 0;+ const y = node.y ?? 0;+ const id = String(node.id ?? "");+ const strong = rank <= 1 || labelled.has(id);+ const fontSize = (strong ? 12 : 11) / globalScale;+ ctx.font = `${strong ? 500 : 400} ${fontSize}px ${CANVAS_FONT}`;+ const radius = paintedRadius(node, id === selected, id === hubRef.current, globalScale);+ const ty = y + radius + 4 / globalScale;+ const width = ctx.measureText(text).width;+ const box: [number, number, number, number] = [+ x - width / 2 - pad,+ ty - pad,+ x + width / 2 + pad,+ ty + fontSize * 1.2 + pad,+ ];+ const collides = placed.some(+ ([l, t, r, b]) => box[0] < r && box[2] > l && box[1] < b && box[3] > t,+ );+ // The open and hovered page always get their name, even over others.+ if (collides && rank > 0) continue;+ placed.push(box);+ // A halo in the room colour instead of a drop shadow: legible over+ // crossing lines in both themes, and no glow.+ ctx.lineWidth = 3.5 / globalScale;+ ctx.strokeStyle = hsl(palette.room, 0.92);+ ctx.strokeText(text, x, ty);+ ctx.fillStyle =+ rank === 0 ? hsl(palette.ink) : strong ? hsl(palette.ink, 0.88) : hsl(palette.muted, 0.95);+ ctx.fillText(text, x, ty);+ }+ ctx.restore();+ }, []);+const linkColor = useCallback((link: RenderEdge) => {const palette = paletteRef.current;if ((link as RenderEdge).broken) return hsl(palette.broken, 0.5);@@ -1082,7 +1195,7 @@ export function WikiGraph({ onNodeClick, highlightSlug }: WikiGraphProps): JSX.E{/* Legend and filter in one: every kind the vault holds, drawn in theshape the map uses for it. A click hides or shows that kind. */}<div- className="absolute left-3 top-3 z-10 w-[200px] rounded-lg border border-border bg-popover/85 p-1.5 backdrop-blur"+ className="absolute left-3 top-3 z-10 w-[188px] rounded-lg border border-border bg-popover/85 p-1.5 backdrop-blur"data-testid="wiki-graph-legend"role="group"aria-label={t("wiki_ui.legend_label")}@@ -1121,7 +1234,7 @@ export function WikiGraph({ onNodeClick, highlightSlug }: WikiGraphProps): JSX.E</div></div>- <div className="absolute right-3 top-3 z-10 flex items-center gap-2">+ <div className="absolute bottom-3 right-3 z-10 flex items-center gap-2"><GraphDimensionToggle className="h-8 bg-popover/85" /><buttontype="button"@@ -1135,7 +1248,7 @@ export function WikiGraph({ onNodeClick, highlightSlug }: WikiGraphProps): JSX.E</button></div>- <p className="pointer-events-none absolute bottom-3 left-1/2 z-10 -translate-x-1/2 whitespace-nowrap text-xs text-foreground-faint">+ <p className="pointer-events-none absolute bottom-5 left-4 z-10 hidden whitespace-nowrap text-xs text-foreground-faint 2xl:block">{t("wiki_ui.map_hint")}</p>@@ -1224,6 +1337,8 @@ export function WikiGraph({ onNodeClick, highlightSlug }: WikiGraphProps): JSX.EnodeColor={nodeColor}nodeCanvasObjectMode={nodeCanvasObjectMode}nodeCanvasObject={nodeCanvasObject}+ nodePointerAreaPaint={nodePointerAreaPaint}+ onRenderFramePost={drawLabels}linkLabel={linkLabel}linkColor={linkColor}linkWidth={linkWidth}diff --git a/jarvis/ui/web/frontend/src/components/wiki/WikiInspector.tsx b/jarvis/ui/web/frontend/src/components/wiki/WikiInspector.tsxindex c9c861def2..ad7a4f5d47 100644--- a/jarvis/ui/web/frontend/src/components/wiki/WikiInspector.tsx+++ b/jarvis/ui/web/frontend/src/components/wiki/WikiInspector.tsx@@ -28,6 +28,7 @@ import {cleanTitle,degreeOf,groupOfKind,+ readableSnippet,relativeAge,uniqueEdges,type LibraryItem,@@ -120,7 +121,7 @@ export function WikiInspector(props: WikiInspectorProps) {const t = useT();return (<aside- className="flex h-full min-h-0 w-[320px] shrink-0 flex-col overflow-y-auto border-l border-border bg-sidebar"+ className="flex h-full min-h-0 w-[280px] shrink-0 flex-col overflow-y-auto border-l border-border bg-sidebar 2xl:w-[320px]"data-testid={props.selectedSlug ? "wiki-inspector-page" : "wiki-backlinks-placeholder"}aria-label={t("wiki_ui.inspector_label")}>@@ -188,7 +189,7 @@ function Block({><header className="mb-3 flex items-baseline justify-between gap-3"><h2 className="text-base font-semibold text-foreground-strong">{title}</h2>- {aside && <div className="text-sm text-foreground-faint">{aside}</div>}+ {aside && <div className="shrink-0 whitespace-nowrap text-sm text-foreground-faint">{aside}</div>}</header>{children}</section>@@ -516,20 +517,6 @@ function HubsBlock({/* Page context *//* ------------------------------------------------------------------------ */-const SNIPPET_LINK_RE = /\[\[([^\]|\n]+)(?:\|([^\]\n]+))?\]\]/g;--/** Backlink snippets arrive with raw `[[target|label]]` markup; show words. */-export function readableSnippet(snippet: string): string {- return snippet- .replace(SNIPPET_LINK_RE, (_m, target: string, label?: string) => {- const text = (label ?? target).trim();- const idx = Math.max(text.lastIndexOf("/"), text.lastIndexOf("\\"));- return idx >= 0 && !label ? text.slice(idx + 1) : text;- })- .replace(/\s+/g, " ")- .trim();-}-function PageContext({slug,itemsBySlug,diff --git a/jarvis/ui/web/frontend/src/components/wiki/WikiLibrary.tsx b/jarvis/ui/web/frontend/src/components/wiki/WikiLibrary.tsxindex 04017e2662..adaf5d0abf 100644--- a/jarvis/ui/web/frontend/src/components/wiki/WikiLibrary.tsx+++ b/jarvis/ui/web/frontend/src/components/wiki/WikiLibrary.tsx@@ -70,7 +70,7 @@ export function WikiLibrary({return (<aside- className="flex h-full min-h-0 w-[272px] shrink-0 flex-col border-r border-border bg-sidebar"+ className="flex h-full min-h-0 w-[240px] shrink-0 flex-col border-r border-border bg-sidebar 2xl:w-[272px]"data-testid="wiki-tree-sidebar"aria-label={t("wiki_ui.library_label")}>diff --git a/jarvis/ui/web/frontend/src/components/wiki/WikiSearch.tsx b/jarvis/ui/web/frontend/src/components/wiki/WikiSearch.tsxindex 3073c56ee1..1e20bc390f 100644--- a/jarvis/ui/web/frontend/src/components/wiki/WikiSearch.tsx+++ b/jarvis/ui/web/frontend/src/components/wiki/WikiSearch.tsx@@ -18,7 +18,7 @@ import { keepPreviousData, useQuery } from "@tanstack/react-query";import { Search } from "lucide-react";-import { cleanTitle, groupOfKind, type WikiGroupId } from "@/lib/wikiModel";+import { cleanTitle, groupOfKind, readableSnippet, type WikiGroupId } from "@/lib/wikiModel";import { KindGlyph } from "@/components/wiki/KindGlyph";import { useT } from "@/i18n";@@ -235,6 +235,22 @@ export const WikiSearch = forwardRef<WikiSearchHandle, WikiSearchProps>(function});const recent = useMemo(() => selectRecentPages(tree), [tree]);+ // The palette's own selection. cmdk picks its first row only when it does+ // the filtering itself; with the backend ranking the hits it would leave+ // nothing selected, so Enter right after typing did nothing.+ const [selectedValue, setSelectedValue] = useState("");+ const firstValue =+ debouncedQuery.length === 0+ ? recent[0]+ ? `recent:${recent[0].slug}`+ : ""+ : data?.ok && data.hits[0]+ ? `hit:${data.hits[0].slug}`+ : "";+ useEffect(() => {+ setSelectedValue(firstValue);+ }, [firstValue]);+const handlePick = useCallback((slug: string) => {onResultClick(slug);@@ -249,6 +265,8 @@ export const WikiSearch = forwardRef<WikiSearchHandle, WikiSearchProps>(function<Command.Dialogopen={open}onOpenChange={setOpen}+ value={selectedValue}+ onValueChange={setSelectedValue}label={t("wiki_search.dialog_label")}// The backend already ranked these hits (FTS5/BM25 over full page// bodies). cmdk's built-in filter would score them a SECOND time@@ -350,7 +368,7 @@ export const WikiSearch = forwardRef<WikiSearchHandle, WikiSearchProps>(function<span className="ml-auto truncate text-sm text-foreground-faint">{hit.path}</span></span><span className="line-clamp-2 pl-5 text-sm text-muted-foreground">- {highlightSnippet(hit.snippet, highlightPattern)}+ {highlightSnippet(readableSnippet(hit.snippet), highlightPattern)}</span></Command.Item>))}diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex 887d19edfc..29b059d6cd 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -4182,7 +4182,7 @@"health_red": "Funktioniert nicht","health_unknown": "Noch nicht geprüft","health_chip_title": "Zustand des Gedächtnisses anzeigen",- "capture_title": "Aus Gesprächen erfasst",+ "capture_title": "Erfassung","capture_window": "letzte {0} Std.","capture_quiet": "In diesem Zeitraum wurde nichts erfasst.","hubs_title": "Am stärksten vernetzt",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex 1186ec86c2..f1a17dceff 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -4182,7 +4182,7 @@"health_red": "Not working","health_unknown": "Not checked yet","health_chip_title": "Show memory health",- "capture_title": "Captured from conversations",+ "capture_title": "Capture","capture_window": "last {0} h","capture_quiet": "Nothing was captured in this window.","hubs_title": "Most connected",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex 85fb7f2206..8b5fd303c6 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -4182,7 +4182,7 @@"health_red": "No funciona","health_unknown": "Aún sin comprobar","health_chip_title": "Mostrar el estado de la memoria",- "capture_title": "Capturado de conversaciones",+ "capture_title": "Captura","capture_window": "últimas {0} h","capture_quiet": "No se capturó nada en este periodo.","hubs_title": "Más conectadas",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/zh.json b/jarvis/ui/web/frontend/src/i18n/locales/zh.jsonindex 1b267964df..585d0cf320 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/zh.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/zh.json@@ -4184,7 +4184,7 @@"health_red": "无法工作","health_unknown": "尚未检查","health_chip_title": "显示记忆状态",- "capture_title": "从对话中捕获",+ "capture_title": "捕获","capture_window": "最近 {0} 小时","capture_quiet": "此时间段内没有捕获任何内容。","hubs_title": "连接最多",diff --git a/jarvis/ui/web/frontend/src/lib/wikiModel.test.ts b/jarvis/ui/web/frontend/src/lib/wikiModel.test.tsnew file mode 100644index 0000000000..65bb2dde50--- /dev/null+++ b/jarvis/ui/web/frontend/src/lib/wikiModel.test.ts@@ -0,0 +1,92 @@+import { describe, expect, it } from "vitest";++import {+ cleanTitle,+ compactAge,+ degreeOf,+ groupOfKind,+ libraryGroups,+ libraryItems,+ matchesFilter,+ readableSnippet,+ recentItems,+ uniqueEdges,+} from "@/lib/wikiModel";+import { stripLeadingTitle } from "@/components/wiki/PageRenderer";++const FOLDERS = [+ {+ name: "entities",+ kind: "entity",+ count: 2,+ files: [+ { slug: "zoe", title: "Zoë", mtime: 10, size: 1 },+ { slug: "ada", title: "Ada", mtime: 30, size: 1 },+ ],+ },+ { name: "concepts", kind: "concept", count: 0, files: [] },+ {+ name: "society/ada",+ kind: "society",+ count: 1,+ files: [{ slug: "MEMORY", title: '"Ada — memory"', mtime: 20, size: 1 }],+ },+];++describe("wikiModel", () => {+ it("strips YAML quotes from titles and falls back to the slug", () => {+ expect(cleanTitle('"Ada — memory"')).toBe("Ada — memory");+ expect(cleanTitle("", "fallback")).toBe("fallback");+ });++ it("maps backend kinds onto library groups", () => {+ expect(groupOfKind("society")).toBe("agent");+ expect(groupOfKind("meta")).toBe("system");+ expect(groupOfKind("project")).toBe("project");+ expect(groupOfKind("whatever")).toBe("other");+ });++ it("groups pages by kind, drops empty groups and sorts by title", () => {+ const groups = libraryGroups(libraryItems(FOLDERS));+ expect(groups.map((g) => g.id)).toEqual(["entity", "agent"]);+ expect(groups[0].items.map((i) => i.title)).toEqual(["Ada", "Zoë"]);+ expect(groups[1].items[0].title).toBe("Ada — memory");+ });++ it("lists the newest pages first and filters accent-insensitively", () => {+ const items = libraryItems(FOLDERS);+ expect(recentItems(items, 2).map((i) => i.slug)).toEqual(["ada", "MEMORY"]);+ expect(items.filter((i) => matchesFilter(i, "zoe")).map((i) => i.slug)).toEqual(["zoe"]);+ });++ it("collapses repeated wikilinks into one weighted edge", () => {+ const edges = uniqueEdges([+ { source: "log", target: "memory", context: "" },+ { source: "log", target: "memory", context: "merge" },+ { source: "log", target: "memory", context: "" },+ { source: "a", target: "a", context: "" },+ { source: "a", target: "b", context: "x" },+ ]);+ expect(edges).toHaveLength(2);+ expect(edges[0]).toMatchObject({ source: "log", target: "memory", weight: 3, context: "merge" });+ expect(degreeOf(edges).get("a")).toBe(1);+ });++ it("formats a compact age", () => {+ const now = 1_000_000 * 1000;+ expect(compactAge(1_000_000 - 3 * 3600, "en", now)).toBe("3h");+ expect(compactAge(1_000_000 - 2 * 86400, "en", now)).toBe("2d");+ expect(compactAge(0, "en", now)).toBe("");+ });++ it("turns markdown snippets into words", () => {+ expect(readableSnippet("# GitHub ## Summary see [[entities/ruben]] and [[x|the label]] **now**")).toBe(+ "GitHub Summary see ruben and the label now",+ );+ });++ it("drops a leading H1 only when it repeats the title", () => {+ expect(stripLeadingTitle("\n# Ruben\n\n## Summary\n", "Ruben")).toBe("## Summary\n");+ expect(stripLeadingTitle("# Other\nbody", "Ruben")).toBe("# Other\nbody");+ });+});diff --git a/jarvis/ui/web/frontend/src/lib/wikiModel.ts b/jarvis/ui/web/frontend/src/lib/wikiModel.tsindex 5f5fe6d777..edea309fbf 100644--- a/jarvis/ui/web/frontend/src/lib/wikiModel.ts+++ b/jarvis/ui/web/frontend/src/lib/wikiModel.ts@@ -55,7 +55,7 @@ export function groupOfKind(kind: string | undefined | null): WikiGroupId {*/export function cleanTitle(title: string | null | undefined, fallback = ""): string {const raw = (title ?? "").trim();- const unquoted = raw.replace(/^["'“‘]+|["'”’]+$/g, "").trim();+ const unquoted = raw.replace(/^["'\p{Pi}\p{Pf}]+|["'\p{Pi}\p{Pf}]+$/gu, "").trim();return unquoted || fallback;}@@ -124,7 +124,7 @@ export function matchesFilter(item: LibraryItem, query: string): boolean {function normalise(value: string): string {return value.normalize("NFD")- .replace(/[̀-ͯ]/g, "")+ .replace(/\p{M}/gu, "").toLowerCase().trim();}@@ -329,3 +329,23 @@ export function traceKindShape(export function isHollowShape(shape: KindShape): boolean {return shape === "ring";}++const SNIPPET_LINK_RE = /\[\[([^\]|\n]+)(?:\|([^\]\n]+))?\]\]/g;++/**+ * Search and backlink snippets arrive as raw Markdown — `## Goal`, `**x**`,+ * `[[target|label]]`. Show the words only.+ */+export function readableSnippet(snippet: string): string {+ return snippet+ .replace(SNIPPET_LINK_RE, (_m, target: string, label?: string) => {+ if (label) return label.trim();+ const text = target.trim();+ const idx = Math.max(text.lastIndexOf("/"), text.lastIndexOf("\\"));+ return idx >= 0 ? text.slice(idx + 1) : text;+ })+ .replace(/(^|\s)#{1,6}\s+/g, "$1")+ .replace(/\*+|__|`/g, "")+ .replace(/\s+/g, " ")+ .trim();+}diff --git a/jarvis/ui/web/frontend/src/views/WikiView.tsx b/jarvis/ui/web/frontend/src/views/WikiView.tsxindex e8c5bbe7da..f3fe66dcbc 100644--- a/jarvis/ui/web/frontend/src/views/WikiView.tsx+++ b/jarvis/ui/web/frontend/src/views/WikiView.tsx@@ -251,7 +251,7 @@ export function WikiView(): JSX.Element {type="button"onClick={() => searchRef.current?.open()}data-testid="wiki-search-trigger"- className="flex h-8 w-60 items-center gap-2 rounded-md border border-border bg-background px-2.5 text-sm text-foreground-faint transition-colors hover:border-border-strong hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"+ className="flex h-8 w-48 items-center gap-2 2xl:w-60 rounded-md border border-border bg-background px-2.5 text-sm text-foreground-faint transition-colors hover:border-border-strong hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"><Search className="h-3.5 w-3.5 shrink-0" aria-hidden /><span className="flex-1 truncate text-left">{t("wiki_ui.search_placeholder")}</span>