Skip to content

fix(playback): end a player an administrator stopped while it was unreachable - #2280

Merged
Quick104 merged 3 commits into
Silo-Server:mainfrom
Rhainland:fix/admin-stop-ends-player
Oct 12, 2026
Merged

Quick104 merged 3 commits into
Silo-Server:mainfrom
Rhainland:fix/admin-stop-ends-player

Conversation

@Rhainland

@Rhainland Rhainland commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: #1205
Validation tasks: unblocks #1206 C2, #1208 C2, Silo-Server/silo-apple#330 C2, Silo-Server/silo-apple#331 C2, Silo-Server/silo-android#340 C2, Silo-Server/silo-android#341 C2

When an administrator stops a session while the player can't be reached over its control socket (it is reconnecting, on a flaky network, or too slow to answer within the deadline), the stop does not stick. The server ends the session after the deadline, but the player keeps playing:

  • The web, iPhone, iPad and Apple TV players lose their stream, replan, get 404, and start a fresh session, so the stopped stream comes back in Activity.
  • The Android players and a direct-playing Apple player keep playing what they have buffered, unlisted in Activity, while progress reports still succeed.
  • An Android TV playing a transcode stops on a "Source error" screen with Retry.

The same happens when a pause or resume is not confirmed in time, because those commands share the stop fallback. The manual promises that a disconnected player "may stop only when it next contacts the server". Today it never stops.

The cause is on the server: the fallback stops the live session but leaves its playback attempt live, so progress keeps succeeding, and the 404 it answers afterwards is the signal clients use to renew after an expiry or a server restart.

Approach

  • Server: the stop/pause/resume fallback (v2 and the bridge) and v2 terminate now stop the session's attempt under a dedicated server-minted stop id, the administrator stop id. Progress and replan for such an attempt answer 410 playback_session_ended instead of 404. Expired or otherwise stopped attempts still answer 404, so restart-resilient renewal is unchanged, and a stop the client made first keeps its own receipt. No migration: the stop id is read from the existing stop receipt.
  • Web player: on that 410 from progress or any replan (including the reconnect path) it leaves playback with the notice "An administrator ended this playback session." instead of renewing or showing an error.
  • Apple and Android make the same client change in fix(player): leave playback when an administrator ended the session silo-apple#730 and fix(player): leave playback when an administrator ended the session silo-android#548. The web player ships with the server, so it never meets an older server.
  • docs/playback-api.md and docs/admin-api.md describe the new answer. jellycompat is not affected: Jellyfin-protocol sessions have no control socket, and their stop already revokes the stream.

Merge this before the client pull requests; they are harmless without it.

Validation

  • Local server, a player whose control socket is taken over by a silent connection before the admin stop (the player can't be reached when the stop is sent):
    • before: the web player started a new session; iPhone, Apple TV and an Android tablet kept playing unlisted; Android TV showed a source error.
    • after (with the client PRs): every player left playback within one progress interval, no replacement session appeared, and the attempt was stopped under the administrator stop id.
  • Reachable players (web, iPhone, iPad, Apple TV, Android phone, tablet and TV): pause, resume, message and stop behave as before.
  • Focused Go tests (handlers, planstore against PostgreSQL) and Vitest for the player hooks and VideoPlayer: pass. make lint-changed: no issues.
  • Full gate from CONTRIBUTING.md: Go build, vet, gofmt, make lint-changed, web lint, format, build and budget, make test-web and every verify-* target pass. make test-go has failures that occur the same way on unmodified main on the macOS machine used (hardware-acceleration probes, the Chromaprint preflight, TestAdminResourceCapabilitiesAndScope, one transcode-segment timing test, TestAdminSubtitleListPageDB). Database-backed tests for the changed packages pass against PostgreSQL.

Evidence

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

Risks

Apple and Android builds without the client change get 410 instead of 404 on progress and replan for a session an administrator ended, and handle it as an unrecognized error. They were not tested against this server change; this case only arises after an administrator stop the player missed.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code
  • Tool(s): Claude Code (Bash, file edits, subagents), GitHub CLI (gh), Playwright, Xcode xcodebuild/simctl, Android emulator and adb
  • Model(s): Claude Opus 5.5 (claude-opus-5-5)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: A separate Claude Code review pass (/code-review, medium) covered this branch with the Apple and Android client branches. It found that the web player handled the 410 only while reconnecting; that was fixed with a test so every replan path leaves. This was an AI self-review; no independent human review is claimed.

…eachable

When an administrator stops a session (or a pause or resume goes unconfirmed)
and the player cannot be reached, the server ended the session after the
deadline but left its playback attempt live. Progress kept succeeding, and a
player that lost its stream replanned, got 404, and started a fresh session,
so the stopped stream came back.

The server now stops the attempt under an administrator stop id on the
command fallback and on terminate. Progress and replan for such an attempt
answer 410 playback_session_ended instead of the 404 that drives renewal, and
the web player leaves playback with a notice when it gets that answer.
The web player left on 410 playback_session_ended only while reconnecting. A
recovery replan, seek or track change that got the same answer showed a generic
playback error instead.
@silo-kody

silo-kody Bot commented Oct 11, 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 commented Oct 11, 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-11T17:29:53.336180Z 85480a5 PR opened
ℹ️ About Codex in GitHub

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

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

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

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 10 minutes.

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
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fb0db1c9-c573-4558-abeb-e7496ffc48b7

📥 Commits

Reviewing files that changed from the base of the PR and between 85480a5 and 219007b.


📒 Files selected for processing (4)
  • internal/api/handlers/playback_service.go
  • internal/api/handlers/playback_service_test.go
  • web/src/player/hooks/useWatchProgress.test.ts
  • web/src/player/hooks/useWatchProgress.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 72e98a68-81fb-4ec9-9545-afd8a4be272a




📥 Commits

Reviewing files that changed from the base of the PR and between 2365c5c and 85480a5.





📒 Files selected for processing (19)
  • docs/admin-api.md
  • docs/playback-api.md
  • internal/api/handlers/admin_playback_commands.go
  • internal/api/handlers/admin_playback_commands_test.go
  • internal/api/handlers/admin_playback_control.go
  • internal/api/handlers/admin_playback_terminate.go
  • internal/api/handlers/admin_playback_terminate_test.go
  • internal/api/handlers/playback_service.go
  • internal/api/handlers/playback_service_test.go
  • internal/playback/planstore/postgres.go
  • internal/playback/planstore/progress_test.go
  • internal/playback/protocol_store_v3.go
  • web/src/player/components/VideoPlayer.test.tsx
  • web/src/player/components/VideoPlayer.tsx
  • web/src/player/hooks/usePlaybackSession.test.ts
  • web/src/player/hooks/usePlaybackSession.ts
  • web/src/player/hooks/useWatchProgress.test.ts
  • web/src/player/hooks/useWatchProgress.ts
  • web/src/player/player-fetch.ts




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






📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

Administrator stops now record a distinct stop identity on playback attempts. Progress and replan requests distinguish administrator-ended attempts from other stopped attempts. The player treats the ended-session response as terminal and exits playback.

Changes

Administrator-ended playback

Layer / File(s) Summary
Persist attempt stop identity
internal/playback/protocol_store_v3.go, internal/playback/planstore/postgres.go, internal/playback/planstore/progress_test.go
Attempt records store the stop ID, preserve it during replanning, and load it from PostgreSQL stop receipts.
Classify stopped attempts
internal/api/handlers/playback_service.go, internal/api/handlers/playback_service_test.go, docs/playback-api.md
The playback service returns 410 playback_session_ended for administrator-ended attempts and retains 404 session_not_found for other stopped or missing attempts. Tests cover both responses and preservation of a prior client stop receipt.
Record administrator stops
internal/api/handlers/admin_playback_commands.go, internal/api/handlers/admin_playback_commands_test.go, internal/api/handlers/admin_playback_control.go, internal/api/handlers/admin_playback_terminate.go, internal/api/handlers/admin_playback_terminate_test.go, docs/admin-api.md
Command fallback and termination paths mark attempts as stopped by an administrator. Tests and API documentation describe or verify the marker and its outcome.
Handle ended sessions in the player
web/src/player/player-fetch.ts, web/src/player/hooks/usePlaybackSession.ts, web/src/player/hooks/usePlaybackSession.test.ts, web/src/player/hooks/useWatchProgress.ts, web/src/player/hooks/useWatchProgress.test.ts, web/src/player/components/VideoPlayer.tsx, web/src/player/components/VideoPlayer.test.tsx
The player recognizes ended-session responses, stops replanning and reconnect recovery, and exits with an informational notice. Tests cover ended-session behavior and other progress errors.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant AdminPlaybackHandler
  participant PlaybackService
  participant PlanStoreV3
  participant Player
  AdminPlaybackHandler->>PlaybackService: end session and record administrator stop ID
  PlaybackService->>PlanStoreV3: StopAttempt with stop ID
  Player->>PlaybackService: request progress or replan
  PlaybackService->>PlanStoreV3: load stopped attempt
  PlaybackService-->>Player: 410 playback_session_ended
Loading

Suggested reviewers: quick104








Merge Risk: ⚪ Minimal · up to 85480

The reviewed administrator-stop behavior is ready to merge after normal checks; no actionable issue remains from this review.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 52.63% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 17 files. (2 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check Passed The title clearly identifies the playback fix for sessions that an administrator stopped while the player was unreachable.
Description check Passed The description directly explains the problem, server and web-player changes, validation results, risks, and related client changes.


Full details: Docstring Coverage

Explanation

Docstring coverage is 52.63% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 17 files. (2 skipped: 2 unsupported.)




✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR







  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

❤️ Share

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

@silo-triage silo-triage Bot added bug Something isn't working evidence-required Needs before-and-after evidence before the Evidence check passes go Pull requests that update go code impact: playback Can't play, stalls, or wrong media javascript Pull requests that update javascript code priority: P1 Core-path bug; painful workaround — next after P0 labels Oct 11, 2026
@silo-triage

silo-triage Bot commented Oct 11, 2026

Copy link
Copy Markdown

Evidence is empty, but this changes the web player's exit behavior and adds “An administrator ended this playback session.” Please add before/after desktop and phone-width web captures (or show why phone width is unaffected), plus a short recording of an administrator stopping an unreachable player: playback ends with the notice and no replacement session appears in Activity. Identify the builds used.

@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: 85480a529f

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

A stop that arrived after the replan precheck reached the replan as a
missing live session or a refused commit, both reported as 404, so the
web player renewed into a fresh session. Re-read the attempt on a 404
and answer 410 when an administrator ended it.

The web progress loop also ignores a 410 that arrives after the player
moved to another session, so a late answer for the old session cannot
end the new one.
@silo-kody

silo-kody Bot commented Oct 11, 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 ❌

@Rhainland

Copy link
Copy Markdown
Contributor Author

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

The page now has before and after recordings at desktop (1440) and phone width (390). In each, the player can't reach its control socket and an administrator stops it, with Admin > Activity shown alongside. Before: the player reconnects and a new session appears in Activity about 15 s after the stop. After: about 12 s after the stop the player is back on the title page with "An administrator ended this playback session.", and Activity stays empty. Builds: before is main c32feb1; after is a local merge of this branch (219007b) with #2281 and #2282.

The review fixes in 219007b are answered in their threads.

AI disclosure: written with Claude Code (claude-opus-5-5).

@Quick104
Quick104 merged commit 88a301a into Silo-Server:main Oct 12, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working evidence-required Needs before-and-after evidence before the Evidence check passes go Pull requests that update go code impact: playback Can't play, stalls, or wrong media javascript Pull requests that update javascript code priority: P1 Core-path bug; painful workaround — next after P0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants