Address review: resolve cache, Date.now fallback, prune-on-open, rename

- Memoize _resolveTuneFor per pane, invalidated by a revision bumped on every
  tune mutation (all writes funnel through _aspectPersist). Panes with an
  override no longer rebuild the merged object every frame; panes without one
  still return the base directly.
- _aspectNowMs falls back to Date.now() when the Performance API is absent, so
  pane/readout pruning still works in older/borrowed contexts.
- _setAspectPanelVisible prunes stale panes before the first dropdown build, so
  panes from a prior song/split don't flash until the first RAF tick.
- Rename _abShortcutRegistered/_registerAspectAbShortcut to
  _tunerShortcutRegistered/_registerTunerShortcut — the shortcut opens/closes
  the tuner now, it isn't an A/B toggle.
- Fix a stale 'pane1' example in a comment (keys are 'arr:<name>'/'pane:<uid>').

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: topkoa <topkoa@gmail.com>
This commit is contained in:
topkoa
2026-07-01 02:47:08 -04:00
co-authored by Claude Opus 4.8
parent 58047e6ad6
commit 24d24ef2cf
2 changed files with 50 additions and 11 deletions
+25
View File
@@ -243,6 +243,31 @@ test('single-pane forces the edit target back to All (no hidden pane edits)', ()
);
});
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('the panel has a dismiss (close) control', () => {
assert.match(
src,