Add Listening Stats plugin, fade in covers, fix low_delay test #119

Merged
SBDeveloper merged 9 commits from fix/fix-rust-build into main 2026-11-12 21:06:02 +01:00
Owner

Summary

 plugins/optional/
 ├── listenbrainz/
+├── stats/                # optional extension: Stats sidebar page
+│   ├── plugin.toml       # ui, playback_events, storage; no network
+│   └── src/
+│       ├── lib.rs        # on_event -> history.jsonl; ui_view / ui_event
+│       └── summary.rs    # pure sums: spans, top artists/Tracks, streak
 └── visualizer/
on_event(TrackChanged)  -> finish previous Track, start new
on_event(Playing)       -> add forward steps <= 2s to listened_ms
on_event(Paused)        -> break the run
finish                  -> append if listened >= min(30s, half duration)

Test fix: low_delay.rs now expects the "not ready" error text instead of "Add a VBAN Receiver" (not re-run here).

Unrelated UI polish: covers loaded from a URL (Cover.svelte) fade in on load, like the small Artwork covers.

 <Cover url=...>
-  <img>                       # pops in as it loads
+  <img class:loaded>          # opacity 0 -> 1 on load (cached images handled)

Evidence

  • Before: no Stats page; Browse covers appear piecemeal.
    After: cargo test --target x86_64-unknown-linux-gnu in plugins/optional/stats: 6 passed (spans split by day, tops ranked and cut, streak from today / survives a day, empty history, durations). Wasm build succeeds. npm run check: 0 errors; npm run e2e: 3 passed. Not run in the real app.

Merge Danger

Door: two-way

The plugin is optional and not bundled; the cover change is CSS and a load handler.

Blast Radius: small

Only Cover.svelte touches existing UI (Browse album/artist/Track cards). A cover whose load never fires stays invisible.

## Summary ```diff plugins/optional/ ├── listenbrainz/ +├── stats/ # optional extension: Stats sidebar page +│ ├── plugin.toml # ui, playback_events, storage; no network +│ └── src/ +│ ├── lib.rs # on_event -> history.jsonl; ui_view / ui_event +│ └── summary.rs # pure sums: spans, top artists/Tracks, streak └── visualizer/ ``` ```text on_event(TrackChanged) -> finish previous Track, start new on_event(Playing) -> add forward steps <= 2s to listened_ms on_event(Paused) -> break the run finish -> append if listened >= min(30s, half duration) ``` Test fix: `low_delay.rs` now expects the "not ready" error text instead of "Add a VBAN Receiver" (not re-run here). Unrelated UI polish: covers loaded from a URL (`Cover.svelte`) fade in on load, like the small `Artwork` covers. ```diff <Cover url=...> - <img> # pops in as it loads + <img class:loaded> # opacity 0 -> 1 on load (cached images handled) ``` ## Evidence - **Before:** no Stats page; Browse covers appear piecemeal. **After:** `cargo test --target x86_64-unknown-linux-gnu` in `plugins/optional/stats`: 6 passed (spans split by day, tops ranked and cut, streak from today / survives a day, empty history, durations). Wasm build succeeds. `npm run check`: 0 errors; `npm run e2e`: 3 passed. Not run in the real app. ## Merge Danger **Door:** two-way The plugin is optional and not bundled; the cover change is CSS and a load handler. **Blast Radius:** small Only `Cover.svelte` touches existing UI (Browse album/artist/Track cards). A cover whose `load` never fires stays invisible.
Sidebar page with listening time (today, 7 days, all time), top artists,
most played Tracks and a daily streak. History stays in plugin storage;
no network.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Fix low_delay test assertion for the not-ready error
Some checks failed
Check / android (pull_request) Has been skipped
AI review / review (pull_request) Failing after 9s
Check / fmt (pull_request) Successful in 44s
AI review / tour (pull_request) Successful in 1m10s
Check / ui (pull_request) Successful in 18s
Check / e2e (pull_request) Has been cancelled
Check / rust (pull_request) Has been cancelled
1d4baad563
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
AI review: find the local Claude Code install in the script
Some checks failed
Check / android (pull_request) Has been skipped
Check / fmt (pull_request) Successful in 38s
Check / ui (pull_request) Successful in 13s
AI review / review (pull_request) Successful in 1m19s
Check / e2e (pull_request) Successful in 42s
AI review / tour (pull_request) Successful in 4m1s
Check / rust (pull_request) Failing after 6m33s
6c4075862e
Forgejo leaves `${{ github.workspace }}` empty in workflow-level env, so
CLAUDE_BIN pointed at /.ai-work/... and the review failed with ENOENT.
lib.mjs now uses .ai-work/claude when it exists, else `claude` on PATH.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
forgejo-actions left a comment

🤖 AI review: ⚠️ Has issues worth fixing

This PR adds an optional stats extension plugin. It records a Track once it has been heard for 30 s (or half its length if shorter), using the same forward-step counting as ListenBrainz, and appends it to /data/history.jsonl. A sidebar page then shows totals, top artists and Tracks, and a UTC daily streak. The pure summary logic is well tested. The event state machine in lib.rs has no tests, and that is where the real risk is: the host only emits TrackChanged when the Track reference changes (player.rs:554), so playing the same Track again (repeat-one, play after Ended) is either merged into one entry or not recorded at all. The Cover.svelte fade, the low_delay assertion fix (matches lib.rs:1543) and the AI-script binary lookup all look correct.

