From b84018d0c04a67ba8056a4daac82d2145811cc58 Mon Sep 17 00:00:00 2001 From: topkoa Date: Sun, 19 Jul 2026 11:38:34 -0400 Subject: [PATCH 1/5] Forward per-stem name/description from song_info to consumers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feedpak 1.16.0 (spec §5.3) added optional presentational fields to a stems[] entry — `name` (display label) and `description` (free text) — and core now passes them through the song_info stems payloads (feedback#1013). Carry them from load to state so consumer plugins can display them: - loadStems keeps name/description on its result rows, stemState keeps them on the live stem objects - the stems:state provider-ready event gains `stems: [{id, name?, description?}]` alongside `stemIds`, which stays a plain string array so existing listeners are untouched - window.stems.getState() rows gain name/description (undefined when the pack or core predates the fields) Purely additive; this plugin's own chip UI still renders ids. Display work lands in stem_mixer. 53/53 node tests + manifest contract pass. Co-Authored-By: Claude Fable 5 Signed-off-by: topkoa --- CHANGELOG.md | 12 ++++++++++++ package.json | 2 +- plugin.json | 2 +- src/main.js | 39 ++++++++++++++++++++++++++++++--------- 4 files changed, 44 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5921dbd..7a6534a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ All notable changes to the Stems Toggle plugin are documented here. ## [Unreleased] +### Added + +- **Forward per-stem `name`/`description`** (feedpak 1.16.0, spec §5.3). Core now + passes the manifest's optional presentational fields through `song_info` stems; + this plugin carries them from load to state, so consumers can display them: + the `stems:state` provider-ready event gains a `stems: [{id, name?, + description?}]` array (alongside `stemIds`, which stays a plain string array + for existing listeners), and `window.stems.getState()` rows gain + `name`/`description` (undefined when the pack or core predates the fields). + Purely additive — this plugin's own chip UI still renders ids; display work + lands in stem_mixer. + ### Changed - **The full mix is a stem** (feedback#933). The pristine mixdown we play while diff --git a/package.json b/package.json index 8d23ef3..72e990a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "feedback-plugin-stems", - "version": "0.8.1", + "version": "0.9.0", "private": true, "type": "module", "scripts": { diff --git a/plugin.json b/plugin.json index e1e109e..b1ea253 100644 --- a/plugin.json +++ b/plugin.json @@ -1,7 +1,7 @@ { "id": "stems", "name": "Stems Toggle", - "version": "0.8.2", + "version": "0.9.0", "private": false, "standards": ["capability-pipelines.v1", "plugin-runtime-idempotent.v1"], "settings": { diff --git a/src/main.js b/src/main.js index bc49a2d..e104ee0 100644 --- a/src/main.js +++ b/src/main.js @@ -486,8 +486,11 @@ import { } // Fetch + decode every stem concurrently. Returns one entry per stem - // ({ id, url, default, buffer }; buffer is null on failure), or null if - // the load was superseded by a newer song (generation mismatch). + // ({ id, url, default, name, description, buffer }; buffer is null on + // failure, name/description are the manifest's optional presentational + // fields — feedpak §5.3 — and undefined when the pack or core predates + // them), or null if the load was superseded by a newer song (generation + // mismatch). async function loadStems(stems, gen, signal) { let completed = 0; showOverlay(completed, stems.length); @@ -500,11 +503,11 @@ import { if (gen !== S.loadGeneration) return null; const buffer = await decodeAudioData(arrayBuf); if (gen !== S.loadGeneration) return null; - return { id: s.id, url: s.url, default: !!s.default, buffer }; + return { id: s.id, url: s.url, default: !!s.default, name: s.name, description: s.description, buffer }; } catch (err) { if (gen !== S.loadGeneration) return null; console.error('[stems] failed to load stem "' + s.id + '":', err); - return { id: s.id, url: s.url, default: !!s.default, buffer: null }; + return { id: s.id, url: s.url, default: !!s.default, name: s.name, description: s.description, buffer: null }; } finally { // Count every finished attempt — success OR failure — so the // overlay progress can't stall at e.g. 5/6 on a failed stem. @@ -624,6 +627,7 @@ import { if (r.buffer.duration > maxDur) maxDur = r.buffer.duration; return { id: r.id, url: r.url, default: r.default, buffer: r.buffer, + name: r.name, description: r.description, source: null, gain, on, vol: initialVol, }; }); @@ -905,7 +909,7 @@ import { injectUI(); installSongFaderBridge(); S.buffersReady = true; - emitStemsState('provider-ready', { stemCount: S.stemState.length, stemIds: S.stemState.map(s => s.id) }); + emitStemsState('provider-ready', { stemCount: S.stemState.length, stemIds: S.stemState.map(s => s.id), stems: stemsMetaPayload() }); if (S.pendingPlay) { S.pendingPlay = false; transportPlay(); } } @@ -1270,6 +1274,19 @@ import { registerStemOwnerStatus('available'); } + // Per-stem display metadata for provider-ready listeners (e.g. stem_mixer): + // id always, plus the manifest's optional `name`/`description` (feedpak + // §5.3) when present. Kept separate from `stemIds`, which stays a plain + // string array for existing consumers. + function stemsMetaPayload() { + return S.stemState.map(s => { + const entry = { id: s.id }; + if (typeof s.name === 'string' && s.name) entry.name = s.name; + if (typeof s.description === 'string' && s.description) entry.description = s.description; + return entry; + }); + } + function emitStemsState(event, payload = {}) { const detail = { event, ...redactedSongRef(), ...payload }; try { window.dispatchEvent(new CustomEvent('stems:state', { detail })); } catch (_) {} @@ -1460,14 +1477,17 @@ import { }); registerStemMixParticipants(); registerStemOwnerStatus(S.stemState.length ? 'available' : 'unavailable'); - emitStemsState('provider-ready', { stemCount: S.stemState.length, stemIds: S.stemState.map(s => s.id) }); + emitStemsState('provider-ready', { stemCount: S.stemState.length, stemIds: S.stemState.map(s => s.id), stems: stemsMetaPayload() }); } /** * Public API exposed at window.stems for other plugins (e.g. stem_mixer). * - * getState() Returns [{id, vol, on, gain, audio}, ...] for the - * current song's stems. Callers may mutate + * getState() Returns [{id, name, description, vol, on, gain, + * audio}, ...] for the current song's stems. + * `name`/`description` are the manifest's optional + * presentational fields (feedpak §5.3) — undefined + * when the pack or core predates them. Callers may mutate * gain.gain.value directly to set a stem's level, * but should re-fetch on every song:loaded because * gains are recreated between songs. In legacy @@ -1487,7 +1507,8 @@ import { */ const stemsApi = { getState: () => S.stemState.map(s => ({ - id: s.id, vol: s.vol, on: s.on, gain: s.gain, audio: null, + id: s.id, name: s.name, description: s.description, + vol: s.vol, on: s.on, gain: s.gain, audio: null, })), setVolume(id, vol) { const v = Number(vol); From c473c7a5b980788dc0c869a05bea21bf3451b74d Mon Sep 17 00:00:00 2001 From: topkoa Date: Sun, 19 Jul 2026 11:50:50 -0400 Subject: [PATCH 2/5] Normalize name/description once at load; reword changelog (review) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Copilot review: stemState carried raw manifest values while the provider-ready payload filtered to non-empty strings, so getState() could expose a different type than the event for the same stem. Fold both through presentationalString() at the loadStems boundary — a non-blank string passes, everything else (missing, blank, non-string) becomes undefined — so every surface exposes `string | undefined` consistently. The changelog no longer implies core passthrough already ships everywhere; it names the core change (feedback#1013) and the older-core behaviour (fields undefined, nothing changes). Co-Authored-By: Claude Fable 5 Signed-off-by: topkoa --- CHANGELOG.md | 10 +++++++--- src/main.js | 23 +++++++++++++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a6534a..26b8fab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,13 @@ All notable changes to the Stems Toggle plugin are documented here. ### Added -- **Forward per-stem `name`/`description`** (feedpak 1.16.0, spec §5.3). Core now - passes the manifest's optional presentational fields through `song_info` stems; - this plugin carries them from load to state, so consumers can display them: +- **Forward per-stem `name`/`description`** (feedpak 1.16.0, spec §5.3). A core + that passes the manifest's optional presentational fields through `song_info` + stems (feedback#1013) gets them carried from load to state, so consumers can + display them; against an older core the fields are simply undefined and + nothing changes. Normalized once at load (`presentationalString`): non-blank + strings pass, everything else becomes undefined, so `getState()` and the + event payload agree. the `stems:state` provider-ready event gains a `stems: [{id, name?, description?}]` array (alongside `stemIds`, which stays a plain string array for existing listeners), and `window.stems.getState()` rows gain diff --git a/src/main.js b/src/main.js index e104ee0..6be8b9d 100644 --- a/src/main.js +++ b/src/main.js @@ -491,11 +491,21 @@ import { // fields — feedpak §5.3 — and undefined when the pack or core predates // them), or null if the load was superseded by a newer song (generation // mismatch). + // Normalize an optional presentational field once, at the boundary: a + // non-blank string passes through, everything else (missing, empty, + // non-string — a core we don't control) becomes undefined, so stemState / + // getState() / the provider-ready payload all expose `string | undefined`. + function presentationalString(v) { + return (typeof v === 'string' && v.trim()) ? v : undefined; + } + async function loadStems(stems, gen, signal) { let completed = 0; showOverlay(completed, stems.length); const out = await Promise.all(stems.map(async (s) => { + const name = presentationalString(s.name); + const description = presentationalString(s.description); try { const resp = await fetch(s.url, { signal }); if (!resp.ok) throw new Error('HTTP ' + resp.status); @@ -503,11 +513,11 @@ import { if (gen !== S.loadGeneration) return null; const buffer = await decodeAudioData(arrayBuf); if (gen !== S.loadGeneration) return null; - return { id: s.id, url: s.url, default: !!s.default, name: s.name, description: s.description, buffer }; + return { id: s.id, url: s.url, default: !!s.default, name, description, buffer }; } catch (err) { if (gen !== S.loadGeneration) return null; console.error('[stems] failed to load stem "' + s.id + '":', err); - return { id: s.id, url: s.url, default: !!s.default, name: s.name, description: s.description, buffer: null }; + return { id: s.id, url: s.url, default: !!s.default, name, description, buffer: null }; } finally { // Count every finished attempt — success OR failure — so the // overlay progress can't stall at e.g. 5/6 on a failed stem. @@ -1276,13 +1286,14 @@ import { // Per-stem display metadata for provider-ready listeners (e.g. stem_mixer): // id always, plus the manifest's optional `name`/`description` (feedpak - // §5.3) when present. Kept separate from `stemIds`, which stays a plain - // string array for existing consumers. + // §5.3) when present — already normalized to `string | undefined` at load + // (presentationalString). Kept separate from `stemIds`, which stays a + // plain string array for existing consumers. function stemsMetaPayload() { return S.stemState.map(s => { const entry = { id: s.id }; - if (typeof s.name === 'string' && s.name) entry.name = s.name; - if (typeof s.description === 'string' && s.description) entry.description = s.description; + if (s.name) entry.name = s.name; + if (s.description) entry.description = s.description; return entry; }); } From 67a4a31abcbdf83b7d0c3b4ff7c23d3eea21acb1 Mon Sep 17 00:00:00 2001 From: topkoa Date: Sun, 19 Jul 2026 11:57:11 -0400 Subject: [PATCH 3/5] Rejoin the changelog bullet split by the previous reword (review) The conditional-on-core rewording left the original continuation ("the stems:state provider-ready event gains...") dangling as a lowercase fragment after a full stop. One bullet again: what a passing core gets, what an older core sees, how values are normalized. Co-Authored-By: Claude Fable 5 Signed-off-by: topkoa --- CHANGELOG.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26b8fab..385a89b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,16 +9,14 @@ All notable changes to the Stems Toggle plugin are documented here. - **Forward per-stem `name`/`description`** (feedpak 1.16.0, spec §5.3). A core that passes the manifest's optional presentational fields through `song_info` stems (feedback#1013) gets them carried from load to state, so consumers can - display them; against an older core the fields are simply undefined and - nothing changes. Normalized once at load (`presentationalString`): non-blank - strings pass, everything else becomes undefined, so `getState()` and the - event payload agree. - the `stems:state` provider-ready event gains a `stems: [{id, name?, - description?}]` array (alongside `stemIds`, which stays a plain string array - for existing listeners), and `window.stems.getState()` rows gain - `name`/`description` (undefined when the pack or core predates the fields). - Purely additive — this plugin's own chip UI still renders ids; display work - lands in stem_mixer. + display them: the `stems:state` provider-ready event gains a `stems: [{id, + name?, description?}]` array (alongside `stemIds`, which stays a plain string + array for existing listeners), and `window.stems.getState()` rows gain + `name`/`description`. Against an older core the fields are simply undefined + and nothing changes. Normalized once at load (`presentationalString`): + non-blank strings pass, everything else becomes undefined, so `getState()` + and the event payload agree. Purely additive — this plugin's own chip UI + still renders ids; display work lands in stem_mixer. ### Changed From 93daf93d56321477c72d44cb30044b03597c1f2f Mon Sep 17 00:00:00 2001 From: topkoa Date: Sun, 19 Jul 2026 12:02:31 -0400 Subject: [PATCH 4/5] Emit stemIds/stems on the stem-less provider-ready too (review) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The early-return for an archive / stem-less sloppak announced only { stemCount: 0 }, so the payload shape depended on which path fired: a listener could not tell "song with 0 stems" from "old plugin that never sent stemIds/stems at all". Emit both as empty arrays there — same contract on every provider-ready. (stemIds was already missing on this path before this branch; fixed while the contract is being extended.) Co-Authored-By: Claude Fable 5 Signed-off-by: topkoa --- src/main.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index 6be8b9d..cf8935f 100644 --- a/src/main.js +++ b/src/main.js @@ -773,7 +773,11 @@ import { teardown(); const info = currentSongInfo(); const stems = (info && info.stems) || []; - if (stems.length === 0) { emitStemsState('provider-ready', { stemCount: 0 }); return; } // archive or stem-less sloppak — do nothing + // Archive or stem-less sloppak — no graph to build, but keep the event + // shape identical to the stem-bearing path (stemIds/stems present and + // empty) so a listener can tell "0 stems" from "old plugin without + // these fields". + if (stems.length === 0) { emitStemsState('provider-ready', { stemCount: 0, stemIds: [], stems: [] }); return; } ensureCtx(); // Decide per-song whether the pitch-preserving worklet is available. From 4ea1650738c1e7bb08b5ad09b483b7eb9a0091a2 Mon Sep 17 00:00:00 2001 From: topkoa Date: Sun, 19 Jul 2026 12:07:47 -0400 Subject: [PATCH 5/5] Cut the 0.9.0 changelog section (review) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The PR bumps plugin.json/package.json to 0.9.0 but its entries sat under [Unreleased]. Retitle the block as "## [0.9.0] — Per-stem display metadata (name/description)" and leave a fresh empty [Unreleased] above, matching the file's versioned-section convention. The block also folds in the items accumulated since [0.8.1] (the full-mix rename, the ES-module migration steps) — 0.9.0 is the release that ships them. Co-Authored-By: Claude Fable 5 Signed-off-by: topkoa --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 385a89b..e201eb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to the Stems Toggle plugin are documented here. ## [Unreleased] +## [0.9.0] — Per-stem display metadata (name/description) + ### Added - **Forward per-stem `name`/`description`** (feedpak 1.16.0, spec §5.3). A core