Merge pull request #674 from got-feedback/feat/3d-wide-pane-tuner-per-panel

3D highway wide-pane tuner: dismiss + per-pane targeting
This commit is contained in:
K. O. A.
2026-07-01 03:02:54 -04:00
committed by GitHub
2 changed files with 465 additions and 85 deletions
+151 -9
View File
@@ -120,11 +120,11 @@ test('applySize caches the pane aspect for camUpdate', () => {
);
});
test('camUpdate reads the live tune bridge and respects splitOnly', () => {
test('camUpdate resolves a per-pane tune and respects splitOnly', () => {
assert.match(
src,
/const\s+_aspTune\s*=\s*_aspectTune\(\)\s*;[\s\S]*?_aspTune\.splitOnly\s*&&\s*!_ssActive\(\)/,
'camUpdate must read the bridge via _aspectTune() and gate splitOnly on _ssActive()',
/const\s+_aspTune\s*=\s*_resolveTuneFor\(\s*_paneKey\s*\)\s*;[\s\S]*?_aspTune\.splitOnly\s*&&\s*!_ssActive\(\)/,
'camUpdate must resolve the tune per pane via _resolveTuneFor(_paneKey) and gate splitOnly',
);
});
@@ -136,11 +136,151 @@ test('the tune bridge seeds from localStorage (persisted sessions apply on load)
);
});
test('a floating tuner panel is built and toggled with the A/B state', () => {
test('a floating tuner panel is built and can be shown/hidden', () => {
assert.match(src, /function\s+_ensureAspectPanel\s*\(\)/,
'_ensureAspectPanel() must exist to build the live panel');
assert.match(src, /function\s+_setAspectPanelVisible\s*\(/,
'_setAspectPanelVisible() must show/hide the panel with the feature');
'_setAspectPanelVisible() must show/hide the panel');
});
// ── Per-pane targeting ────────────────────────────────────────────────────────
test('the tune resolves per pane with a sparse override map', () => {
// _resolveTuneFor overlays a pane's __panels[key] overrides onto the base so
// one split pane can be framed independently of the others.
assert.match(
src,
/function\s+_resolveTuneFor\s*\(\s*paneKey\s*\)[\s\S]*?base\.__panels\s*&&\s*base\.__panels\[\s*paneKey\s*\]/,
'_resolveTuneFor must overlay per-pane overrides from base.__panels',
);
});
test('panel writes route to the selected target (base or a pane override)', () => {
// _aspectWriteVal writes to the base when target is empty, else into the
// pane override sub-object; camUpdate consumes it via _resolveTuneFor.
assert.match(
src,
/function\s+_aspectWriteVal\s*\([\s\S]*?if\s*\(\s*!_aspectEditTarget\s*\)[\s\S]*?base\.__panels\b[\s\S]*?\[\s*_aspectEditTarget\s*\]/,
'_aspectWriteVal must target base for "all" and __panels[target] for a pane',
);
});
test('a Target select and pane registry drive the per-pane picker', () => {
assert.match(src, /_aspectTargetSel\s*=\s*document\.createElement\(\s*'select'\s*\)/,
'the panel must build a Target <select>');
assert.match(src, /function\s+_aspectRegisterPane\s*\(/,
'_aspectRegisterPane must record live panes for the picker');
assert.match(src, /if\s*\(\s*window\.__h3dAspectPanelOpen\s*\)\s*_aspectRegisterPane\(\s*_paneKey\s*\)/,
'camUpdate must register its pane only while the tuner panel is open');
});
test('panes are keyed by arrangement (stable across songs, no split-API dep)', () => {
// 'arr:<name>' keys are distinct between split panes AND stable across
// songs, without depending on the external splitscreen panel index (which
// isn't always available). A per-instance id is the no-arrangement fallback.
assert.match(
src,
/function\s+_aspectPaneKey\s*\(\s*arrangement\s*,\s*uid\s*\)[\s\S]*?'arr:'\s*\+\s*a[\s\S]*?'pane:'\s*\+\s*uid/,
'_aspectPaneKey must prefer arr:<name> and fall back to pane:<uid>',
);
assert.match(
src,
/const\s+_paneKey\s*=\s*_aspectPaneKey\(\s*[\s\S]*?songInfo[\s\S]*?arrangement\s*,\s*_paneUid\s*\)\s*;/,
'camUpdate must key the pane by arrangement (with the uid fallback)',
);
});
test('arrangement-keyed overrides persist; instance-id keys stay session-only', () => {
assert.match(
src,
/function\s+_aspectPersist\s*\(\)[\s\S]*?k\.slice\(0,\s*4\)\s*===\s*'arr:'[\s\S]*?out\.__panels\s*=\s*p/,
'_aspectPersist must persist only arr:* overrides so they carry across songs',
);
});
test('the target dropdown prunes dead panes and does not rebuild while focused', () => {
assert.match(src, /function\s+_aspectPrunePanes\s*\(\)[\s\S]*?delete\s+reg\[k\]/,
'_aspectPrunePanes must drop panes not seen recently');
assert.match(src, /_aspectPrunePanes\(\)\s*;[\s\S]*?if\s*\(\s*_aspectPanesDirty\s*\)\s*_aspectBuildTargets\(\)/,
'the readout tick must prune then rebuild only when dirty');
assert.match(src, /function\s+_aspectBuildTargets\s*\(\)[\s\S]*?document\.activeElement\s*===\s*_aspectTargetSel[\s\S]*?return/,
'_aspectBuildTargets must skip rebuilding while the select is focused');
});
test('programmatic sync does not write back into the tune', () => {
// _syncAspectPanel dispatches synthetic input events to refresh labels; the
// slider handler must skip the write while syncing, else opening/switching a
// target would populate a full override for every field.
assert.match(src, /_aspectSyncing\s*=\s*true[\s\S]*?finally[\s\S]*?_aspectSyncing\s*=\s*false/,
'_syncAspectPanel must set/reset the _aspectSyncing guard');
assert.match(src, /if\s*\(\s*!_aspectSyncing\s*\)\s*_aspectWriteVal\(\s*f\.k\s*,/,
'the slider input handler must skip the write while syncing');
});
test('unchecking hfov override clears a pane override key (re-inherits base)', () => {
assert.match(
src,
/function\s+_aspectClearVal\s*\(\s*k\s*\)[\s\S]*?delete\s+ov\[k\][\s\S]*?delete\s+m\[\s*_aspectEditTarget\s*\]/,
'_aspectClearVal must delete the pane override key (and empty object)',
);
assert.match(src, /else\s+_aspectClearVal\(\s*'hfovDeg'\s*\)/,
'unchecking the hfov override must call _aspectClearVal');
});
test('pruning drops the matching readout slot and a dangling __last', () => {
assert.match(
src,
/delete\s+reg\[k\]\s*;[\s\S]*?delete\s+ro\[k\]\s*;\s*if\s*\(\s*ro\.__last\s*===\s*k\s*\)\s*delete\s+ro\.__last/,
'_aspectPrunePanes must prune the readout cache alongside the registry',
);
});
test('single-pane forces the edit target back to All (no hidden pane edits)', () => {
assert.match(
src,
/if\s*\(\s*keys\.length\s*<=\s*1\s*\|\|\s*\(\s*_aspectEditTarget\s*&&\s*!reg\[_aspectEditTarget\]\s*\)\s*\)\s*\{\s*_aspectEditTarget\s*=\s*''/,
'_aspectBuildTargets must reset the edit target to "" when the Target row is hidden',
);
});
test('resolved per-pane tune is memoized and invalidated by a revision', () => {
assert.match(src, /_aspectRev\s*\+\+/, 'a mutation revision must be bumped on persist');
assert.match(
src,
/_aspectResolveCache\.get\(\s*paneKey\s*\)[\s\S]*?c\.rev\s*===\s*_aspectRev[\s\S]*?return\s+c\.obj/,
'_resolveTuneFor must return a cached object when the revision is unchanged',
);
});
test('the pane clock falls back to Date.now so pruning keeps working', () => {
assert.match(
src,
/function\s+_aspectNowMs\s*\(\)[\s\S]*?performance\.now\(\)[\s\S]*?return\s+Date\.now\(\)/,
'_aspectNowMs must fall back to Date.now() when the Performance API is absent',
);
});
test('opening the panel prunes before the first dropdown build', () => {
assert.match(
src,
/if\s*\(\s*on\s*\)\s*\{\s*_aspectPrunePanes\(\)\s*;\s*_aspectBuildTargets\(\)/,
'_setAspectPanelVisible must prune stale panes before building the dropdown',
);
});
test('Reset on All restores defaults exactly (no forced enabled)', () => {
// Panel visibility is independent of the enabled flag now, so Reset must not
// force enabled true — it should restore _ASPECT_DEFAULTS verbatim.
assert.doesNotMatch(src, /Object\.keys\(_ASPECT_DEFAULTS\)[\s\S]*?base\.enabled\s*=\s*true/,
'Reset must not override the default enabled state');
});
test('the panel has a dismiss (close) control', () => {
assert.match(
src,
/close\.textContent\s*=\s*'×'[\s\S]*?_setAspectPanelVisible\(\s*false\s*\)/,
'the panel header must have a × button that hides the panel',
);
});
test('camUpdate only writes cam.fov when it actually changes', () => {
@@ -153,14 +293,16 @@ test('camUpdate only writes cam.fov when it actually changes', () => {
);
});
// ── A/B toggle + lifecycle reset ──────────────────────────────────────────────
// ── Shortcut (open/close) + lifecycle reset ───────────────────────────────────
test('an A/B toggle shortcut flips the tune enabled flag', () => {
test('the shortcut opens/closes the tuner panel', () => {
assert.match(
src,
/registerShortcut\(\{[\s\S]*?const\s+t\s*=\s*_aspectTune\(\)\s*;[\s\S]*?t\.enabled\s*=\s*!\s*t\.enabled/,
'a registerShortcut handler must toggle the bridge enabled flag',
/registerShortcut\(\{[\s\S]*?_toggleAspectPanel\(\)/,
'a registerShortcut handler must toggle the tuner panel',
);
assert.match(src, /function\s+_toggleAspectPanel\s*\(\)/,
'_toggleAspectPanel() must exist to reveal/dismiss the panel');
});
test('destroy() resets the pane aspect and restores the base fov', () => {