diff --git a/apps/epiphany-gui/scripts/visual-smoke.mjs b/apps/epiphany-gui/scripts/visual-smoke.mjs index 5575f8c6..80626c9e 100644 --- a/apps/epiphany-gui/scripts/visual-smoke.mjs +++ b/apps/epiphany-gui/scripts/visual-smoke.mjs @@ -96,6 +96,38 @@ async function smokeViewport(browser, viewport, screenshotPath, exerciseFluidPan throw new Error(`no crisp operator surface rendered: ${crispProbe.reason}`); } + const projectionProbe = await page.evaluate(() => { + const node = document.querySelector('[data-agent-node="coordinator"]'); + if (!(node instanceof HTMLElement)) return { ok: false, reason: "coordinator DOM node missing" }; + const style = node.style; + const x = style.getPropertyValue("--agent-x"); + const y = style.getPropertyValue("--agent-y"); + const glow = Number.parseFloat(style.getPropertyValue("--agent-glow-pulse")); + return { + ok: x.endsWith("%") && y.endsWith("%") && Number.isFinite(glow), + reason: `x=${x} y=${y} glow=${glow}`, + }; + }); + if (!projectionProbe.ok) { + throw new Error(`DOM agent projection was not synchronized: ${projectionProbe.reason}`); + } + + await page.locator('[data-agent-node="research"]').hover(); + await page.waitForTimeout(180); + const hoverProbe = await page.evaluate(() => { + const node = document.querySelector('[data-agent-node="research"]'); + if (!(node instanceof HTMLElement)) return { ok: false, reason: "research DOM node missing" }; + const hover = Number.parseFloat(node.style.getPropertyValue("--agent-hover")); + const acknowledgement = Number.parseFloat(node.style.getPropertyValue("--agent-ack")); + return { + ok: hover > 0.7 && acknowledgement >= 0, + reason: `hover=${hover} ack=${acknowledgement}`, + }; + }); + if (!hoverProbe.ok) { + throw new Error(`DOM hover did not reach aquarium projection: ${hoverProbe.reason}`); + } + let persistedParams = null; if (exerciseFluidPanel) { await page.evaluate((key) => window.localStorage.removeItem(key), fluidStorageKey); diff --git a/apps/epiphany-gui/src/App.tsx b/apps/epiphany-gui/src/App.tsx index 1b50e6e4..5854b5d7 100644 --- a/apps/epiphany-gui/src/App.tsx +++ b/apps/epiphany-gui/src/App.tsx @@ -14,12 +14,12 @@ import { RefreshCw, } from "lucide-react"; import { EpiphanyGraphViewer, validateEpiphanyGraphsState } from "@epiphanygraph/epiphany-graph-viewer"; -import { useEffect, useMemo, useRef, useState } from "react"; +import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { createAquariumRenderer } from "./aquariumFluid"; import { loadOperatorSnapshot, runOperatorAction } from "./operatorApi"; import type { ArtifactBundle, OperatorAction, OperatorActionResult, OperatorSnapshot, StatusRequest } from "./types"; import type { EpiphanyCodeRef, EpiphanyGraphsState } from "@epiphanygraph/epiphany-graph-viewer"; -import type { AquariumOptionFrame, AquariumRenderer, AquariumUiFrame } from "./aquariumFluid"; +import type { AquariumAgentProjection, AquariumOptionFrame, AquariumRenderer, AquariumUiFrame } from "./aquariumFluid"; const roleOrder = ["implementation", "imagination", "research", "eyes", "modeling", "verification", "reorientation"]; const constellationSpecs = [ @@ -424,13 +424,15 @@ function projectedThought(value: unknown, fallback: string): string { function projectedActivity(status: unknown, jobCount = 0): number { const lower = text(status).toLowerCase(); - const jobBoost = Math.min(jobCount * 0.08, 0.24); - if (lower.includes("critical") || lower.includes("running") || lower.includes("launch")) return 1; - if (lower.includes("blocked") || lower.includes("needed") || lower.includes("regather")) return 0.82 + jobBoost; - if (lower.includes("prepare") || lower.includes("review") || lower.includes("ready")) return 0.68 + jobBoost; - if (lower.includes("completed") || lower.includes("continue") || lower.includes("pass")) return 0.48 + jobBoost; - if (lower.includes("idle")) return 0.24 + jobBoost; - return 0.34 + jobBoost; + const jobBoost = Math.min(jobCount * 0.06, 0.18); + if (lower.includes("critical") || lower.includes("panic") || lower.includes("fatal")) return 1; + if (lower.includes("failed") || lower.includes("error") || lower.includes("high")) return 0.74 + jobBoost; + if (lower.includes("running") || lower.includes("launch") || lower.includes("active")) return 0.58 + jobBoost; + if (lower.includes("blocked") || lower.includes("needed") || lower.includes("regather")) return 0.38 + jobBoost; + if (lower.includes("prepare") || lower.includes("review") || lower.includes("ready")) return 0.3 + jobBoost; + if (lower.includes("completed") || lower.includes("continue") || lower.includes("pass")) return 0.24 + jobBoost; + if (lower.includes("idle")) return 0.12 + jobBoost; + return 0.22 + jobBoost; } function findingSummary(result: any): string | undefined { @@ -1328,6 +1330,8 @@ function AgentConstellation({ const optionByKeyRef = useRef(new globalThis.Map()); const uiOptionByKeyRef = useRef(new globalThis.Map()); const rendererRef = useRef(null); + const agentNodeRefs = useRef(new globalThis.Map()); + const thoughtNodeRefs = useRef(new globalThis.Map()); const [selectedAgentId, setSelectedAgentId] = useState("coordinator"); const agents = useMemo(() => { return constellationSpecs.map((spec) => { @@ -1440,15 +1444,56 @@ function AgentConstellation({ }; }, []); + const bindAgentNode = useCallback((id: string, node: HTMLButtonElement | null) => { + if (node) { + agentNodeRefs.current.set(id, node); + } else { + agentNodeRefs.current.delete(id); + } + }, []); + + const bindThoughtNode = useCallback((id: string, node: HTMLDivElement | null) => { + if (node) { + thoughtNodeRefs.current.set(id, node); + } else { + thoughtNodeRefs.current.delete(id); + } + }, []); + + const applyProjectionFrame = useCallback((projections: AquariumAgentProjection[]) => { + for (const projection of projections) { + const agentNode = agentNodeRefs.current.get(projection.id); + const thoughtNode = thoughtNodeRefs.current.get(projection.id); + const properties: Array<[string, string]> = [ + ["--agent-x", `${projection.xPercent}%`], + ["--agent-y", `${projection.yPercent}%`], + ["--agent-tilt", `${projection.tilt}deg`], + ["--agent-bubble-tilt", `${projection.tilt * 0.32}deg`], + ["--agent-glow-pulse", String(projection.glowPulse)], + ["--agent-glow-radius", `${14 + projection.glowPulse * 10}px`], + ["--agent-hover-glow", `${projection.hover * (6 + projection.glowPulse * 8)}px`], + ["--agent-expression", String(projection.expression)], + ["--agent-hover", String(projection.hover)], + ["--agent-ack", String(projection.acknowledgement)], + ["--agent-scale", String(1 + projection.acknowledgement * 0.035 + projection.hover * 0.018)], + ]; + for (const [name, value] of properties) { + agentNode?.style.setProperty(name, value); + thoughtNode?.style.setProperty(name, value); + } + } + }, []); + useEffect(() => { rendererRef.current?.setFrame({ activeLabel: activeDeck ? `${deckLabels[activeDeck]} / ${activeSubdeck ?? ""}` : undefined, agents: aquariumAgents, + onProjectionFrame: applyProjectionFrame, selectedAgentId, ui, variant, }); - }, [activeDeck, activeSubdeck, aquariumAgents, selectedAgentId, ui, variant]); + }, [activeDeck, activeSubdeck, applyProjectionFrame, aquariumAgents, selectedAgentId, ui, variant]); function handlePointerMove(event: React.PointerEvent) { rendererRef.current?.setPointerClient(event.clientX, event.clientY); @@ -1471,6 +1516,19 @@ function AgentConstellation({ rendererRef.current?.pointerUp(); } + function handleAgentPointerEnter(agentId: string, event: React.PointerEvent) { + rendererRef.current?.setPointerClient(event.clientX, event.clientY); + rendererRef.current?.setHoveredAgent(agentId); + } + + function handleAgentPointerMove(event: React.PointerEvent) { + rendererRef.current?.setPointerClient(event.clientX, event.clientY); + } + + function handleAgentPointerLeave() { + rendererRef.current?.setHoveredAgent(null); + } + function handleCanvasClick() { const optionKey = rendererRef.current?.pickOption(); if (optionKey) { @@ -1521,9 +1579,16 @@ function AgentConstellation({