Skip to content

fix(lyrics): show LRC lines with several timestamps at each one - #834

Merged
LargeModGames merged 2 commits into
LargeModGames:mainfrom
jadhavgaurav:fix/lrc-multiple-timestamps-826
Oct 14, 2026
Merged

LargeModGames merged 2 commits into
LargeModGames:mainfrom
jadhavgaurav:fix/lrc-multiple-timestamps-826

Conversation

@jadhavgaurav

@jadhavgaurav jadhavgaurav commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #826

What changed

parse_synced_lyrics in src/infra/network/utils.rs read only the first [mm:ss.xx] tag on a line and kept the rest as text. A line like [00:12.00][00:45.30]Chorus showed once at 0:12 with [00:45.30] printed in it, and never at 0:45.

  • The timestamp math moved unchanged into a private parse_lrc_timestamp(tag) helper, so the fraction rules and the rejection of [offset:+500] and [ar:...] are the same as before.
  • The parser now peels leading [...] groups in a loop, stops at the first group that is not a timestamp, and emits one (ms, text) per timestamp. A line with no leading timestamp still produces nothing.
  • The result goes through a stable sort_by_key, so active_lyric_index gets ascending times and equal timestamps keep file order.
  • CHANGELOG.md has a Fixed entry. Nothing else is touched; active_lyric_index is unchanged.

Tests

New tests in the utils.rs test module: two timestamps on one line (the exact case from the issue), three out-of-order timestamps, unsorted input, same-timestamp stability, empty text with several timestamps, a non-timestamp group staying in the text, malformed tags dropped, and a single-timestamp line unchanged. I ran the new tests against the old parser first and four of them failed (two timestamps, three timestamps, empty text, sorting), then passed after the change.

Testing

Run locally on this branch:

  • cargo fmt --all -- --check: clean
  • cargo clippy --no-default-features --features telemetry,tui -- -D warnings: clean
  • cargo test --no-default-features --features telemetry,tui: 1567 passed, 0 failed
  • cargo test --no-default-features --features telemetry,tui lrc: 14 passed (all 7 existing LRC tests plus the new ones, 1553 filtered out)
  • cargo test --no-default-features --features telemetry,tui parses_timestamped_lyric_lines_and_drops_untimed_ones: 1 passed

I did not run the optional manual check in the lyrics view, and did not run the wider CI feature matrix.

AI note: this change was drafted with an AI assistant (Claude Code). I read the full diff and ran the commands above myself.

Summary by CodeRabbit

  • Bug Fixes
    • Lyrics with multiple timestamps now appear at each specified time, and synced lyrics are sorted chronologically. Lyrics with matching timestamps retain their original order.

parse_synced_lyrics read only the first [mm:ss.xx] tag, so a line like
[00:12.00][00:45.30]Chorus showed once and kept the second tag in its text.
Peel every leading timestamp, emit the line once per timestamp, and sort the
result so active_lyric_index still sees ascending times. The timestamp math
moves into parse_lrc_timestamp unchanged.

Fixes LargeModGames#826
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T11:13:03.462497Z 0a479c4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: LargeModGames/spotatui/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 667141c9-ea3a-42cc-bee6-45e6da060451
📥 Commits

Reviewing files that changed from the base of the PR and between 0a479c4 and f398254.

📒 Files selected for processing: 1
  • src/infra/network/utils.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

📝 Walkthrough

The synced lyrics parser now emits lyric text for each consecutive valid leading timestamp. It sorts parsed entries by time and preserves file order for equal timestamps.

Changes: Synced lyrics parsing

Layer / File(s) Summary
Timestamp parsing and sorted lyric entries
src/infra/network/utils.rs, CHANGELOG.md
The parser emits an entry for each valid leading timestamp and sorts entries by time. Equal timestamps retain file order. Tests cover multiple timestamps, sorting, empty text, malformed tags, and single-timestamp behavior. The changelog records the update.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to f3982

Stacked LRC timestamps are emitted in chronological order with their lyric text preserved. No concrete current-head issue prevents merging, subject to normal checks.

Pre-merge checks: Passed 4
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title uses the allowed conventional-commit prefix fix(lyrics):, clearly describes the multi-timestamp lyric fix, and uses an imperative subject.
Linked Issues check Passed Issue #826 requires one entry per leading timestamp, timestamp tags removed from lyric text, ascending ordering, stable equal-time ordering, unchanged timestamp rules, and parser tests. `src/infra/net…
Out of Scope Changes check Passed The production change and tests are limited to src/infra/network/utils.rs. The CHANGELOG.md entry documents the fix for issue #826. These changes directly support the linked issue. No unrelated pr…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
✨ Simplify code
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.25926% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/infra/network/utils.rs 99.2% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Oud-Idk Oud-Idk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice PR you got there! Looks clean and no out-of-scope changes. I Really like the direction here.

One minor real-world edge case is a space between the timestamps. Sometimes, hand-crafted or loosely formatted LRC files might have spaces and tabs between tags: [00:12.00] [00:45.30] [01:10.00] Chorus line

With the current parser, rest.strip_prefix('[') breaks on that space, so [00:45.30] leaks into the chorus text.

Adding a .trim_start() directly on the while check would catch those cleanly without complicating the parser logic. As a bonus, it handles leading indentation on the line as well.

@jadhavgaurav

Copy link
Copy Markdown
Contributor Author

Thanks for the review, and good catch. Pushed f398254.

parse_synced_lyrics now calls trim_start() in the while check, as you suggested, so spaces and tabs between tags (and before the first tag) are skipped. The text after the last tag is still trimmed, so [00:12.00] [00:45.30] Chorus gives "Chorus" at both stamps, same as a single-timestamp line.

One test changed: malformed_lrc_tags_are_dropped had an indented " [00:03.00]indented" line expected to be dropped. Leading indentation is now accepted, so I removed that case and covered it positively.

New tests:

  • spaces_between_lrc_timestamps_are_ignored
  • tabs_between_lrc_timestamps_are_ignored
  • mixed_whitespace_between_and_before_lrc_timestamps_is_ignored
  • an_indented_single_timestamp_lrc_line_is_parsed
  • a_spaced_non_timestamp_tag_stays_in_the_text

fmt, clippy -D warnings and the full test suite pass with --no-default-features --features telemetry,tui.

@Oud-Idk Oud-Idk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! That's fixed and appreciate the new test coverage.

(Shower thought nit, non-blocking: since the original timestamp parser collects into Vecs twice, we could swap tag.split(':').collect() for split_once to save a couple of allocations. This is possible since we only expect mm:ss or mm:ss.xx)

@LargeModGames
LargeModGames merged commit 4c3c345 into LargeModGames:main Oct 14, 2026
32 checks passed
@LargeModGames

Copy link
Copy Markdown
Owner

@all-contributors please add @jadhavgaurav for code

@allcontributors

Copy link
Copy Markdown
Contributor

@LargeModGames

I've put up a pull request to add @jadhavgaurav! 🎉

LargeModGames pushed a commit that referenced this pull request Oct 14, 2026
Adds @jadhavgaurav as a contributor for code.

This was requested by LargeModGames [in this
comment](#834 (comment))

[skip ci]

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
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.

Lyrics: LRC lines with several timestamps only show at the first one

3 participants