[Bug] History should record playback stop events on pause and sleep-timer expiry #44

Closed
opened 2026-09-18 08:48:31 +02:00 by alexander · 0 comments
Owner

Migrated from GitHub issue #139. Forgejo issue: #44. GitHub source content synchronized on 2026-09-19. Migrated issue references below use Forgejo numbers where an equivalent issue exists; historical references without a Forgejo counterpart remain explicit GitHub links.

Classification

Playback-history correctness / product-behavior field report.

Observed on device after GitHub PR #93 was merged. This issue is being logged separately from the headset cold-resume regression because the underlying ownership and acceptance criteria are different.

Field report

Playback History shows Play events, but the listener also needs to see when that listening interval stopped.

At minimum, History should show a stop/end event when:

  • playback is paused;
  • a sleep timer expires and stops playback.

The observed History did not provide that end-of-listening information clearly/reliably.

Product intent

History is meant to answer what happened to this audiobook and when. A Play row without a corresponding end marker makes a listening interval incomplete and makes it harder to reconstruct where/why playback stopped.

The user-facing concept should be clear: playback stopped here, with the cause represented where useful (ordinary pause vs sleep timer). Avoid producing multiple confusing rows for the same physical stop.

Current repository state

The underlying model already has much of this intent:

  • PlaybackEvent.Play;
  • PlaybackEvent.Pause;
  • PlaybackEvent.SleepTimerExpired;
  • PlaybackEvent.SleepTimerStarted / SleepTimerExtended / SleepTimerRewind.

HistorySheet already has labels/icons for both Pause and SleepTimerExpired.

PlaybackService records Play/Pause from onPlayWhenReadyChanged, deliberately using playWhenReady rather than isPlaying so buffering does not look like a stop.

SleepTimerController.expire() currently calls player.pause() and then records SleepTimerExpired.

Therefore this is not a request to invent a second history/logging architecture. The tree already expresses the intended events, but the device result says the actual persisted/rendered history does not reliably communicate the end of playback.

Investigation scope for eventual implementation

Determine whether the missing stop/end row is caused by:

  • the player callback not firing on one or more controller/background paths;
  • history recording racing with service/process teardown;
  • event persistence ordering;
  • History refresh/query state not observing the newly recorded row;
  • sleep-timer expiry producing an event that is hidden/duplicated by the ordinary pause;
  • or simply current event semantics/UI wording failing to represent the requested Stop concept clearly.

Do not add a parallel recorder just to make a row appear. Playback transition ownership should remain in the service/player boundary that already owns these events.

Expected behavior

Every locally owned transition from active listening to stopped/paused should leave one clear, durable playback-end marker in History at the final position.

For sleep-timer expiry, History must make it clear that the timer caused playback to stop. Whether the final implementation models this as a generic Stop with a cause or keeps Pause / SleepTimerExpired as distinct event types is an implementation detail, provided the timeline is unambiguous and does not duplicate the same stop misleadingly.

Acceptance criteria

  • Start playback, then pause from the in-app transport: History shows one clear end/stop event at the paused position.
  • Repeat pause from notification/system controls and a physical headset/Bluetooth control: the same History contract holds.
  • Let a fixed sleep timer expire while BookWave is backgrounded/screen-off: History shows one clear end-of-playback event attributable to the sleep timer at the final position.
  • If Pause and SleepTimerExpired are both retained internally for one timer expiry, the UI must not present them as two unrelated stops for one transition.
  • Stop/end history survives closing/reopening the History sheet and process/service recreation.
  • A network/server failure must not prevent the local stop/end event from being persisted.
  • Buffering, temporary suppression, or other non-stop player state changes must not create false stop events.
  • Existing seek/chapter/remote-progress/history behavior remains unchanged.
  • Add the lowest-level player/history tests that prove the event is persisted, plus a device acceptance case for background sleep-timer expiry and physical media-button pause.
  • #43 — headset Play after update can cold-resume the correct book at 0:00
  • GitHub PR #93 / #9 — unified media-control resume path; relevant to controller coverage but not the owner of History semantics
> Migrated from [GitHub issue #139](https://github.com/AlexanderWilhelmsenBerg/Audiobookshelf-Manager-Claude/issues/139). Forgejo issue: #44. GitHub source content synchronized on 2026-09-19. Migrated issue references below use Forgejo numbers where an equivalent issue exists; historical references without a Forgejo counterpart remain explicit GitHub links. ## Classification Playback-history correctness / product-behavior field report. Observed on device after [GitHub PR #93](https://github.com/AlexanderWilhelmsenBerg/Audiobookshelf-Manager-Claude/pull/93) was merged. This issue is being logged separately from the headset cold-resume regression because the underlying ownership and acceptance criteria are different. ## Field report Playback History shows **Play** events, but the listener also needs to see when that listening interval **stopped**. At minimum, History should show a stop/end event when: - playback is paused; - a sleep timer expires and stops playback. The observed History did not provide that end-of-listening information clearly/reliably. ## Product intent History is meant to answer **what happened to this audiobook and when**. A Play row without a corresponding end marker makes a listening interval incomplete and makes it harder to reconstruct where/why playback stopped. The user-facing concept should be clear: playback **stopped here**, with the cause represented where useful (ordinary pause vs sleep timer). Avoid producing multiple confusing rows for the same physical stop. ## Current repository state The underlying model already has much of this intent: - `PlaybackEvent.Play`; - `PlaybackEvent.Pause`; - `PlaybackEvent.SleepTimerExpired`; - `PlaybackEvent.SleepTimerStarted` / `SleepTimerExtended` / `SleepTimerRewind`. `HistorySheet` already has labels/icons for both `Pause` and `SleepTimerExpired`. `PlaybackService` records Play/Pause from `onPlayWhenReadyChanged`, deliberately using `playWhenReady` rather than `isPlaying` so buffering does not look like a stop. `SleepTimerController.expire()` currently calls `player.pause()` and then records `SleepTimerExpired`. Therefore this is **not a request to invent a second history/logging architecture**. The tree already expresses the intended events, but the device result says the actual persisted/rendered history does not reliably communicate the end of playback. ## Investigation scope for eventual implementation Determine whether the missing stop/end row is caused by: - the player callback not firing on one or more controller/background paths; - history recording racing with service/process teardown; - event persistence ordering; - History refresh/query state not observing the newly recorded row; - sleep-timer expiry producing an event that is hidden/duplicated by the ordinary pause; - or simply current event semantics/UI wording failing to represent the requested **Stop** concept clearly. Do not add a parallel recorder just to make a row appear. Playback transition ownership should remain in the service/player boundary that already owns these events. ## Expected behavior Every locally owned transition from active listening to stopped/paused should leave one clear, durable playback-end marker in History at the final position. For sleep-timer expiry, History must make it clear that the timer caused playback to stop. Whether the final implementation models this as a generic `Stop` with a cause or keeps `Pause` / `SleepTimerExpired` as distinct event types is an implementation detail, provided the timeline is unambiguous and does not duplicate the same stop misleadingly. ## Acceptance criteria - Start playback, then pause from the in-app transport: History shows one clear end/stop event at the paused position. - Repeat pause from notification/system controls and a physical headset/Bluetooth control: the same History contract holds. - Let a fixed sleep timer expire while BookWave is backgrounded/screen-off: History shows one clear end-of-playback event attributable to the sleep timer at the final position. - If `Pause` and `SleepTimerExpired` are both retained internally for one timer expiry, the UI must not present them as two unrelated stops for one transition. - Stop/end history survives closing/reopening the History sheet and process/service recreation. - A network/server failure must not prevent the local stop/end event from being persisted. - Buffering, temporary suppression, or other non-stop player state changes must not create false stop events. - Existing seek/chapter/remote-progress/history behavior remains unchanged. - Add the lowest-level player/history tests that prove the event is persisted, plus a device acceptance case for background sleep-timer expiry and physical media-button pause. ## Related - #43 — headset Play after update can cold-resume the correct book at `0:00` - [GitHub PR #93](https://github.com/AlexanderWilhelmsenBerg/Audiobookshelf-Manager-Claude/pull/93) / #9 — unified media-control resume path; relevant to controller coverage but not the owner of History semantics
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
alexander/Audiobookshelf-Manager-Claude#44
No description provided.