Skip to content

feat(lyrics): Test word-level lyrics connection IPC + Settings button + per-cookie-file 401 toast (PR-2 companion) #934

@Salem874

Description

@Salem874

Summary

User-visible diagnostic for the syllable-lyrics auth path. Replaces the current "silently skipped" failure mode with two surfaces: a Settings > Lyrics "Test word-level lyrics connection" button, and a per-cookie-file 401 toast that re-fires when the underlying cookies file changes.

Background

The user's concern was "do they really work?" — verifying that the existing word-level path actually delivers TTML in practice. The audit confirmed multiple silent-failure modes (HTTP defects in PR-2, expired Music-User-Token, missing MusicKit credentials). A diagnostic is the right primary signal.

New IPC

#[tauri::command]
pub async fn test_syllable_lyrics_connection(app: AppHandle) -> TestConnectionResult {
    TestConnectionResult {
        auth_present: bool,        // credentials + cookies available
        http_status: u16,           // last HTTP status from probe
        granularity_detected: String, // Syllable / Word / Line / Unknown
        error_hint: Option<String>, // "Music-User-Token expired — re-import cookies"
        source_header: String,      // "Music-User-Token" or "Media-User-Token" (which we sent)
    }
}

Probes against a known-stable song ID (e.g. Closer 1175630113 — gh search code shows no recent takedowns). One-shot, ~5s typical.

UI

  • Settings > Lyrics: add "Test word-level lyrics connection" button under the "Enhanced LRC" toggle. Calls the IPC, surfaces the result inline (status pill: green=Syllable/Word, yellow=Line, red=auth missing).
  • Activity log: continue emitting per-track outcomes.

401 toast keyed by cookies file mtime

The current activity-log INFO on "auth missing at startup" doesn't re-fire when the user's Music-User-Token expires mid-session. Fix:

  • Replace once-per-session keyed toast with mtime-keyed ({cookies_path}@{mtime_secs}).
  • A re-import of cookies updates the mtime → toast re-fires if the new file is also expired.

New setting

lyrics_locale: Option<String> (default None = follow ui_language). When Some, appended as &l={locale} to the syllable-lyrics URL. Dropdown under the Enhanced LRC toggle.

Files to modify

Depends on

PR-2 HTTP-layer fixes (above). Implementation order: PR-2 → this issue.

Out of scope

Telemetry-driven Music-User-TokenMedia-User-Token rename — that's a follow-up once we have a few weeks of source_header data from the IPC.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions