Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat(songs): provider/model picker for harmony 'Derive with AI'
[._.]/ Adam Eivy4db315493735
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 10754dba82..f9cf16e261 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -21,6 +21,7 @@## Changed+- **Songs: pick the AI provider & model for "Derive with AI"** — the harmony-parts deriver in the Sheet music editor now has a compact provider + model picker next to the **Derive with AI** button, so you can run the derivation on a specific provider/model (e.g. a stronger local model for richer chord-tone voicing) instead of always using the active default. It defaults to **Active provider (default)** / **Default model** (no behaviour change unless you choose otherwise), is a per-run choice (not persisted on the song), and is built on the shared `useProviderModels` hook + `ProviderModelSelector` so it lists the same selectable models (embedding-only models filtered out) as the rest of the app. The server side already accepted `providerId`/`model` on the derive endpoint — this surfaces it in the UI.- **Songs: play any combination of sheet-music parts together** — the read/perform view's Sheet music card now has a layered MIDI player. When a song carries harmony parts beyond the melody, a checkbox per part (**Layers: Melody, Bass, Mid Harmony I/II, High Harmony I/II…**) lets you pick any combination — melody + bass, the whole stack, two inner harmonies on their own — and a single **Play parts** transport synthesizes them all together, sample-aligned on one audio clock (Web Audio oscillators, no MIDI.js / Tone.js), with the master level backing off as voices stack so the blend doesn't clip. All parts are checked by default, so Play gives the full harmony stack out of the box. A **Tempo** field controls playback for the whole stack, and the pill row still picks which staff is *shown* independently of what plays — the moving playhead lights up on the shown staff whenever it's one of the sounding parts. A single-part song keeps the simple per-staff reference-tone player.- **Songs: recording "take types" now match the harmony stack you generate** — the voice-layer vocabulary used for vocal takes (the "Next take is for layer" picker, the per-take layer dropdown, the "Add layer from ladder" presets, and the Learning Guide ladder) was the old folk set (Lead melody, Bass / root, Harmony third/fifth, Drone, Counter-melody, Vocal percussion) — out of step with the **Melody, Bass, Mid Harmony I/II, High Harmony I/II** stack the AI derive tool actually writes. The two vocabularies are now unified: a recorded take's layer lines up by id and label with the notated part of the same name, so you can record yourself singing each generated part and stack them. A test guards the two lists against drifting apart again. Existing songs keep their stored layers; "Refresh from template" pulls the new set onto built-in songs.- **Songs: the built-in "500 Miles" ships the full song, not just verse 1** — the bundled sheet-music melody now spans every verse and the closing coda (46 bars) instead of only the first verse, so the Sheet music view shows the whole song. Existing installs that still hold the earlier single-verse (or the original C-major placeholder) melody can pull it via the song's "Refresh from template" button; the per-section harmony parts can be regenerated to match with "Derive with AI" (it now reads the full melody).diff --git a/client/src/components/songs/SongScoreParts.jsx b/client/src/components/songs/SongScoreParts.jsxindex 8201f532d0..3ae43368f7 100644--- a/client/src/components/songs/SongScoreParts.jsx+++ b/client/src/components/songs/SongScoreParts.jsx@@ -21,6 +21,8 @@ import { useState } from 'react';import { Music2, Plus, Trash2, Wand2, Loader2, ChevronDown, ChevronRight, AlertTriangle } from 'lucide-react';import toast from '../ui/Toast';import ScoreSheet from './ScoreSheet.jsx';+import ProviderModelSelector from '../ProviderModelSelector.jsx';+import useProviderModels from '../../hooks/useProviderModels.js';import { deriveSongParts } from '../../services/api';import { HARMONY_PARTS, harmonyPartLabel, harmonyPartOrder } from '../../lib/songCraft';import { scoreHasMusic } from '../../lib/scoreNotation';@@ -39,6 +41,21 @@ export default function SongScoreParts({ songId, baseScore = '', baseDirty = falconst [deriving, setDeriving] = useState(false);const [openId, setOpenId] = useState(null);+ // AI provider/model for the derive run, via the shared hook. `allowDefault`+ // keeps the empty-string "use the active provider's default" sentinel selected+ // until the user picks (the server's optProvider coerces '' → undefined), and+ // `silent` means a failed provider fetch just hides the picker rather than+ // toasting. The choice is transient — it scopes this derive call only, not+ // persisted on the song (unlike the pipeline's SeriesLlmPicker → series.llm).+ const {+ providers,+ selectedProviderId,+ selectedModel,+ availableModels,+ setSelectedProviderId,+ setSelectedModel,+ } = useProviderModels({ allowDefault: true, silent: true });+const hasBase = scoreHasMusic(baseScore);// Derive needs a SAVED base melody — the server reads the persisted score, so a// dirty (unsaved) base would derive harmony from stale notes.@@ -56,7 +73,7 @@ export default function SongScoreParts({ songId, baseScore = '', baseDirty = falconst derive = async () => {setDeriving(true);- const data = await deriveSongParts(songId, {}, { silent: true })+ const data = await deriveSongParts(songId, { providerId: selectedProviderId, model: selectedModel }, { silent: true }).catch((err) => { toast.error(err?.message || 'Could not derive harmony parts'); return null; });setDeriving(false);if (!data?.scoreParts?.length) return;@@ -113,6 +130,28 @@ export default function SongScoreParts({ songId, baseScore = '', baseDirty = falDerive writes a full set with AI (Bass, Mid Harmony I/II, High Harmony I/II); review and <strong>Save</strong> to keep.</p>+ {/* AI provider/model for the derive run (defaults to the active provider). */}+ {hasBase && providers.length > 0 && (+ <div className="flex items-center gap-2 mb-2">+ <span className="text-xs text-gray-500 shrink-0">Derive with</span>+ <ProviderModelSelector+ providers={providers}+ selectedProviderId={selectedProviderId}+ selectedModel={selectedModel}+ availableModels={availableModels}+ onProviderChange={setSelectedProviderId}+ onModelChange={setSelectedModel}+ label="AI provider"+ disabled={deriving}+ modelDisabled={availableModels.length === 0}+ compact+ alwaysShowModel+ emptyProviderOption="Active provider (default)"+ emptyModelOption="Default model"+ />+ </div>+ )}+{!hasBase && (<p className="text-xs text-gray-500">Add a base melody in the Sheet music editor above, then derive or add harmony parts.</p>)}