Skip to content

fix(media-keys): withdraw paused session on blur, dedup SMTC pushes, sanitize titles, decode Xtream names - #1429

Open
Thunderhawkk wants to merge 1 commit into
harborstremio:beta-branchfrom
Thunderhawkk:media-keys
Open

Thunderhawkk wants to merge 1 commit into
harborstremio:beta-branchfrom
Thunderhawkk:media-keys

Conversation

@Thunderhawkk

Copy link
Copy Markdown
Collaborator

Summary

Fixes Harbor hijacking OS media keys (Windows SMTC / Linux MPRIS) from other apps. Five files, no refactors:

  • src-tauri/.../media_controls.rs (Windows): update() now skips identical pushes via a last-pushed cache, so background/paused Harbor stops bumping itself to most-recent; pushed titles are trimmed, control-char-filtered, and length-capped.
  • src/lib/media-session.ts: new isMediaSessionActive gate, force re-push option, and setMediaSessionWindowFocused — a paused session is withdrawn when the window loses focus and re-asserted on refocus; ended/unmount clears permanently.
  • src/views/player.tsx: media-controls effect clears on ended/idle/error (not just unmount), clock ticks re-check the gate, focus changes route to the policy function. Key handling (toggle/next/previous) untouched.
  • src/lib/iptv/xtream.ts, xtream-vod.ts: live/VOD/series names go through the existing defensive decodeBase64 (plain names pass through unchanged), so provider-encoded names no longer reach the flyout as eyJ... garbage.

Why

A paused/background Harbor kept an enabled OS session and re-announced it, so Windows routed Play/Pause to Harbor instead of the active app (Harbor resumed while Spotify paused — same failure class as known Spotify-vs-YouTube reports). Ended playback never cleared the session, leaving dead entries whose keys did nothing. The VLC-style approach (no enabled session while paused-and-unfocused, keep it while playing in background, reclaim on refocus) fits Harbor because playback, background listening, and hotkeys keep working exactly as before — only session advertisement changes.

Verification

  • Adjacent suites (interaction-lock, buffer-policy, mouse-hold, subtitle-fps, critical-path, focus-resume, lifecycle, unlisten): 62/62 pass.
  • pnpm run typecheck (tsc -b): clean. cargo check: clean

Platform Impact

  • Windows: SMTC push dedup + title sanitization + withdraw-on-blur-while-paused; the reported hijack and garbage-title cases.
  • Linux: same frontend withdraw/re-assert policy applies to the MPRIS session (clear → Stopped unchanged); MPRIS already diffs before signaling.

Checklist

  • This pull request is focused and contains no unrelated refactors.
  • I ran vp check for the changed files.
  • I ran vp run typecheck after TypeScript changes.
  • I ran the relevant Cargo checks after Rust changes.
  • I tested affected platforms when the change is platform-specific.
  • I preserved playback, navigation, and configured hotkey behavior where applicable.
  • I added or updated tests for behavior changes.
  • I removed secrets, tokens, private URLs, and personal data from logs and screenshots.

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