Move operator UI into aquarium

This commit is contained in:
Meta Vens 2026-05-05 12:04:10 +01:00
commit e504a0f6ad
4 changed files with 175 additions and 30 deletions

View file

@ -77,7 +77,7 @@ async function smokeViewport(browser, viewport, screenshotPath, exerciseFluidPan
const operatorSurface = await page.evaluate(() => {
return [".immersiveTopbar", ".deckRail", ".diegeticPanel"].every((selector) => {
const element = document.querySelector(selector);
const element = document.querySelector(`.agentStage ${selector}`);
if (!element) return false;
const style = window.getComputedStyle(element);
const rect = element.getBoundingClientRect();
@ -195,6 +195,12 @@ async function smokeViewport(browser, viewport, screenshotPath, exerciseFluidPan
throw new Error(`aquarium audio did not wake correctly: ${JSON.stringify(audio)}`, { cause: error });
}
audioProbe = await page.evaluate(() => window.__epiphanyAquariumAudio ?? null);
await page.locator(".deckRail button").nth(1).click();
await page.waitForFunction(() => {
const audio = window.__epiphanyAquariumAudio;
return audio?.state === "running" && audio.interfaceHitCount >= 1;
}, null, { timeout: 5000 });
audioProbe = await page.evaluate(() => window.__epiphanyAquariumAudio ?? null);
}
let persistedParams = null;

View file

@ -805,10 +805,11 @@ export function App() {
<button
className="secondaryButton hudActionButton"
onClick={() => void runAction(button.action)}
disabled={disabled}
title={title}
key={button.action}
>
disabled={disabled}
title={title}
data-interface-sound={disabled ? "action-disabled" : "action-primary"}
key={button.action}
>
<ActionIcon icon={button.icon} />
{runningAction === button.action ? button.runningLabel : button.label}
</button>
@ -930,27 +931,9 @@ export function App() {
});
}, [objectiveDrafts, setRequest]);
return (
<main className="immersiveShell">
<AgentConstellation
roles={roles}
roleResults={roleResults}
reorientResult={reorientResult}
coordinator={coordinator}
crrc={crrc}
pressure={pressure}
reorient={reorient}
jobs={jobs}
variant="fullscreen"
activeDeck={activeDeck}
activeSubdeck={activeSubdeck}
ui={aquariumUi}
harmonyFrame={harmony.frame}
onAgentOption={handleAquariumOption}
isActionBlocked={actionBlocked}
/>
const operatorSurface = (
<>
<div className="hudGrid" aria-hidden="true" />
<header className="immersiveTopbar">
<div className="operatorIdentity">
<p className="eyebrow">Epiphany MVP</p>
@ -963,7 +946,13 @@ export function App() {
</Pill>
<Pill tone={statusClass(pressure.level)}>pressure {text(pressure.level, "unknown")}</Pill>
<Pill tone={statusClass(reorient.action)}>continuity {text(reorient.action, "unknown")}</Pill>
<button className="primaryButton" onClick={() => void refresh()} disabled={loading} title="Refresh status">
<button
className="primaryButton"
onClick={() => void refresh()}
disabled={loading}
title="Refresh status"
data-interface-sound={loading ? "primary-disabled" : "primary-refresh"}
>
<RefreshCw size={16} aria-hidden="true" />
{loading ? "Refreshing" : "Refresh"}
</button>
@ -983,6 +972,7 @@ export function App() {
type="button"
className={activeDeck === deck ? "active" : ""}
onClick={() => selectDeck(deck)}
data-interface-sound="deck-menu"
key={deck}
>
{deck === "command" && <ClipboardCheck size={17} aria-hidden="true" />}
@ -1006,6 +996,7 @@ export function App() {
type="button"
className={activeSubdeck === subdeck ? "active" : ""}
onClick={() => selectSubdeck(activeDeck, subdeck)}
data-interface-sound="subdeck-menu"
key={subdeck}
>
{subdeck}
@ -1371,6 +1362,29 @@ export function App() {
</section>
)}
</aside>
</>
);
return (
<main className="immersiveShell">
<AgentConstellation
roles={roles}
roleResults={roleResults}
reorientResult={reorientResult}
coordinator={coordinator}
crrc={crrc}
pressure={pressure}
reorient={reorient}
jobs={jobs}
variant="fullscreen"
activeDeck={activeDeck}
activeSubdeck={activeSubdeck}
ui={aquariumUi}
harmonyFrame={harmony.frame}
operatorSurface={operatorSurface}
onAgentOption={handleAquariumOption}
isActionBlocked={actionBlocked}
/>
</main>
);
}
@ -1399,15 +1413,15 @@ function PlaylistControl({
}) {
return (
<details className="playlistControl">
<summary title={frame?.sourcePath ?? error ?? "Loading classical MIDI harmony"}>
<summary title={frame?.sourcePath ?? error ?? "Loading classical MIDI harmony"} data-interface-sound="playlist-panel">
<span>Harmony</span>
<strong>{loading ? "loading" : frame?.chordLabel ?? "silent"}</strong>
</summary>
<div className="playlistBody">
<p title={frame?.sourcePath ?? undefined}>{error ?? frame?.sourceName ?? "Finding a classical MIDI file."}</p>
<div className="playlistButtons">
<button type="button" onClick={() => void onNext()} disabled={loading}>Shuffle Song</button>
<button type="button" onClick={() => void onChangeFolder()} disabled={loading}>Folder</button>
<button type="button" onClick={() => void onNext()} disabled={loading} data-interface-sound="playlist-next">Shuffle Song</button>
<button type="button" onClick={() => void onChangeFolder()} disabled={loading} data-interface-sound="playlist-folder">Folder</button>
</div>
</div>
</details>
@ -1428,6 +1442,7 @@ function AgentConstellation({
activeSubdeck,
ui,
harmonyFrame,
operatorSurface,
onAgentOption,
isActionBlocked,
}: {
@ -1444,6 +1459,7 @@ function AgentConstellation({
activeSubdeck?: string;
ui?: AquariumUiFrame;
harmonyFrame: AquariumHarmonyFrame | null;
operatorSurface?: React.ReactNode;
onAgentOption?: (option: AquariumOption) => void;
isActionBlocked?: (action: OperatorAction) => boolean;
}) {
@ -1691,6 +1707,24 @@ function AgentConstellation({
};
}
function handleInterfacePointerDown(event: React.PointerEvent<HTMLElement>) {
const target = event.target;
if (!(target instanceof HTMLElement)) return;
if (target.closest(".agentCharacter")) return;
const control = target.closest("button, summary, input, select, [data-interface-sound]");
if (!(control instanceof HTMLElement)) return;
const disabled =
control instanceof HTMLButtonElement || control instanceof HTMLInputElement || control instanceof HTMLSelectElement
? control.disabled
: false;
const explicitKind = control.dataset.interfaceSound;
const kind =
explicitKind ??
(control.closest(".diegeticPanel") ? "panel-control" : control.closest(".deckRail") ? "deck-menu" : "control");
rendererRef.current?.wakeSoundscape();
rendererRef.current?.triggerInterfaceHit(disabled ? `${kind}-disabled` : kind);
}
function handleCanvasClick() {
const optionKey = rendererRef.current?.pickOption();
if (optionKey) {
@ -1726,6 +1760,9 @@ function AgentConstellation({
</div>
)}
<div className="agentStage">
<div className="aquariumOperatorLayer" onPointerDownCapture={handleInterfacePointerDown}>
{operatorSurface}
</div>
<canvas
ref={canvasRef}
className="agentSmokeCanvas"
@ -1750,7 +1787,6 @@ function AgentConstellation({
type="button"
data-agent-node={agent.id}
onClick={() => {
rendererRef.current?.acknowledgeAgent(agent.id, "selected");
setSelectedAgentId(agent.id);
}}
onPointerEnter={(event) => handleAgentPointerEnter(agent.id, event)}
@ -1837,6 +1873,7 @@ function AgentConstellation({
key={option.key}
disabled={option.disabled}
title={option.label}
data-interface-sound={option.disabled ? "agent-option-disabled" : "agent-option"}
style={optionPositionStyle(index, options.length)}
onClick={(event) => handleOptionClick(event, option.key)}
>

View file

@ -89,6 +89,7 @@ export interface AquariumRenderer {
setFrame(frame: AquariumFrame): void;
setHoveredAgent(id: string | null): void;
setPointerClient(clientX: number, clientY: number): void;
triggerInterfaceHit(kind?: string): void;
wakeSoundscape(): void;
}
@ -691,6 +692,10 @@ class WebglAquariumRenderer implements AquariumRenderer {
this.ensureSoundscape();
}
triggerInterfaceHit(kind = "control") {
this.ensureSoundscape()?.triggerInterfaceHit(kind);
}
setPointerClient(clientX: number, clientY: number) {
const rect = this.canvas.getBoundingClientRect();
const x = ((clientX - rect.left) / Math.max(rect.width, 1)) * this.simWidth;
@ -706,6 +711,7 @@ class WebglAquariumRenderer implements AquariumRenderer {
this.ensureSoundscape();
const zone = this.fluidParamZones.find((candidate) => pointInRect(this.pointer.x, this.pointer.y, candidate));
if (!zone) return;
this.triggerInterfaceHit(`fluid-${zone.key}`);
if (zone.key === "toggle") {
this.fluidPanelPinned = !this.fluidPanelPinned;
return;
@ -2362,6 +2368,7 @@ class BufferedGpuSpectrumOutput {
class AquariumSoundscape {
private compressor: DynamicsCompressorNode;
private context: AudioContext;
private interfaceHitCount = 0;
private lastAgents: ProjectedAgent[] = [];
private master: GainNode;
private lastBurstChirpDrivers = 0;
@ -2433,6 +2440,18 @@ class AquariumSoundscape {
this.publishDebugState(action);
}
triggerInterfaceHit(kind: string) {
if (this.context.state === "suspended") {
void this.context.resume().then(() => {
this.playInterfaceResonator(kind);
this.publishDebugState();
});
return;
}
this.playInterfaceResonator(kind);
this.publishDebugState();
}
private flushPendingBursts() {
if (this.context.state === "suspended" || !this.pendingBursts.length) return;
const bursts = this.pendingBursts.splice(0, this.pendingBursts.length).slice(-8);
@ -2448,11 +2467,75 @@ class AquariumSoundscape {
pendingBursts: this.pendingBursts.length,
lastBurst: lastBurst ?? (window as any).__epiphanyAquariumAudio?.lastBurst ?? null,
lastBurstChirpDrivers: this.lastBurstChirpDrivers,
interfaceHitCount: this.interfaceHitCount,
masterGain: this.master.gain.value,
spectral: this.spectralOutput.stats(),
error: error ?? null,
};
}
private playInterfaceResonator(kind: string) {
const now = this.context.currentTime;
const duration = kind.includes("panel") ? 0.32 : kind.includes("menu") ? 0.24 : 0.18;
const seed = hashString(`${kind}:${this.interfaceHitCount}`);
const random = mulberry32(seed);
const noise = this.context.createBuffer(1, Math.ceil(this.context.sampleRate * duration), this.context.sampleRate);
const data = noise.getChannelData(0);
for (let index = 0; index < data.length; index += 1) {
data[index] = random() * 2 - 1;
}
const source = this.context.createBufferSource();
const body = this.context.createGain();
const output = this.context.createGain();
source.buffer = noise;
body.gain.setValueAtTime(1, now);
body.gain.exponentialRampToValueAtTime(0.001, now + duration);
output.gain.setValueAtTime(0.0001, now);
output.gain.exponentialRampToValueAtTime(kind.includes("disabled") ? 0.045 : 0.085, now + 0.006);
output.gain.exponentialRampToValueAtTime(0.0001, now + duration);
const profile = interfaceHarmonicProfile(kind, seed);
for (const [index, frequency] of profile.entries()) {
const resonator = this.context.createBiquadFilter();
const gain = this.context.createGain();
resonator.type = "bandpass";
resonator.frequency.setValueAtTime(frequency, now);
resonator.Q.setValueAtTime(9 + index * 2.2 + random() * 5, now);
gain.gain.setValueAtTime((kind.includes("primary") ? 0.12 : 0.085) / Math.pow(index + 1, 0.72), now);
source.connect(resonator);
resonator.connect(gain);
gain.connect(body);
}
body.connect(output);
output.connect(this.master);
source.start(now);
source.stop(now + duration);
source.onended = () => {
source.disconnect();
body.disconnect();
output.disconnect();
};
this.interfaceHitCount += 1;
}
}
function interfaceHarmonicProfile(kind: string, seed: number) {
const random = mulberry32(seed ^ 0x9e3779b9);
const root = kind.includes("deck")
? 146.83
: kind.includes("subdeck")
? 196
: kind.includes("playlist")
? 261.63
: kind.includes("primary")
? 329.63
: 220;
const profile = kind.includes("panel")
? [1, 1.5, 2, 2.5, 3, 4.5]
: kind.includes("disabled")
? [1, 1.33, 2, 2.66]
: [1, 2, 3, 5, 8];
return profile.map((ratio, index) => root * ratio * (1 + (random() - 0.5) * 0.012 * (index + 1)));
}
class CanvasAquariumRenderer implements AquariumRenderer {
@ -2498,6 +2581,10 @@ class CanvasAquariumRenderer implements AquariumRenderer {
// The 2D fallback has no soundscape.
}
triggerInterfaceHit(_kind?: string) {
// The 2D fallback has no soundscape.
}
setPointerClient(clientX: number, clientY: number) {
const rect = this.canvas.getBoundingClientRect();
this.pointer = {

View file

@ -472,6 +472,21 @@ body:has(.immersiveShell) {
mask-image: radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0.8), transparent 72%);
}
.aquariumOperatorLayer {
position: absolute;
inset: 0;
z-index: 7;
pointer-events: none;
}
.aquariumOperatorLayer > * {
pointer-events: auto;
}
.aquariumOperatorLayer .hudGrid {
pointer-events: none;
}
.immersiveTopbar,
.deckRail,
.diegeticPanel,