3 findings: 1 major, 2 minor; 3 as comments on the diff.

Reviewed 6c4075862e with Claude Code. An AI review can be wrong: weigh it, don't obey it.

<!-- medley-ai-review --> ### 🤖 AI review: ⚠️ Has issues worth fixing This PR adds an optional `stats` extension plugin. It records a Track once it has been heard for 30 s (or half its length if shorter), using the same forward-step counting as ListenBrainz, and appends it to `/data/history.jsonl`. A sidebar page then shows totals, top artists and Tracks, and a UTC daily streak. The pure summary logic is well tested. The event state machine in `lib.rs` has no tests, and that is where the real risk is: the host only emits `TrackChanged` when the Track reference changes (`player.rs:554`), so playing the same Track again (repeat-one, play after `Ended`) is either merged into one entry or not recorded at all. The `Cover.svelte` fade, the `low_delay` assertion fix (matches `lib.rs:1543`) and the AI-script binary lookup all look correct. **3 findings**: 1 major, 2 minor; 3 as comments on the diff. <sub>Reviewed 6c4075862e with Claude Code. An AI review can be wrong: weigh it, don't obey it.</sub>
@ -0,0 +110,4 @@
play.last_position = None;
}
}),
PlaybackEvent::Playback { .. } => finish(),

🟠 Playing the same Track again is merged into one entry or not recorded (major)

The player emits TrackChanged only when the Track reference differs from the last announced one (crates/core/src/player.rs:554). This plugin starts a new Play only on TrackChanged, which causes two failures:

  1. After Ended: the Playback { .. } => finish() arm takes play and leaves None. If the user presses play again, Player::play on Ended repositions to 0 with Playing (player.rs:1246), and picking the same Track again from the library doesn't change the reference either. No TrackChanged arrives, so every Playing event hits play == None and the whole listen is never recorded.
  2. Repeat-one / jump back to the start: the position drops to ~0 while still Playing. The backward step is ignored but listened_ms keeps growing in the same Play. Five loops are written as one entry with 5× the time, and the "Most played Tracks" count is 1 instead of 5.

The ListenBrainz plugin handles this case (REPLAY_WITHIN_MS, and it keeps play on non-Playing statuses). Suggested fix: on Ended, write the entry but keep the Track's metadata. Then treat a Playing event at a position near 0, arriving after Ended or as a backward jump from near the end, as a new play (finish the old one, reset listened_ms/started_at). Moving the counting into a pure function in summary.rs (or a sibling module) would also let it be tested natively alongside the existing tests. None of the current 6 tests touches on_event.

🟠 **Playing the same Track again is merged into one entry or not recorded** (major) The player emits `TrackChanged` only when the Track reference differs from the last announced one (`crates/core/src/player.rs:554`). This plugin starts a new `Play` only on `TrackChanged`, which causes two failures: 1. **After `Ended`:** the `Playback { .. } => finish()` arm takes `play` and leaves `None`. If the user presses play again, `Player::play` on `Ended` repositions to 0 with `Playing` (`player.rs:1246`), and picking the same Track again from the library doesn't change the reference either. No `TrackChanged` arrives, so every `Playing` event hits `play == None` and the whole listen is never recorded. 2. **Repeat-one / jump back to the start:** the position drops to ~0 while still `Playing`. The backward step is ignored but `listened_ms` keeps growing in the same `Play`. Five loops are written as one entry with 5× the time, and the "Most played Tracks" count is 1 instead of 5. The ListenBrainz plugin handles this case (`REPLAY_WITHIN_MS`, and it keeps `play` on non-Playing statuses). Suggested fix: on `Ended`, write the entry but keep the Track's metadata. Then treat a `Playing` event at a position near 0, arriving after `Ended` or as a backward jump from near the end, as a new play (finish the old one, reset `listened_ms`/`started_at`). Moving the counting into a pure function in `summary.rs` (or a sibling module) would also let it be tested natively alongside the existing tests. None of the current 6 tests touches `on_event`.
SBDeveloper marked this conversation as resolved
@ -0,0 +117,4 @@
}
/// Ends the current Track, writing it to the history if it was listened to.
fn finish() {

🟡 The Track playing when the app quits is lost (minor)

A listen is written only in finish(), i.e. on the next TrackChanged or a Stopped/Ended status. If the user closes Medley partway through a Track (or the process crashes), the in-memory Play is dropped, even after minutes of listening. The last Track of every session is a common case. Suggested fix: write the entry as soon as listened_ms crosses needed and update it in place afterwards, or keep a small /data/current.json checkpoint that is turned into an entry on the next start.

🟡 **The Track playing when the app quits is lost** (minor) A listen is written only in `finish()`, i.e. on the next `TrackChanged` or a `Stopped`/`Ended` status. If the user closes Medley partway through a Track (or the process crashes), the in-memory `Play` is dropped, even after minutes of listening. The last Track of every session is a common case. Suggested fix: write the entry as soon as `listened_ms` crosses `needed` and update it in place afterwards, or keep a small `/data/current.json` checkpoint that is turned into an entry on the next start.
SBDeveloper marked this conversation as resolved
@ -0,0 +158,4 @@
})
})
.collect();
if entries.len() > HISTORY_CAP {

🟡 History file is never trimmed; "All time" silently stops being all time (minor)

HISTORY_CAP is applied only to the parsed Vec. history.jsonl grows without limit, and every ui_view reads and parses all of it with read_to_string before dropping the oldest entries. The doc comment says older entries "are dropped when the file is read", but they are only skipped. Once the file passes 50,000 entries, the "All time" totals, top artists and top Tracks quietly cover only the newest 50,000, while the page still says "All time". Suggested fix: rewrite the file with the newest HISTORY_CAP lines when it exceeds the cap (e.g. in finish() every N appends), and either label the span honestly or keep running all-time totals in a separate small file.

🟡 **History file is never trimmed; "All time" silently stops being all time** (minor) `HISTORY_CAP` is applied only to the parsed `Vec`. `history.jsonl` grows without limit, and every `ui_view` reads and parses all of it with `read_to_string` before dropping the oldest entries. The doc comment says older entries "are dropped when the file is read", but they are only skipped. Once the file passes 50,000 entries, the "All time" totals, top artists and top Tracks quietly cover only the newest 50,000, while the page still says "All time". Suggested fix: rewrite the file with the newest `HISTORY_CAP` lines when it exceeds the cap (e.g. in `finish()` every N appends), and either label the span honestly or keep running all-time totals in a separate small file.
SBDeveloper marked this conversation as resolved

🎬 Change tour: Listening Stats page and fading covers

The tour opens the new Stats sidebar page with a realistic history: the streak badge, the listening time today, over the last 7 days and overall, the top-artist meters and the most played Tracks. It then clears the history, going through the confirmation to the empty state. Last, it searches and shows album covers loaded from a URL fading in on Browse. The plugin's drawn views are faked with the same shapes its view code returns.

▶ Watch the tour (MP4)

Slideshow: unzip and open index.html, for step-by-step slides with the voice.

Transcript

the Stats page

  • 0:01 This pull request adds Listening Stats, an optional plugin that sums up what you have been listening to. It keeps its history on this device and asks for no network.
  • 0:11 Once installed, it adds a Stats page to the sidebar.
  • 0:16 At the top is a daily streak: days in a row with at least one Track listened to.
  • 0:21 Then the listening time for today, the last seven days, and overall.
  • 0:27 A Track only counts once it has been heard for thirty seconds, or half its length if it is shorter. Seeks and pauses add nothing.
  • 0:35 Top artists are shown as meters, scaled against the artist you listened to most.
  • 0:40 And below them, the Tracks played most often, with a play count.

clearing the history

  • 0:47 At the bottom, the history can be cleared. It asks first.
  • 0:54 Here is the confirmation, with a way to keep it.
  • 0:58 Confirm, and the page goes back to its empty state, which explains what will show up.

covers fade in on Browse

  • 1:04 One smaller change rides along: covers loaded from a link now fade in once they have loaded, instead of popping in one by one.
  • 1:14 Here are search results with album covers. Each one faded in as it finished loading, so the grid settles calmly.
  • 1:21 That wraps it up: an optional Stats page that stays on your device, and smoother covers when browsing.

Written and narrated by Claude Code · run. The tour runs against a fake backend, not the Rust core.

<!-- medley-ai-tour --> ### 🎬 Change tour: Listening Stats page and fading covers The tour opens the new Stats sidebar page with a realistic history: the streak badge, the listening time today, over the last 7 days and overall, the top-artist meters and the most played Tracks. It then clears the history, going through the confirmation to the empty state. Last, it searches and shows album covers loaded from a URL fading in on Browse. The plugin's drawn views are faked with the same shapes its view code returns. <video src="https://git.sbdevelopment.tech/attachments/8829e226-2308-4a54-83c3-7e128057f4a6" controls width="100%"></video> [▶ Watch the tour (MP4)](https://git.sbdevelopment.tech/attachments/8829e226-2308-4a54-83c3-7e128057f4a6) [Slideshow](https://git.sbdevelopment.tech/attachments/45d67f73-1bb1-44d8-bcc6-f13c040395c4): unzip and open `index.html`, for step-by-step slides with the voice. <details><summary>Transcript</summary> **the Stats page** - `0:01` This pull request adds Listening Stats, an optional plugin that sums up what you have been listening to. It keeps its history on this device and asks for no network. - `0:11` Once installed, it adds a Stats page to the sidebar. - `0:16` At the top is a daily streak: days in a row with at least one Track listened to. - `0:21` Then the listening time for today, the last seven days, and overall. - `0:27` A Track only counts once it has been heard for thirty seconds, or half its length if it is shorter. Seeks and pauses add nothing. - `0:35` Top artists are shown as meters, scaled against the artist you listened to most. - `0:40` And below them, the Tracks played most often, with a play count. **clearing the history** - `0:47` At the bottom, the history can be cleared. It asks first. - `0:54` Here is the confirmation, with a way to keep it. - `0:58` Confirm, and the page goes back to its empty state, which explains what will show up. **covers fade in on Browse** - `1:04` One smaller change rides along: covers loaded from a link now fade in once they have loaded, instead of popping in one by one. - `1:14` Here are search results with album covers. Each one faded in as it finished loading, so the grid settles calmly. - `1:21` That wraps it up: an optional Stats page that stays on your device, and smoother covers when browsing. </details> <sub>Written and narrated by Claude Code · [run](https://git.sbdevelopment.tech/SBDeveloper/medley/actions/runs/150). The tour runs against a fake backend, not the Rust core.</sub>
Author
Owner

Thanks, all three held up; I checked the player claims (player.rs:554, :1246) before changing anything. Fixed in 834b16e (committed, being pushed now).

  • 🟠 Same Track played again: confirmed. The counting moved into a pure Listener (listen.rs). Ended/Stopped now writes the entry but keeps the Track, and the next Playing starts a new pass. A jump back to within 5 s of the start (from a position more than one step ahead) ends the current pass and starts another, the same idea as ListenBrainz's REPLAY_WITHIN_MS. A seek back into the middle is not a replay. Tests added: loop gives one entry per pass, replay after Ended, seek-back is not a replay.
  • 🟡 Quit mid-Track loses the listen: confirmed. Once a listen counts, it is checkpointed to /data/current.json every 30 s. The next start turns the checkpoint into an entry, so at most about 30 s is lost. Went with the checkpoint file and not in-place rewrite, because the history stays append-only.
  • 🟡 History never trimmed / "All time" lies: confirmed, and the doc comment was wrong. When the file passes 8 MiB it is rewritten with the newest 50,000 entries and a /data/trimmed marker is set; the page then says "Recent" instead of "All time". Clear history removes the marker too. I did not add running all-time totals: for a stats page of this size, honest labelling seemed enough.

Not covered: the recover/checkpoint/trim file handling in lib.rs has no native test (it needs /data); the decision logic they rely on is tested (15 tests pass, wasm build clean).

Thanks, all three held up; I checked the player claims (`player.rs:554`, `:1246`) before changing anything. Fixed in 834b16e (committed, being pushed now). - 🟠 **Same Track played again:** confirmed. The counting moved into a pure `Listener` (`listen.rs`). `Ended`/`Stopped` now writes the entry but keeps the Track, and the next `Playing` starts a new pass. A jump back to within 5 s of the start (from a position more than one step ahead) ends the current pass and starts another, the same idea as ListenBrainz's `REPLAY_WITHIN_MS`. A seek back into the middle is not a replay. Tests added: loop gives one entry per pass, replay after `Ended`, seek-back is not a replay. - 🟡 **Quit mid-Track loses the listen:** confirmed. Once a listen counts, it is checkpointed to `/data/current.json` every 30 s. The next start turns the checkpoint into an entry, so at most about 30 s is lost. Went with the checkpoint file and not in-place rewrite, because the history stays append-only. - 🟡 **History never trimmed / "All time" lies:** confirmed, and the doc comment was wrong. When the file passes 8 MiB it is rewritten with the newest 50,000 entries and a `/data/trimmed` marker is set; the page then says "Recent" instead of "All time". Clear history removes the marker too. I did not add running all-time totals: for a stats page of this size, honest labelling seemed enough. Not covered: the recover/checkpoint/trim file handling in `lib.rs` has no native test (it needs `/data`); the decision logic they rely on is tested (15 tests pass, wasm build clean).
Stats: count replays, checkpoint live listens, trim history
Some checks failed
Check / android (pull_request) Has been skipped
Check / fmt (pull_request) Successful in 37s
Check / ui (pull_request) Successful in 12s
Check / e2e (pull_request) Successful in 29s
AI review / review (pull_request) Successful in 1m27s
AI review / tour (pull_request) Successful in 4m41s
Check / rust (pull_request) Has been cancelled
834b16e3e6
Move listening rules into a tested Listener: playing a Track again after it
ended or by a jump to its start is a new entry; a counting listen is
checkpointed every 30s and recovered on next start; the history file is
trimmed past 8 MiB and the page then says Recent instead of All time.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
forgejo-actions left a comment

🤖 AI review: ⚠️ Has issues worth fixing

This PR adds an optional stats extension plugin. It logs each Track heard for at least 30 s (or half its length, if shorter) from playback events into a JSON-lines history in the plugin's private storage. A Track still playing is saved every 30 s so a quit doesn't lose it, and a sidebar page shows listening time, top artists and Tracks, and a daily streak. Separately, URL covers in Cover.svelte now fade in, the low_delay test now expects the "not ready" message that Core really returns, and the AI-review script finds the local Claude install by itself. The cover, test and script changes look correct. The risk is in how the plugin counts listens. Some Tracks are recorded twice: the host sends the end of a Track and the start of the next as separate events. And the Stats page runs in a separate WASM instance from the event handler, so the two instances don't share in-memory state.

2 findings: 2 major; 2 as comments on the diff.

Reviewed 834b16e3e6 with Claude Code. An AI review can be wrong: weigh it, don't obey it.

<!-- medley-ai-review --> ### 🤖 AI review: ⚠️ Has issues worth fixing This PR adds an optional `stats` extension plugin. It logs each Track heard for at least 30 s (or half its length, if shorter) from playback events into a JSON-lines history in the plugin's private storage. A Track still playing is saved every 30 s so a quit doesn't lose it, and a sidebar page shows listening time, top artists and Tracks, and a daily streak. Separately, URL covers in `Cover.svelte` now fade in, the low_delay test now expects the "not ready" message that `Core` really returns, and the AI-review script finds the local Claude install by itself. The cover, test and script changes look correct. The risk is in how the plugin counts listens. Some Tracks are recorded twice: the host sends the end of a Track and the start of the next as separate events. And the Stats page runs in a separate WASM instance from the event handler, so the two instances don't share in-memory state. **2 findings**: 2 major; 2 as comments on the diff. <sub>Reviewed 834b16e3e6 with Claude Code. An AI review can be wrong: weigh it, don't obey it.</sub>
@ -0,0 +171,4 @@
if req.view_id != "page" {
return Err(Error::msg(format!("no view {}", req.view_id)).into());
}
recover();

🟠 Opening the page turns the live Track's checkpoint into a history entry, then the Track is counted again (major)

The host runs each lane in its own WASM instance (plugin_host::Lane). on_event is called on Lane::Events (extensions.rs:246), while ui_view runs on the main lane. So STATE.recovered is set separately in each instance.

Scenario: the app starts and the events instance runs recover() on its first event. A Track plays past 30 s, so the events instance writes /data/current.json. The user then opens the Stats page for the first time. The main instance's recovered is still false, so its recover() reads the live checkpoint, appends it to the history and deletes the file. When the Track finishes, the events instance's Listener appends its full entry as well. That Track now has two entries: one partial, one complete.

The same split affects "Clear history" (it also runs on the main lane): it deletes the checkpoint while the events instance still holds the current play, so that Track comes back afterwards. That part is less serious.

Fix: only the events instance should recover, i.e. don't call recover() from ui_view. If the page must show a checkpoint left by an earlier run before any event arrives, read it there without appending or deleting it. A checkpoint that carries a per-run id would also let a stale one be told apart from a live one.

🟠 **Opening the page turns the live Track's checkpoint into a history entry, then the Track is counted again** (major) The host runs each lane in its own WASM instance (`plugin_host::Lane`). `on_event` is called on `Lane::Events` (extensions.rs:246), while `ui_view` runs on the main lane. So `STATE.recovered` is set separately in each instance. Scenario: the app starts and the events instance runs `recover()` on its first event. A Track plays past 30 s, so the events instance writes `/data/current.json`. The user then opens the Stats page for the first time. The main instance's `recovered` is still `false`, so its `recover()` reads the live checkpoint, appends it to the history and deletes the file. When the Track finishes, the events instance's `Listener` appends its full entry as well. That Track now has two entries: one partial, one complete. The same split affects "Clear history" (it also runs on the main lane): it deletes the checkpoint while the events instance still holds the current play, so that Track comes back afterwards. That part is less serious. Fix: only the events instance should recover, i.e. don't call `recover()` from `ui_view`. If the page must show a checkpoint left by an earlier run before any event arrives, read it there without appending or deleting it. A checkpoint that carries a per-run id would also let a stale one be told apart from a live one.
SBDeveloper marked this conversation as resolved
@ -0,0 +113,4 @@
/// The Track ended or playback stopped. Keeps the Track, so playing it
/// again starts a new pass.
pub fn ended(&mut self) -> Option<Entry> {

🟠 A Track that ended or was stopped is counted again on the next TrackChanged (major)

ended() returns the entry and sets over = true, but it leaves listened_ms as it was. The next track_changed() then runs self.play.take().and_then(|p| p.entry()) on that same Play, which still meets the threshold, so the listen is returned and appended a second time.

The host takes this path in normal use. When the Queue runs out, the player publishes Ended (player.rs:1372). Stopping playback publishes Stopped (Player::stop, clear()). Both reach l.ended() through the catch-all PlaybackEvent::Playback { .. } arm. When the user then picks another Track, TrackChanged arrives and the previous Track is written again. Every stop followed by playing something else double-counts the last Track in plays, time, top Tracks and top artists.

Fix: in track_changed, skip the entry when p.over is set (.filter(|p| !p.over).and_then(|p| p.entry())), or zero listened_ms in ended() once the entry has been handed out. Add a unit test that plays 40 s, calls ended(), then track_changed(..), and expects None.

🟠 **A Track that ended or was stopped is counted again on the next TrackChanged** (major) `ended()` returns the entry and sets `over = true`, but it leaves `listened_ms` as it was. The next `track_changed()` then runs `self.play.take().and_then(|p| p.entry())` on that same `Play`, which still meets the threshold, so the listen is returned and appended a second time. The host takes this path in normal use. When the Queue runs out, the player publishes `Ended` (player.rs:1372). Stopping playback publishes `Stopped` (`Player::stop`, `clear()`). Both reach `l.ended()` through the catch-all `PlaybackEvent::Playback { .. }` arm. When the user then picks another Track, `TrackChanged` arrives and the previous Track is written again. Every stop followed by playing something else double-counts the last Track in plays, time, top Tracks and top artists. Fix: in `track_changed`, skip the entry when `p.over` is set (`.filter(|p| !p.over).and_then(|p| p.entry())`), or zero `listened_ms` in `ended()` once the entry has been handed out. Add a unit test that plays 40 s, calls `ended()`, then `track_changed(..)`, and expects `None`.
SBDeveloper marked this conversation as resolved
AI review: run once per PR, follow-up rounds on request
Some checks failed
Check / android (pull_request) Has been skipped
Check / ui (pull_request) Successful in 17s
Check / e2e (pull_request) Successful in 35s
Check / fmt (pull_request) Successful in 47s
Check / rust (pull_request) Has been cancelled
a5ab3cee01
Pushes no longer re-run the review and the tour, which bill the Claude
subscription. Both run when a pull request opens or reopens; the
`ai-review` and `ai-tour` labels ask for another run on the latest
commit, and the job takes the label off again (scripts/ai/trigger.mjs,
which reads the event payload since Forgejo's label events differ from
GitHub's).

A second review is a follow-up: each review stores its findings in a
hidden state block, and the next round gets them with the replies and
reactions on each, plus the diff since the reviewed commit. It settles
each earlier finding (fixed, open, withdrawn, kept) and raises new ones
only for changed code, so rounds converge instead of finding new things
or contradicting the last round.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

Both confirmed (I checked extensions.rs:246: on_event runs on Lane::Events, views on the main lane). Fixed in the next commit on this branch.

  • 🟠 Ended Track counted again on TrackChanged: my bug. track_changed now ignores a Play that is already over, since its entry was handed out at ended(). Test added: 40 s, ended(), then track_changed gives None.
  • 🟠 Page recovers the live checkpoint: ui_view no longer calls recover(); only on_event does, in the instance that owns the checkpoint. A checkpoint left by an earlier run therefore appears once the first playback event arrives, not on opening the page.

Known and left: "Clear history" runs on the main lane and deletes the checkpoint, so a Track playing at that moment can come back with its listen at the next 30 s checkpoint. I judged that acceptable (it reflects what was listened to after the clear); say if you want a cleared-at marker instead.

Both confirmed (I checked `extensions.rs:246`: `on_event` runs on `Lane::Events`, views on the main lane). Fixed in the next commit on this branch. - 🟠 **Ended Track counted again on `TrackChanged`:** my bug. `track_changed` now ignores a `Play` that is already `over`, since its entry was handed out at `ended()`. Test added: 40 s, `ended()`, then `track_changed` gives `None`. - 🟠 **Page recovers the live checkpoint:** `ui_view` no longer calls `recover()`; only `on_event` does, in the instance that owns the checkpoint. A checkpoint left by an earlier run therefore appears once the first playback event arrives, not on opening the page. Known and left: "Clear history" runs on the main lane and deletes the checkpoint, so a Track playing at that moment can come back with its listen at the next 30 s checkpoint. I judged that acceptable (it reflects what was listened to after the clear); say if you want a cleared-at marker instead.
Stats: don't count an ended Track twice, recover only in events instance
Some checks failed
Check / android (pull_request) Has been skipped
Check / ui (pull_request) Successful in 16s
Check / e2e (pull_request) Successful in 37s
Check / fmt (pull_request) Successful in 45s
AI review / tour (pull_request) Has been skipped
AI review / review (pull_request) Successful in 2m36s
Check / rust (pull_request) Has been cancelled
b38d3d6135
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
forgejo-actions left a comment

🤖 AI review: ⚠️ Has issues worth fixing

This PR does four things. It adds an optional stats extension plugin. It makes Cover.svelte images fade in once loaded. It updates the low_delay.rs assertion to the current "not ready" message, which does match crates/core/src/lib.rs:1543. It reworks the AI review/tour workflow so each runs once per PR, again on request via a label, with follow-up rounds that carry state.

The plugin's counting logic (listen.rs) holds up against how the host actually emits events. Position updates come every 250 ms, and the 2 s step and replay rules fit that. Repeat-one gets no TrackChanged, so the replay check covers it. Ended and Stopped are guarded so they count once.

The risks are in the file side of the plugin, which only has native unit tests for its pure logic. First, the history is re-read and re-parsed on every redraw, and the open page redraws every second. Second, the trim can rewrite the whole file on every listen. Third, the new follow-up review trusts a state block from any PR comment.

3 new findings: 3 minor; 3 as comments on the diff.

Reviewed b38d3d6135 with Claude Code. An AI review can be wrong: weigh it, don't obey it. Reply to a finding or react 👎 to dispute it; add the ai-review label for a follow-up on the latest commit.

<!-- medley-ai-review --> ### 🤖 AI review: ⚠️ Has issues worth fixing This PR does four things. It adds an optional `stats` extension plugin. It makes `Cover.svelte` images fade in once loaded. It updates the `low_delay.rs` assertion to the current "not ready" message, which does match `crates/core/src/lib.rs:1543`. It reworks the AI review/tour workflow so each runs once per PR, again on request via a label, with follow-up rounds that carry state. The plugin's counting logic (`listen.rs`) holds up against how the host actually emits events. Position updates come every 250 ms, and the 2 s step and replay rules fit that. Repeat-one gets no `TrackChanged`, so the replay check covers it. Ended and Stopped are guarded so they count once. The risks are in the file side of the plugin, which only has native unit tests for its pure logic. First, the history is re-read and re-parsed on every redraw, and the open page redraws every second. Second, the trim can rewrite the whole file on every listen. Third, the new follow-up review trusts a state block from any PR comment. **3 new findings**: 3 minor; 3 as comments on the diff. <sub>Reviewed b38d3d6135 with Claude Code. An AI review can be wrong: weigh it, don't obey it. Reply to a finding or react 👎 to dispute it; add the <code>ai-review</code> label for a follow-up on the latest commit.</sub> <!-- medley-ai-review-state:eyJzaGEiOiJiMzhkM2Q2MTM1MWFjMmEyMzFmYzgxYmMxZmNmYWY5NDVlM2EyMTdmIiwicm91bmQiOjEsImZpbmRpbmdzIjpbeyJmaWxlIjoicGx1Z2lucy9vcHRpb25hbC9zdGF0cy9zcmMvbGliLnJzIiwibGluZSI6MTc4LCJzZXZlcml0eSI6Im1pbm9yIiwidGl0bGUiOiJTdGF0cyBwYWdlIHJlLXJlYWRzIGFuZCByZS1wYXJzZXMgdGhlIHdob2xlIGhpc3RvcnkgZXZlcnkgc2Vjb25kIGR1cmluZyBwbGF5YmFjayIsImJvZHkiOiJgUGx1Z2luVmlld1BhbmVsLnN2ZWx0ZWAgcmVkcmF3cyBhIHBsdWdpbiB2aWV3IHdoZW5ldmVyIGB0cmFja19pZHxzdGF0dXN8Zmxvb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d3JvbmcuIiwiaWQiOiJGMyIsInN0YXR1cyI6Im9wZW4iLCJyb3VuZCI6MX1dfQ== -->
@ -0,0 +138,4 @@
fn trim() {
let text = fs::read_to_string(HISTORY_FILE).unwrap_or_default();
let lines: Vec<&str> = text.lines().collect();
if lines.len() <= HISTORY_CAP {

🟡 F2: Trim keeps 50,000 lines however large they are, so long lines make every append re-read or rewrite the file (minor)

append calls trim() whenever the file is over TRIM_BYTES, but trim caps lines, not bytes. If the average line is over ~168 bytes, the file passes 8 MiB before it reaches 50,000 lines. That is about 120 characters of artist plus title, which is common with classical metadata such as "Symphony No. 5 in C minor, Op. 67: I. Allegro con brio" by "Berliner Philharmoniker, Herbert von Karajan".

In that state:

  • Every listen reads the whole file again just to find lines.len() <= HISTORY_CAP and return.
  • Once it reaches 50,001 lines, each new listen rewrites roughly 8 to 9 MiB to drop one line, because the file stays over the threshold.

The docs' "past about 8 MiB" claim also no longer holds.

Fix: trim by bytes with some headroom, for example keep the newest lines that fit in TRIM_BYTES / 2. Or keep the line cap but trim down to something like HISTORY_CAP * 3 / 4, so a trim happens rarely and not on every listen.

🟡 **F2: Trim keeps 50,000 lines however large they are, so long lines make every append re-read or rewrite the file** (minor) `append` calls `trim()` whenever the file is over `TRIM_BYTES`, but `trim` caps lines, not bytes. If the average line is over ~168 bytes, the file passes 8 MiB before it reaches 50,000 lines. That is about 120 characters of artist plus title, which is common with classical metadata such as "Symphony No. 5 in C minor, Op. 67: I. Allegro con brio" by "Berliner Philharmoniker, Herbert von Karajan". In that state: - Every listen reads the whole file again just to find `lines.len() <= HISTORY_CAP` and return. - Once it reaches 50,001 lines, each new listen rewrites roughly 8 to 9 MiB to drop one line, because the file stays over the threshold. The docs' "past about 8 MiB" claim also no longer holds. **Fix:** trim by bytes with some headroom, for example keep the newest lines that fit in `TRIM_BYTES / 2`. Or keep the line cap but trim down to something like `HISTORY_CAP * 3 / 4`, so a trim happens rarely and not on every listen. <!-- medley-ai-finding:F2 -->
SBDeveloper marked this conversation as resolved
@ -0,0 +175,4 @@
// No `recover()` here: this runs in another instance than `on_event`, and a
// checkpoint it finds may belong to the Track playing right now.
// The Track playing right now is not in the history yet.
let s = summarize(&history(), now(), TOP);

🟡 F1: Stats page re-reads and re-parses the whole history every second during playback (minor)

PluginViewPanel.svelte redraws a plugin view whenever track_id|status|floor(position_ms/1000) changes, so while the Stats page is open and music plays, ui_view runs about once a second. Each call does history(): it reads the whole file (up to ~8 MiB / ~80,000 lines, by design) and parses every line into a serde_json::Value, in wasm, and then summarize builds the HashMaps again. With a long history this keeps a core busy the whole time the page is open. The panel also dims the page (stale) while a slow draw is in flight.

Nothing in the history changes between those calls. Only append (on the events instance) and clear_yes change it.

Fix: cache the parsed Vec<Entry> or the Summary in STATE on the UI instance, keyed by the file's len() (plus now()/DAY_SECS, so 'Today' rolls over). Re-read only when that key changes.

🟡 **F1: Stats page re-reads and re-parses the whole history every second during playback** (minor) `PluginViewPanel.svelte` redraws a plugin view whenever `track_id|status|floor(position_ms/1000)` changes, so while the Stats page is open and music plays, `ui_view` runs about once a second. Each call does `history()`: it reads the whole file (up to ~8 MiB / ~80,000 lines, by design) and parses every line into a `serde_json::Value`, in wasm, and then `summarize` builds the HashMaps again. With a long history this keeps a core busy the whole time the page is open. The panel also dims the page (`stale`) while a slow draw is in flight. Nothing in the history changes between those calls. Only `append` (on the events instance) and `clear_yes` change it. **Fix:** cache the parsed `Vec<Entry>` or the `Summary` in `STATE` on the UI instance, keyed by the file's `len()` (plus `now()/DAY_SECS`, so 'Today' rolls over). Re-read only when that key changes. <!-- medley-ai-finding:F1 -->
SBDeveloper marked this conversation as resolved
@ -101,0 +203,4 @@
...comments.map((c) => ({ body: c.body, at: c.created_at, user: c.user?.login })),
].filter((p) => p.body && STATE.test(p.body));
if (!posts.length) return null;
const latest = posts.sort((a, b) => String(a.at).localeCompare(String(b.at))).at(-1);

🟡 F3: Follow-up review accepts a state block from any commenter (minor)

previousRound() builds posts from all reviews and all issue comments whose body matches STATE, takes the newest, and sets bot = latest.user. Anyone who can comment on the PR can post a comment with <!-- medley-ai-review-state:<base64> -->. On the next ai-review run:

  • Their forged state becomes the previous round. They can list real findings as fixed/withdrawn, which the prompt calls "never raise these again", or put arbitrary text into finding bodies that go into Claude's prompt.
  • bot becomes that commenter, so their own replies and reactions are dropped and the real bot's are counted as people's.
  • A block that decodes but lacks findings/sha/round makes history.state.findings.filter throw, and the review fails.

The review is advisory, but this lets a third party silence or steer it.

Fix: only accept state from posts by the identity that posts reviews (GET /user with REVIEW_TOKEN, or the known bot login). Validate the shape before use, and fall back to a fresh review if it is wrong.

🟡 **F3: Follow-up review accepts a state block from any commenter** (minor) `previousRound()` builds `posts` from all reviews and *all issue comments* whose body matches `STATE`, takes the newest, and sets `bot = latest.user`. Anyone who can comment on the PR can post a comment with `<!-- medley-ai-review-state:<base64> -->`. On the next `ai-review` run: - Their forged state becomes the previous round. They can list real findings as `fixed`/`withdrawn`, which the prompt calls "never raise these again", or put arbitrary text into finding bodies that go into Claude's prompt. - `bot` becomes that commenter, so their own replies and reactions are dropped and the real bot's are counted as people's. - A block that decodes but lacks `findings`/`sha`/`round` makes `history.state.findings.filter` throw, and the review fails. The review is advisory, but this lets a third party silence or steer it. **Fix:** only accept state from posts by the identity that posts reviews (`GET /user` with `REVIEW_TOKEN`, or the known bot login). Validate the shape before use, and fall back to a fresh review if it is wrong. <!-- medley-ai-finding:F3 -->
SBDeveloper marked this conversation as resolved
Author
Owner
  • F1 (page re-reads history every second): fixed in 277541a. The page keeps its summary and redoes the sums only when the history file's size or the day changes; "Clear history" drops it. The redraw each second is now cheap.
  • F2 (trim by lines, not bytes): fixed in 277541a. A trim now keeps the newest lines that fit in half of the 8 MiB limit (and at most 50,000), so it happens rarely and never rewrites on every listen. The docs say so. newest() has a unit test; the file handling around it does not.
  • F3 (follow-up review trusts any state comment): not changed here. The finding is right, but it is in scripts/ai/review.mjs from a5ab3ce, the review-workflow commit, not the Stats work, and I can't run that workflow to verify a change. It is advisory only, so I'd take it as a follow-up: accept state only from the bot identity and validate its shape.
- **F1 (page re-reads history every second): fixed** in 277541a. The page keeps its summary and redoes the sums only when the history file's size or the day changes; "Clear history" drops it. The redraw each second is now cheap. - **F2 (trim by lines, not bytes): fixed** in 277541a. A trim now keeps the newest lines that fit in half of the 8 MiB limit (and at most 50,000), so it happens rarely and never rewrites on every listen. The docs say so. `newest()` has a unit test; the file handling around it does not. - **F3 (follow-up review trusts any state comment): not changed here.** The finding is right, but it is in `scripts/ai/review.mjs` from a5ab3ce, the review-workflow commit, not the Stats work, and I can't run that workflow to verify a change. It is advisory only, so I'd take it as a follow-up: accept state only from the bot identity and validate its shape.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Stats: fix newest() test bound
Some checks failed
Check / android (pull_request) Has been skipped
Check / ui (pull_request) Successful in 14s
Check / e2e (pull_request) Successful in 34s
Check / fmt (pull_request) Successful in 46s
Check / ui (push) Successful in 13s
Check / fmt (push) Successful in 42s
Check / e2e (push) Successful in 36s
Check / android (push) Successful in 6m21s
Publish plugins / publish (push) Successful in 32s
Check / rust (push) Failing after 8m33s
Check / rust (pull_request) Failing after 11m25s
Release / linux (push) Successful in 10m22s
Release / android (push) Successful in 8m42s
df650a4bdd
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
SBDeveloper deleted branch fix/fix-rust-build 2026-11-12 21:06:02 +01:00
Sign in to join this conversation.
No description provided.