Skip to content

feat(settings): adopt contract language catalogs - #114

Merged
Quick104 merged 3 commits into
mainfrom
t3code/audit-metadata-subtitle-languages
Jul 30, 2026
Merged

Quick104 merged 3 commits into
mainfrom
t3code/audit-metadata-subtitle-languages

Conversation

@Quick104

@Quick104 Quick104 commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The Apple clients used separate hard-coded language lists, leaving iOS, tvOS, and macOS with fewer metadata and subtitle choices than the web app and making future cross-platform drift likely.

Approach

  • vendor and pin Silo Server settings manifest revision 2 from 025083159f9624269483479cc05de02a822c6cd2
  • consume generated, definition-specific audio, subtitle, and metadata option sets
  • build each picker from the contract floor, server-provided suggested_values, and the exact current wire value
  • localize language labels with Foundation locale data while persisting BCP 47 tags
  • deduplicate true ISO aliases without collapsing explicit regions or scripts
  • propagate runtime suggestions through PlayerSettings and ProfilePrefsEditor
  • apply the same data source to shared iOS/macOS settings and tvOS settings surfaces
  • add manifest/binding drift coverage and preserve unknown current tags as selectable rows

Canonical Server contract: Silo-Server/silo-server#521

Companion PRs

Verification

Verified on the remote mac-builder from an exact sync of commit 2fadaabc plus this branch's changes:

  • full Silo XCTest suite on a clean iPhone 17 Pro simulator — 944 tests, 0 failures
  • focused SettingsConformanceTests after the final Server commit pin — 7 tests, 0 failures
  • unsigned iOS build — succeeded
  • unsigned tvOS build — succeeded
  • unsigned macOS build — succeeded
  • generated Swift metadata and vendored manifest comparison — byte-identical to Server commit 02508315
  • vendored manifest/conformance fixtures — byte-identical to Server commit 02508315

A first run on an existing signed-in simulator produced 12 old settings-refresh assertions because persisted profile state triggered the one-time migration path. The unchanged tree passed all 944 tests on a newly created clean simulator; that disposable simulator was removed afterward without touching the existing simulator.

Risks and follow-up

  • Merge/deploy the Server contract first; revision-aware clients intentionally report an upgrade requirement against an older revision.
  • Runtime suggestions are advisory. The generated floor remains available if the server omits them, and valid unknown current tags remain visible.
  • Verification covers simulator tests and unsigned platform builds; no physical-device behavior changed.

AI Disclosure

  • Tool(s): Codex in T3 Code; Claude Code CLI
  • Model(s): gpt-5.6-sol; claude-fable-5
  • Involvement: fully AI-generated
  • Adversarial review: Reviewed generated metadata drift, alias versus region identity, Foundation localization, iOS/macOS and tvOS propagation, current-value retention, and old-server behavior. The only anomalous test result was traced to persisted simulator account state and cleared by a clean-simulator full run without weakening production revision checks.

Summary by CodeRabbit

  • New Features

    • Language pickers on iOS and tvOS now use server-provided suggestions while preserving current selections.
    • Audio, subtitle, and metadata language options include clearer default labels and improved alias handling.
    • Settings can display suggested values from the server.
  • Bug Fixes

    • Improved duplicate and bibliographic language alias handling.
    • Added compatibility handling for mismatched settings contract revisions.
  • Tests

    • Expanded coverage for dynamic options, migration, aliases, suggested values, and presentation metadata.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The settings contract now defines revisioned language option sets and unset labels. Server-provided suggestions are decoded, merged with contract values, normalized, deduplicated, and localized for dynamic iOS and tvOS language pickers. Older server contract revisions now produce upgrade-required errors.

Changes

Language picker contract and UI

