// The trajectory page, drawn the way LayerFS's own History picture is: // main is the green middle bough, every other branch a bough that splits // off it, a checkpoint a badge on its bough bearing its agent's own // icon (the marks magpie itself ships for them), and a publish a graft // back onto main that lands a Layer badge. The replay is one continuous // timeline, driven by requestAnimationFrame through the pure motion // model in view.js: boughs draw themselves as the playhead passes, // badges land with a pulse while their icons draw themselves, and the // counters count up along the same easing magpie itself uses // (--ease, cubic-bezier(.2,.8,.2,1)). // // The data is the trajectory bundled with the package (trajectory.js, // a labeled sample from the benchmark run). A magpie page cannot read // plugin-private data: the bridge's reads are a fixed host list // (usage:summary, providers:list), and the sandbox allows no fetch. // The live recording the tools keep lives in the store as // trajectory.json, next to the store's own data. (async () => { const V = globalThis.LayerfsView; const $ = (id) => document.getElementById(id); const SVG = "http://www.w3.org/2000/svg"; const RM = matchMedia("(prefers-reduced-motion: reduce)").matches; const STEP_MS = 560; // one checkpoint's stretch of timeline at 1× const PULSE_MS = 650; let theme = { lang: "en", dark: matchMedia("(prefers-color-scheme: dark)").matches }; try { theme = (await magpie.ready) || theme; } catch { /* standalone preview */ } const lang = theme.lang || "en"; const t = V.text(lang); document.querySelectorAll("[data-t]").forEach((e) => { e.textContent = t[e.dataset.t]; }); // branch colours: an agent's branch wears the agent's own brand // colour in both themes; the rest take magpie's chart series, and // main is the leaf green (deeper on light, brighter on dark) const SERIES = { dark: ["#a5b4fc", "#7dd3fc", "#6ee7b7", "#fcd34d", "#f9a8d4", "#c4b5fd", "#94a3b8"], light: ["#4f46e5", "#0ea5e9", "#10b981", "#f59e0b", "#ec4899", "#8b5cf6", "#64748b"], }; const series = () => SERIES[theme.dark ? "dark" : "light"]; const mainColor = () => (theme.dark ? "#4ade80" : "#16a34a"); const colorOf = (branch, lane) => (V.agentOf(branch) || {}).color || (lane === 0 ? mainColor() : series()[(lane - 1) % series().length]); const data = globalThis.LayerfsTrajectory; const projects = (data && data.projects || []).filter((p) => p.branches.some((b) => b.commits.length)); if (!projects.length) { $("stage").hidden = true; $("controls").hidden = true; $("stats").hidden = true; $("empty").hidden = false; $("empty").textContent = t.noData; return; } $("stamp").textContent = data.sample ? t.sample : `${t.recorded} ${String(data.generatedAt || "").replace("T", " ").slice(0, 19)} · ${data.backend || ""}`; // the project picker: a magpie-style menu (a button and a listbox), // not a native