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
fold the songbook header cards onto the shared disclosure and storage hooks
[._.]/ Adam Eivy03e3740a0e4d
diff --git a/client/src/components/songbook/ChordTransportBar.jsx b/client/src/components/songbook/ChordTransportBar.jsxindex 997492b2ed..c34a2b341e 100644--- a/client/src/components/songbook/ChordTransportBar.jsx+++ b/client/src/components/songbook/ChordTransportBar.jsx@@ -18,7 +18,7 @@* sits with setup rather than beside Play.*/-import { useState } from 'react';+import { memo, useState } from 'react';import { SlidersHorizontal, Volume2, VolumeX } from 'lucide-react';import { CHORD_BEATS_MIN, CHORD_BEATS_MAX } from '../../lib/chordPlayback.js';import { ctrlBtnClass, activeCtrlClass, smallSelectClass } from './constants.js';@@ -32,7 +32,7 @@ const BEATS_OPTIONS = Array.from((_, i) => CHORD_BEATS_MIN + i,);-export default function ChordTransportBar({+function ChordTransportBar({playing, onToggle, hasChords = true,bpm, onBpmChange, onPercent, writtenTempo,beatsPerBar, onBeatsPerBarChange,@@ -125,3 +125,8 @@ export default function ChordTransportBar({</div>);}++// Every prop is a primitive or a stable hook callback apart from `pulse`, which+// the host nulls while its card is collapsed — so a bar nobody can see costs no+// reconciliation per beat.+export default memo(ChordTransportBar);diff --git a/client/src/components/songbook/ChordsUsedCard.jsx b/client/src/components/songbook/ChordsUsedCard.jsxindex 9b2569c58e..a6540e1104 100644--- a/client/src/components/songbook/ChordsUsedCard.jsx+++ b/client/src/components/songbook/ChordsUsedCard.jsx@@ -1,6 +1,6 @@-import { useMemo } from 'react';+import { memo, useMemo } from 'react';import ChordDiagram from './ChordDiagram.jsx';-import CollapsibleBar from './CollapsibleBar.jsx';+import CollapsibleSection from '../ui/CollapsibleSection.jsx';import { sheetUsedChords } from '../../lib/chordShapes.js';/**@@ -10,22 +10,22 @@ import { sheetUsedChords } from '../../lib/chordShapes.js';* It lived inside `<TabSheetView>` (a strip above the sheet) until it moved out* here so the viewer can pin it in the header band ABOVE the scroller: the* shapes you are reaching for are the thing you want on screen at bar 60, not- * only at bar 1. Collapsible (and persisted by the host) because it is the- * tallest of the header cards.- *- * The diagram row scrolls internally — a 12-chord song must not push the sheet- * itself off a phone screen.+ * only at bar 1. The host owns (and persists) the open flag.*/-export default function ChordsUsedCard({ text, instrument = 'guitar', open, onToggle }) {+function ChordsUsedCard({ text, instrument, open, onToggle }) {const chords = useMemo(() => sheetUsedChords(text), [text]);if (chords.length === 0) return null;return (- <CollapsibleBar+ <CollapsibleSectionid="song-chords-used"+ size="bar"label={`Chords used (${chords.length})`}summary={chords.join(' · ')}open={open}- onToggle={onToggle}+ onOpenChange={onToggle}+ className="shrink-0"+ buttonClassName="border-b border-port-border bg-port-card/60 px-3"+ // A 12-chord song must not push the sheet itself off a phone screen.bodyClassName="border-b border-port-border bg-port-card/40 px-3 py-2 max-h-[30vh] overflow-y-auto"><div className="flex flex-wrap items-end gap-x-4 gap-y-2">@@ -36,6 +36,10 @@ export default function ChordsUsedCard({ text, instrument = 'guitar', open, onTo</div>))}</div>- </CollapsibleBar>+ </CollapsibleSection>);}++// Every prop is a primitive or the host's stable toggle, so memo keeps the+// diagrams out of the viewer's per-beat re-render.+export default memo(ChordsUsedCard);diff --git a/client/src/components/songbook/ChordsUsedCard.test.jsx b/client/src/components/songbook/ChordsUsedCard.test.jsxindex 3a8cced19e..f83cd77074 100644--- a/client/src/components/songbook/ChordsUsedCard.test.jsx+++ b/client/src/components/songbook/ChordsUsedCard.test.jsx@@ -12,7 +12,7 @@ Nonsense lyric line// The card is a controlled disclosure — the viewer owns (and persists) the// open flag — so the tests drive it through a tiny host rather than reaching// into the component's internals.-const Host = ({ text = SAMPLE, defaultOpen = true, instrument }) => {+const Host = ({ text = SAMPLE, defaultOpen = true, instrument = 'guitar' }) => {const [open, setOpen] = useState(defaultOpen);return (<ChordsUsedCard@@ -41,11 +41,11 @@ describe('ChordsUsedCard', () => {render(<Host />);const toggle = screen.getByRole('button', { name: /Chords used/ });expect(toggle.getAttribute('aria-expanded')).toBe('true');- // Collapsed: the body is hidden (kept mounted) and the summary names the- // chords, so a closed card still says what the song asks for.+ // Collapsed: the diagrams are gone and the summary names the chords, so a+ // closed card still says what the song asks for.fireEvent.click(toggle);expect(toggle.getAttribute('aria-expanded')).toBe('false');- expect(document.getElementById('song-chords-used').hidden).toBe(true);+ expect(document.getElementById('song-chords-used')).toBeNull();expect(toggle.textContent).toContain('C · G');});});diff --git a/client/src/components/songbook/CollapsibleBar.jsx b/client/src/components/songbook/CollapsibleBar.jsxdeleted file mode 100644index 212781c7fe..0000000000--- a/client/src/components/songbook/CollapsibleBar.jsx+++ /dev/null@@ -1,48 +0,0 @@-import { ChevronDown, ChevronRight } from 'lucide-react';--/**- * A collapsible header band for the SongBook viewer's play mode — the shared- * chrome behind the Audio, Play along, and Chords used cards that sit ABOVE the- * sheet scroller (`shrink-0`, so they persist while the sheet scrolls under- * them).- *- * The header row is deliberately terse (one line, `text-xs`): three stacked- * cards must cost almost nothing when collapsed, which is the whole point of- * moving them out of the scroller. `summary` renders beside the label only- * while collapsed, truncated to one line, so a closed card still says what it- * holds.- *- * The body stays MOUNTED and is hidden with the `hidden` attribute rather than- * unmounted: the cards wrap live transports whose inner setup disclosure- * (`ChordTransportBar`'s "More") is local state, and collapsing the card while- * a play-along runs must not throw that away.- */-export default function CollapsibleBar({- id,- label,- summary = '',- open,- onToggle,- bodyClassName = '',- children,-}) {- const Chevron = open ? ChevronDown : ChevronRight;- return (- <div className="shrink-0">- <button- type="button"- onClick={onToggle}- aria-expanded={open}- aria-controls={id}- className="w-full flex items-center gap-1.5 border-b border-port-border bg-port-card/60 px-3 py-2 text-xs text-gray-400 hover:text-white"- >- <Chevron size={13} className="shrink-0" />- <span className="font-semibold shrink-0">{label}</span>- {summary && !open- ? <span className="min-w-0 truncate text-gray-500">{summary}</span>- : null}- </button>- <div id={id} hidden={!open} className={bodyClassName}>{children}</div>- </div>- );-}diff --git a/client/src/components/songbook/DrumTransportBar.jsx b/client/src/components/songbook/DrumTransportBar.jsxindex 0bfeb5a0a8..a1dc0bbd96 100644--- a/client/src/components/songbook/DrumTransportBar.jsx+++ b/client/src/components/songbook/DrumTransportBar.jsx@@ -22,7 +22,7 @@* touch targets.*/-import { useMemo, useState } from 'react';+import { memo, useMemo, useState } from 'react';import { Repeat, SlidersHorizontal, Volume2, VolumeX } from 'lucide-react';import { DRUM_KIT_LIST, resolveDrumKit } from '../../lib/drumKits.js';import { clampClickVolume, DEFAULT_CLICK_VOLUME } from '../../lib/drumPlayback.js';@@ -32,7 +32,7 @@ import {CountInSelect, PercentButtons, PlayStopButton, TempoControls,} from './TransportControls.jsx';-export default function DrumTransportBar({+function DrumTransportBar({playing, onToggle, hasMusic = true,bpm, onBpmChange, onPercent, writtenTempo,countInBars, onCountInChange,@@ -196,3 +196,8 @@ export default function DrumTransportBar({</div>);}++// Every prop is a primitive or a stable hook callback apart from `pulse`, which+// the host nulls while its card is collapsed — so a bar nobody can see costs no+// reconciliation per beat.+export default memo(DrumTransportBar);diff --git a/client/src/components/songbook/TabSheetView.jsx b/client/src/components/songbook/TabSheetView.jsxindex 825b6b351f..782f4c2929 100644--- a/client/src/components/songbook/TabSheetView.jsx+++ b/client/src/components/songbook/TabSheetView.jsx@@ -30,9 +30,6 @@ import { activeCtrlClass, ctrlBtnClass } from './constants.js';* because `text` arrives already transposed the diagrams follow the transposed* names for free. Tab staffs are guitar-specific, so non-guitar views collapse* each staff block to a one-line note with an inline "show" expand.- * The "chords used" strip is NOT here: it moved out to- * `<ChordsUsedCard>` so the viewer can pin it in the header band above the- * scroller, where it stays visible past bar 1.** Play-along support (issue #4104): `soundingChord` — `{ lineIndex, chordIndex }`* or null — lights the chord token the synth preview is currently sounding, the@@ -376,8 +373,9 @@ function TabSheetView({);}-// Props are all primitives (`format`/`instrumentView` included) apart from `soundingChord`, which the host memoizes and which only-// changes when the sounding chord does (once a bar, not once a frame) — so memo+// Props are all primitives (`format`/`instrumentView` included) apart from+// `soundingChord`, which the host memoizes and which only changes when the+// sounding chord does (once a bar, not once a frame) — so memo// makes re-renders of a host page (stage flips, autoscroll ticks) skip the full// sheet re-render.export default memo(TabSheetView);diff --git a/client/src/components/ui/CollapsibleSection.jsx b/client/src/components/ui/CollapsibleSection.jsxindex 289390b916..a60082e38a 100644--- a/client/src/components/ui/CollapsibleSection.jsx+++ b/client/src/components/ui/CollapsibleSection.jsx@@ -33,6 +33,15 @@ const SIZES = {label: 'text-gray-300',summary: 'text-gray-500 normal-case',},+ // Full-width header band stacked above a scroller (the SongBook viewer's+ // play-mode cards): sentence-case text-xs, 44px touch target, so several of+ // them collapsed still cost almost nothing.+ bar: {+ iconSize: 13,+ button: 'gap-1.5 min-h-[44px] text-xs text-gray-400 hover:text-white',+ label: 'font-semibold',+ summary: 'text-gray-500',+ },// Card row (digital-twin analysis card): size-14 icons, gap-2, sentence-case text-sm.lg: {iconSize: 14,@@ -45,6 +54,10 @@ const SIZES = {export default function CollapsibleSection({icon: Icon = null,label,+ // Body id, wired to the header's `aria-controls`. Only worth passing when+ // something outside the section addresses the body (a test, a caller's own+ // label), but the ARIA link is free once it exists.+ id,summary = '',defaultOpen = false,size = 'sm',@@ -59,6 +72,12 @@ export default function CollapsibleSection({// section owns its own state, which is what every other call site wants.open: controlledOpen,onOpenChange,+ // Render the body always and hide it with the `hidden` attribute instead of+ // unmounting it. For a section wrapping a LIVE surface whose own local state+ // would otherwise be thrown away by a collapse — the SongBook transport bars'+ // "More" disclosure. The attribute sits on a wrapper the caller can't+ // restyle, so a `bodyClassName` display utility can't defeat it.+ keepMounted = false,children,}) {const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);@@ -77,6 +96,7 @@ export default function CollapsibleSection({type="button"aria-expanded={open}onClick={toggle}+ aria-controls={id}className={`flex w-full items-center ${tone.button} ${buttonClassName}`.trim()}><Chevron size={tone.iconSize} className="shrink-0" />@@ -90,7 +110,9 @@ export default function CollapsibleSection({? <span className={`min-w-0 truncate ${tone.summary}`.trim()}>{summary}</span>: null}</button>- {open ? <div className={bodyClassName}>{children}</div> : null}+ {keepMounted+ ? <div id={id} hidden={!open}><div className={bodyClassName}>{children}</div></div>+ : open ? <div id={id} className={bodyClassName}>{children}</div> : null}</div>);}diff --git a/client/src/components/ui/README.md b/client/src/components/ui/README.mdindex 1b7c216e15..e84d7a944b 100644--- a/client/src/components/ui/README.md+++ b/client/src/components/ui/README.md@@ -11,7 +11,7 @@ accessibility). Feature-specific components live under their own feature directo| `AutoSizeTextarea` | Controlled `<textarea>` that grows to fit its content — no internal scroll, no hand-resize. || `Banner` | Toned alert block (icon + content + actions) for warnings, errors, and info callouts. || `BeatPulse` | Metronome dot row — one dot per beat of the bar, the current one lit. |-| `CollapsibleSection` | Disclosure section header — chevron, leading icon, collapsed summary, `aria-expanded`. |+| `CollapsibleSection` | Disclosure section header — chevron, leading icon, collapsed summary, `aria-expanded`/`aria-controls`; `keepMounted` hides the body instead of unmounting it. || `CollapsibleText` | Collapsed content preview with a show-more/less toggle — line-clamped `text`, or `children` capped by `maxHeight` when `line-clamp` can't (rendered markdown). || `ConfirmButtonPair` | Compact inline confirm/cancel pair for a destructive action in a dense control row. || `CopyableId` | Click-to-copy record-id badge — short prefix shown, full id copied. |diff --git a/client/src/hooks/README.md b/client/src/hooks/README.mdindex 0dfebc4109..98fe07fcfd 100644--- a/client/src/hooks/README.md+++ b/client/src/hooks/README.md@@ -124,7 +124,6 @@ grep -i "what you want to do" client/src/hooks/README.md| `useLiveSuggest` | Post-typing debounce for an imperative panel trigger: `{ registerTrigger, scheduleSuggest }` re-arms one `debounceMs` timer per keystroke and fires the registered fn only while `enabled` and still mounted. | An editor that asks a sibling AI panel to suggest once the writer pauses (WorkEditor ↔ LiveContinuationPanel). || `useLockToggle` | Optimistic-PATCH lock toggle. | New "lock this field/stage/arc" button — use this, do not re-implement. || `usePersistedOptions` | Registry for "saved default + per-run override" form options: one spec row per option (`{ defaultValue, read, clamp, persistOnEdit }`) owns the state, per-field dirty flag, hydrate-if-untouched pass and edited-only override collection. Returns `{ values, edit, hydrate, collectOverrides, inputProps }`, all identity-stable and ref-backed so a caller's `useCallback` needs one dep instead of one per option. | Any panel where each option must load a saved default, persist edits, and send ONLY edited fields as per-run overrides (AutopilotPanel) — use this instead of hand-copying the state/editedRef/hydrate/collect scaffold per option. |-| `usePersistedDisclosure` | Disclosure open/closed state persisted under a localStorage key (`'1'`/`'0'` via safeStorage); absent falls through to the caller's `defaultOpen` rather than reading as closed. Returns `[open, toggle]`. | A collapsible card whose open state should survive a remount/reload (the SongBook viewer's Audio / Play along / Chords used header cards). || `usePopoverPosition` | Viewport-clamped `{ left, top, width }` for a fixed-position portal popover anchored to a trigger; re-measures on open and rAF-coalesced on capture-phase scroll/resize. Returns `{ triggerRef, popoverRef, style, reposition }`; pass `anchorRef` to follow a parent-owned trigger. | Any portal-into-`<body>` menu/popover placed relative to a button (ThemeSwitcher, CollectionPickerShell) — use this instead of re-rolling the measure/flip/clamp/reflow plumbing. || `useScrollLock` | Body-scroll lock with ref-count. | Modals, drawers, lightboxes. || `useSidebarResize` | Drag-to-resize split-pane width persisted to `localStorage`; returns `{ containerRef, width, maxWidth, onMouseDown, reset }` and caps the drag at `maxFraction` of the measured container. | A desktop sidebar/split pane with a draggable divider (WorkEditor's storyboard sidebar). |@@ -144,7 +143,7 @@ grep -i "what you want to do" client/src/hooks/README.md| Hook | Purpose | Use when ||---|---|---|-| `useLocalStorageBool` | Boolean `useState` mirrored to `localStorage`. | Per-user UI preference toggle. |+| `useLocalStorageBool` | Boolean `useState` mirrored to `localStorage`; returns `[value, setValue, toggle]`. | Per-user UI preference toggle, and any remembered disclosure (the SongBook viewer's Audio / Sheet controls / Chords used cards). || `useNavWorkingSet` | Sidebar Pinned + Recent working set (localStorage MRU + pins); resolves stored paths to `{ path, label, icon }` rows via a `resolveNavEntry` arg. | Rendering the sidebar's Pinned/Recent sections. |## Sidebar navigation datadiff --git a/client/src/hooks/index.js b/client/src/hooks/index.jsindex 458c4937b1..0dd1150ebf 100644--- a/client/src/hooks/index.js+++ b/client/src/hooks/index.js@@ -60,7 +60,6 @@ export { default as useMoltworldWs } from './useMoltworldWs.js';export { default as useCharacterAugmentation } from './useCharacterAugmentation.js';export { default as useMounted } from './useMounted.js';export { default as usePendingListRows } from './usePendingListRows.js';-export { default as usePersistedDisclosure } from './usePersistedDisclosure.js';export { default as usePopoverPosition } from './usePopoverPosition.js';export { default as useAgyModels } from './useAgyModels.js';export * from './useAgyModels.js';diff --git a/client/src/hooks/useLocalStorageBool.js b/client/src/hooks/useLocalStorageBool.jsindex 69e0c16d61..d96ba9ffc1 100644--- a/client/src/hooks/useLocalStorageBool.js+++ b/client/src/hooks/useLocalStorageBool.js@@ -17,6 +17,8 @@ import {// `format`: `'1'` writes `'1'`/`'0'`; `'true'` writes `'true'`/`'false'`.// Reads always treat either `'1'` or `'true'` as truthy so existing values// keep working when a page switches its `format` later.+// Returns `[value, setValue, toggle]` — the third element is the flip a+// disclosure header wants, so a caller never re-rolls `() => set((v) => !v)`.export function useLocalStorageBool(key, defaultValue = false, { format = '1' } = {}) {const [value, setValue] = useState(() => readBool(key, defaultValue));@@ -29,7 +31,9 @@ export function useLocalStorageBool(key, defaultValue = false, { format = '1' }});}, [key, format]);- return [value, write];+ const toggle = useCallback(() => write((prev) => !prev), [write]);++ return [value, write, toggle];}// JSON-blob variant: hydrates from localStorage on first render, persists ondiff --git a/client/src/hooks/usePersistedDisclosure.js b/client/src/hooks/usePersistedDisclosure.jsdeleted file mode 100644index 6b88e48feb..0000000000--- a/client/src/hooks/usePersistedDisclosure.js+++ /dev/null@@ -1,31 +0,0 @@-import { useCallback, useState } from 'react';-import { safeReadStorage, safeWriteStorage } from '../lib/safeStorage.js';--/**- * Disclosure open/closed state remembered across mounts (and reloads) under a- * localStorage key.- *- * `'1'` / `'0'` rather than JSON so the stored bytes are readable and a- * corrupted entry is unambiguous. Absent — never toggled — is NOT "closed": it- * falls through to the caller's `defaultOpen`, so a card that ships collapsed- * can later ship expanded without every install that never touched it being- * pinned to the old default.- *- * `storageKey` is read once, at mount. A caller that swaps the key per record- * wants a `key` on the component instead; the keys here name a card, not a row.- */-export default function usePersistedDisclosure(storageKey, defaultOpen = false) {- const [open, setOpen] = useState(() => {- const raw = safeReadStorage(storageKey);- if (raw !== '1' && raw !== '0') return defaultOpen;- return raw === '1';- });- const toggle = useCallback(() => {- setOpen((prev) => {- const next = !prev;- safeWriteStorage(storageKey, next ? '1' : '0');- return next;- });- }, [storageKey]);- return [open, toggle];-}diff --git a/client/src/pages/SongBookViewer.jsx b/client/src/pages/SongBookViewer.jsxindex b78fa12796..ed592562cf 100644--- a/client/src/pages/SongBookViewer.jsx+++ b/client/src/pages/SongBookViewer.jsx@@ -72,7 +72,7 @@ import DrumTransportBar from '../components/songbook/DrumTransportBar';import ChordPreview from '../components/songbook/ChordPreview';import ChordTransportBar from '../components/songbook/ChordTransportBar';import ChordsUsedCard from '../components/songbook/ChordsUsedCard';-import CollapsibleBar from '../components/songbook/CollapsibleBar';+import CollapsibleSection from '../components/ui/CollapsibleSection';import PracticeLogger from '../components/songbook/PracticeLogger';import { SongLinkChips, SongLinksEditor } from '../components/songbook/SongLinks';import {@@ -84,7 +84,7 @@ import { useAsyncAction } from '../hooks/useAsyncAction';import { useConfirmDelete } from '../hooks/useConfirmDelete';import useDrawerTab from '../hooks/useDrawerTab';import useKeyboardShortcuts from '../hooks/useKeyboardShortcuts';-import usePersistedDisclosure from '../hooks/usePersistedDisclosure';+import { useLocalStorageBool } from '../hooks/useLocalStorageBool';import useAutoscroll from '../hooks/useAutoscroll';import useDrumPlayer from '../hooks/useDrumPlayer';import useChordPlayer from '../hooks/useChordPlayer';@@ -345,26 +345,23 @@ export default function SongBookViewer() {// unconditionally (hooks rule) — a drum chart, and a `plain` sheet (the// explicit opt-out of all notation UI, chord tokens included), parse to zero// chords and stand up no player.- const chord = useChordPlayer(- isDrum || contentFormat === 'plain' ? '' : renderedText,- { songId: id },- );+ // Chord voicings, the chord play-along and the chords-used card are all the+ // same question: does this sheet have chords to work with at all?+ const chordUiEnabled = !isDrum && contentFormat !== 'plain';+ const chord = useChordPlayer(chordUiEnabled ? renderedText : '', { songId: id });// --- Header cards. Each play-mode band above the sheet is a disclosure whose// state is remembered globally (a practice posture carries across songs, the// way font size does). Audio ships COLLAPSED: it is the tallest band and the// one you set once, so the sheet starts higher up a phone screen.- const [audioOpen, toggleAudio] = usePersistedDisclosure('songbook:audioOpen', false);- const [controlsOpen, toggleControls] = usePersistedDisclosure('songbook:controlsOpen', true);- const [chordsOpen, toggleChords] = usePersistedDisclosure('songbook:chordsOpen', true);+ const [audioOpen, setAudioOpen, toggleAudio] = useLocalStorageBool('songbook:audioOpen', false);+ const [controlsOpen, , toggleControls] = useLocalStorageBool('songbook:controlsOpen', true);+ const [chordsOpen, , toggleChords] = useLocalStorageBool('songbook:chordsOpen', true);// What a collapsed card says about itself — the couple of values you would// otherwise have to open it to read.const transport = isDrum ? drum : chord;- const audioSummary = [- transport.playing ? 'playing' : null,- `${transport.bpm} BPM`,- ].filter(Boolean).join(' · ');+ const audioSummary = `${transport.playing ? 'playing · ' : ''}${transport.bpm} BPM`;const controlsSummary = [playing ? 'scrolling' : null,transpose ? `${transpose > 0 ? '+' : ''}${transpose} semitones` : null,@@ -406,8 +403,15 @@ export default function SongBookViewer() {// Play-mode shortcuts. A drum chart rebinds them onto the kit transport (space// play/stop, +/- BPM, [ ] loop ends, m mutes the click) since transpose/// scroll-speed don't apply.+ // A shortcut that SOUNDS something opens the Audio card first: the card ships+ // collapsed, and a kit starting with no transport on screen leaves the tempo,+ // the kit and the loop unreachable by anyone who hasn't found the chevron.+ const startTransport = (toggleTransport) => () => {+ setAudioOpen(true);+ toggleTransport();+ };const drumShortcuts = {- ' ': drum.toggle,+ ' ': startTransport(drum.toggle),m: () => drum.setClickEnabled(!drum.clickEnabled),'+': () => drum.setBpm(drum.bpm + 1),'=': () => drum.setBpm(drum.bpm + 1),@@ -427,7 +431,7 @@ export default function SongBookViewer() {// The chord play-along gets `p`, not space: space already drives autoscroll// here, and the two are complementary (scroll the sheet while the backing// sounds) rather than rival meanings of "play".- p: chord.toggle,+ p: startTransport(chord.toggle),// Only bound when the song HAS a target — otherwise the key would toast// "nothing to fit" at a user who never set one....(fitDurationSec != null ? { f: fitToSongDuration } : {}),@@ -874,212 +878,215 @@ export default function SongBookViewer() {higher up the screen and the summary keeps tempo visible whileit is closed. */}{(isDrum || chord.chordCount > 0) && (- <CollapsibleBar- id="song-audio-controls"- label="Audio"- summary={audioSummary}- open={audioOpen}- onToggle={toggleAudio}- >- {/* Drum play-along transport — its own bar above the shared controls,- so the kit's tempo/loop/click sit together rather than interleaved- with the sheet controls. */}- {isDrum && (- <DrumTransportBar- playing={drum.playing}- onToggle={drum.toggle}- hasMusic={drum.hasMusic}- bpm={drum.bpm}- onBpmChange={drum.setBpm}- onPercent={drum.setBpmPercent}- writtenTempo={drum.writtenTempo}- countInBars={drum.countInBars}- onCountInChange={drum.setCountInBars}- loopEnabled={drum.loopEnabled}- onLoopToggle={drum.setLoopEnabled}- loopFrom={drum.loopFrom}- loopTo={drum.loopTo}- onLoopRangeChange={drum.setLoopRange}- barCount={drum.barCount}- clickEnabled={drum.clickEnabled}- onClickToggle={drum.setClickEnabled}- clickVolume={drum.clickVolume}- onClickVolumeChange={drum.setClickVolume}- kitId={drum.kitId}- onKitChange={drum.setKitId}- beatsPerBar={drum.beatsPerBar}- pulse={drum.pulse}- currentBar={drum.currentBar}- />- )}-- {/* Chord-sheet play-along transport (#4104) — the same slot one format- over, and only for a sheet that actually carries chords (a lyrics-- only or plain sheet has nothing to sound, so no bar appears). */}- {!isDrum && chord.chordCount > 0 && (- <ChordTransportBar- playing={chord.playing}- onToggle={chord.toggle}- hasChords={chord.hasChords}- bpm={chord.bpm}- onBpmChange={chord.setBpm}- onPercent={chord.setBpmPercent}- writtenTempo={chord.writtenTempo}- beatsPerBar={chord.beatsPerBar}- onBeatsPerBarChange={chord.setBeatsPerBar}- countInBars={chord.countInBars}- onCountInChange={chord.setCountInBars}- clickEnabled={chord.clickEnabled}- onClickToggle={chord.setClickEnabled}- chordCount={chord.chordCount}- pulse={chord.pulse}- // Play mode is the only host that binds a key for this transport.- keyHint="(p)"- />- )}- </CollapsibleBar>+ <CollapsibleSection+ id="song-audio-controls"+ size="bar"+ label="Audio"+ summary={audioSummary}+ open={audioOpen}+ onOpenChange={toggleAudio}+ className="shrink-0"+ buttonClassName="border-b border-port-border bg-port-card/60 px-3"+ // Kept mounted: a transport's own "More" disclosure (and the+ // sound it is making) must survive a collapse.+ keepMounted+ >+ {isDrum ? (+ <DrumTransportBar+ playing={drum.playing}+ onToggle={drum.toggle}+ hasMusic={drum.hasMusic}+ bpm={drum.bpm}+ onBpmChange={drum.setBpm}+ onPercent={drum.setBpmPercent}+ writtenTempo={drum.writtenTempo}+ countInBars={drum.countInBars}+ onCountInChange={drum.setCountInBars}+ loopEnabled={drum.loopEnabled}+ onLoopToggle={drum.setLoopEnabled}+ loopFrom={drum.loopFrom}+ loopTo={drum.loopTo}+ onLoopRangeChange={drum.setLoopRange}+ barCount={drum.barCount}+ clickEnabled={drum.clickEnabled}+ onClickToggle={drum.setClickEnabled}+ clickVolume={drum.clickVolume}+ onClickVolumeChange={drum.setClickVolume}+ kitId={drum.kitId}+ onKitChange={drum.setKitId}+ beatsPerBar={drum.beatsPerBar}+ // The beat readout is the one prop that turns over per beat.+ // A collapsed card doesn't render it, so passing null there+ // lets the memoized bar skip reconciliation entirely.+ pulse={audioOpen ? drum.pulse : null}+ currentBar={drum.currentBar}+ />+ ) : (+ <ChordTransportBar+ playing={chord.playing}+ onToggle={chord.toggle}+ hasChords={chord.hasChords}+ bpm={chord.bpm}+ onBpmChange={chord.setBpm}+ onPercent={chord.setBpmPercent}+ writtenTempo={chord.writtenTempo}+ beatsPerBar={chord.beatsPerBar}+ onBeatsPerBarChange={chord.setBeatsPerBar}+ countInBars={chord.countInBars}+ onCountInChange={chord.setCountInBars}+ clickEnabled={chord.clickEnabled}+ onClickToggle={chord.setClickEnabled}+ chordCount={chord.chordCount}+ pulse={audioOpen ? chord.pulse : null}+ // Play mode is the only host that binds a key for this transport.+ keyHint="(p)"+ />+ )}+ </CollapsibleSection>)}{/* Sheet controls — what you drive the SHEET with (autoscroll,transpose, size, instrument view, stage). Open by default: this isthe band you reach for mid-song. Named for the sheet, not "playalong", which is the transport's own Play button one card up. */}- <CollapsibleBar+ <CollapsibleSectionid="song-sheet-controls"+ size="bar"label="Sheet controls"summary={controlsSummary}open={controlsOpen}- onToggle={toggleControls}+ onOpenChange={toggleControls}+ className="shrink-0"+ buttonClassName="border-b border-port-border bg-port-card/60 px-3"+ bodyClassName="border-b border-port-border bg-port-card/60 px-3 py-2 flex flex-wrap items-center gap-x-4 gap-y-2">- <div className="border-b border-port-border bg-port-card/60 px-3 py-2 flex flex-wrap items-center gap-x-4 gap-y-2">- {/* Autoscroll — a drum chart scrolls HORIZONTALLY under its own- playhead (DrumSheetView), so a second vertical-scroll play button- would be a rival transport with a rival meaning of "play". */}- {!isDrum && (- <div className="flex items-center gap-2">+ {/* Autoscroll — a drum chart scrolls HORIZONTALLY under its own+ playhead (DrumSheetView), so a second vertical-scroll play button+ would be a rival transport with a rival meaning of "play". */}+ {!isDrum && (+ <div className="flex items-center gap-2">+ <button+ type="button"+ onClick={toggle}+ className={`${ctrlBtnClass} ${playing ? 'text-port-accent border-port-accent/50' : ''}`}+ aria-label={playing ? 'Pause autoscroll' : 'Play autoscroll'}+ title={playing ? 'Pause autoscroll (space)' : 'Play autoscroll (space)'}+ >+ {playing ? <Pause size={18} /> : <Play size={18} />}+ </button>+ <label htmlFor="song-speed" className="sr-only">Autoscroll speed</label>+ <input+ id="song-speed"+ type="range"+ min={SPEED_MIN}+ max={SPEED_MAX}+ value={pxPerSec}+ onChange={(e) => setPxPerSec(Number(e.target.value))}+ className="w-24 sm:w-32 accent-port-accent"+ title="Autoscroll speed (+/-)"+ />+ {/* Fit to duration — only for a song that carries a target run+ time (set in Edit). Solves the speed from the sheet as it is+ rendered right now, so re-fitting after a font-size or+ transpose change is a single click. */}+ {fitDurationSec != null && (<buttontype="button"- onClick={toggle}- className={`${ctrlBtnClass} ${playing ? 'text-port-accent border-port-accent/50' : ''}`}- aria-label={playing ? 'Pause autoscroll' : 'Play autoscroll'}- title={playing ? 'Pause autoscroll (space)' : 'Play autoscroll (space)'}+ onClick={fitToSongDuration}+ className={`${ctrlBtnClass} gap-1.5 px-2 text-xs`}+ aria-label={`Fit autoscroll to ${formatDurationSec(fitDurationSec)}`}+ title={`Fit autoscroll to ${formatDurationSec(fitDurationSec)} (f)`}>- {playing ? <Pause size={18} /> : <Play size={18} />}- </button>- <label htmlFor="song-speed" className="sr-only">Autoscroll speed</label>- <input- id="song-speed"- type="range"- min={SPEED_MIN}- max={SPEED_MAX}- value={pxPerSec}- onChange={(e) => setPxPerSec(Number(e.target.value))}- className="w-24 sm:w-32 accent-port-accent"- title="Autoscroll speed (+/-)"- />- {/* Fit to duration — only for a song that carries a target run- time (set in Edit). Solves the speed from the sheet as it is- rendered right now, so re-fitting after a font-size or- transpose change is a single click. */}- {fitDurationSec != null && (- <button- type="button"- onClick={fitToSongDuration}- className={`${ctrlBtnClass} gap-1.5 px-2 text-xs`}- aria-label={`Fit autoscroll to ${formatDurationSec(fitDurationSec)}`}- title={`Fit autoscroll to ${formatDurationSec(fitDurationSec)} (f)`}- >- <Timer size={16} />- <span className="hidden sm:inline font-mono">{formatDurationSec(fitDurationSec)}</span>- </button>- )}- </div>- )}-- {/* Transpose — meaningless on a kit grid, so hidden for drum charts */}- {!isDrum && (- <div className="flex items-center gap-1" role="group" aria-label="Transpose">- <button type="button" onClick={() => setTranspose(transpose - 1)} className={ctrlBtnClass} aria-label={`Transpose down (currently ${transpose > 0 ? '+' : ''}${transpose} semitones)`} title="Transpose down ([)">- <Minus size={16} />- </button>- <span className="min-w-[3.5rem] text-center text-sm text-gray-300 font-mono" title="Transpose (semitones)" role="status" aria-live="polite" aria-atomic="true">- <span className="sr-only">Transpose </span>- <span>{transpose > 0 ? `+${transpose}` : transpose}</span>- <span className="sr-only"> semitones</span>- </span>- <button type="button" onClick={() => setTranspose(transpose + 1)} className={ctrlBtnClass} aria-label={`Transpose up (currently ${transpose > 0 ? '+' : ''}${transpose} semitones)`} title="Transpose up (])">- <Plus size={16} />+ <Timer size={16} />+ <span className="hidden sm:inline font-mono">{formatDurationSec(fitDurationSec)}</span></button>- </div>- )}+ )}+ </div>+ )}- {/* Font size — on a drum chart the same control zooms the kit grid- (DrumSheetView scales the whole strip off fontSizeRem), so it's- labelled for what it actually does there. */}- <div className="flex items-center gap-1" role="group" aria-label={isDrum ? 'Grid size' : 'Font size'}>- <span className="sr-only" role="status" aria-live="polite" aria-atomic="true">{isDrum ? `Grid size ${fontSize.toFixed(3)} rem` : `Font size ${fontSize.toFixed(3)} rem`}</span>- <button type="button" onClick={() => setFontSize(fontSize - FONT_STEP)} className={`${ctrlBtnClass} text-xs font-bold`} aria-label={`${isDrum ? 'Zoom out' : 'Smaller text'} (currently ${fontSize.toFixed(3)} rem)`}>- A−+ {/* Transpose — meaningless on a kit grid, so hidden for drum charts */}+ {!isDrum && (+ <div className="flex items-center gap-1" role="group" aria-label="Transpose">+ <button type="button" onClick={() => setTranspose(transpose - 1)} className={ctrlBtnClass} aria-label={`Transpose down (currently ${transpose > 0 ? '+' : ''}${transpose} semitones)`} title="Transpose down ([)">+ <Minus size={16} /></button>- <button type="button" onClick={() => setFontSize(fontSize + FONT_STEP)} className={`${ctrlBtnClass} text-sm font-bold`} aria-label={`${isDrum ? 'Zoom in' : 'Larger text'} (currently ${fontSize.toFixed(3)} rem)`}>- A++ <span className="min-w-[3.5rem] text-center text-sm text-gray-300 font-mono" title="Transpose (semitones)" role="status" aria-live="polite" aria-atomic="true">+ <span className="sr-only">Transpose </span>+ <span>{transpose > 0 ? `+${transpose}` : transpose}</span>+ <span className="sr-only"> semitones</span>+ </span>+ <button type="button" onClick={() => setTranspose(transpose + 1)} className={ctrlBtnClass} aria-label={`Transpose up (currently ${transpose > 0 ? '+' : ''}${transpose} semitones)`} title="Transpose up (])">+ <Plus size={16} /></button></div>+ )}- {/* Instrument view (chord diagrams) — render-only, URL-backed. A drum- chart has no chords to voice, so the picker hides. */}- {!isDrum && (- <TabPills- variant="pills"- size="sm"- tabs={VIEW_TABS}- activeTab={instrumentView}- onChange={setInstrumentView}- ariaLabel="Instrument view"- mobileDropdown- mobileSelectId="song-instrument-view"- />- )}+ {/* Font size — on a drum chart the same control zooms the kit grid+ (DrumSheetView scales the whole strip off fontSizeRem), so it's+ labelled for what it actually does there. */}+ <div className="flex items-center gap-1" role="group" aria-label={isDrum ? 'Grid size' : 'Font size'}>+ <span className="sr-only" role="status" aria-live="polite" aria-atomic="true">{isDrum ? `Grid size ${fontSize.toFixed(3)} rem` : `Font size ${fontSize.toFixed(3)} rem`}</span>+ <button type="button" onClick={() => setFontSize(fontSize - FONT_STEP)} className={`${ctrlBtnClass} text-xs font-bold`} aria-label={`${isDrum ? 'Zoom out' : 'Smaller text'} (currently ${fontSize.toFixed(3)} rem)`}>+ A−+ </button>+ <button type="button" onClick={() => setFontSize(fontSize + FONT_STEP)} className={`${ctrlBtnClass} text-sm font-bold`} aria-label={`${isDrum ? 'Zoom in' : 'Larger text'} (currently ${fontSize.toFixed(3)} rem)`}>+ A++ </button>+ </div>- {/* Stage */}- <div>- <label htmlFor="song-stage" className="sr-only">Learning stage</label>- <select- id="song-stage"- value={song.stage || 'new'}- onChange={(e) => onStageChange(e.target.value)}- className={`text-xs rounded-full border px-2 py-2 min-h-[44px] focus:outline-none focus-visible:ring-2 focus-visible:ring-port-accent ${stageClass}`}- >- {SONG_STAGES.map((s) => <option key={s.id} value={s.id} className="bg-port-card text-white">{s.label}</option>)}- </select>- </div>+ {/* Instrument view (chord diagrams) — render-only, URL-backed. A drum+ chart has no chords to voice, so the picker hides. */}+ {!isDrum && (+ <TabPills+ variant="pills"+ size="sm"+ tabs={VIEW_TABS}+ activeTab={instrumentView}+ onChange={setInstrumentView}+ ariaLabel="Instrument view"+ mobileDropdown+ mobileSelectId="song-instrument-view"+ />+ )}- {/* Badges + source */}- <div className="flex flex-wrap items-center gap-2 text-xs text-gray-400 ml-auto">- {song.key && <span className="px-2 py-1 rounded-full bg-port-bg border border-port-border">Key {song.key}</span>}- {song.capo > 0 && <span className="px-2 py-1 rounded-full bg-port-bg border border-port-border">Capo {song.capo}</span>}- {song.tuning && <span className="px-2 py-1 rounded-full bg-port-bg border border-port-border">{song.tuning}</span>}- {isHttpUrl(song.sourceUrl) && (- <a- href={song.sourceUrl}- target="_blank"- rel="noopener noreferrer"- className="flex items-center gap-1 px-2 py-1 rounded-full bg-port-bg border border-port-border text-port-accent hover:border-port-accent/50"- >- <ExternalLink size={12} />- Source- </a>- )}- </div>+ {/* Stage */}+ <div>+ <label htmlFor="song-stage" className="sr-only">Learning stage</label>+ <select+ id="song-stage"+ value={song.stage || 'new'}+ onChange={(e) => onStageChange(e.target.value)}+ className={`text-xs rounded-full border px-2 py-2 min-h-[44px] focus:outline-none focus-visible:ring-2 focus-visible:ring-port-accent ${stageClass}`}+ >+ {SONG_STAGES.map((s) => <option key={s.id} value={s.id} className="bg-port-card text-white">{s.label}</option>)}+ </select>+ </div>++ {/* Badges + source */}+ <div className="flex flex-wrap items-center gap-2 text-xs text-gray-400 ml-auto">+ {song.key && <span className="px-2 py-1 rounded-full bg-port-bg border border-port-border">Key {song.key}</span>}+ {song.capo > 0 && <span className="px-2 py-1 rounded-full bg-port-bg border border-port-border">Capo {song.capo}</span>}+ {song.tuning && <span className="px-2 py-1 rounded-full bg-port-bg border border-port-border">{song.tuning}</span>}+ {isHttpUrl(song.sourceUrl) && (+ <a+ href={song.sourceUrl}+ target="_blank"+ rel="noopener noreferrer"+ className="flex items-center gap-1 px-2 py-1 rounded-full bg-port-bg border border-port-border text-port-accent hover:border-port-accent/50"+ >+ <ExternalLink size={12} />+ Source+ </a>+ )}</div>- </CollapsibleBar>+ </CollapsibleSection>{/* Chords used — pinned in the header band rather than scrolled awaywith the sheet: the shapes you are reaching for matter at bar 60,not only at bar 1. Follows the transposed text and the instrumentview, and a `plain` sheet (the opt-out of all notation UI) and adrum chart have no chords to show. */}- {!isDrum && contentFormat !== 'plain' && (+ {chordUiEnabled && (<ChordsUsedCardtext={renderedText}instrument={instrumentView}diff --git a/client/src/pages/SongBookViewer.test.jsx b/client/src/pages/SongBookViewer.test.jsxindex 4711713ae1..246c8a2474 100644--- a/client/src/pages/SongBookViewer.test.jsx+++ b/client/src/pages/SongBookViewer.test.jsx@@ -517,8 +517,9 @@ K: o - - - - - o -`;it('recomputes BPM from a percent-of-written button', async () => {api.getSong.mockResolvedValue(drumSong());renderPage();- expect(await screen.findByLabelText('Practice tempo (BPM)')).toBeTruthy();+ await screen.findByRole('button', { name: /^Audio/ });openAudioCard();+ expect(screen.getByLabelText('Practice tempo (BPM)')).toBeTruthy();fireEvent.click(screen.getByRole('button', { name: '50%' }));await waitFor(() => expect(screen.getByLabelText('Practice tempo (BPM)').value).toBe('48'));fireEvent.click(screen.getByRole('button', { name: '100%' }));