Skip to content

fix(web): keep the Audio menu on a saved pick when a later pick fails - #4541

Merged
Quick104 merged 2 commits into
mainfrom
fix/audio-pick-save-before-refetch
Nov 18, 2026
Merged

Quick104 merged 2 commits into
mainfrom
fix/audio-pick-save-before-refetch

Conversation

@Quick104

@Quick104 Quick104 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: none

Other clients: Apple N/A (web-only: the defect is in the web app's save hooks); Android N/A (web-only, same reason); Roku N/A (web-only, same reason)

On a movie or episode page, the Audio menu can show Auto after the server has saved a track pick. Pick track A, then quickly pick track B. If B's save fails while the page is still reloading the item after A's save, the menu goes back to Auto. The server kept A, so the menu no longer shows what the next Play will use.

The menu counts a pick as saved when the save's mutateAsync resolves. useSetAudioPreference and useDeleteAudioPreference returned the item-detail and catalog refetch from onSuccess, so mutateAsync resolved only after those refetches finished. The write queue sends B as soon as A's request returns. When B failed first, the menu rolled back to the last pick it had recorded as saved, which was still Auto.

Approach

Both audio hooks now start the refetches in onSuccess without waiting for them, so a save counts as done when the server answers. #4538 makes the same change to the subtitle hooks. Nothing else used those mutations' pending state, and Play already waits on the write queue rather than on the mutation.

This touches trackPreferences.ts next to #4534's networkMode lines, so whichever merges second needs a small rebase.

Validation

  • Not reproduced live: the race needs the detail refetch to still be running when the second save fails, and a sandbox can't hold that reliably. A new test in EpisodeContent.test.tsx holds it. It keeps the item page's detail query open with a refetch that never finishes, saves track 1, and fails the next pick. On main the menu ends on Auto; with this change it stays on track 1.
  • Web tests for src/player, src/hooks/queries, and src/pages/ItemDetail pass (1192 tests).
  • Prettier, ESLint, and the web typecheck pass.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/audio-pick-save-before-refetch/

Risks

None identified. The item page still refetches after a save; the save just doesn't wait for it.

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 how I checked a change nobody sees.

AI Disclosure

🤖 Generated with Claude Code

Note

Fix Audio menu losing a saved pick when a later pick fails

  • The audio-preference save and reset mutation hooks no longer await item-detail invalidation in their success callbacks; the invalidation still runs, but the mutation resolves immediately.
  • This keeps a previously saved audio pick selected in the Audio menu when a later pick fails while the detail query's refetch is still pending.
  • Adds a regression test in EpisodeContent.test.tsx using a QueryObserver setup where the first detail fetch succeeds and the refetch stays pending; the renderWithTracks helper now accepts an optional QueryClient.

Macroscope summarized d5febed.

The audio preference hooks returned the item-detail refetch from onSuccess,
so mutateAsync resolved only once those refetches finished. The pre-play
Audio menu records a pick as saved when mutateAsync resolves, but the write
queue sends the next pick as soon as the HTTP write settles. A quick second
pick that failed during the first pick's refetch rolled the menu back to
the choice before the first pick, although the server kept it.

Start the refetches without waiting for them, as the subtitle hooks do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Nov 18, 2026
@silo-kody

silo-kody Bot commented Nov 18, 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 Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T23:40:01.524567Z c421b31 PR opened
🔒 Security Review ✅ Completed 2026-11-18T23:42:00.898399Z c421b31 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.

@silo-triage silo-triage Bot added bug Something isn't working impact: polish Annoyance, cosmetic, or nice-to-have priority: P2 Limited scope, workaround exists, or polish labels Nov 18, 2026
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The audio preference mutations now start item-detail query invalidation without waiting for its refetch. A test covers a successful preference save followed by a failed pick while the invalidation refetch remains pending.

Changes: Audio preference invalidation

Layer / File(s) Summary
Preference writes and pending-refetch coverage
web/src/hooks/queries/trackPreferences.ts, web/src/pages/ItemDetail/EpisodeContent.test.tsx
Both audio preference mutation success callbacks start item-detail invalidation without returning its promise. The test verifies that a later failed pick does not replace the saved track while the query refetch is pending.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

Suggested reviewers: blurbery, rhainland

Merge Risk: Minimal · up to d5feb

The audio menu now keeps a saved track selection when a later pick fails while the item page is still refreshing. The change is small and confined to the web client, and it is covered by a regression test, so merge risk is minimal.

Security architecture risk: Minimal · up to d5feb

The change aligns save completion with the successful server write rather than a background refresh. The inspected flow preserves write ordering and selection rollback without expanding access or changing preference ownership.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed completion timing remains within the existing viewer-initiated audio-preference flow. Preferences remain scoped to the acting profile and movie or series target; series choices can affect subsequent episodes. The inspected delta does not widen that resource scope.

Trust Boundaries and Controls

  • observed — The write wrapper still captures the profile request context before queueing, rejects missing context and passes the captured context to the existing PUT or DELETE request. The PR changes only the post-success refresh handling, not this identity handoff or request authority.

Resilience and Maintainability Implications

  • observed — The unchanged queue serializes writes by profile, preference dimension and target. Failed writes do not block later writes, and settled entries are removed without deleting a newer queued entry. Playback startup separately awaits pending preference writes, subject to the existing two-second bound, before requesting playback; it does not use refetch completion as its barrier.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the Audio menu keeps a saved track pick when a later pick fails. The raw summary says both audio preference mutations stop awaiting item-detail invalidation after succ…
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 is specific and related to the changeset. It explains the race in the Audio menu, names the two audio hooks (useSetAudioPreference and useDeleteAudioPreference) whose onSuccess handler…
Full details: Title check

Explanation

The title names the main change: the Audio menu keeps a saved track pick when a later pick fails. The raw summary says both audio preference mutations stop awaiting item-detail invalidation after success, which is the fix behind that behavior. The title is specific, single-sentence, and matches the changeset.

Full details: Description check

Explanation

The description is specific and related to the changeset. It explains the race in the Audio menu, names the two audio hooks (useSetAudioPreference and useDeleteAudioPreference) whose onSuccess handlers now start refetches without waiting, and describes the new regression test in EpisodeContent.test.tsx. It also lists validation steps and the reported risks.

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
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: fdb74f4a-a763-40e0-8259-c599d0e936f4
Commits

Reviewing files that changed from the base of the PR and between c421b31 and d5febed.

Files selected for processing: 1

  • web/src/pages/ItemDetail/EpisodeContent.test.tsx

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

@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.2-sol, reviewed c421b31)

One low severity finding on the regression test.

reviewed by gpt-6.2-sol via Codex in T3 Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-kody

silo-kody Bot commented Nov 18, 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 ❌
⚠️ 4 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
  • Preserve durable media identity and share identity-evidence precedence
  • Bound decoder throughput trades and share direct-play eligibility

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

Labels

bug Something isn't working impact: polish Annoyance, cosmetic, or nice-to-have priority: P2 Limited scope, workaround exists, or polish size/M 50–199 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant