Skip to content

fix(player): keep the resume point when playback stops early - #765

Merged
Quick104 merged 2 commits into
mainfrom
fix/player-early-end-resume
Nov 14, 2026
Merged

Quick104 merged 2 commits into
mainfrom
fix/player-early-end-resume

Conversation

@Quick104

@Quick104 Quick104 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A (split from #611)
Validation tasks: none
Other clients: Android N/A (an early end of a response is a retryable error, closing reports the player position with no Next Up rounding, and Keep Watching only hides the card); Roku Silo-Server/silo-roku#73 (fix in Silo-Server/silo-roku#75); Web N/A (reports the element position, has no prompt-window completion rule, and the post-roll after an end has no way back into the ended player)

When the source stops before the end of an item, the player parks on the "Connection lost" postroll. Two paths from there still lose the resume point:

  • Closing inside the Next Up window marks the item watched. The postroll shows Next Up, and the completion check falls through to the prompt-window rule. Stopping at 175 of 200 seconds with the default 30-second prompt reports 200 and marks the item watched. This affects items short enough that the last 1.5% is shorter than the prompt (under about 33 minutes at the default prompt).
  • Back jumps to the last 10 seconds. Back (Keep Watching) seeks to duration - 10 even after a stop at 20:00 of 60:00. Aether ignores seeks on an ended session, but the player still moves its playhead to the target, so closing afterwards reports about 99.7% and the server marks the item watched. After a natural end the same seek leaves the player stopped behind a dismissed postroll.

Approach

  • An end short of the end of the item (reachedEndPrematurely) no longer counts as reaching the Next Up prompt. Skipping credits that run to the end still finishes the item.
  • Keep Watching from the end-of-playback screen now remounts the item: where the source stopped after an early end, or a 10-second tail after a natural end. The remount is the reload Watch Party already used, generalised to remountCurrentPlayback(at:origin:). It asks for the version, audio and subtitles playing now, and a download stays local.
  • The remount keeps the viewer's choices about the item: skipped credits, a dismissed Next Up prompt, and cancelled autoplay. The credits auto-skip latch is now keyed on the content, file and marker rather than the session (matching the intro key), so the replayed tail does not skip the credits again. A credits skip the playhead has since left is resolved before the remount, so it can't finish an item that stopped early.
  • After an early end, the cancelled autoplay that the dropped stream set does not carry into a mid-item resume, so the real end still offers Next Up, even with the prompt turned off. A cancel the viewer made earlier still holds.
  • Back on the "Connection lost" postroll resumes even when the transport is already gone, rather than closing the player.
  • Back never remounts a session an administrator ended, or one a stop from an administrator or a remote is closing. It closes the player as before.
  • A failed remount shows the same error and Retry as a failed manual start. Until the remount shows a frame, Retry remounts at the same position and keeps the viewer's choices, however the load failed: a failed start, a route recovery, a failure after the load committed, or a failed session renewal. A reconnect or renewal of that remount keeps the choices too, and a seek during the reconnect moves the Retry position. A successful retry does not reopen Next Up, start autoplay, or skip the credits again.
  • Closing while the remount of a finished episode loads moves its Series page on to the next episode, as closing from the end screen does.

This does not reopen a source automatically after an early end. That is a separate design decision.

Rebased onto main at 55da563 (squashed). #764's recap latch is keyed on the content and survives a same-item reload, so the remount keeps it without a ViewerChoices field. Main's credits latch is now a set (#915); ViewerChoices carries that set.

Validation

Focused XCTest classes at e85fad1, each run on this task's own simulators with Xcode 27.2: PlayerPrematureEndReopenTests, PlayerNextUpCompletionPolicyTests, CreditsAutoSkipPolicyTests, PlaybackReconnectTests, WatchPartyEndOfFileTests, SeriesPlaybackReturnTests, PlayerStillWatchingGuardTests, RecapAutoSkipPolicyTests.

With main's completion rule and main's Keep Watching seek restored and the new tests kept, 9 of the 13 new tests fail on iOS. The 4 that pass either way cover guards: an administrator-ended session, a stop already closing the player, the viewer's own autoplay cancel, and skipped credits.

Checked live at 7d85d57 on an iOS 27.0 simulator against a sandbox running main's server, before (main 55da563) and after. The test episode's file was cut by bytes: its header says 3:20, but the data ends at about 2:52, so a direct-play stream ends cleanly before the end of the item. On current main this is the case that still reaches the end-of-playback screen, because main's end-of-stream reconnect (#802) applies only to a stalled source or a remux or transcode.

  • Closing from that screen: before, the server marked the episode watched; after, it kept the resume point at 2:52.
  • Back on that screen, with the full file put back: before, the picture froze with the Play button showing while the elapsed time ran past the end; after, playback resumed at the stop point and played on.
  • Back after a natural end (after only): it replayed from 3:10 and returned to the end screen without an autoplay countdown.

e85fad1 changes two paths the captures don't reach: a seek made while the remount prepares now moves the Retry position, and Back on a download saves the stop point locally first. Both were checked by reading the code. The unit-test player can't reach them, because it has no first frame and no download context.

Not verified live: a stream dropped by the network mid-session, an administrator or remote stop during Back, Retry after a failed remount, and a reconnect or renewal during the remount.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-apple/pr-765/

After the stream stops early, closing the player keeps the resume point where it stopped instead of marking the item watched, and Back on the "Connection lost" screen resumes from there instead of the last 10 seconds. After a natural end, Back replays the last 10 seconds instead of leaving the player stuck on the last frame.

Risks

  • Keep Watching after a natural end now starts a new session for the 10-second tail instead of seeking the ended one. This costs one start-session round trip.
  • The Watch Party remount now asks for the audio and subtitles playing now, not the tracks of the request that opened playback.
  • The credits auto-skip latch now survives a session change within the same item, including a protocol-v3 replan.
  • On a short item whose pre-end Next Up prompt was already showing when the source dropped, closing now reports the position reached rather than the duration. This only changes the watched state for items of about 5 minutes or less at the default prompt.

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 (in T3 Code), with Claude Code subagents
  • Tool(s): Claude Code, Codex (cross-provider review)
  • Model(s): claude-opus-5-5, gpt-6.1-sol
  • Involvement: Fully AI-generated, not yet human verified
  • Adversarial review: gpt-6.1-sol (Codex harness in T3 Code) reviewed 5184ac4 and found one problem: Retry after a failed Keep Watching dropped the viewer's choices and resumed at the very end. Fixed in 1f16c37. An independent Claude Opus review found no blocking issues; Keep Watching now waits for the server like a manual start, as it suggested. A /silo review of 1f16c37 (claude-opus-5-5) found five more, fixed in d9a6362. Two further gpt-6.1-sol rounds on d9a6362 and c074bf8 found four gaps in those fixes, fixed in c074bf8 and fbf212e. After the rebase onto main, a /silo review of 7d85d57 (claude-opus-5-5 subagents) and a gpt-6.1-sol round found that Retry dropped a seek made while the remount prepares (CodeRabbit flagged it as well) and that a download's stop point could be lost during the remount. Both are fixed in e85fad1.

🤖 Generated with Claude Code

Note

Keep the resume point in PlayerViewModel when playback stops early

  • Fixes premature stream ends inside the Next Up prompt window reporting the item duration as progress. PlayerNextUpCompletionPolicy.shouldFinalizeAsCompleted and progressPosition now take an endedPrematurely input and return the stopped position instead of finalizing, though EOF and skipped credits still complete the item.
  • keepWatchingCurrentEpisode now remounts a prematurely ended item through a fresh load at the stopped position instead of seeking the dead session. It refuses to remount when a remote stop is closing the player or the session was administrator-ended.
  • Adds a resumeAfterEnd load origin. beginFreshLoad preserves viewer choices (credits skip, Next Up choices) and the pending remount resume position across the remount, recovery, and reconnect loads; retries of a failed remount reuse the pending position, and a seek during the remount updates it.
  • remountCurrentPlayback generalizes the Watch Party remount path and can retain the offline download ID and selected audio track. The credits-skip key now uses content ID and file ID so it survives a remount into a new session.
  • Series return completion during teardown now follows the same premature-end rules, and seriesPlaybackReturn only marks a loading episode completed when it matches the last recorded episode.
  • Risk: PlayerViewModel.endedPrematurely drives progress reporting in cleanup and the completion policy — check that offline progress writes and series return marks match the stopped position, not the duration. Also makeRecoveryLoadRequest defaults to clearing the download ID; only Keep Watching passes keepingDownload.

Macroscope summarized e85fad1.

@silo-kody

silo-kody Bot commented Oct 13, 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 commented Oct 13, 2026 •

Copy link
Copy Markdown

Explain Change →

Walkthrough

The player now distinguishes premature stream endings from completed playback. Keep Watching can remount the current item and retain viewer choices and resume position. Recovery supports offline downloads and Watch Party seeks from EOF.

Changes: Player End Recovery

Layer / File(s) Summary
Premature-end completion policy
iosApp/iosApp/Screens/Player/PlayerNextUpCompletionPolicy.swift, iosApp/iosApp/Screens/Player/PlayerViewModel.swift, iosApp/Tests/PlayerNextUpCompletionPolicyTests.swift, iosApp/Tests/PlayerPrematureEndReopenTests.swift
The completion policy now accepts endedPrematurely. PlayerViewModel passes that state to completion calculations. Tests cover prompt-window behavior and completion after credits are skipped.
Keep Watching remount and carried state
iosApp/iosApp/Screens/Player/PlayerViewModel.swift, iosApp/Tests/PlayerPrematureEndReopenTests.swift
Keep Watching can start a fresh load after an end when session and load-request checks allow it. The remount carries viewer choices and resume position. Retry handling and tests cover stop conditions, remount failures, and retained state.
Shared remount, downloads, and Watch Party
iosApp/iosApp/Screens/Player/PlayerViewModel.swift, iosApp/Tests/PlayerPrematureEndReopenTests.swift
A shared remount path supports playback recovery and Watch Party seeks from EOF. Recovery requests can retain offline-download context. Tests cover the selected audio track during a download remount.

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

Change: Bug fix

Suggested reviewers: blurbery

Merge Risk: Low · up to 7d85d

After Back from an ended item, a viewer's secondary subtitle track is dropped and must be re-selected. If a remount fails after the viewer has seeked during preparation, Retry returns to the earlier stop point rather than the new seek. Both are small, recoverable glitches, so this is mergeable once the owner is aware of them.

Security architecture risk: Minimal · up to 7d85d

The inspected recovery flow preserves the current item's identity, respects administrator and remote stops, and uses cancellation and cleanup controls when replacing playback. No introduced risk materially affecting security, failure containment or ownership was established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — The added Keep Watching remount accepts no new content identifier. It reconstructs the request from the current playback's content and library identity, selected file and tracks, and existing download identifier. Its directly changed state is the current item's playback and resume/completion state.

Trust Boundaries and Controls

  • observed — Keep Watching is rejected during Watch Party playback. End remounts also reject a known administrator-ended session, a pending remote stop, or a missing load request before dismissing the postroll. The shared remount and fresh-load entry both reject a disposed owner.

Resilience and Maintainability Implications

  • observed — Remount inherits fresh-load cancellation, epoch retirement and generation checks. Abandoned provisional loads are rolled back, while cleanup cancels replacement work and advances the stream generation. These controls constrain stale loads from taking ownership after replacement or player exit.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(player): keep the resume point when playback stops early" matches the main change. The PR stops a premature end from counting as reaching the Next Up prompt, and it makes Keep Watching …
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 description states the problem (premature stream ends losing the resume point through Next Up completion and Back/Keep Watching seeks), the approach (remount via remountCurrentPlayback, ViewerChoi…
Full details: Title check

Explanation

The title "fix(player): keep the resume point when playback stops early" matches the main change. The PR stops a premature end from counting as reaching the Next Up prompt, and it makes Keep Watching remount playback at the stop point. The title is specific and describes the primary fix from the developer's perspective.

Full details: Description check

Explanation

The description states the problem (premature stream ends losing the resume point through Next Up completion and Back/Keep Watching seeks), the approach (remount via remountCurrentPlayback, ViewerChoices, endedPrematurely completion rule), validation, and risks. It is specific and directly related to the changeset.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-triage silo-triage Bot added bug Something isn't working evidence-required Needs before-and-after evidence before the Evidence check passes impact: playback Can't play, stalls, or wrong media needs-review Needs maintainer review to resolve uncertain classification, scope, or changed evidence. priority: P1 Core-path bug; painful workaround — next after P0 triaged High-confidence review completed; does not mean fixed, validated, or accepted for release. labels Oct 13, 2026
@silo-triage

silo-triage Bot commented Oct 13, 2026

Copy link
Copy Markdown

Evidence is incomplete for the described user-visible change. Please attach or publish before-and-after captures of the same playback/postroll flow with the same content and build/commit, showing that an early stop keeps the resume point and that Keep Watching resumes from that point rather than the last 10 seconds. Include a short recording if the postroll interaction or remount timing is material.

// play does not revive it. Remount at a playable position: a
// short tail of a finished episode (resuming at exact EOF would
// end again at once), or where a lost source stopped.
let target = max(0, min(currentTime, duration - 10))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Kody Rules high

When the stop was premature, preserve the observed resume position and reserve the ten-second rewind for a natural end; otherwise a premature stop near the end is moved backward and the saved resume point is wrong.

Kody rule violation: Preserve playback intent across reconnects and replacement loads

let target = endedPrematurely
    ? max(0, min(currentTime, duration))
    : max(0, duration - 10)
Prompt for LLM

File iosApp/iosApp/Screens/Player/PlayerViewModel.swift:

Line 3148:

When the stop was premature, preserve the observed resume position and reserve the ten-second rewind for a natural end; otherwise a premature stop near the end is moved backward and the saved resume point is wrong.

Suggested Code:

            let target = endedPrematurely
                ? max(0, min(currentTime, duration))
                : max(0, duration - 10)

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This one doesn't hold up. isBeforeNaturalEnd only counts a stop as premature when more than 8 s and more than 1.5% of the item remain. So min(currentTime, duration - 10) can only move a premature target back by less than 2 s, and only on items shorter than about 11 minutes. The saved resume point is unaffected: completionProgressPositionForCurrentItem reads currentTime, not this target. Replaying under 2 s before the stop point is harmless, so I'm leaving the code as it is.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You're right—this is a false positive.

  • With more than 8 seconds and more than 1.5% remaining, this expression can rewind a premature stop by less than 2 seconds, and only for items shorter than roughly 11 minutes.
  • The completion report reads currentTime, not the local remount target. My claim that this expression corrupts the saved resume point was unsupported.

That bounded replay does not justify a high-severity finding or establish a violation of the playback-intent rule. I withdraw the recommendation; leaving the code unchanged is reasonable.

@silo-kody

This comment has been minimized.

resumePosition: resumePositionOverride,
allowNearEndResume: allowNearEndResume,
timeout: origin == .userInitiated ? nil : Self.autoplayStartSessionTimeout
timeout: origin == .userInitiated || origin == .resumeAfterEnd

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Kody Rules high

Unbounded timeout on the nil branch allows a replacement/recovery load triggered by resumeAfterEnd to wait indefinitely if the session stalls. Keep resumeAfterEnd on the finite Self.autoplayStartSessionTimeout branch.

Kody rule violation: Preserve playback intent across reconnects and replacement loads

timeout: origin == .userInitiated
Prompt for LLM

File iosApp/iosApp/Screens/Player/PlayerViewModel.swift:

Line 5065:

Unbounded timeout on the `nil` branch allows a replacement/recovery load triggered by `resumeAfterEnd` to wait indefinitely if the session stalls. Keep `resumeAfterEnd` on the finite `Self.autoplayStartSessionTimeout` branch.

Suggested Code:

                        timeout: origin == .userInitiated

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is intentional. 5184ac4 made Keep Watching wait for the server the way a manual start does: the viewer asked to keep watching, and a 15 s cutoff would turn a slow server into an error that a manual start wouldn't show. The start isn't unbounded in practice either. The API client's request timeout (HTTPClient.makeSession, timeoutIntervalForRequest) fails a dead server quickly, and that failure shows the error and Retry. The viewer can also close the player at any time while it loads. Leaving it as is.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Agreed—Keep Watching is an explicit viewer action, not autoplay, so matching manual-start timeout behavior is intentional. Given the HTTP request timeout and error/Retry handling you described, my “unbounded wait” claim was too strong. I don’t recommend adding the 15-second autoplay cutoff here.

No code, rules, or memories have been changed. If useful, I can save this distinction as repository guidance for future reviews: viewer-requested Keep Watching uses manual-start timeout behavior rather than the autoplay deadline.

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Adversarial review (gpt-6.1-sol, reviewed 5184ac4)

One verified finding from static source analysis. Xcode and device execution were unavailable on this host.

AI disclosure: reviewed by gpt-6.1-sol through the Codex harness in T3 Code.

PosterImageCache.trimDecodedMemory()
#endif
isNextUpTransitioning = origin == .autoplay && showNextUpScreen
let carriedViewerChoices = origin == .resumeAfterEnd ? viewerChoices : nil

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

[P2] Preserve Keep Watching choices when its failed remount is retried

After a natural end, choose Keep Watching, let the new start-session request fail transiently, then press Retry. The first remount carries viewerChoices, but retry() calls beginFreshLoad with the default .userInitiated origin, so this condition drops them. resetPublishedLoadState clears nextUpPromptDismissed, nextUpAutoplayCancelled, and autoSkippedCreditsKey; the successful-load restoration also has no snapshot to restore. With the default 30-second prompt, the resumed ten-second tail immediately qualifies for updateNextUpPresentation, reopening Next Up and enabling autoplay despite Keep Watching. With automatic credits skipping enabled, the cleared marker latch also permits the tail to be skipped again. Carry the same-item resume intent and its choices through Retry until playback succeeds, and cover failure followed by a successful retry. The new tests stop at the first remount failure, so they do not exercise this transition.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed and fixed in 1f16c37. When a Keep Watching remount fails, the player now records the position it was resuming to, and Retry repeats that remount with the .resumeAfterEnd origin, so the viewer's choices carry over. It also fixes a second problem: Retry used to resume from currentTime, which is still at the very end after a natural finish, so playback ended again at once. testRetryAfterAFailedRemountKeepsTheViewersChoices failed before the fix and passes now; iOS and tvOS 49/49, macOS build.

@silo-kody

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

Comment on lines +5251 to +5253
if origin == .resumeAfterEnd {
self.failedResumeAfterEndPosition = resumePositionOverride
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug medium

Resume-state loss occurs when Keep Watching failures enter protocol-V3 route recovery and return from beginFreshLoad before recording failedResumeAfterEndPosition; if recovery exhausts its retryable route ladder, retry() falls back to the ordinary load origin and resets the viewer's credits and Next Up choices. Retain the remount position and origin before handing off to recovery, and clear them only after successful playback or an unrelated load.

Prompt for LLM

File iosApp/iosApp/Screens/Player/PlayerViewModel.swift:

Line 5251 to 5253:

Resume-state loss occurs when Keep Watching failures enter protocol-V3 route recovery and return from `beginFreshLoad` before recording `failedResumeAfterEndPosition`; if recovery exhausts its retryable route ladder, `retry()` falls back to the ordinary load origin and resets the viewer's credits and Next Up choices. Retain the remount position and origin before handing off to recovery, and clear them only after successful playback or an unrelated load.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed. When the Keep Watching remount's start succeeds but its first route fails to open, the catch hands off to attemptProtocolV3Replan and returns before this line records the position. A replan that then fails terminally, or a failure after the load commits (through handleAetherFailure), reaches the error with no position recorded, so Retry runs an ordinary reload: the viewer's choices reset, and in a replayed tail the Next Up prompt and autoplay come back and credits auto-skip can fire again.

A reconnect or session renewal started from that failure has the same problem: it reloads with its own origin and resets the choices.

I'm fixing it in a commit on this branch: the position is recorded when the Keep Watching load starts, kept through a reconnect or renewal of that load, and cleared at its first frame or by any other load. Retry, reconnect, and renewal all carry the viewer's choices until the remount plays.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That plan addresses the gap. Start-session success or load commit is not enough to consider the remount successful—the pending resume position and viewer choices need to survive until its first frame, including across replan, reconnect, and session renewal.

The regression cases worth covering are:

  • First-route open failure → exhausted replan → Retry preserves the remount position and viewer choices.
  • Post-commit handleAetherFailure before the first frame → Retry preserves the same context.
  • Reconnect or renewal while the remount is pending → choices remain intact.
  • The remount’s first frame clears the pending context; an unrelated load clears it without inheriting those choices.

For the recovery cases, assert that dismissed Next Up stays dismissed, canceled autoplay stays canceled, and credits do not auto-skip again. That would directly cover the paths missing from the original failure tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in d9a6362, c074bf8 and fbf212e. pendingResumeAfterEndPosition (renamed from failedResumeAfterEndPosition) is set when the Keep Watching load starts and cleared at its first frame or by any other load. A reconnect or session renewal of that remount keeps it and the viewer's choices, a seek during the reconnect moves it, and a failed renewal shows the error and Retry. testKeepWatchingAfterTheEndRemountsTheItem checks the position is held from the start; the reconnect and renewal paths were checked by reading the code, since the tests can't stage a reconnect. iOS and tvOS 70/70 on the focused classes, macOS builds; the new tests fail against 1f16c37's production code.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I checked the relevant code at the current PR head, fbf212e5. This addresses the original resume-state-loss suggestion.

  • beginFreshLoad sets pendingResumeAfterEndPosition synchronously, before any asynchronous work or protocol-V3 recovery handoff.
  • Failure teardown leaves that position intact, so retry() selects .resumeAfterEnd instead of an ordinary reload.
  • Same-content reconnect and renewal loads preserve the pending context and restore ViewerChoices after both the published-state reset and the session/Next Up setup. Reconnect seeks also update the pending position.
  • A failed renewal continuing the remount uses the remount’s error handling. The current load’s startup milestone clears the position; an unrelated fresh load clears it without carrying the choices.

The immediate assertion in testKeepWatchingAfterTheEndRemountsTheItem directly guards the original late-recording bug.

The validation distinction remains important: the reported 70/70 runs and failures against the older production code support the tested regressions, but reconnect/renewal and successful first-frame cleanup remain code-reviewed rather than exercised. I haven’t run those tests myself.

No further blocking feedback from me on this finding. Injected session/engine tests for those recovery paths would strengthen future coverage.

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Review of 1f16c37 (/silo review, Claude Code with claude-opus-5-5, plus a gpt-6.1-sol round on the follow-up commits).

Four findings below, all in the Keep Watching remount. A fifth, Retry losing the Keep Watching state when the failure goes through route recovery, is Kody's comment on line 5253, so I answered it there. I'm fixing all five in a commit on this branch, so there's no need to change them yourself.

Kody's comments on lines 3152 and 5070 don't hold up; the reasons are in their threads.

@silo-kody

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

@Quick104

Quick104 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor Author

/silo review summary

Reviewed 7d85d57, this branch rebased onto main at 55da563. Fixes are pushed through e85fad1. The branch was rewritten: the six earlier commits were squashed and rebased to resolve 8 conflicts in PlayerViewModel.swift.

Fit: 8/10 · Readiness: 8/10 — conditional (assuming CI is green)

Rebase

Addressed

Found on the rebased head and fixed in e85fad1:

  • Medium (CodeRabbit, line 7462; also found by gpt-6.1-sol): a seek made while the Keep Watching remount prepared went into main's newer held-seek path, which didn't move the Retry position. A failed remount then retried at the old position.
  • Low (gpt-6.1-sol): after Back on a download, closing before the remount prepared wrote no local progress, so the download kept an older resume point.

Remaining

  • CodeRabbit's secondary-subtitle comment (line 4226) holds, but every same-item fresh load on main clears the secondary subtitle, not only this remount. It's left open as a follow-up for same-item reloads in general.
  • No human has checked "I read and can explain the complete diff" yet.
  • Roku and Web parity haven't been checked. Android doesn't need the change.
  • Unchanged older behavior: other same-item reloads, such as a renewal or reconnect during ordinary playback, still reset the viewer's Next Up and credits choices.

Verification

  • XCTest at e85fad1, 8 focused classes: iOS 83/83 and tvOS 83/83, both on simulators. SiloMac builds. The tvOS run excluded BrowseCollectionGridTests.swift locally because it breaks the tvOS test target on main ([bug] SiloTV tests don't compile: BrowseCollectionGridTests uses iOS-only types #1168, test(tvos): build the tvOS test bundle again #1169).
  • With main's completion rule and main's Keep Watching seek restored, 9 of the 13 new tests fail. The other 4 cover guards that hold either way.
  • Live at 7d85d57 on an iOS 27.0 simulator against a sandbox running main's server. The test episode's file was cut by bytes, so its direct-play stream ends at about 2:52 of 3:20.
    • Closing from the end screen marked the episode watched on main and kept the resume point on this PR.
    • Back froze the picture on main while the clock ran past the end. On this PR it resumed from the stop point.
    • Back after a natural end replayed the last seconds on this PR.
  • e85fad1's two fixes were checked by reading the code. The unit-test player can't reach those paths.

Evidence: https://evidence.siloserver.org/r/silo-apple/pr-765/

Validated features

None affected. No passed v1.0 case covers end of playback, watched state, the resume point, Keep Watching, credits skip, reconnect, downloads or the Series page return. Validation tasks: none.

User manual

No change needed. The watch-history page already says playback saves your resume point, and no page covers the end-of-playback screen or Keep Watching.

Scores

  • Fit 8/10: this keeps resume points and doesn't mark unfinished items watched, which is core playback correctness. What holds it down: the remount carries the viewer's choices with dedicated state, rather than making every same-item reload keep them the way intro and recap decisions already are.
  • Readiness 8/10: both fixes are shown live on the rebased head, the new tests fail on main's code, and the review findings are fixed. What remains is human review of the diff and the Roku and Web parity check.

AI disclosure: reviewed by Claude Code (claude-opus-5-5) with Claude Code subagents, plus a gpt-6.1-sol round through Codex in T3 Code.

🤖 Generated with Claude Code

When the source stops before the end of an item, closing inside the Next
Up window no longer marks it watched, and Keep Watching remounts the item
where the source stopped (or a 10-second tail after a natural end) instead
of seeking the ended session to its last 10 seconds. The remount keeps the
viewer's choices about the item, and Retry, reconnects and renewals of it
keep them too.

Squashes e492f48..fbf212e for the rebase onto main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Quick104
Quick104 force-pushed the fix/player-early-end-resume branch from fbf212e to 7d85d57 Compare November 14, 2026 18:55
@silo-triage silo-triage Bot added the size/XL 500–999 added + deleted lines (all files); change volume, not priority. label Nov 14, 2026
@silo-kody

silo-kody Bot commented Nov 14, 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 ❌

@macroscopeapp

macroscopeapp Bot commented Nov 14, 2026

Copy link
Copy Markdown

The described evidence covers preserving progress on close and Keep Watching after early and natural ends, but not the changed failed-remount Retry flow (retrying from the held resume position while keeping the viewer's Next Up and credits choices). Please add a recording of that failure-and-retry flow. The linked evidence page should show the affected playback behavior on iPhone, iPhone Duo folded and open, iPad, Mac, and Apple TV; the shared player code reaches all of these targets.

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

Posted via Macroscope — Visible change evidence

@coderabbitai coderabbitai 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.

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: 7f093ea5-d0ca-46df-b17f-2ecf83b693c5
Commits

Reviewing files that changed from the base of the PR and between 5184ac4 and 7d85d57.

Files selected for processing: 2

  • iosApp/Tests/PlayerPrematureEndReopenTests.swift
  • iosApp/iosApp/Screens/Player/PlayerViewModel.swift

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

// does: the remount has no credits marker until it loads, and a
// skip the playhead has since left must not finish the item.
didSkipCreditsToEnd = skippedCreditsToEnd
remountCurrentPlayback(at: target, origin: .resumeAfterEnd)

@coderabbitai coderabbitai Bot Nov 14, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Minor · Functional Correctness · Quick win

Preserve the secondary subtitle selection during the remount.

When the viewer has a secondary subtitle selected, this remount calls resetPublishedLoadState, which clears selectedSecondarySubtitleId at Line 6056. Neither the recovery request nor ViewerChoices restores that selection. Back therefore removes the secondary subtitles after either kind of end.

Carry the secondary selection identity through the remount and restore it after the replacement inventory is available.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This holds, but it isn't specific to Keep Watching. Every fresh load clears the secondary subtitle in resetPublishedLoadState, including main's other same-item reloads: route recovery, session renewal and a reconnect's new session. Before this PR, Back seeked the ended session in place, which kept the secondary track but left the player frozen. I'm leaving this open as a follow-up for same-item reloads in general rather than adding a Keep Watching-only carry here.

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

🤖 Generated with Claude Code

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Review of 7d85d57, the rebase of this branch onto main (/silo review with Claude Code subagents, plus a gpt-6.1-sol round through Codex in T3 Code).

One new finding is below. The other real one, Retry dropping a seek made while the remount prepares, is CodeRabbit's comment on line 7462; I answer it in that thread. Both get fix commits on this branch, so there's no need to change them yourself.

AI disclosure: reviewed by Claude Code (claude-opus-5-5) and gpt-6.1-sol (Codex in T3 Code).

🤖 Generated with Claude Code

…rough the remount

A seek made while the Keep Watching remount prepares now moves the Retry
position, as a seek during its reconnect already did. Back on a download
saves the stop point locally before the remount clears the download's
progress context, so closing before it prepares keeps that resume point.

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

silo-kody Bot commented Nov 14, 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 ❌

Comment on lines 8074 to +8076
freshLoadHeldSeek = (clampedTarget, roomCommand)
// A Keep Watching remount that has not played retries here too.
if pendingResumeAfterEndPosition != nil { pendingResumeAfterEndPosition = clampedTarget }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug medium

Closing during an offline remount loses a held seek

Closing before preparation restores offlinePlaybackContext loses the held seek, so playback resumes at the old position. Retain the offline context and persist the held seek during teardown.

Prompt for LLM
File iosApp/iosApp/Screens/Player/PlayerViewModel.swift, lines 8074-8076:

Closing during an offline remount loses a held seek

A seek during an offline Keep Watching remount updates the pending retry position but leaves the saved offline position at the pre-remount value. If the viewer closes before preparation restores `offlinePlaybackContext`, teardown cannot persist the seek and the next playback resumes at the old position; retain the offline context and persist the held seek on teardown.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

@Quick104
Quick104 merged commit 08ff656 into main Nov 14, 2026
5 checks passed
@Quick104
Quick104 deleted the fix/player-early-end-resume branch November 14, 2026 19:52
Quick104 added a commit to Darhole/silo-apple that referenced this pull request Nov 14, 2026
With Back now closing the player, nothing on the Up Next screen resumed
an episode whose stream stopped early: the screen opens in its ended
state, which hid Keep Watching, and Back had been the resume control
there since Silo-Server#765. iPhone and iPad have no Menu button to fall back on.

Keep Watching now shows after an early end that can be remounted, and
takes default focus there. After a natural end, or once an administrator
ended the session, the screen still offers Back alone. The Silo-Server#765 tests
now describe Keep Watching rather than Back.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 impact: playback Can't play, stalls, or wrong media needs-review Needs maintainer review to resolve uncertain classification, scope, or changed evidence. priority: P1 Core-path bug; painful workaround — next after P0 size/XL 500–999 added + deleted lines (all files); change volume, not priority. triaged High-confidence review completed; does not mean fixed, validated, or accepted for release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant