feat(presence): "Listening to" from Navidrome / Dropped Needle (#491) #492

Merged
jared merged 2 commits from feat/now-playing-491 into lotus 2026-11-16 23:55:10 -05:00
Owner

Closes #491. Needs the backend from LotusGuild/matrix (now-playing/) deployed first. Until then the client just gets errors from /now-playing and backs off, and nothing shows.

What users see

  • Profile popout: a "Listening to" card with cover art, track, artist · album, player, and a live progress bar. It shows "Paused" when paused.
  • Member list: a "🎵 Track · Artist" line when the member has no typed status of their own.
  • Settings → Profile: "Share what I'm listening to", off by default. If no Navidrome account matches the user, it says so and the switch is disabled.
  • Matrix status text: while their Lotus Chat is open and they share, other clients (Element etc.) see 🎵 Artist – Track.

Status rules (Jared's decisions)

  • A typed status always wins, and so do DND and Invisible. The music text is only published when the user has no status of their own. Their saved status and its auto-clear are never edited, so there is nothing to restore.
  • The music text is marked: the note is followed by a thin space (U+2009), built from code points. Every device reads it as "no typed status":
    • pickHeartbeatStatus never adopts it;
    • the Profile sync never puts it in the field or localStorage;
    • a typed "🎵 vibes" (normal space) still counts as a real status.
  • Clearing a status by hand or by auto-clear falls back to the music. A track change re-sends presence in the current state, so a hidden window stays away. Closing the window drops the music, because pagehide sends the typed status.
  • Known limitation: a crash or killed process can leave the last track in the status until Lotus runs again. The card itself always comes live from the service.

Implementation

  • utils/nowPlaying.ts: pure helpers (format, marker, effectiveStatus priority, position, config and cover URLs).
  • utils/nowPlayingClient.ts: the API with an OpenID token cache, plus the user's own store (sharing state and music text).
  • utils/nowPlayingStore.ts: batched polling of other users, every 20 s while visible.
  • hooks/useNowPlaying.ts, components/now-playing/NowPlaying.tsx.
  • Hooked into usePresenceUpdater, ownStatusSync, the StatusExpiryMonitor/PresenceUpdater in ClientNonUIFeatures, Profile.tsx, MembersDrawer, UserRoomProfile.
  • config.json: nowPlaying["matrix.lotusguild.org"].url.

Tests

  • npm test: 1476 pass, 0 fail, including new nowPlaying.test.ts (8 cases) and a heartbeat case in ownStatusSync.test.ts.
  • tsc: only the 5 known baseline errors.
  • eslint and prettier are clean on all touched files.
  • A local vite build fails only on the pre-existing stale matrix-js-sdk in the local node_modules (OAuth2 export), which is unrelated.
  • Not yet tested against the live service.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA

Closes #491. Needs the backend from LotusGuild/matrix (`now-playing/`) deployed first. Until then the client just gets errors from `/now-playing` and backs off, and nothing shows. ## What users see - **Profile popout:** a "Listening to" card with cover art, track, artist · album, player, and a live progress bar. It shows "Paused" when paused. - **Member list:** a "🎵 Track · Artist" line when the member has no typed status of their own. - **Settings → Profile:** "Share what I'm listening to", **off by default**. If no Navidrome account matches the user, it says so and the switch is disabled. - **Matrix status text:** while their Lotus Chat is open and they share, other clients (Element etc.) see `🎵 Artist – Track`. ## Status rules (Jared's decisions) - **A typed status always wins**, and so do DND and Invisible. The music text is only published when the user has no status of their own. Their saved status and its auto-clear are never edited, so there is nothing to restore. - **The music text is marked:** the note is followed by a thin space (U+2009), built from code points. Every device reads it as "no typed status": - `pickHeartbeatStatus` never adopts it; - the Profile sync never puts it in the field or localStorage; - a typed "🎵 vibes" (normal space) still counts as a real status. - **Clearing a status** by hand or by auto-clear falls back to the music. A track change re-sends presence in the current state, so a hidden window stays away. Closing the window drops the music, because pagehide sends the typed status. - **Known limitation:** a crash or killed process can leave the last track in the status until Lotus runs again. The card itself always comes live from the service. ## Implementation - `utils/nowPlaying.ts`: pure helpers (format, marker, `effectiveStatus` priority, position, config and cover URLs). - `utils/nowPlayingClient.ts`: the API with an OpenID token cache, plus the user's own store (sharing state and music text). - `utils/nowPlayingStore.ts`: batched polling of other users, every 20 s while visible. - `hooks/useNowPlaying.ts`, `components/now-playing/NowPlaying.tsx`. - Hooked into `usePresenceUpdater`, `ownStatusSync`, the `StatusExpiryMonitor`/`PresenceUpdater` in `ClientNonUIFeatures`, `Profile.tsx`, `MembersDrawer`, `UserRoomProfile`. - `config.json`: `nowPlaying["matrix.lotusguild.org"].url`. ## Tests - `npm test`: 1476 pass, 0 fail, including new `nowPlaying.test.ts` (8 cases) and a heartbeat case in `ownStatusSync.test.ts`. - `tsc`: only the 5 known baseline errors. - eslint and prettier are clean on all touched files. - A local `vite build` fails only on the pre-existing stale `matrix-js-sdk` in the local `node_modules` (`OAuth2` export), which is unrelated. - Not yet tested against the live service. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
jared added 2 commits 2026-11-16 23:33:05 -05:00
feat(presence): "Listening to" from Navidrome / Dropped Needle (#491)
CI / Build & Quality Checks (push) Skipped
CI / Secret scan (gitleaks) (push) Skipped
CI / Playwright smoke (e2e) (push) Skipped
0cfca75f6f
Discord/Spotify-style now playing, served by the new Lotus now-playing
service (matrix repo, now-playing/):

- Profile popout: a "Listening to" card (cover, track, artist, album,
  live progress); member list: a 🎵 line when the member has no typed
  status. Data comes from GET /now-playing/v1/users, batched across all
  visible users and polled every 20 s while the page is visible.
- Settings → Profile: "Share what I'm listening to", off by default,
  stored by the service (GET/PUT /v1/me). Auth is a Matrix OpenID token.
- Status text: while Lotus is open and sharing, the Matrix status shows
  "🎵 Artist – Track" so other clients see it, but only when the user has
  no typed status, and never in DND/Invisible. The typed status and its
  auto-clear are never touched. The music text uses a thin space after
  the note, and every device reads it as "no typed status"
  (pickHeartbeatStatus, Profile sync), so it can't be adopted as the
  user's status. Clearing or auto-clearing a status falls back to the
  music; closing the window drops it (pagehide sends the typed status).
- config.json: nowPlaying → https://matrix.lotusguild.org/now-playing.

Tests: nowPlaying.test.ts (format, marker, priority matrix, position,
config/cover URLs) and a heartbeat case in ownStatusSync.test.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
fix(now-playing): build the status marker from code points
CI / Build & Quality Checks (push) Skipped
CI / Secret scan (gitleaks) (push) Skipped
CI / Playwright smoke (e2e) (push) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 13s
CI / Build & Quality Checks (pull_request) Successful in 2m28s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Playwright smoke (e2e) (pull_request) Successful in 17m13s
2e30f9ec44
Keeps the thin space out of the source as a raw invisible character.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
jared scheduled this pull request to auto merge when all checks succeed 2026-11-16 23:54:18 -05:00
jared merged commit 4fe9b97eb2 into lotus 2026-11-16 23:55:10 -05:00
jared deleted branch feat/now-playing-491 2026-11-16 23:55:11 -05:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/cinny#492