feat: rebuild the orbital vault as an operational map
This commit is contained in:
@@ -1,21 +1,27 @@
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { chromium } from "playwright";
|
||||
|
||||
const base = process.env.TESSERA_URL ?? "http://127.0.0.1:8787/";
|
||||
const outFlow =
|
||||
process.env.FLOW_SHOT ?? "/cursor/stores/self/media/tessera-galaxy-flow-polish.png";
|
||||
const outLock =
|
||||
process.env.LOCK_SHOT ?? "/cursor/stores/self/media/tessera-galaxy-locked-polish.png";
|
||||
const outFlow = process.env.FLOW_SHOT ?? join(tmpdir(), "tessera-galaxy-flowing.png");
|
||||
const outLock = process.env.LOCK_SHOT ?? join(tmpdir(), "tessera-galaxy-locked.png");
|
||||
|
||||
const browser = await chromium.launch({ headless: true });
|
||||
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
|
||||
await page.goto(base, { waitUntil: "networkidle", timeout: 30_000 });
|
||||
await page.waitForTimeout(2500);
|
||||
await page.screenshot({ path: outFlow, fullPage: false });
|
||||
const svg = page.locator('[aria-label="Galaxy vault viewport"]');
|
||||
const box = await svg.boundingBox();
|
||||
if (!box) throw new Error("galaxy svg not found");
|
||||
await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
|
||||
await page.waitForTimeout(1400);
|
||||
await page.screenshot({ path: outLock, fullPage: false });
|
||||
await browser.close();
|
||||
console.log("saved", outFlow, outLock);
|
||||
try {
|
||||
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
|
||||
const [orbitResponse] = await Promise.all([
|
||||
page.waitForResponse((response) => new URL(response.url()).pathname === "/api/v1/orbits" && response.ok()),
|
||||
page.goto(base),
|
||||
]);
|
||||
await page.getByText("Hub online", { exact: true }).waitFor();
|
||||
await page.screenshot({ path: outFlow });
|
||||
|
||||
const firstOrbit = page.locator(".register-row").first();
|
||||
if ((await orbitResponse.json()).length) await firstOrbit.click();
|
||||
else await page.getByRole("button", { name: "Pause motion" }).click();
|
||||
await page.getByRole("button", { name: "Resume motion" }).waitFor();
|
||||
await page.screenshot({ path: outLock });
|
||||
console.log("saved", outFlow, outLock);
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
|
||||
64
web/scripts/galaxy.test.mjs
Normal file
64
web/scripts/galaxy.test.mjs
Normal file
@@ -0,0 +1,64 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { assignOrbitSlots, orbitPose, groupSnapshots, moonPoses } from "../src/lib/galaxyLayout.ts";
|
||||
import { placeLabels } from "../src/lib/galaxyLabelLayout.ts";
|
||||
|
||||
test("slot identities survive reordering, insertion and removal", () => {
|
||||
const first = assignOrbitSlots(["a", "b", "c"]);
|
||||
const next = assignOrbitSlots(["new", "c", "a"], first);
|
||||
assert.equal(next.get("a"), first.get("a"));
|
||||
assert.equal(next.get("c"), first.get("c"));
|
||||
assert.equal(next.get("new"), first.get("b"));
|
||||
});
|
||||
|
||||
test("overview fits 50 distinct orbits and promotes a selected orbit beyond capacity", () => {
|
||||
const ids = Array.from({ length: 75 }, (_, i) => String(i));
|
||||
const slots = assignOrbitSlots(ids);
|
||||
assert.ok(slots.size >= 50);
|
||||
assert.equal(new Set(slots.values()).size, slots.size);
|
||||
const promoted = assignOrbitSlots(ids, slots, "74");
|
||||
assert.ok(promoted.has("74"));
|
||||
assert.equal(promoted.get("0"), slots.get("0"));
|
||||
for (const slot of promoted.values()) {
|
||||
const point = orbitPose(slot, 7);
|
||||
assert.ok(Math.abs(point.x) < 320 && Math.abs(point.y) < 220);
|
||||
}
|
||||
});
|
||||
|
||||
test("snapshot ownership uses IDs and only falls back to an unambiguous name", () => {
|
||||
const orbits = [
|
||||
{ id: "a", name: "daily" }, { id: "b", name: "daily" }, { id: "c", name: "archive" },
|
||||
];
|
||||
const snapshot = (id, orbit_name, taken_at, orbit_id) =>
|
||||
({ id, orbit_name, taken_at, orbit_id, size_bytes: 1 });
|
||||
const groups = groupSnapshots(orbits, [
|
||||
snapshot("old", "renamed", "2026-10-01", "a"),
|
||||
snapshot("ambiguous", "daily", "2026-10-03"),
|
||||
snapshot("new", "daily", "2026-10-03", "a"),
|
||||
snapshot("legacy", "archive", "2026-10-02"),
|
||||
snapshot("orphan", "archive", "2026-10-02", "deleted"),
|
||||
]);
|
||||
assert.deepEqual(groups.get("a").map((s) => s.id), ["new", "old"]);
|
||||
assert.equal(groups.has("b"), false);
|
||||
assert.deepEqual(groups.get("c").map((s) => s.id), ["legacy"]);
|
||||
});
|
||||
|
||||
test("moon fan opens away from the vault and separates touch targets", () => {
|
||||
const moons = moonPoses({ x: 150, y: 0 }, 3, 55);
|
||||
assert.equal(moons.length, 3);
|
||||
assert.ok(moons.every((p) => p.x > 150));
|
||||
assert.ok(Math.hypot(moons[0].x - moons[1].x, moons[0].y - moons[1].y) >= 55);
|
||||
const shifted = moonPoses({ x: 150, y: 0 }, 3, 55, moons);
|
||||
assert.equal(shifted.length, 3);
|
||||
assert.ok(shifted.every((moon) => moons.every((star) => Math.hypot(star.x - moon.x, star.y - moon.y) >= 14)));
|
||||
});
|
||||
|
||||
test("labels respect screen bounds and preserve priority in a crowded scene", () => {
|
||||
const candidates = [
|
||||
{ id: "focused", x: 70, y: 60, width: 72 },
|
||||
{ id: "other", x: 70, y: 60, width: 200 },
|
||||
];
|
||||
const labels = placeLabels(candidates, 140, 120, []);
|
||||
assert.deepEqual(labels.map((l) => l.id), ["focused"]);
|
||||
assert.ok(labels[0].x >= 0 && labels[0].x + 72 <= 140);
|
||||
});
|
||||
Reference in New Issue
Block a user