diff --git a/apps/epiphany-gui/scripts/visual-smoke.mjs b/apps/epiphany-gui/scripts/visual-smoke.mjs index ed3009df..b53aad45 100644 --- a/apps/epiphany-gui/scripts/visual-smoke.mjs +++ b/apps/epiphany-gui/scripts/visual-smoke.mjs @@ -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; diff --git a/apps/epiphany-gui/src/App.tsx b/apps/epiphany-gui/src/App.tsx index bdaec609..733f7a97 100644 --- a/apps/epiphany-gui/src/App.tsx +++ b/apps/epiphany-gui/src/App.tsx @@ -805,10 +805,11 @@ export function App() { 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} + > {runningAction === button.action ? button.runningLabel : button.label} @@ -930,27 +931,9 @@ export function App() { }); }, [objectiveDrafts, setRequest]); - return ( - - + const operatorSurface = ( + <> - Epiphany MVP @@ -963,7 +946,13 @@ export function App() { pressure {text(pressure.level, "unknown")} continuity {text(reorient.action, "unknown")} - void refresh()} disabled={loading} title="Refresh status"> + void refresh()} + disabled={loading} + title="Refresh status" + data-interface-sound={loading ? "primary-disabled" : "primary-refresh"} + > {loading ? "Refreshing" : "Refresh"} @@ -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" && } @@ -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() { )} + > + ); + + return ( + + ); } @@ -1399,15 +1413,15 @@ function PlaylistControl({ }) { return ( - + Harmony {loading ? "loading" : frame?.chordLabel ?? "silent"} {error ?? frame?.sourceName ?? "Finding a classical MIDI file."} - void onNext()} disabled={loading}>Shuffle Song - void onChangeFolder()} disabled={loading}>Folder + void onNext()} disabled={loading} data-interface-sound="playlist-next">Shuffle Song + void onChangeFolder()} disabled={loading} data-interface-sound="playlist-folder">Folder @@ -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) { + 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({ )} + + {operatorSurface} + { - 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)} > diff --git a/apps/epiphany-gui/src/aquariumFluid.ts b/apps/epiphany-gui/src/aquariumFluid.ts index 1ef61329..9bd9e9dc 100644 --- a/apps/epiphany-gui/src/aquariumFluid.ts +++ b/apps/epiphany-gui/src/aquariumFluid.ts @@ -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 = { diff --git a/apps/epiphany-gui/src/styles.css b/apps/epiphany-gui/src/styles.css index 39d1c89e..8c9bd79f 100644 --- a/apps/epiphany-gui/src/styles.css +++ b/apps/epiphany-gui/src/styles.css @@ -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,
Epiphany MVP
{error ?? frame?.sourceName ?? "Finding a classical MIDI file."}