Skip to content

fix(playback): record admin history for every way a session ends - #3191

Merged
Quick104 merged 8 commits into
mainfrom
feat/playback-end-history
Oct 28, 2026
Merged

Quick104 merged 8 commits into
mainfrom
feat/playback-end-history

Conversation

@Quick104

@Quick104 Quick104 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: none (the change reaches #1206 C2 and #1246 C1, which have no recorded results yet)

Some ways a playback session ends leave no row in admin playback history, so the play never appears there:

  • a server abort (the source file went missing, or a replacement transport failed);
  • a Jellyfin client switching play method mid-play, which drops the old session;
  • a v2 stop, a Jellyfin Stopped report or an Audiobookshelf close that reaches an API server without the session's live copy (another replica holds it, or the server restarted).

A monitoring tool that reconciles a missed stop against admin history (the plan behind #3184) can't find these plays at all. This change makes each of these ends write one history row with its end reason, and adds a replaced end reason for the method switch.

Builds on #3184, which has merged.

Approach

  • Detached ends. SessionManager.FinishDetached runs the finish hooks for a session snapshot this server no longer holds, with the end reason carried in the context. The playback handler's existing finish hook writes the history. Watch history follows the same rules as today. An aborted or replaced play goes to the admin log only: aborts never wrote watch history, and a replaced play continues under the session that replaced it.
  • Where the snapshot comes from. A snapshot without a start time takes its start, client, device and stream facts from the shared live row (playback_sessions_sync) when one is left. For a v2 stop it falls back to the attempt row's creation time, which AttemptRecordV3.CreatedAt now exposes.
  • Paths.
    • Both abort handlers record aborted.
    • The Jellyfin method switch keeps a copy of the old session and finishes it as replaced once the attach CAS has moved the play off it, whether this request or a concurrent one won.
    • A Jellyfin teardown or Audiobookshelf close whose FinishSession finds no local copy finishes the stop's own snapshot.
    • A v2 stop without the live copy writes admin history from the attempt row.
  • Reason of a replayed stop. A replayed v2 stop that finishes an administrator's, an expiry's or an abort's unfinished stop now records that stop's reason, derived from the attempt's stop id, instead of stopped. Aborts get their own server-minted stop id (they shared expiry's), so a replayed abort stays aborted and writes no watch history.
  • What a detached end knows. A Jellyfin stop that reported no position, or a method switch whose old copy is on another server, records the play from its identity. A reported zero position is kept; only a position nobody reported is taken from the live row. The Audiobookshelf store now reads the session's media file, which a close without the native copy needs.
  • A file that left the catalog. An end whose media file is gone (an abort because the file went missing, or a library deleted mid-play) still records its row, without the item and duration only the file gave. Any other lookup failure still returns its error, because the history upsert never fills in an item later. A Jellyfin copy that never reported progress still records nothing: it may only have served media while another copy took the play, and docs/admin-api.md now says so.
  • Server stop ids. A v2 stop that names one of the session's server-minted stop ids (administrator, expiry, abort) is refused with 400. They are derived from the visible session id, so a client could otherwise record its own play as terminated, expired or aborted. Clients mint random ids, so none is affected.
  • Contract. replaced joins the end_reason enum on GET /api/v2/admin/playback-history and the history capabilities' end_reason_values, and docs/admin-api.md describes it. contracts/api/v2/breaking-approvals.json approves the added enum value pre-lock: the field is new in feat(admin): record device, client, stream decisions and end reason in playback history #3184 and no client reads it yet.
  • Comment fix. The comments on Jellyfin expiry no longer say the session is revived under the same id. A claimed expiry is terminal. The play's own stop still reaches watch providers because the client's Stopped report finds the terminal play.
  • Surfaces. Admin-only data, so Apple, Android and the web UI need no change. For jellycompat parity: Jellyfin has no admin history surface, and Jellyfin plays are among the sessions this change records.

Known limit, fixed by the next PR in this stack: a stale Jellyfin copy on another server can still expire later and relabel a stopped play as expired, because end_reason follows the latest finalization.

Validation

  • Ran on an isolated sandbox built from this branch, with real HTTP calls. A hard restart of the single API server stood in for "a server without the live copy". Each run checked the history row's reason, watched seconds, start time, client and device:
    • v2 start, progress, restart, then v2 stop at 480 s: stopped, 480 s, client and device from the live row.
    • v2 start, progress at 200 s, source file made unreadable, then a stream request: 404, row aborted at 200 s.
    • Jellyfin direct play to HLS and HLS to direct play on one PlaySessionId: each replaced session has a replaced row at 600 s; the new sessions have none while playing.
    • Jellyfin play, restart, then a Stopped report at 960 s: stopped, 960 s.
    • Not run live: the Audiobookshelf close (the sandbox has no audiobook library). Covered by review only; ABS is beta.
  • Tests cover each detached end (reason, the admin-only rule, live-row facts, a Jellyfin copy without progress), the v2 stop without a live copy, and a replayed stop finishing an administrator's stop. A new DB contract, TestLiveSessionReadsTheSyncedRowDB, is listed in scripts/ci/db-contracts.txt.
  • Gate: build, gofmt, vet, make lint-changed (0 issues), make lint-router-recovery, every make verify-* target and TestCommittedArtifactMatchesRouter, web lint, format, build and budget, and make test-web pass.
    • make verify-apiv2-contract passes with the approval entry for the added replaced enum value.
    • make verify-actionlint didn't run: actionlint 1.7.12 isn't installed on the machine used, and no workflow changed.
    • make test-go passed every package except internal/database: TestLogPartitionsMatchPartmanOnNonUTCServer fails for America/New_York. It builds its own database from migrations up to 028 and doesn't reach this change. US daylight saving time ends on November 1, inside the test's eight-day window, so it fails on any branch this week.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-3191/

No visible change: no screen shows end reasons. The evidence page has the sandbox steps and results, the build and the test results.

Risks

  • A Jellyfin stop that finds no local copy now writes watch history from the stop's snapshot. It uses the play's stable history id, so a copy elsewhere can't add a second row. Before, such a play was recorded only if a stale copy on another server expired later.
  • One extra indexed read of playback_sessions_sync per detached end.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code in T3 Code
  • Tool(s): Claude Code; Codex (gpt-6.1-sol) for read-only design reviews
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated. claude-opus-5-5 wrote the code, tests, docs change and this description from a maintainer-approved plan.
  • Adversarial review: The lifecycle-events design this PR serves had two read-only Codex reviews (gpt-6.1-sol, xhigh then high). They found these history gaps and the method-switch ordering this PR follows. A review of this diff follows in the PR thread.

🤖 Generated with Claude Code

Note

Record admin history for every playback session end reason, including replaced

  • Adds the replaced end reason for Jellyfin method switches and records aborted, replaced, and detached-stopped sessions in the admin history log, without writing watch history for aborts and replacements
  • Adds SessionManager.FinishDetached so finish hooks run for snapshots not held on the local replica; detached snapshots are enriched from a shared live session row via PGPlaybackAdminStore.LiveSession
  • Derives the end reason from the server-minted stop ID (administrator, expiry, abort) in finalizeStopV2 and endReasonForStop; StopPlaybackV2 now rejects client stops that reuse a server stop ID with HTTP 400
  • Missing media files no longer block history entry construction in PlaybackHandler.buildAdminHistoryEntry; entries are recorded without file details
  • Updates the OpenAPI contract, fixtures, and docs for the new replaced enum value
  • Behavioral Change: end_reason enum in AdminPlaybackHistoryEntry gains replaced; client stop requests with server stop IDs now return HTTP 400 in playback_service.go

Macroscope summarized 2e4806a.

@silo-triage silo-triage Bot added the size/XL 500–999 added + deleted lines (all files); change volume, not priority. label Oct 27, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 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-28T15:27:00.815954Z 2e4806a New commits
🔒 Security Review ✅ Completed 2026-10-28T15:30:12.705576Z 2e4806a New commits

Security findings

Advisory findings (1)

ℹ️ 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.

@silo-triage silo-triage Bot added api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase bug Something isn't working go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish stacked Base is another open PR; merge in stack order named in the body labels Oct 27, 2026
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 17 seconds.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4b019a2e-89c0-4ba2-b7b0-5bce1d6cdf51
Commits

Reviewing files that changed from the base of the PR and between 190a00e and 2e4806a.

Files selected for processing: 27
  • contracts/api/v2/breaking-approvals.json
  • contracts/api/v2/fixtures/get_admin_playback_history_capabilities_ok.json
  • contracts/api/v2/fixtures/index.json
  • contracts/api/v2/openapi.json
  • docs/admin-api.md
  • docs/playback-api.md
  • internal/api/handlers/playback.go
  • internal/api/handlers/playback_admin_store.go
  • internal/api/handlers/playback_finish_history_test.go
  • internal/api/handlers/playback_realtime.go
  • internal/api/handlers/playback_service.go
  • internal/api/handlers/playback_service_test.go
  • internal/api/handlers/stream.go
  • internal/apiv2/admin_playback_history.go
  • internal/audiobooks/abs/native_sessions.go
  • internal/audiobooks/abs/progress.go
  • internal/audiobooks/abs_playback_session_store.go
  • internal/audiobooks/abs_playback_session_store_db_test.go
  • internal/jellycompat/audio_selection_test.go
  • internal/jellycompat/handlers_playback.go
  • internal/jellycompat/routing_policy_test.go
  • internal/jellycompat/streams.go
  • internal/playback/planstore/postgres.go
  • internal/playback/protocol_store_v3.go
  • internal/playback/session.go
  • scripts/ci/db-contracts.txt
  • web/src/api/v2/schema.ts

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 224ebdc5-dec6-4216-af9f-5b40b4a5fb2b
Commits

Reviewing files that changed from the base of the PR and between 0e933a2 and 190a00e.

Files selected for processing: 14
  • contracts/api/v2/fixtures/get_admin_playback_history_capabilities_ok.json
  • contracts/api/v2/fixtures/index.json
  • contracts/api/v2/openapi.json
  • docs/admin-api.md
  • internal/api/handlers/playback.go
  • internal/api/handlers/playback_admin_store.go
  • internal/api/handlers/playback_finish_history_test.go
  • internal/api/handlers/playback_realtime.go
  • internal/api/handlers/playback_service.go
  • internal/apiv2/admin_playback_history.go
  • internal/jellycompat/streams.go
  • internal/playback/session.go
  • scripts/ci/db-contracts.txt
  • web/src/api/v2/schema.ts
Files skipped from review as they are similar to previous changes: 1
  • scripts/ci/db-contracts.txt

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

Walkthrough

Playback finalization now records admin history for detached stops, aborts, and replaced sessions. Detached snapshots can use shared live-session data to fill missing facts. The admin playback-history API adds the replaced end reason, and stop handling rejects client IDs reserved for server-side endings.

Changes: Playback history finalization

Layer / File(s) Summary
Detached history and session data
internal/playback/session.go, internal/api/handlers/playback.go, internal/api/handlers/playback_admin_store.go, internal/playback/protocol_store_v3.go, internal/playback/planstore/postgres.go, internal/api/handlers/playback_finish_history_test.go
Finish hooks accept detached snapshots and carry end reasons in context. The history handler fills missing snapshot facts from a shared live row. Attempt records retain their creation time, and the admin store exposes synced session data. Tests cover detached history and snapshot fields.
Stop and abort finalization
internal/api/handlers/playback_service.go, internal/api/handlers/playback_realtime.go, internal/api/handlers/stream.go, internal/api/handlers/playback.go, internal/api/handlers/playback_service_test.go, docs/playback-api.md
Stop IDs reserved for server endings are rejected from clients. Finalization maps the winning stop ID to an end reason and records history when no live session is available. Aborts record admin history but not watch history. Tests and documentation cover these behaviors.
Detached finish callers
internal/jellycompat/..., internal/audiobooks/..., internal/jellycompat/routing_policy_test.go
Jellyfin-compatible playback submits detached snapshots when a session is replaced or its local copy is missing. Audiobookshelf close handling can submit a detached snapshot when the native session copy is missing. Tests cover replaced-session snapshots and retrieval of the media-file ID.
Admin history API contract
internal/apiv2/admin_playback_history.go, contracts/api/v2/*, web/src/api/v2/schema.ts, docs/admin-api.md, scripts/ci/db-contracts.txt
The admin history contract and fixtures include replaced. The approval record, fixture validator, documentation, generated client schema, and database-contract registry are updated.

Priority: Pending latest changes

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant ensureUpstreamPlayback
  participant SessionManager
  participant handleFinishedSession
  participant PGPlaybackAdminStore
  ensureUpstreamPlayback->>SessionManager: FinishDetached with replaced reason and session snapshot
  SessionManager->>handleFinishedSession: Invoke finish hook with detached context
  handleFinishedSession->>PGPlaybackAdminStore: Read shared live-session facts
Loading

Possibly related PRs

Suggested labels: impact: playback

Suggested reviewers: rhainland, brady3035

Merge Risk: Low · previous review 190a0

The change is mergeable with a documentation follow-up: qualify the history-row guarantee so it matches the zero-progress Jellyfin behavior.

Security architecture risk: Low · up to 190a0

The change affects playback history across replicas and restarts. Ownership checks remain in the inspected stop paths, and no new cross-account access was established. Residual risk centers on best-effort history recording and concurrent finalization rather than expanded privileges.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — The new persistent effects concern session-keyed playback history, including account/profile attribution and client, device, and IP metadata recovered from shared live rows. Ordinary detached stops can also enter the existing watch-history persistence path.

Trust Boundaries and Controls

  • observed — The v2 stop path validates the authenticated caller and installation, then requires the attempt’s user and profile to match before mutation. Its detached snapshot derives identity from that owned attempt; live-row enrichment rejects another user’s facts.
  • observed — Audiobookshelf closes check the stored session’s user/profile principal before closing and constructing a detached snapshot. Jellyfin reports resolve finalizable plays under the authenticated token, and ID-less stop reports do not tear down a play through route-only matching.

Resilience and Maintainability Implications

  • inferred — Admin playback history should not be treated as an immutable terminal-event ledger. Repeated detached calls can rerun hooks, and the pre-existing latest-finalization rule can replace a previously recorded reason. The new paths reuse this behavior rather than introducing authoritative terminal ownership.

Hardening Proposals

  • proposed — If automated reconciliation requires guaranteed terminal history, consider a durable session-scoped history intent with retryable completion, separate from transport teardown. This would strengthen the existing best-effort design rather than remediate a verified access-control vulnerability.
Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title is concise and accurately summarizes the primary change: recording admin history for every playback-session termination path.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The pull request description directly explains the playback-history changes, detached session handling, new end reason, validation, risks, and affected paths.
Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@macroscopeapp

macroscopeapp Bot commented Oct 27, 2026

Copy link
Copy Markdown

The admin user's Watch history/Playback History now includes plays that were previously omitted (aborted, replaced, or stopped on a server without the live copy). The linked evidence should show before-and-after captures of the same history screen with these added rows at desktop and phone widths; the description documents sandbox/API checks but does not identify captures of the history UI. Suggested fix: add those captures to the linked evidence page and update the Evidence section to identify the visible change.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1cc67f37d9

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/api/handlers/playback.go Resolved
Comment thread internal/api/handlers/playback.go Resolved
@coderabbitai coderabbitai Bot added the impact: playback Can't play, stalls, or wrong media label Oct 27, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 57ebc99b-494b-403b-bda9-70e439cc9495
Commits

Reviewing files that changed from the base of the PR and between f9a560e and 466f047.

Files selected for processing: 21
  • contracts/api/v2/breaking-approvals.json
  • contracts/api/v2/fixtures/get_admin_playback_history_capabilities_ok.json
  • contracts/api/v2/fixtures/index.json
  • contracts/api/v2/openapi.json
  • docs/admin-api.md
  • internal/api/handlers/playback.go
  • internal/api/handlers/playback_admin_store.go
  • internal/api/handlers/playback_finish_history_test.go
  • internal/api/handlers/playback_service.go
  • internal/api/handlers/playback_service_test.go
  • internal/api/handlers/stream.go
  • internal/apiv2/admin_playback_history.go
  • internal/audiobooks/abs/native_sessions.go
  • internal/audiobooks/abs/progress.go
  • internal/jellycompat/handlers_playback.go
  • internal/jellycompat/streams.go
  • internal/playback/planstore/postgres.go
  • internal/playback/protocol_store_v3.go
  • internal/playback/session.go
  • scripts/ci/db-contracts.txt
  • web/src/api/v2/schema.ts

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

Comment thread internal/api/handlers/playback.go Resolved
Comment thread internal/jellycompat/streams.go Resolved
@macroscopeapp

macroscopeapp Bot commented Oct 28, 2026

Copy link
Copy Markdown

The Validation tasks: line is stale: #1206 C2 and #1246 C1 have recorded results in their issue comments, contrary to “no recorded results yet.” The admin-stop fallback and its 410 behavior are unchanged; the Jellyfin smoke matrix does not exercise detached stops or method switches, and the added history records are outside those checks. Please replace the line with Validation tasks: none.

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: 34ca26f432

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Base automatically changed from feat/admin-history-device-fields to main October 28, 2026 13:07
@silo-triage silo-triage Bot added size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority. and removed size/XL 500–999 added + deleted lines (all files); change volume, not priority. labels Oct 28, 2026
@Quick104
Quick104 force-pushed the feat/playback-end-history branch from 0e933a2 to 190a00e Compare October 28, 2026 13:19
@silo-triage silo-triage Bot added size/XL 500–999 added + deleted lines (all files); change volume, not priority. and removed size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority. labels Oct 28, 2026
@silo-kody

silo-kody Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 87c4f525-b3cb-42ff-bebe-f75bd1a27731
Commits

Reviewing files that changed from the base of the PR and between dce508c and 0e933a2.

Files selected for processing: 85
  • cmd/silo/session_sync.go
  • contracts/api/v2/fixtures/admin_account_delete_break_glass_required.json
  • contracts/api/v2/fixtures/admin_download_revoke_mixed.json
  • contracts/api/v2/fixtures/admin_download_storage_delete_invalid_id.json
  • contracts/api/v2/fixtures/admin_login_session_forbidden.json
  • contracts/api/v2/fixtures/admin_network_access_status_not_found.json
  • contracts/api/v2/fixtures/admin_network_access_unknown_host.json
  • contracts/api/v2/fixtures/admin_subtitle_metadata_precondition_required.json
  • contracts/api/v2/fixtures/approve_device_login_api_key_forbidden.json
  • contracts/api/v2/fixtures/cancel_admin_download_preparations_invalid_id.json
  • contracts/api/v2/fixtures/cancel_device_login_not_found.json
  • contracts/api/v2/fixtures/clear_resume_position_not_found.json
  • contracts/api/v2/fixtures/clear_resume_position_not_leaf.json
  • contracts/api/v2/fixtures/collection_order_foreign_id.json
  • contracts/api/v2/fixtures/complete_account_identity_link_invalid_grant.json
  • contracts/api/v2/fixtures/complete_oauth_login_invalid_grant.json
  • contracts/api/v2/fixtures/create_account_identity_link_ticket_wrong_password.json
  • contracts/api/v2/fixtures/create_admin_user_identity_linked_elsewhere.json
  • contracts/api/v2/fixtures/delete_account_identity_last_sign_in_method.json
  • contracts/api/v2/fixtures/get_admin_playback_history_capabilities_ok.json
  • contracts/api/v2/fixtures/get_favorite_membership_not_found.json
  • contracts/api/v2/fixtures/get_home_layout_include_items_out_of_range.json
  • contracts/api/v2/fixtures/get_not_interested_not_found.json
  • contracts/api/v2/fixtures/get_ratings_capability_authentication_required.json
  • contracts/api/v2/fixtures/get_watch_trickplay_not_found.json
  • contracts/api/v2/fixtures/ignore_unmatched_item_not_found.json
  • contracts/api/v2/fixtures/index.json
  • contracts/api/v2/fixtures/link_account_identity_with_credentials_directory_refused.json
  • contracts/api/v2/fixtures/list_admin_playback_history_ok.json
  • contracts/api/v2/fixtures/list_series_seasons_invalid_artwork.json
  • contracts/api/v2/fixtures/login_account_required.json
  • contracts/api/v2/fixtures/login_provider_null.json
  • contracts/api/v2/fixtures/mark_not_interested_episode_rejected.json
  • contracts/api/v2/fixtures/mark_not_interested_not_found.json
  • contracts/api/v2/fixtures/notification_mute_notification_series_not_found.json
  • contracts/api/v2/fixtures/playback_installation_changed.json
  • contracts/api/v2/fixtures/playback_invalid_protocol.json
  • contracts/api/v2/fixtures/playback_progress_conflict.json
  • contracts/api/v2/fixtures/refresh_session_provider_unavailable.json
  • contracts/api/v2/fixtures/regenerate_admin_item_trickplay_disabled.json
  • contracts/api/v2/fixtures/sign_in_with_network_identity_off_overlay.json
  • contracts/api/v2/fixtures/start_account_identity_link_unknown_ticket.json
  • contracts/api/v2/fixtures/start_device_login_temporary_null.json
  • contracts/api/v2/fixtures/theme_songs_playback_not_acceptable.json
  • contracts/api/v2/fixtures/theme_songs_playback_unauthorized.json
  • contracts/api/v2/fixtures/token_refresh_required.json
  • contracts/api/v2/fixtures/unmark_not_interested_locked_profile.json
  • contracts/api/v2/openapi.json
  • docs/admin-api.md
  • docs/playback-api.md
  • internal/api/handlers/admin_playback_control.go
  • internal/api/handlers/admin_playback_history.go
  • internal/api/handlers/admin_playback_terminate.go
  • internal/api/handlers/playback.go
  • internal/api/handlers/playback_admin_store.go
  • internal/api/handlers/playback_finish_history_test.go
  • internal/api/handlers/playback_realtime.go
  • internal/api/handlers/playback_service.go
  • internal/api/handlers/playback_service_test.go
  • internal/api/handlers/playback_session_recipe.go
  • internal/api/handlers/playback_session_recipe_test.go
  • internal/api/handlers/playback_sessions.go
  • internal/api/handlers/playback_sessions_test.go
  • internal/api/handlers/playback_test.go
  • internal/api/handlers/playback_transcode_rehome_test.go
  • internal/api/handlers/playback_v3.go
  • internal/api/handlers/playback_v3_node_recipe_test.go
  • internal/api/handlers/playback_v3_test.go
  • internal/api/handlers/session_ws.go
  • internal/api/testdata/media_routes.txt
  • internal/apiv2/admin_playback_history.go
  • internal/apiv2/admin_playback_history_test.go
  • internal/apiv2/admin_sessions.go
  • internal/jellycompat/handlers_playback.go
  • internal/jellycompat/playback_client_name_test.go
  • internal/jellycompat/streams.go
  • internal/playback/recipecard.go
  • internal/playback/recipecard_test.go
  • internal/playback/session.go
  • internal/playback/transcode_manager.go
  • internal/worker/reconciler.go
  • migrations/sql/20261027185055_playback_device_identity_and_end_reason.sql
  • scripts/ci/db-contracts.txt
  • web/src/api/v2/operations.ts
  • web/src/api/v2/schema.ts

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

Comment thread docs/admin-api.md Resolved
Comment thread internal/api/handlers/playback.go Resolved
@silo-kody

silo-kody Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌
⚠️ 2 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Preserve optional store capabilities through production wrappers
  • Detach mandatory cleanup from request cancellation and bound its lifetime

1 similar comment
@silo-kody

silo-kody Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌
⚠️ 2 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Preserve optional store capabilities through production wrappers
  • Detach mandatory cleanup from request cancellation and bound its lifetime

Quick104 and others added 2 commits October 28, 2026 15:05
Aborts, Jellyfin method switches, and stops, closes or teardowns that reach
a replica without the session's live copy now each write one admin history
row with their end reason. A detached end takes its start, client and device
from the shared live row when one is left. Adds the "replaced" end reason.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quick104 and others added 5 commits October 28, 2026 15:05
A stop or method switch that finds no local copy now records the play from
its identity, completed from the shared live row, and only a position nobody
reported is taken from it. An Audiobookshelf close reads the session's file,
and aborts get their own stop id, so a replayed abort stays an abort that
writes the admin log only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The server's stop ids are derived from the session id and say who ended the
attempt; a client could send one and record its own play as terminated,
expired or aborted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An abort for a missing file, or any end after its library was deleted, now
records its admin history row without the item and duration only the file
gave. Other lookup failures still return the error.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Quick104
Quick104 force-pushed the feat/playback-end-history branch from 250f88e to 05c801f Compare October 28, 2026 15:10
@silo-kody

silo-kody Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 05c801f66e

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/jellycompat/streams.go Resolved
Comment thread internal/api/handlers/playback.go Resolved
Comment thread internal/jellycompat/streams.go Resolved
… abort no copy saw

A Jellyfin method switch that stopped the old upstream copy now records its
end even when the replacement fails to start, so that play is not lost. An
abort of a Jellyfin copy that never reported progress records no row, as for
every other end.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌
⚠️ 2 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Preserve optional store capabilities through production wrappers
  • Detach mandatory cleanup from request cancellation and bound its lifetime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase bug Something isn't working go Pull requests that update go code impact: playback Can't play, stalls, or wrong media priority: P2 Limited scope, workaround exists, or polish size/XL 500–999 added + deleted lines (all files); change volume, not priority. stacked Base is another open PR; merge in stack order named in the body

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant