fix(playback): throttle legacy bridge-hit recording; emit loop-set for manual A/B - #811
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe playback bridge recording function now throttles repeated hits per bridge/surface pair. The manual A/B loop control ChangesPlayback bridge and loop event fixes
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant AppJS as static/app.js
participant Plugin
User->>AppJS: setLoopEnd()
AppJS->>AppJS: arm loopA/loopB
AppJS->>Plugin: transportEvent('loop-set', loopA, loopB, loop payload)
Plugin->>Plugin: react to playback:loop-set
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
…r manual A/B window.feedBack.getLoop() is a read surface plugins legitimately poll (note_detect HUD ticked it at ~30 Hz), but every call recorded a playback.loop-api bridge hit: compat-shim bookkeeping, a playback:bridge-hit event, and a diagnostics snapshot rebuild + stringify per call — real main-thread cost and a saturated hitCount in the capability inspector, even with no song playing. - _recordPlaybackBridge now throttles per bridgeId|surface (5 s window). Bridge hits are a 'surface still in use' signal, not a call counter. - setLoopEnd() (manual A/B buttons) now emits the same loop-set transport event as setLoop(), so event-driven consumers no longer need to poll getLoop() to see button-armed loops. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
37eeb9c to
8c23270
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
static/app.js (1)
5539-5563: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueThrottle logic looks correct.
Per-key throttling with a 5s window is implemented correctly (check-then-set ordering avoids allowing bursts). One minor note:
_bridgeRecordLastis a module-levelMapwith no eviction, unlikeplayback.js's ownbridgesmap which caps size viaMAX_BRIDGES. In practice the key space (bridgeId/legacySurface pairs) is likely small and bounded, so this is unlikely to be a real problem, but consider capping it defensively if bridge identifiers can ever be dynamic/unbounded.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@static/app.js` around lines 5539 - 5563, The per-surface throttling in _recordPlaybackBridge uses a module-level _bridgeRecordLast Map that never evicts entries, so add a bounded cleanup strategy or size cap similar to playback.js’s bridged state handling. Update _recordPlaybackBridge and _bridgeRecordLast so old bridgeId|legacySurface keys are removed or the map is capped when identifiers can grow unbounded, keeping the 5s throttle behavior intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@static/app.js`:
- Around line 5539-5563: The per-surface throttling in _recordPlaybackBridge
uses a module-level _bridgeRecordLast Map that never evicts entries, so add a
bounded cleanup strategy or size cap similar to playback.js’s bridged state
handling. Update _recordPlaybackBridge and _bridgeRecordLast so old
bridgeId|legacySurface keys are removed or the map is capped when identifiers
can grow unbounded, keeping the 5s throttle behavior intact.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: e3ee0ae2-7f15-41dd-968f-78b0e7b1d0d2
📒 Files selected for processing (2)
CHANGELOG.mdstatic/app.js
Problem
The capability inspector showed
playback.loop-apifiring dozens of times per second — even with no song playing.Root cause chain:
window.slopsmith.getLoop()per tick (a legitimately cheap read when it was written).window.feedBack.getLoop()call as a legacy bridge hit: compat-shim bookkeeping, aplayback:bridge-hitevent, and a diagnostics snapshot rebuild +JSON.stringifyper call.hitCountdrowning genuine legacy-surface signal.Fix
_recordPlaybackBridgenow throttles perbridgeId|surface(5 s window). First call records immediately; repeats inside the window are dropped. Bridge hits are a "this surface is still in use" signal, not a call counter.setLoopEnd()(manual A/B buttons) now emits the sameloop-settransport event assetLoop(), so plugins can go event-driven viaplayback:loop-set/playback:loop-clearedinstead of pollinggetLoop()— polling was the only way to see button-armed loops before.Companion PR in note_detect makes its drill sync event-driven with a 1 Hz fallback poll.
Testing
node --check static/app.jsnode --test tests/js/*.test.js)🤖 Generated with Claude Code
Summary by CodeRabbit
loop-setevent as other loop actions (including the active loop payload), enabling plugins to react without polling.