best-practices: Integrating with the app (event bus + feedBack API) - #9
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
Adds an “Integrating with the app” section to the best-practices guide, documenting how plugins should observe app state (event bus) and drive navigation/playback via the supported runtime API, plus a checklist update and corresponding changelog entry.
Changes:
- Documented the
window.feedBackevent bus and a catalog of commonly used lifecycle/transport events and payloads. - Added guidance on driving navigation/playback via the Host runtime API (vs DOM), wrapping Host functions safely, and supporting both player UIs (
v2/v3). - Renumbered Shipping rules and extended the pre-publish checklist; updated
CHANGELOG.mdaccordingly.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| spec/best-practices.md | Adds “Integrating with the app” rules (30–33), renumbers Shipping (34–38), and adds a checklist block. |
| CHANGELOG.md | Records the new best-practices section and its major points under Unreleased. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
25ce206 to
2c0f693
Compare
Add a section on reacting to and driving the app via window.feedBack, the biggest gap found in a completeness sweep of the real plugin surface. Rules (30-33): - Subscribe to app state through the event bus: catalog the commonly-used events (screen:changed, song:loading/ready/play/pause/stop/ended/seek/position-changed/ arrangement-changed, library:changed, viz:renderer:ready/reverted, highway:canvas-replaced/visibility) with their event.detail payloads; keep handlers cheap and unsubscribe when hidden. - Drive the app through the feedBack API (navigate/getNavParams/showScreen/ setReturnScreen, playSong/seek/setLoop/clearLoop/getLoop/playQueue, currentSong/isPlaying) — never the app's private DOM controls (#btn-loop-*). - Wrap Host functions carefully: always call and await the original, install once (idempotent), clean up on transitions, and don't assume load order. - Support both player UIs (v2/v3): detect uiVersion and mount into the Host- provided slot, verify in both. Renumber Shipping to 34-38 and add a checklist block. Docs only. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: K. O. A. <topkoa@gmail.com>
… globals Disambiguate the transport/nav surface: methods on window.feedBack (navigate/getNavParams/seek/setLoop/currentSong) vs legacy top-level globals (showScreen/playSong/setReturnScreen), and say to feature-detect and prefer the feedBack-namespaced call. Signed-off-by: K. O. A. <topkoa@gmail.com>
e96f451 to
f74c4c1
Compare
Summary
First of four PRs closing the glaring gaps a completeness sweep found: we documented plugin mechanics well but under-covered the runtime integration API. This adds an "Integrating with the app" section — the single most-used integration surface.
Rules (30–33)
window.feedBackevents with theirevent.detailpayloads:screen:changed {id},song:loading/song:ready/song:play/pause/stop/ended/seek/song:position-changed {time,duration}/song:arrangement-changed,library:changed {reason},viz:renderer:ready/viz:reverted {reason},highway:canvas-replaced/highway:visibility. Keep handlers cheap (some fire during playback) and unsubscribe when hidden.feedBackAPI, not its DOM.navigate/getNavParams/showScreen/setReturnScreen,playSong/seek/setLoop/clearLoop/getLoop/playQueue,currentSong/isPlaying— never#btn-loop-*and friends (private, and they move between UI versions).playSong/showScreen: always call +awaitthe original, install once (idempotent, rule 12), clean up on transitions, and don't assume load order.v2andv3— detectuiVersion, mount into the Host slot (ui.playerControlSlot()), verify in both; don't rely on the compat shim.Added an "Integrating with the app" checklist block; Shipping renumbered to 34–38 (contiguous 1–38).
Scope & stacking
Docs only. API framed as the current Host contract. Stacked on #8. Full stack: #2 → #4 → #3 → #5 → #6 → #7 → #8 → #9. Three more coming on top (server robustness, styling, diagnostics).
mkdocs build --strict+check_versions.pypass.🤖 Generated with Claude Code