Skip to content

feat(v3): flag library songs by working-tuning match (working-tuning PR 6)#668

Merged
byrongamatos merged 2 commits into
mainfrom
feat/v3-library-tuning-match
Jul 1, 2026
Merged

feat(v3): flag library songs by working-tuning match (working-tuning PR 6)#668
byrongamatos merged 2 commits into
mainfrom
feat/v3-library-tuning-match

Conversation

@ChrisBeWithYou

Copy link
Copy Markdown
Contributor

Working-tuning PR 6 (Phase D — library / song-picker consumer). Based on main; feature-detects the tuner's coverageReport + the host workingTuning (from #657/#660 + #658), so it merges independently and lights up once those land.

What

Each song's existing tuning chip in the v3 library grid is coloured by whether your current working tuning covers it — so you can see at a glance what you can play right now vs. what needs a retune.

  • Green = your tuning covers it (play now) · Amber = needs a retune · neutral otherwise. Tooltip says which.

How

  • A post-paint decoration pass (decorateTuningChips): songCard tags each chip with data-tuning-offsets; after the (sync) window paints, an async pass calls the tuner plugin's coverageReport(songInfo) per visible chip and applies bg-emerald-500 / bg-amber-400. A token cancels a superseded pass (re-paint / tuning change) so scrolling stays snappy.
  • Re-flags on working-tuning-changed — re-colours in place, no re-fetch or re-paint.
  • Feature-detected — without window._tunerAutoOpen.coverageReport + window.feedBack.workingTuning, the chips render exactly as today.

The companion half — "on picking a mismatched song, prompt retune/switch" — is already the #666 gate (opening a mismatched song auto-opens the tuner and holds playback). This PR is the passive flagging that pairs with it.

v3-only; single file (static/v3/songs.js).

Test

Verified headless (Chrome via playwright-core) against the real library — 8/8: chip neutral before the capability; a matching tuning → green (+ "matches your tuning"); a mismatched tuning → amber (+ "needs a retune"); re-flags to green on the event; all 14 visible chips decorate; zero console errors.

Note

Touches songs.js, which in-flight library PRs also touch (A-Z rail #653, favorites #654) — different regions, so a clean merge is expected.

🤖 Generated with Claude Code
https://claude.ai/code/session_01QbexxfTt8q2tAn436MqGWF

ChrisBeWithYou and others added 2 commits July 1, 2026 10:42
…PR 6)

Each song's tuning chip in the v3 library grid is now coloured by whether your
CURRENT working tuning covers it: green = play it now, amber = needs a retune
(with a matching tooltip). Uses the tuner plugin's coverageReport (async), so it
runs as a post-paint decoration pass — chips render instantly, then colour a tick
later; a token cancels a superseded pass so scrolling stays snappy. Re-flags on
working-tuning-changed (retune / instrument swap / reset), no re-fetch.

Fully feature-detected: without the tuner coverage API + the host workingTuning
state, the chips render exactly as before. v3-only, single file (static/v3/songs.js).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QbexxfTt8q2tAn436MqGWF
…668 review)

Review fixes for working-tuning PR 6 (library tuning-match chips):

- Bass songs were scored against the guitar tuning. The chip passed no arrangement
  to coverageReport, so isBassArrangement fell back to guitar — a 4-string bass
  drop-D read as guitar could FALSE-MATCH a drop-D guitar player (green). songCard
  now flags a bass-only song (every arrangement name matches /\bbass\b/) with
  data-tuning-bass, and decorateTuningChips passes arrangement 'Bass'/'Lead' so
  coverage uses the right base pitches. Mixed guitar+bass songs → guitar (the
  song-level tuning is the guitar one); least-wrong given one tuning per song.

- Per-chip /api/settings fetch storm. coverageReport()→_playerTuning() fetched
  /api/settings once per visible chip per grid paint (~60). _playerTuning is now
  memoized (the player's tuning is song-independent) so all callers share one read;
  invalidated on instrument:changed / working-tuning-changed, with a 3s TTL so a
  settings write that doesn't emit an event still heals. A transient fetch failure
  is NOT cached (next read retries) — else one hiccup would freeze coverage.

Tests: player tuning shared across songs (one fetch); transient-failure retry
(fails without the fix). The prior #680 dedup test updated for the memoized behavior.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@byrongamatos
byrongamatos force-pushed the feat/v3-library-tuning-match branch from f3dbaa3 to 55e1e59 Compare July 1, 2026 08:51
@byrongamatos
byrongamatos merged commit df4e17b into main Jul 1, 2026
1 of 3 checks passed
@byrongamatos
byrongamatos deleted the feat/v3-library-tuning-match branch July 1, 2026 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants