Skip to content

feat(catalog): show profile-controlled advisory ages - #587

Merged
Quick104 merged 6 commits into
Silo-Server:mainfrom
pceiley:feat/advisory-age-display
Oct 5, 2026
Merged

Quick104 merged 6 commits into
Silo-Server:mainfrom
pceiley:feat/advisory-age-display

Conversation

@pceiley

@pceiley pceiley commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Apple clients receive advisory-age metadata but did not consistently expose the profile preference or display the resulting badge across detail and poster surfaces.

This adds the profile display toggle and shows advisory age on iOS, tvOS, and macOS item details and poster overlays. The preference store pins reads and writes to the active server/profile identity and rejects stale responses after profile changes.

This addresses the display portions of #416 and #548. Profile access limits and enforcement remain separate work.

Validation

  • Focused iOS AdvisoryAgePreferenceStoreTests: 6 passed
  • iOS simulator build and authenticated UI verification: passed
  • tvOS simulator build using scheme SiloTV and authenticated UI verification: passed
  • ARM64 macOS build using scheme SiloMac: passed
  • git diff --check: passed

The macOS build used an explicit ARM64 destination because the current media dependencies do not provide local x86_64 macOS modules under Xcode 27.

Evidence

iOS film detail — before and after

With Show Advisory Age disabled, only the content rating appears. When enabled, the advisory-age badge appears beside it.

DisabledEnabled
iOS film detail with advisory age disabled iOS film detail with Common Sense 9+ advisory age

Poster overlays

Advisory ages appear alongside the existing quality and IMDb overlays on iOS and tvOS.

iOS poster advisory-age overlays tvOS poster advisory-age overlays

tvOS profile setting

The profile-scoped toggle appears under General → Cards & Posters.

tvOS Show Advisory Age setting enabled

Coordination

  • Server changes: none; this consumes the existing settings contract and catalog fields.
  • Android changes: none required for this Apple-client display patch.

Risks and follow-up

  • Servers whose settings contract predates catalog.show_advisory_age keep the preference and badges hidden.
  • Advisory-age access limits and enforcement remain follow-up work outside this PR.

Review fixes

A maintainer review added four commits (103aabbc, 7e22a445, f3a146df, 3f296716):

  • The preference re-reads when General settings opens and on the first detail page after the app returns to the foreground; a passing "unavailable" settings answer no longer hides it for the session.
  • The toggle shows the new value while saving, rolls back on failure, and explains why under the row on iOS, macOS and tvOS. It stays hidden until the profile's value has loaded.
  • Detail pages without a rating chip no longer render an empty chip stack that pushed the metadata 4pt off centre.
  • A read in flight at foreground, or a failed save, leaves the next read due so the toggle reconciles with the server.

Verified on iOS 27 and tvOS 27 simulators against a dev sandbox, before and after; AdvisoryAgePreferenceStoreTests now has 15 cases (iOS 28 and tvOS 30 focused tests pass), and SiloMac builds.

Validation tasks: none

Android parity: Silo-Server/silo-android#375 (detail badge and toggle) and Silo-Server/silo-android#416 (poster badge).

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

AI Disclosure

  • Harness: OpenAI Codex
  • Tool(s): Codex coding agent
  • Model(s): GPT-6
  • Involvement: AI-assisted
  • Adversarial review: Codex reviewed the complete diff for scope, request-identity safety, stale asynchronous responses, focused tests, documentation, and platform compilation. The review found stale-response races and outdated comments; both were resolved, and regression tests were added.
  • Maintainer review: Claude Code (claude-opus-5-5) reviewed the PR, with a cross-provider pass by Codex (gpt-6.1-sol), and wrote commits 103aabbc, 7e22a445, f3a146df and 3f296716.

Note

Add profile-controlled advisory-age badges and settings toggle

  • Adds a new advisory_age overlay (disabled by default, users icon, bottom-right) that shows a source-attributed age badge such as "Common Sense 14" on browse cards, section cards, and detail screens on iOS and tvOS
  • Adds AdvisoryAgePreferenceStore, a shared main-actor store that checks server settings capabilities, reads the profile's effective value via SiloAPI, and writes the profile-scoped boolean optimistically with rollback and error messages on failure
  • General settings on both platforms show a "Show Advisory Age" toggle only for supported servers, hidden until the value loads
  • Server responses now carry advisory age and source through CatalogItemDetail, BrowseItem, SectionItem, and ItemDetail; an advisory age that cannot be converted to the legacy integer representation causes the catalog projection to throw
  • Risk: profile transitions and sign-out now clear advisory-age state and invalidate pending writes via generation checks; foreground transitions mark the store stale, so the next detail or settings view triggers a fresh network read

Macroscope summarized 103aabb.

@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

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: ade92e7a-5c65-40a2-bf3c-f674d7580c24
📥 Commits

Reviewing files that changed from the base of the PR and between 6d751db and ebfa847.

📒 Files selected for processing (20)
  • iosApp/Tests/AdvisoryAgePreferenceStoreTests.swift
  • iosApp/Tests/DisplayRatingTests.swift
  • iosApp/iosApp/Networking/APIv2/APIv2CatalogReadModels.swift
  • iosApp/iosApp/Networking/APIv2/APIv2CatalogReadProjection.swift
  • iosApp/iosApp/Networking/AdvisoryAgePreferenceStore.swift
  • iosApp/iosApp/Networking/Models.swift
  • iosApp/iosApp/Overlays/OverlayExtractors.swift
  • iosApp/iosApp/Overlays/OverlayIcon.swift
  • iosApp/iosApp/Overlays/OverlayRegistry.swift
  • iosApp/iosApp/Overlays/OverlayTypes.swift
  • iosApp/iosApp/Screens/Auth/AuthService.swift
  • iosApp/iosApp/Screens/Detail/ItemDetailViewModel.swift
  • iosApp/iosApp/Screens/Detail/Phone/PhoneDetailHero.swift
  • iosApp/iosApp/Screens/Settings/GeneralSettingsView.swift
  • iosApp/iosApp/tvOS/Screens/Detail/TVDetailHero.swift
  • iosApp/iosApp/tvOS/Screens/Detail/TVItemDetailView.swift
  • iosApp/iosApp/tvOS/Screens/Detail/TVMovieDetailView.swift
  • iosApp/iosApp/tvOS/Screens/Detail/TVSeriesDetailView.swift
  • iosApp/iosApp/tvOS/Screens/Settings/TVGeneralSettingsView.swift
  • iosApp/iosApp/tvOS/Screens/Settings/TVSettingsView.swift

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


📝 Walkthrough

Walkthrough

The iOS and tvOS apps now carry advisory-age metadata into detail overlays. A shared profile-scoped preference controls whether detail views show advisory-age badges. Settings expose the preference when the server reports support.

Changes

Advisory Age

Layer / File(s) Summary
Catalog metadata and overlay data
iosApp/iosApp/Networking/APIv2/*, iosApp/iosApp/Networking/Models.swift, iosApp/iosApp/Overlays/*, iosApp/iosApp/Screens/Detail/ItemDetailViewModel.swift, iosApp/iosApp/tvOS/Screens/Detail/TVItemDetailView.swift, iosApp/Tests/DisplayRatingTests.swift
Catalog and presentation models carry advisory age and source into overlay data. Overlay labels recognize Common Sense and MDBList. Tests cover badge labels, defaults, and handling of missing or nonpositive ages.
Profile-scoped preference state
iosApp/iosApp/Networking/AdvisoryAgePreferenceStore.swift, iosApp/iosApp/Screens/Auth/AuthService.swift, iosApp/Tests/AdvisoryAgePreferenceStoreTests.swift
The store checks capability support before reading or writing the active profile’s preference. It guards asynchronous results against identity changes and concurrent mutations. Cache-clearing methods clear the store. Tests cover hydration, writes, and overlapping operations.
Advisory-age settings controls
iosApp/iosApp/Screens/Settings/GeneralSettingsView.swift, iosApp/iosApp/tvOS/Screens/Settings/*
iOS and tvOS settings hydrate the shared preference and show a supported-only toggle. The toggle is disabled while saving. The tvOS settings focus enum adds an advisory-age case.
Detail-view badge display
iosApp/iosApp/Screens/Detail/Phone/PhoneDetailHero.swift, iosApp/iosApp/tvOS/Screens/Detail/*
Phone and TV detail views pass overlay data to their heroes. The heroes add the advisory-age badge to rating chips when the shared preference enables it.

Priority: ➖ Normal

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant SettingsView
  participant AdvisoryAgePreferenceStore
  participant SiloAPI
  participant DetailHero
  SettingsView->>AdvisoryAgePreferenceStore: hydrate preference
  AdvisoryAgePreferenceStore->>SiloAPI: fetch capabilities
  SiloAPI-->>AdvisoryAgePreferenceStore: capability response
  AdvisoryAgePreferenceStore->>SiloAPI: fetch effective profile value
  SiloAPI-->>AdvisoryAgePreferenceStore: effective-value response
  SettingsView->>AdvisoryAgePreferenceStore: save preference
  AdvisoryAgePreferenceStore->>SiloAPI: write profile setting
  DetailHero->>AdvisoryAgePreferenceStore: read enabled preference
  DetailHero->>DetailHero: include badge in rating chips
Loading

Suggested reviewers: quick104

Merge Risk: ⚪ Minimal · up to ebfa8

The advisory-age preference and badges are ready to merge after normal checks; no actionable merge-blocking issue remains.

Security Architecture Review

Security architecture risk: 🔵 Low · up to ebfa8

The inspected changes affect advisory labels and a profile display preference, not viewing permissions. Identity checks and state invalidation limit cross-profile exposure. No introduced security issue was established, but server-side authorization and metadata provenance were not independently verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The inspected exposure is bounded to advisory labels for returned catalog items and an authenticated active-profile display preference. A manipulated catalog response could mislead advisory presentation, but the traced fields do not grant playback authority or select another profile for mutation.

Trust Boundaries and Controls

  • observed — The new preference calls inherit settings operations that capture ordinary authentication, require profile agreement, compare expected request identity, and execute under an ownership fence. Effective-value responses reject explicit foreign-profile rows. Authentication transitions clear the new store before normal use resumes, and store guards reject late results.

Resilience and Maintainability Implications

  • observed — Failed writes preserve the previous visible value. A failed effective-value refresh after successful hydration also preserves the same-profile value and hydrated flag, so ordinary hydrateIfNeeded calls do not retry that refresh. This is a display-freshness limitation; identity clearing remains independent of it.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 40 functions across 20 files. 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 summarizes the main change: profile-controlled advisory ages in the catalog.
Description check ✅ Passed The description explains the preference toggle, advisory-age badges, profile-scoped behavior, validation, and scope of the changes.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · 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-kody

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

@silo-kody

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

@pceiley

pceiley commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

@kody start-review

@pceiley

pceiley commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

UI evidence

iOS film detail — before and after

With Show Advisory Age disabled, only the content rating appears. When enabled, the advisory-age badge appears beside it.

Poster overlays

Advisory ages appear alongside the existing quality and IMDb overlays on iOS and tvOS.

tvOS profile setting

The profile-scoped toggle appears under General → Cards & Posters.
ios-film-detail-advisory-age
ios-film-detail-before
ios-poster-overlay-enabled
tvos-poster-overlay-enabled
tvos-show-advisory-age-setting

@pceiley
pceiley marked this pull request as ready for review October 3, 2026 12:38

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

I reviewed this against the server contract and the web client, then ran the unfixed head on iOS and tvOS simulators against a fresh dev sandbox with advisory ages seeded on six titles. The contract matches: detail, browse, sections and search all carry advisory_age and advisory_source, the setting is profile-scoped and off by default, the labels match the web client's MetadataBadges, and the poster overlay uses the same id, position, default and icon. The badge and the settings rows render correctly on both platforms.

Three things need changes before this is ready, plus one small one. I'm fixing all four in commits on this branch, so there's no need to change anything yourself. I'll reply in each thread with the commit.

The Android app needs the same badge, setting and poster overlay; silo-android#375 and #416 track it. My summary comment follows once the fixes are pushed and verified.

Reviewed with Claude Code (claude-opus-5-5), with a cross-provider pass by Codex (gpt-6.1-sol).

The advisory age preference was read once per sign-in, so a change made
on the web or another device never reached the badge or the toggle. It
now re-reads when General settings opens and on the first detail page
after the app returns to the foreground, and a passing "unavailable"
settings answer no longer hides the setting for the whole session.

The toggle shows the new value while it saves, rolls back to the last
confirmed value if the save fails, and says why under the row on iOS,
macOS and tvOS. It stays hidden until the profile's value has loaded.

Detail pages without a rating chip no longer gain an empty chip stack
that pushed the metadata line 4pt off centre.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@silo-kody

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

Copy link
Copy Markdown
Contributor

Review summary

Reviewed head: 3f296716 (your two commits plus four fix commits from this review). The first pass was against ebfa8470.

Fit: 8/10 · Readiness: 8/10 — conditional

What I checked

  • Contract: detail, browse, sections and search all carry advisory_age and advisory_source. catalog.show_advisory_age is profile-scoped and off by default. The detail labels match the web client's MetadataBadges ("Common Sense 13+", "MDBList 10+", bare "13+"), and the poster overlay matches the web registry (id, bottom-right, off by default, users icon, "13+"). Like the web client, the overlay is not gated by the profile setting.
  • macOS: SiloMac compiles the shared detail hero and General settings, so the badge and setting ship there too (arm64 build passed).
  • Live check: unfixed and fixed heads on iOS 27 and tvOS 27 simulators against a fresh dev sandbox with advisory ages seeded on six titles.

Addressed in 103aabbc, 7e22a445, f3a146df and 3f296716

  1. The preference never re-read during a session (medium): it now re-reads when General settings opens and on the first detail page after the app returns to the foreground. .unavailable no longer hides the setting for the session. Reproduced before, gone after.
  2. The toggle showed the old value while saving, and failures were silent (medium): the toggle now applies the choice at once, rolls back on failure, and explains why under the row on iOS, macOS and tvOS.
  3. The toggle could appear before its value loaded (low): it now stays hidden until the value is read.
  4. Detail metadata 4pt off centre for titles with no rating chip (low): there's no empty chip stack anymore.
  5. Kody's follow-ups on the fix (7e22a445): a read already in flight when the app returns to the foreground no longer counts as the fresh read, and a failed save leaves the next read due so a save that actually landed is reconciled. f3a146df and 3f296716 make a caller that joins a read invalidated before or during the wait read again. I declined the manifest-revision, generation-bump and held-write suggestions and explained why in their threads.

Tests: AdvisoryAgePreferenceStoreTests grows from 6 to 15 cases. Your two race regressions are kept; the two that toggled during the first read now race a later refresh, since toggling before the first read can no longer happen. On 3f296716, iOS: 28 focused tests pass. tvOS: 30 pass. SiloMac builds (checked on 103aabbc; the later commit only touches the shared store).

Checked and dropped

The tvOS row disables itself while saving, so I expected focus to jump to a neighbouring row. With saves slowed to 1.5 s, tvOS 27 kept focus on the row, so I left .disabled as it is.

Remaining

  • Apple regression, CI scripts and Kody have to finish on 3f296716.
  • Android parity: the Android app has the setting key but no badge, toggle or overlay. silo-android#375 (detail badge and toggle) and silo-android#416 (poster badge) track it; the PR body now links them.
  • User manual: the "Show advisory ages" section of the profiles page (src/content/docs/docs/using-silo/profiles.md) only describes the web app. Once this merges, it should also say where the toggle lives on iPhone, iPad and Mac (Settings > General > Ratings) and on Apple TV (Settings > General > Cards & Posters). I recommend a Silo-Server/siloserver.org issue for that page. I haven't opened one for your PR.

Validated features

No passed validation case reaches this change in a way that alters its result. The checked cases are the Apple calendar cases (silo-apple#303/#304), person detail navigation and restricted profiles (#307/#308), and Apple TV remote navigation. Detail pages gain a chip only when the profile opts in; the profile-switch and sign-out paths only clear this store.

Validation tasks: none

Scores

  • Fit 8: this brings the Apple apps up to the web client on a setting the server already defines, profile-scoped and off by default. It's new user-facing surface during polish, and Android isn’t there yet (tracked in the linked silo-android issues).
  • Readiness 8: the fixes are verified on both simulators and by tests, and the earlier race fixes still hold. A pending check holds it below 9.

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

Reviewed with Claude Code (claude-opus-5-5), with a cross-provider pass by Codex (gpt-6.1-sol). Claude wrote the fix commits.

/// Lets the next ``hydrateIfNeeded()`` read again while keeping the last
/// answer on screen. Called when the app returns to the foreground.
func markStale() {
hasHydrated = false

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

Stale-value race: a refresh started before markStale() can complete afterward and republish data that should have been invalidated. Invalidate the refresh generation and cancel any in-flight hydration before marking the value stale.

Kody rule violation: Fence asynchronous results by scope and invalidation generation

generation &+= 1
hydrationTask?.cancel()
hydrationTask = nil
hasHydrated = false
Prompt for LLM

File iosApp/iosApp/Networking/AdvisoryAgePreferenceStore.swift:

Line 82:

Stale-value race: a refresh started before markStale() can complete afterward and republish data that should have been invalidated. Invalidate the refresh generation and cancel any in-flight hydration before marking the value stale.

Suggested Code:

        generation &+= 1
        hydrationTask?.cancel()
        hydrationTask = nil
        hasHydrated = false

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

Choose a reason for hiding this comment

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

Fixed in 7e22a44, with a different repair. markStale() now bumps a counter, and a read that started before it still shows its answer (the newest one the app has) but no longer marks the value fresh, so the next detail page reads again. Cancelling the in-flight read would discard that answer and leave the old one on screen. Covered by testReadInFlightWhenMarkedStaleDoesNotCountAsFresh.

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’s a solid fix. Keeping the in-flight read’s result avoids showing stale data, while the counter prevents that result from being treated as fresh after markStale(). The regression test also clearly captures the intended behavior.

showsAdvisoryAge = enabled
isSaving = true
defer {
if generation == currentGeneration {

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

Saving-hold corruption: releasing the hold for every failed PUT allows uncertain transport outcomes to escape suppression while reconciliation is pending. Distinguish confirmed failures from uncertain outcomes, and clear the hold only after the matching reconciliation completes or an operation-specific expiry fires.

Kody rule violation: Handle uncertain mutations with operation-specific holds

Prompt for LLM

File iosApp/iosApp/Networking/AdvisoryAgePreferenceStore.swift:

Line 152:

Saving-hold corruption: releasing the hold for every failed PUT allows uncertain transport outcomes to escape suppression while reconciliation is pending. Distinguish confirmed failures from uncertain outcomes, and clear the hold only after the matching reconciliation completes or an operation-specific expiry fires.

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

Choose a reason for hiding this comment

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

Partly addressed in 7e22a44. You're right that a PUT which fails on transport may still have landed. A failed save now leaves the next read due, so the toggle reconciles with the server on the next detail page, Settings visit or foreground (testFailedWriteIsReconciledByTheNextRead). I haven't added held-change machinery: this is a display-only boolean that the user can re-press, it already rolls back to the last confirmed value with an explanation, and the seek-interval settings on the same screens handle failures the same way.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Understood. No changes were made this turn, and I won’t claim that anything was saved, created, recorded, or updated.

self.localMutationRevision == mutationRevision else { return }
let value = response.value(for: .catalogShowAdvisoryAge)?.value.boolValue == true
self.confirmedValue = value
self.isSupported = true

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

Capability-scope race: publishing support from the Boolean isSupported flag alone can allow putValue to transmit against an unknown or stale capability manifest revision. Persist the capability manifest revision with the server, profile, and device identity before publishing support, then gate putValue at transmission time on that scope-bound revision and defer the write when it is unknown or stale.

Kody rule violation: Scope capability revisions and gate settings at transmission time

Prompt for LLM

File iosApp/iosApp/Networking/AdvisoryAgePreferenceStore.swift:

Line 128:

Capability-scope race: publishing support from the Boolean isSupported flag alone can allow putValue to transmit against an unknown or stale capability manifest revision. Persist the capability manifest revision with the server, profile, and device identity before publishing support, then gate putValue at transmission time on that scope-bound revision and defer the write when it is unknown or stale.

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

Choose a reason for hiding this comment

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

Not changing this. Every capability and value result is already fenced by the request identity (server id, server URL, profile) and the store generation, so a result from another server or profile is dropped. If the connected server stops supporting the key, the PUT fails as unknownSetting, the toggle rolls back, and the row says "This server can't save Show Advisory Age." Tracking a manifest revision per scope would add state without changing what the user sees.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Understood. No action was taken this turn.

…failed saves

A read already in flight when the app returned to the foreground could
mark the value fresh and skip the re-read the foreground asked for. It
still shows its answer, but the next detail page now reads again. A save
that fails may still have landed on the server, so it also leaves the
next read due, which reconciles the toggle with the server.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@silo-kody

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

/// Lets the next ``hydrateIfNeeded()`` read again while keeping the last
/// answer on screen. Called when the app returns to the foreground.
func markStale() {
staleMarks &+= 1

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

Hydration task invalidation is incomplete because incrementing staleMarks alone does not invalidate the hydration task already in flight, allowing its captured generation to pass canApply and publish after markStale(). Advance the refresh generation, cancel and clear the current task, then mark the value stale.

Kody rule violation: Fence asynchronous results by scope and invalidation generation

generation &+= 1
hydrationTask?.cancel()
hydrationTask = nil
staleMarks &+= 1
Prompt for LLM

File iosApp/iosApp/Networking/AdvisoryAgePreferenceStore.swift:

Line 85:

Hydration task invalidation is incomplete because incrementing staleMarks alone does not invalidate the hydration task already in flight, allowing its captured generation to pass canApply and publish after markStale(). Advance the refresh generation, cancel and clear the current task, then mark the value stale.

Suggested Code:

        generation &+= 1
        hydrationTask?.cancel()
        hydrationTask = nil
        staleMarks &+= 1

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

Choose a reason for hiding this comment

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

Not changing this; it's the trade-off settled in the earlier thread on this line. Bumping generation in markStale() would discard a valid in-flight answer and, if a save were running, leave isSaving stuck, because the save's defer only clears it for the same generation. The in-flight read may publish its value (the newest the app has) but no longer counts as fresh, and with the commit above a caller that joins it reads again.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Understood. No changes or other actions were performed.

writeError = Self.writeFailureMessage(for: error)
// A save that timed out may still have landed; the next read
// reconciles it.
markStale()

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

Uncertain PUT failures are indistinguishable from confirmed failures, and the surrounding defer still clears isSaving so a timed-out request can be resent immediately. Track an operation-specific hold for uncertain saves, release it only after matching reconciliation or a bounded expiry, and keep confirmed failures separate.

Kody rule violation: Handle uncertain mutations with operation-specific holds

Prompt for LLM

File iosApp/iosApp/Networking/AdvisoryAgePreferenceStore.swift:

Line 173:

Uncertain PUT failures are indistinguishable from confirmed failures, and the surrounding defer still clears isSaving so a timed-out request can be resent immediately. Track an operation-specific hold for uncertain saves, release it only after matching reconciliation or a bounded expiry, and keep confirmed failures separate.

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

Choose a reason for hiding this comment

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

Same as the earlier thread on the failure path: no held-change machinery for this display-only boolean. A failed save rolls back to the last confirmed value, explains why, and leaves the next read due, which reconciles a save that actually landed. Resending is a PUT of the same value, which is idempotent.

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—no held-change machinery for this display-only boolean. On save failure, we restore the last confirmed value, explain the failure, and leave the next read due. That read reconciles the state if the save actually landed despite the error. A retry sends the same value via PUT, so it’s idempotent.

Comment on lines +85 to +88
staleMarks &+= 1
hasHydrated = false
}

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 high

Stale hydration state leaves an in-flight hydrationTask coalesced as the completed refresh even though staleMarks causes that task to finish with hasHydrated=false; a hydrateIfNeeded() call that overlaps the stale-marked read awaits the old task and returns at lines 90-93, so no replacement read occurs and the profile setting remains stale until another caller retries. Re-check hasHydrated and staleMarks after awaiting the existing hydration task and start a new refresh when the awaited task was invalidated, or cancel and invalidate the task in markStale() so the next hydration call cannot return through it.

Prompt for LLM

File iosApp/iosApp/Networking/AdvisoryAgePreferenceStore.swift:

Line 85 to 88:

Stale hydration state leaves an in-flight hydrationTask coalesced as the completed refresh even though staleMarks causes that task to finish with hasHydrated=false; a hydrateIfNeeded() call that overlaps the stale-marked read awaits the old task and returns at lines 90-93, so no replacement read occurs and the profile setting remains stale until another caller retries. Re-check hasHydrated and staleMarks after awaiting the existing hydration task and start a new refresh when the awaited task was invalidated, or cancel and invalidate the task in markStale() so the next hydration call cannot return through it.

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

Choose a reason for hiding this comment

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

Fixed in f3a146d. refresh() records the stale mark each in-flight read started under; a caller that joins a read started before markStale() waits for it and then starts a fresh read. Covered by testHydrateJoiningAStaleReadStartsAFreshOne.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Understood. No action was taken this turn, and nothing was saved, created, recorded, or updated.

…h one

A detail page that asked for the advisory age setting while a read
started before the app returned to the foreground was still running
joined that read and returned, so the re-read never happened. It now
waits for that read and then starts a fresh one.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@silo-kody

silo-kody Bot commented Oct 5, 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:

  • Centralize server-relative authentication path validation
  • Enforce latest-link-wins centrally across deferred deep links

while let hydrationTask {
let isCurrent = hydrationStaleMark == staleMarks
await hydrationTask.value
if isCurrent { return }

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

Race condition in iosApp/iosApp/Networking/AdvisoryAgePreferenceStore.swift:95-95: returning based on the pre-suspension isCurrent snapshot can ignore invalidation during hydration, allowing a stale result to suppress the required replacement read. Compare the task's captured generation, taskStaleMark, with staleMarks after the await before returning.

Kody rule violation: Fence asynchronous results by scope and invalidation generation

if taskStaleMark == staleMarks { return }
Prompt for LLM

File iosApp/iosApp/Networking/AdvisoryAgePreferenceStore.swift:

Line 97:

Race condition in `iosApp/iosApp/Networking/AdvisoryAgePreferenceStore.swift:95-95`: returning based on the pre-suspension `isCurrent` snapshot can ignore invalidation during hydration, allowing a stale result to suppress the required replacement read. Compare the task's captured generation, `taskStaleMark`, with `staleMarks` after the await before returning.

Suggested Code:

            if taskStaleMark == staleMarks { return }

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

Choose a reason for hiding this comment

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

Fixed in 3f29671, the same change as the neighbouring thread: the comparison now happens after the await, against the mark captured for the joined read.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks—comparing the joined read’s captured mark with staleMarks after the await addresses the reported race. An invalidation during suspension will no longer cause an early return that skips the replacement read.

Based on your description, this suggestion is addressed in 3f296716.

Comment on lines +94 to +98
while let hydrationTask {
let isCurrent = hydrationStaleMark == staleMarks
await hydrationTask.value
if isCurrent { return }
}

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 high

Race condition in refresh(): capturing isCurrent before await hydrationTask.value misses any markStale() during suspension, allowing refresh() to return with the preference marked stale without starting the required replacement read. Compare hydrationStaleMark with staleMarks after the await, or otherwise re-check invalidation after suspension, before returning.

while let hydrationTask {
    await hydrationTask.value
    if hydrationStaleMark == staleMarks { return }
}
Prompt for LLM

File iosApp/iosApp/Networking/AdvisoryAgePreferenceStore.swift:

Line 94 to 98:

Race condition in `refresh()`: capturing `isCurrent` before `await hydrationTask.value` misses any `markStale()` during suspension, allowing `refresh()` to return with the preference marked stale without starting the required replacement read. Compare `hydrationStaleMark` with `staleMarks` after the await, or otherwise re-check invalidation after suspension, before returning.

Suggested Code:

while let hydrationTask {
    await hydrationTask.value
    if hydrationStaleMark == staleMarks { return }
}

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

Choose a reason for hiding this comment

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

Fixed in 3f29671. refresh() captures the joined read's stale mark before waiting and compares it with staleMarks afterwards, so a markStale() during the wait starts a replacement read. Covered by testMarkedStaleWhileJoinedReadRunsStartsAFreshOne.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks—capturing the joined read’s stale mark before the await and comparing it with staleMarks afterward addresses the reported race, including invalidation during suspension. testMarkedStaleWhileJoinedReadRunsStartsAFreshOne covers that scenario. Based on your description of 3f296716, this resolves the suggestion.

…read

A caller that joined a read in flight decided whether that read was
current before waiting on it, so a foreground arriving during the wait
left the setting stale with no replacement read. It now compares the
read's stale mark after the wait.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@silo-kody

silo-kody Bot commented Oct 5, 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:

  • Centralize server-relative authentication path validation
  • Enforce latest-link-wins centrally across deferred deep links

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants