Skip to content

Milestone 3: controller matching - #4

Merged
rodzy merged 3 commits into
mainfrom
milestone-3-controllers
Nov 27, 2026
Merged

rodzy merged 3 commits into
mainfrom
milestone-3-controllers

Conversation

@rodzy

@rodzy rodzy commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

What does this change?

Milestone 3 of the roadmap: src/controllers.js safely reads metadata from each tab's media controller and matches media cards to sessions.

  • readMetadata returns null for an inactive controller (NS_ERROR_NOT_AVAILABLE) and rethrows any other error.
  • mediaSessions pairs each tab's browser with its active controller's metadata.
  • readCardTrack reads the title and artist shown on a media card.
  • matchCards maps each card to a session with the same title and artist. Each session is claimed at most once, and cards with no title never match.

The bundle zen-media-viz.uc.js is unchanged because src/index.js does not import the module yet. Wiring happens in Milestone 5.

How was it tested?

  • test/controllers.test.js covers each function with fake controllers and DOM cards (happy-dom).
  • The match is checked against the recorded Zen 1.24.3b fixture (test/fixtures/zen-1.24.3b.json).
  • npm test, npm run lint, npm run format:check and npm run check:bundle pass locally.
  • Not checked by hand in Zen. The card-to-controller behaviour comes from Zen's source and is not yet verified in a real install (Milestone 5).

Checklist

  • Tests were written first and cover the change (npm test)
  • npm run lint and npm run format:check pass
  • Bundle rebuilt and committed (npm run build) if anything in src/ changed (not needed here: the bundle is unchanged)
  • Relevant items in docs/manual-testing.md checked in a real Zen + Sine install (Milestone 5)
  • CHANGELOG.md updated under Unreleased

readMetadata treats an inactive controller as no session and rethrows
other errors. mediaSessions pairs each tab with its active metadata,
and matchCards maps each card to one session by exact title and artist,
so a session is claimed at most once.
Records the controller matching change in the changelog and moves the
roadmap to milestone 4 as next.
Cover a card matching its own session whatever order the sessions arrive in, and a card staying unmatched when its tab's controller is inactive.
@rodzy
rodzy merged commit 621a9d3 into main Nov 27, 2026
1 check passed
@rodzy
rodzy deleted the milestone-3-controllers branch November 27, 2026 23:08
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.

1 participant