Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat: add a manual soundscape override to CyberCity settings (#3395)

[._.]/ Adam Eivy9711eaa90294
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 00742336b8..3dfb0bc091 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -4,6 +4,7 @@
- **Each family runs an ORDERED list of burn jobs, each with its own type, model, and target** — so "have codex render every universe bible entry that has no image, and only then fall through to agent work" is expressible. Two job types ship: `agent-prompt` (the previous behavior — queue a CoS agent in a *named* managed app, so the work can still target any app) and `universe-bible-images`, a fully programmatic job that enqueues renders for bible entries whose `imageRefs[]` is empty, defaulting the render backend to the burning family's own image mode so a codex burn spends codex's image quota. A new job type is three server edits; the config form builds itself from the server's job catalog.
- The page states, per family, whether it will burn on the next tick and — when it won't — the exact gate that closed (`resets in 40h — outside the 24h window`, `dispatch cap reached (2/2)`, `62% left is at or below the 70% reserve`), evaluated by the same predicate the runner uses. Per-job pending counts, a run log that records skips *with reasons*, and manual "Evaluate now" / "Burn now" / per-job force-run controls are all on the page.
- **Game studio music bindings can now publish into the game repo, symmetric with the artwork lane.** `POST /api/games/:id/music/:bindingId/publish` copies the bound track's library audio into the managed app repository with SHA-256 provenance, an occupied/diverged-destination guard behind an explicit overwrite acknowledgement, a mid-deploy refusal, and per-repo write serialization shared with the artwork lane (one queue, so artwork and music publishes into the same repo can't race). Music bindings gained an editable repo-relative `destinationPath` (`PATCH /api/games/:id/music/:bindingId`, defaulted from the rendered audio filename under `game/assets/music/` at bind time), the integrity preflight now reports published/pending state for music exactly as it does for artwork — without changing the manifest-input hash of destination-less legacy bindings, so upgrading alone can't flag an existing bundle stale — and the Assets tab's music rows grew destination editing, a Publish button, and an inline overwrite-consent flow.
+- **CyberCity's ambient music mood can now be pinned by hand.** The Audio tab of the city settings drawer gained a SOUNDSCAPE select — AUTO plus every mood (bright / neutral / tense) — persisted with the other city settings. AUTO is an explicit `null` sentinel, so "following live system health and agent activity" is never confused with a pinned mood, and an unrecognized stored value degrades to AUTO rather than freezing the music. A pinned mood re-derives the whole mood half of the soundscape (chord table, filter cutoff, pad detune) while leaving the activity-driven half live, and setting or clearing it re-ramps the running graph immediately instead of waiting for the next system-state change. (#3395)
## Fixed
diff --git a/client/src/components/city/CitySettingsDrawer.jsx b/client/src/components/city/CitySettingsDrawer.jsx
index 01b5b9d010..5c3f0f3ef0 100644
--- a/client/src/components/city/CitySettingsDrawer.jsx
+++ b/client/src/components/city/CitySettingsDrawer.jsx
@@ -2,6 +2,16 @@ import Drawer from '../Drawer';
import useDrawerTab from '../../hooks/useDrawerTab';
import { useCitySettingsContext } from './CitySettingsContext';
import { QUALITY_PRESETS } from '../../hooks/useCitySettings';
+import { SOUNDSCAPE_MOODS, isSoundscapeMood } from '../../utils/citySoundscape';
+
+// The soundscape override's "no override" option. A `<select>` can't carry `null`, so the
+// auto choice rides as the empty string and the change handler maps it back to the `null`
+// sentinel — keeping "following live state" distinct from "pinned to a mood".
+const SOUNDSCAPE_AUTO = '';
+const SOUNDSCAPE_OPTIONS = [
+ { value: SOUNDSCAPE_AUTO, label: 'AUTO' },
+ ...SOUNDSCAPE_MOODS.map(mood => ({ value: mood, label: mood.toUpperCase() })),
+];
// City settings migrated onto the shared tabbed <Drawer> (issue #2591) — replaces
// the old bespoke bottom-right 19rem page-length scroller. Grouped into
@@ -61,6 +71,27 @@ function SettingSlider({ id, label, value, onChange, min = 0, max = 1, step = 0.
);
}
+// Dropdown enum picker, for enums with too many options to read as a segmented row.
+// `options` is [{ value, label }]; values are plain strings (the caller maps any sentinel).
+function SettingSelect({ id, label, value, onChange, options, hint, description }) {
+ return (
+ <div className="py-2" title={description}>
+ <label htmlFor={id} className="block font-pixel text-[11px] text-gray-300 tracking-wide mb-1.5">{label}</label>
+ <select
+ id={id}
+ value={value}
+ onChange={(e) => onChange(e.target.value)}
+ className="w-full font-pixel text-[10px] min-h-[44px] px-2 rounded border border-gray-700/40 bg-gray-800/40 text-gray-300 tracking-wide focus:border-cyan-500/50 focus:outline-none"
+ >
+ {options.map(({ value: optionValue, label: optionLabel }) => (
+ <option key={optionValue} value={optionValue}>{optionLabel}</option>
+ ))}
+ </select>
+ {hint && <div className="font-pixel text-[8px] text-gray-500 tracking-wide mt-1.5">{hint}</div>}
+ </div>
+ );
+}
+
// Segmented enum picker. `isActive` defaults to strict equality; pass a predicate
// for legacy-value mapping.
function SettingSegment({ label, options, value, onChange, hint, isActive }) {
@@ -214,13 +245,26 @@ export default function CitySettingsDrawer({ open, onClose, qualityMode = 'manua
description="Enable ambient synthwave music"
/>
{settings.musicEnabled && (
- <SettingSlider
- id="city-music-volume"
- label="VOLUME"
- value={settings.musicVolume}
- onChange={(v) => updateSetting('musicVolume', v)}
- description="Music playback volume"
- />
+ <>
+ <SettingSlider
+ id="city-music-volume"
+ label="VOLUME"
+ value={settings.musicVolume}
+ onChange={(v) => updateSetting('musicVolume', v)}
+ description="Music playback volume"
+ />
+ {/* Manual mood override (#3395). AUTO is the empty-string option, mapped back to
+ the `null` sentinel — distinct from a pinned mood, never conflated with one. */}
+ <SettingSelect
+ id="city-soundscape-override"
+ label="SOUNDSCAPE"
+ value={isSoundscapeMood(settings.soundscapeOverride) ? settings.soundscapeOverride : SOUNDSCAPE_AUTO}
+ onChange={(v) => updateSetting('soundscapeOverride', v === SOUNDSCAPE_AUTO ? null : v)}
+ options={SOUNDSCAPE_OPTIONS}
+ hint="AUTO FOLLOWS SYSTEM HEALTH AND AGENT ACTIVITY"
+ description="Pin the ambient music's mood, or follow live system state"
+ />
+ </>
)}
</div>
<div>
diff --git a/client/src/components/city/CitySettingsDrawer.test.jsx b/client/src/components/city/CitySettingsDrawer.test.jsx
index 6040dca650..7a280d199d 100644
--- a/client/src/components/city/CitySettingsDrawer.test.jsx
+++ b/client/src/components/city/CitySettingsDrawer.test.jsx
@@ -73,6 +73,28 @@ describe('CitySettingsDrawer', () => {
expect(onClose).toHaveBeenCalledTimes(1);
});
+ it('offers a soundscape override with Auto plus every mood, and persists the choice', () => {
+ window.localStorage.clear();
+ renderDrawer('?cityTab=audio');
+ // The override rides with the music controls, so it appears once music is on.
+ expect(screen.queryByLabelText('SOUNDSCAPE')).toBeNull();
+ fireEvent.click(screen.getByRole('switch', { name: 'SYNTHWAVE' }));
+
+ const select = screen.getByLabelText('SOUNDSCAPE');
+ expect([...select.options].map(o => o.textContent)).toEqual(['AUTO', 'BRIGHT', 'NEUTRAL', 'TENSE']);
+ expect(select.value).toBe('');
+
+ fireEvent.change(select, { target: { value: 'tense' } });
+ expect(screen.getByLabelText('SOUNDSCAPE').value).toBe('tense');
+ expect(JSON.parse(window.localStorage.getItem('portos-city-settings')).soundscapeOverride).toBe('tense');
+
+ // Back to Auto — stored as the explicit null sentinel, not an empty string.
+ fireEvent.change(screen.getByLabelText('SOUNDSCAPE'), { target: { value: '' } });
+ expect(screen.getByLabelText('SOUNDSCAPE').value).toBe('');
+ expect(JSON.parse(window.localStorage.getItem('portos-city-settings')).soundscapeOverride).toBeNull();
+ window.localStorage.clear();
+ });
+
it('renders nothing when closed', () => {
const { container } = render(
<MemoryRouter initialEntries={['/city']}>
diff --git a/client/src/hooks/useCityAudio.js b/client/src/hooks/useCityAudio.js
index 063e3b4f5c..b7f77f428f 100644
--- a/client/src/hooks/useCityAudio.js
+++ b/client/src/hooks/useCityAudio.js
@@ -2,6 +2,7 @@ import { useState, useEffect, useCallback, useRef } from 'react';
import { initAudio, setMusicVolume, setSfxVolume, scheduleCleanup as scheduleAudioCleanup } from '../components/city/audio/cityAudioEngine';
import { startMusic, stopMusic, setSoundscape } from '../components/city/audio/citySynthMusic';
import { playSfx as playSfxFn } from '../components/city/audio/citySoundEffects';
+import { applyMoodOverride } from '../utils/citySoundscape';
// `soundscape` is the computeSoundscape() view-model (roadmap 3.4): the live mood/energy the
// ambient music should reflect. Optional — when omitted the music plays its default progression.
@@ -10,10 +11,15 @@ export default function useCityAudio(settings, soundscape) {
const initedRef = useRef(false);
const settingsRef = useRef(settings);
settingsRef.current = settings;
+ // A manual soundscape override (#3395) pins the mood, overriding the live classification; the
+ // `null` sentinel (auto) passes the computed soundscape straight through. Everything below
+ // works off this effective view-model, so the forced mood reaches every apply path — the
+ // gesture-init start, the music-toggle start, and the live-state effect alike.
+ const effectiveSoundscape = applyMoodOverride(soundscape, settings?.soundscapeOverride);
// Mirror the latest soundscape so deferred starts (gesture-init, music-toggle) apply it without
// depending on render timing.
- const soundscapeRef = useRef(soundscape);
- soundscapeRef.current = soundscape;
+ const soundscapeRef = useRef(effectiveSoundscape);
+ soundscapeRef.current = effectiveSoundscape;
const musicEnabled = settings?.musicEnabled;
const musicVolume = settings?.musicVolume;
const sfxVolume = settings?.sfxVolume;
@@ -56,19 +62,22 @@ export default function useCityAudio(settings, soundscape) {
}
}, [isAudioReady, musicEnabled]);
- // Drive the ambient soundscape from live system state. The deps are the individual field
- // values (not the `soundscape` object), so a poll that recomputes an equal snapshot — a new
- // object with identical fields — doesn't re-ramp the graph; only an actual mood/energy change
- // does. The effect reads the freshest snapshot from the ref at run time.
- const chordSet = soundscape?.chordSet;
- const filterBase = soundscape?.filterBase;
- const arpGain = soundscape?.arpGain;
- const padDetune = soundscape?.padDetune;
+ // Drive the ambient soundscape from live system state (or the manual override). The deps are
+ // the individual field values (not the `soundscape` object), so a poll that recomputes an equal
+ // snapshot — a new object with identical fields — doesn't re-ramp the graph; only an actual
+ // mood/energy change does. Setting or clearing the override changes these same fields, so the
+ // music re-ramps the moment it flips rather than waiting for the next live mood change. The
+ // effect reads the freshest snapshot from the ref at run time.
+ const mood = effectiveSoundscape?.mood;
+ const chordSet = effectiveSoundscape?.chordSet;
+ const filterBase = effectiveSoundscape?.filterBase;
+ const arpGain = effectiveSoundscape?.arpGain;
+ const padDetune = effectiveSoundscape?.padDetune;
useEffect(() => {
const s = soundscapeRef.current;
if (!isAudioReady || !musicEnabled || !s) return;
setSoundscape(s);
- }, [isAudioReady, musicEnabled, chordSet, filterBase, arpGain, padDetune]);
+ }, [isAudioReady, musicEnabled, mood, chordSet, filterBase, arpGain, padDetune]);
// Update music volume
useEffect(() => {
diff --git a/client/src/hooks/useCityAudio.test.jsx b/client/src/hooks/useCityAudio.test.jsx
new file mode 100644
index 0000000000..63b888772b
--- /dev/null
+++ b/client/src/hooks/useCityAudio.test.jsx
@@ -0,0 +1,108 @@
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+import { renderHook, act } from '@testing-library/react';
+
+vi.mock('../components/city/audio/cityAudioEngine', () => ({
+ initAudio: vi.fn(() => ({})),
+ setMusicVolume: vi.fn(),
+ setSfxVolume: vi.fn(),
+ scheduleCleanup: vi.fn(),
+}));
+vi.mock('../components/city/audio/citySynthMusic', () => ({
+ startMusic: vi.fn(),
+ stopMusic: vi.fn(() => 0),
+ setSoundscape: vi.fn(),
+}));
+vi.mock('../components/city/audio/citySoundEffects', () => ({
+ playSfx: vi.fn(),
+}));
+
+import useCityAudio from './useCityAudio.js';
+import { setSoundscape } from '../components/city/audio/citySynthMusic';
+import { computeSoundscape } from '../utils/citySoundscape';
+
+// A healthy, moderately busy city — the live mood is `bright`, so a `tense` override is an
+// observable change and clearing it back to auto is observable in the other direction.
+const LIVE = computeSoundscape({ systemHealth: { overallHealth: 'healthy' }, agentCount: 3 });
+
+const baseSettings = {
+ musicEnabled: true,
+ musicVolume: 0.3,
+ sfxEnabled: true,
+ sfxVolume: 0.5,
+ soundscapeOverride: null,
+};
+
+// The AudioContext only comes up on a user gesture; without it the hook never applies anything.
+const primeAudio = () => act(() => { window.dispatchEvent(new Event('click')); });
+
+const lastSoundscape = () => setSoundscape.mock.calls.at(-1)?.[0];
+
+beforeEach(() => {
+ vi.clearAllMocks();
+});
+
+describe('useCityAudio soundscape override', () => {
+ it('applies the live soundscape when no override is set', () => {
+ renderHook(() => useCityAudio(baseSettings, LIVE));
+ primeAudio();
+ expect(lastSoundscape()).toMatchObject({ mood: 'bright', chordSet: 'bright' });
+ });
+
+ it('applies the forced chord set while the override is set', () => {
+ const { rerender } = renderHook(
+ ({ settings }) => useCityAudio(settings, LIVE),
+ { initialProps: { settings: baseSettings } },
+ );
+ primeAudio();
+
+ rerender({ settings: { ...baseSettings, soundscapeOverride: 'tense' } });
+ expect(lastSoundscape()).toMatchObject({ mood: 'tense', chordSet: 'tense' });
+ expect(lastSoundscape().filterBase).toBeLessThan(LIVE.filterBase);
+ });
+
+ it('keeps the forced mood when live system state changes underneath it', () => {
+ const { rerender } = renderHook(
+ ({ settings, soundscape }) => useCityAudio(settings, soundscape),
+ { initialProps: { settings: { ...baseSettings, soundscapeOverride: 'bright' }, soundscape: LIVE } },
+ );
+ primeAudio();
+ expect(lastSoundscape()).toMatchObject({ chordSet: 'bright' });
+
+ // The system goes critical — auto would swap to the tense table; the override must not.
+ const stressed = computeSoundscape({ systemHealth: { overallHealth: 'critical' }, agentCount: 3 });
+ rerender({ settings: { ...baseSettings, soundscapeOverride: 'bright' }, soundscape: stressed });
+ expect(lastSoundscape()).toMatchObject({ mood: 'bright', chordSet: 'bright' });
+ });
+
+ it('resumes live computation immediately when the override is cleared to Auto', () => {
+ const { rerender } = renderHook(
+ ({ settings }) => useCityAudio(settings, LIVE),
+ { initialProps: { settings: { ...baseSettings, soundscapeOverride: 'tense' } } },
+ );
+ primeAudio();
+ expect(lastSoundscape()).toMatchObject({ chordSet: 'tense' });
+
+ rerender({ settings: { ...baseSettings, soundscapeOverride: null } });
+ expect(lastSoundscape()).toMatchObject({ mood: LIVE.mood, chordSet: LIVE.chordSet });
+ expect(lastSoundscape().filterBase).toBeCloseTo(LIVE.filterBase, 5);
+ });
+
+ it('ignores an unknown stored override value and stays on live state', () => {
+ renderHook(() => useCityAudio({ ...baseSettings, soundscapeOverride: 'stale-mood' }, LIVE));
+ primeAudio();
+ expect(lastSoundscape()).toMatchObject({ mood: LIVE.mood, chordSet: LIVE.chordSet });
+ });
+
+ it('does not re-apply when a poll recomputes an identical soundscape', () => {
+ const { rerender } = renderHook(
+ ({ soundscape }) => useCityAudio(baseSettings, soundscape),
+ { initialProps: { soundscape: LIVE } },
+ );
+ primeAudio();
+ const callsAfterInit = setSoundscape.mock.calls.length;
+
+ // A fresh object with identical fields — the graph must not re-ramp.
+ rerender({ soundscape: { ...LIVE } });
+ expect(setSoundscape.mock.calls.length).toBe(callsAfterInit);
+ });
+});
diff --git a/client/src/hooks/useCitySettings.js b/client/src/hooks/useCitySettings.js
index 1887495d35..b6729212eb 100644
--- a/client/src/hooks/useCitySettings.js
+++ b/client/src/hooks/useCitySettings.js
@@ -42,6 +42,9 @@ const DEFAULT_SETTINGS = {
musicVolume: 0.3,
sfxEnabled: true,
sfxVolume: 0.5,
+ // Manual soundscape override (issue #3395). `null` is the explicit "auto" sentinel: the music's
+ // mood follows live system state. A mood name from SOUNDSCAPE_MOODS pins it instead.
+ soundscapeOverride: null,
// Auto quality (issue #2592): new installs adapt at runtime, always beginning at High
// (see CyberCity's autoStartTier). `qualityPreset` names the *Manual* preset only.
qualityMode: 'auto', // 'auto' = adaptive render budget; 'manual' = fixed preset
diff --git a/client/src/utils/README.md b/client/src/utils/README.md
index bb95f8a7fc..15fd4f4015 100644
--- a/client/src/utils/README.md
+++ b/client/src/utils/README.md
@@ -97,7 +97,7 @@ its tunable constants and placement helpers.
| `cityRooftops` | Deterministic rooftop fixture kits (antenna/tank/AC/dish) per app name (`computeRooftopKit`). |
| `cityProductivity` | Productivity monument from streak/velocity tiers (`computeProductivityMonument`). |
| `citySeasonalDecor` | Season/holiday resolution → seasonal decoration placements (`computeSeasonalDecor`). |
-| `citySoundscape` | Ambient soundscape: mood/energy classification and chord selection (`computeSoundscape`). |
+| `citySoundscape` | Ambient soundscape: mood/energy classification, chord selection (`computeSoundscape`), and the manual mood override (`applyMoodOverride`). |
| `cityTaskFlowRiver` | Task-flow river width/speed from backlog & throughput (`computeTaskFlowRiver`). |
| `cityTaskQueue` | Task-queue state/color from status counts (`computeTaskQueue`). |
| `cityTimeline` | Activity-log density bins and timeline buckets (`computeActivityDensity`, `buildTimelineBuckets`). |
diff --git a/client/src/utils/citySoundscape.js b/client/src/utils/citySoundscape.js
index 9c949c86d8..9dd1e7b957 100644
--- a/client/src/utils/citySoundscape.js
+++ b/client/src/utils/citySoundscape.js
@@ -23,6 +23,17 @@ export const CHORD_SETS = {
],
};
+// The moods the soundscape can be in, in brightening→darkening order. Also the set of values a
+// manual override (#3395) may pin the music to — anything outside this list is not a mood.
+export const SOUNDSCAPE_MOODS = ['bright', 'neutral', 'tense'];
+
+// Validate an override value. `null`/`undefined` is the "auto" sentinel (follow live system
+// state); an unknown string (a stale or hand-edited stored setting) is also treated as auto
+// rather than silently pinning the music to a mood that no longer exists.
+export function isSoundscapeMood(mood) {
+ return SOUNDSCAPE_MOODS.includes(mood);
+}
+
// Classify overall system stress into a mood. Driven primarily by the health verdict, with a
// CPU/memory fallback so a system that's hammered but not yet "warning" still tenses up.
// `health` is the /system/health/details payload (or null); `agentCount` is live agents.
@@ -50,9 +61,13 @@ export function computeActivityEnergy(agentCount) {
// widens the pads as tension rises for an uneasy shimmer. Deterministic for a given snapshot.
export function computeSoundscape(snapshot = {}) {
const { systemHealth, agentCount } = snapshot;
- const mood = classifyMood(systemHealth);
- const energy = computeActivityEnergy(agentCount);
+ return soundscapeForMood(classifyMood(systemHealth), computeActivityEnergy(agentCount));
+}
+// Build the view-model for an explicit (mood, energy) pair. Split out of computeSoundscape so a
+// manual mood override re-derives every mood-driven field — chord table, filter, pad detune —
+// instead of swapping the chord set alone and leaving a bright filter over a tense progression.
+export function soundscapeForMood(mood, energy) {
// Brighter (higher) filter cutoff when healthy; clamped low when tense for a muffled, anxious
// tone. Energy nudges it up a touch so a busy-but-healthy city sparkles.
const filterBase = (mood === 'bright' ? 320 : mood === 'neutral' ? 220 : 150) + energy * 80;
@@ -70,3 +85,17 @@ export function computeSoundscape(snapshot = {}) {
pulse: energy,
};
}
+
+// Pin a computed soundscape to a manually chosen mood (#3395). `mood` is the persisted override:
+// `null`/`undefined` (or any non-mood value) means auto, in which case the live soundscape passes
+// through untouched. The activity-driven half stays live even under an override — the listener is
+// choosing a mood, not freezing the city's energy — so `energy`/`arpGain`/`pulse` still follow the
+// running agent count. With no live soundscape yet, the override still yields a playable
+// view-model at the resting energy floor so the forced mood applies immediately.
+export function applyMoodOverride(soundscape, mood) {
+ if (!isSoundscapeMood(mood)) return soundscape;
+ const energy = typeof soundscape?.energy === 'number' && Number.isFinite(soundscape.energy)
+ ? soundscape.energy
+ : computeActivityEnergy(0);
+ return soundscapeForMood(mood, energy);
+}
diff --git a/client/src/utils/citySoundscape.test.js b/client/src/utils/citySoundscape.test.js
index 9c67d634dc..9a1bee9984 100644
--- a/client/src/utils/citySoundscape.test.js
+++ b/client/src/utils/citySoundscape.test.js
@@ -1,9 +1,12 @@
import { describe, it, expect } from 'vitest';
import {
CHORD_SETS,
+ SOUNDSCAPE_MOODS,
+ applyMoodOverride,
classifyMood,
computeActivityEnergy,
computeSoundscape,
+ isSoundscapeMood,
} from './citySoundscape';
describe('CHORD_SETS', () => {
@@ -89,3 +92,53 @@ describe('computeSoundscape', () => {
expect(Number.isFinite(s.filterBase)).toBe(true);
});
});
+
+describe('isSoundscapeMood', () => {
+ it('accepts every listed mood and rejects the auto sentinel or junk', () => {
+ SOUNDSCAPE_MOODS.forEach(mood => expect(isSoundscapeMood(mood)).toBe(true));
+ [null, undefined, '', 'auto', 'BRIGHT', 0, {}].forEach(value => {
+ expect(isSoundscapeMood(value)).toBe(false);
+ });
+ });
+});
+
+describe('applyMoodOverride', () => {
+ const live = computeSoundscape({ systemHealth: { overallHealth: 'healthy' }, agentCount: 4 });
+
+ it('pins the forced mood, re-deriving chord set, filter and detune', () => {
+ expect(live.mood).toBe('bright');
+ const forced = applyMoodOverride(live, 'tense');
+ expect(forced.mood).toBe('tense');
+ expect(forced.chordSet).toBe('tense');
+ expect(forced.filterBase).toBeLessThan(live.filterBase);
+ expect(forced.padDetune).toBeGreaterThan(live.padDetune);
+ });
+
+ it('keeps the activity-driven half live under an override', () => {
+ const forced = applyMoodOverride(live, 'tense');
+ expect(forced.energy).toBe(live.energy);
+ expect(forced.arpGain).toBe(live.arpGain);
+ expect(forced.pulse).toBe(live.pulse);
+ });
+
+ it('forces the neutral mood onto the bright table with a darker filter', () => {
+ const forced = applyMoodOverride(live, 'neutral');
+ expect(forced.chordSet).toBe('bright');
+ expect(forced.filterBase).toBeLessThan(live.filterBase);
+ });
+
+ it('passes the live soundscape through untouched for auto or an unknown value', () => {
+ expect(applyMoodOverride(live, null)).toBe(live);
+ expect(applyMoodOverride(live, undefined)).toBe(live);
+ expect(applyMoodOverride(live, '')).toBe(live);
+ expect(applyMoodOverride(live, 'stale-mood')).toBe(live);
+ });
+
+ it('still yields a playable view-model when there is no live soundscape yet', () => {
+ const forced = applyMoodOverride(null, 'tense');
+ expect(forced.chordSet).toBe('tense');
+ expect(forced.energy).toBeCloseTo(computeActivityEnergy(0), 5);
+ expect(Number.isFinite(forced.filterBase)).toBe(true);
+ expect(applyMoodOverride(null, null)).toBe(null);
+ });
+});