Layer / File(s) Summary
Contract metadata and decoding
iosApp/Tests/Fixtures/SettingsContract/*, iosApp/Tests/SettingsContractResolve.swift, iosApp/Tests/SettingsConformanceTests.swift
The manifest revision increases to 2, adds language option sets and unset labels, and extends test-side decoding and conformance validation for the new metadata.
Runtime suggestions and option generation
iosApp/iosApp/Networking/SettingValueModels.swift, iosApp/iosApp/Networking/PlaybackPrefsModels.swift, iosApp/iosApp/Screens/Player/PlayerSettings.swift, iosApp/iosApp/Screens/Settings/ProfilePrefsEditor.swift, iosApp/Tests/ProfileAndQualitySettingsTests.swift, iosApp/Tests/PlayerSettingsFlushTests.swift
Effective-setting responses expose suggested values, which feed dynamic language option generation with ISO alias normalization, deduplication, localization, migration preservation, and option-generation tests.
Server contract compatibility
iosApp/iosApp/Networking/ContinuumAPI+Settings.swift, iosApp/Tests/SettingValuesAPITests.swift
Capability and effective-value reads reject older server contract revisions with serverUpgradeRequired, with revision-aware API stub coverage.
iOS dynamic picker wiring
iosApp/iosApp/Screens/Settings/SettingsViewModel.swift, iosApp/iosApp/Screens/Settings/PlaybackSettingsView.swift, iosApp/iosApp/Screens/Settings/SubtitleSettingsView.swift
iOS pickers use view-model-generated language options and manifest-driven unset labels instead of static language lists.
tvOS dynamic picker wiring
iosApp/iosApp/tvOS/Screens/Settings/*
tvOS view models and picker components use dynamic audio, subtitle, and metadata language options with contract-driven unset labels.

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

Sequence Diagram(s)

sequenceDiagram
  participant SettingsContractManifest
  participant EffectiveSettingValue
  participant PlayerSettings
  participant ProfilePrefsEditor
  participant SettingsViewModel
  participant PlaybackLanguageOption
  participant LanguagePicker
  SettingsContractManifest->>SettingsViewModel: provide option metadata and unset labels
  EffectiveSettingValue->>PlayerSettings: provide audio suggestedValues
  EffectiveSettingValue->>ProfilePrefsEditor: provide subtitle and metadata suggestedValues
  PlayerSettings->>SettingsViewModel: expose audio suggestions
  ProfilePrefsEditor->>SettingsViewModel: expose subtitle and metadata suggestions
  SettingsViewModel->>PlaybackLanguageOption: pass selections and suggestions
  PlaybackLanguageOption->>LanguagePicker: return normalized localized options
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 58.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the PR's primary change: adopting contract-defined language catalogs for settings.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch t3code/audit-metadata-subtitle-languages

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

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@iosApp/iosApp/Networking/PlaybackPrefsModels.swift`:
- Around line 188-195: Update languageIdentity to canonicalize the first
language component using Locale’s ISO-639-1 alpha-2 identifier, falling back to
the original language component when no alpha-2 value exists; retain the
existing normalization and lowercase joining behavior for the remaining
components.

In `@iosApp/iosApp/Screens/Player/PlayerSettings.swift`:
- Line 741: Update importLegacySettingsIfNeeded where it creates the synthetic
EffectiveSettingValue to copy the original entry.suggestedValues into the
replacement. Preserve those suggestions so the audioLanguageSuggestions
assignment from effectiveByKey retains server-provided runtime choices during
legacy import.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a9fbb39c-e11f-43ae-923c-11dc28a481a8

📥 Commits

Reviewing files that changed from the base of the PR and between 2fadaab and 3069112.

⛔ Files ignored due to path filters (1)
  • iosApp/iosApp/Networking/SettingKeys.generated.swift is excluded by !**/*.generated.*
📒 Files selected for processing (18)
  • iosApp/Tests/Fixtures/SettingsContract/SOURCE
  • iosApp/Tests/Fixtures/SettingsContract/conformance.json
  • iosApp/Tests/Fixtures/SettingsContract/manifest.json
  • iosApp/Tests/ProfileAndQualitySettingsTests.swift
  • iosApp/Tests/SettingValuesAPITests.swift
  • iosApp/Tests/SettingsConformanceTests.swift
  • iosApp/Tests/SettingsContractResolve.swift
  • iosApp/iosApp/Networking/PlaybackPrefsModels.swift
  • iosApp/iosApp/Networking/SettingValueModels.swift
  • iosApp/iosApp/Screens/Player/PlayerSettings.swift
  • iosApp/iosApp/Screens/Settings/PlaybackSettingsView.swift
  • iosApp/iosApp/Screens/Settings/ProfilePrefsEditor.swift
  • iosApp/iosApp/Screens/Settings/SettingsViewModel.swift
  • iosApp/iosApp/Screens/Settings/SubtitleSettingsView.swift
  • iosApp/iosApp/tvOS/Screens/Settings/TVPlaybackSettingsView.swift
  • iosApp/iosApp/tvOS/Screens/Settings/TVSettingsComponents.swift
  • iosApp/iosApp/tvOS/Screens/Settings/TVSettingsViewModel.swift
  • iosApp/iosApp/tvOS/Screens/Settings/TVSubtitleSettingsView.swift

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 306911293d

ℹ️ About Codex in GitHub

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

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

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

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cde1bee6af

ℹ️ About Codex in GitHub

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

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

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

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

@Quick104
Quick104 merged commit 560da51 into main Jul 30, 2026
1 check was pending
@Quick104
Quick104 deleted the t3code/audit-metadata-subtitle-languages branch July 30, 2026 23:09

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
iosApp/iosApp/Screens/Player/PlayerSettings.swift (1)

183-185: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Clear stale runtime suggestions on scope/cache reload.

applyCachedSettingsForCurrentScope() restores audioLanguage but leaves this transient array intact. After a server/profile change followed by a failed refresh, the picker can show suggestions from the prior scope. Clear it with the cached state (or persist it per scope).

Proposed fix
 private func applyCachedSettingsForCurrentScope() {
+    audioLanguageSuggestions = []
     preferredQualityResolution = Self.cachedQualityResolution(defaults)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@iosApp/iosApp/Screens/Player/PlayerSettings.swift` around lines 183 - 185,
Update applyCachedSettingsForCurrentScope() to clear audioLanguageSuggestions
whenever cached settings are restored, ensuring failed refreshes cannot retain
suggestions from a previous scope while preserving the existing audioLanguage
restoration behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@iosApp/iosApp/Screens/Player/PlayerSettings.swift`:
- Around line 183-185: Update applyCachedSettingsForCurrentScope() to clear
audioLanguageSuggestions whenever cached settings are restored, ensuring failed
refreshes cannot retain suggestions from a previous scope while preserving the
existing audioLanguage restoration behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fc29faf9-e7ab-451f-a84d-2db33851426b

📥 Commits

Reviewing files that changed from the base of the PR and between 3069112 and 5b40fd1.

📒 Files selected for processing (8)
  • iosApp/Tests/PlayerSettingsFlushTests.swift
  • iosApp/Tests/ProfileAndQualitySettingsTests.swift
  • iosApp/Tests/SettingValuesAPITests.swift
  • iosApp/Tests/SettingsConformanceTests.swift
  • iosApp/iosApp/Networking/ContinuumAPI+Settings.swift
  • iosApp/iosApp/Networking/PlaybackPrefsModels.swift
  • iosApp/iosApp/Networking/SettingValueModels.swift
  • iosApp/iosApp/Screens/Player/PlayerSettings.swift

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5b40fd1114

ℹ️ About Codex in GitHub

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

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

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

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

Comment on lines +100 to +102
guard !decoded.contractIsAheadOfServer else {
throw SettingsAPIError.serverUpgradeRequired
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Propagate revision failure to playback controls

When this revision-2 client connects to a revision-1 server, this guard now makes PlayerSettings.refreshFromServer() return .serverUpgradeRequired, but both settings view models discard that result and the iOS/macOS and tvOS playback controls remain enabled; they display cached values and continue queueing quality, audio-language, and behavior writes despite declaring the server contract incompatible. The fresh evidence after the earlier comment is that effective reads are now rejected here, but the resulting state is propagated only through ProfilePrefsEditor, so carry the player refresh result into the playback UI and disable or explain those controls as well.

AGENTS.md reference: AGENTS.md:L19-L22

Useful? React with 👍 / 👎.

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.

1 participant