Skip to content

feat(metadata): add original-language preferences - #526

Merged
Quick104 merged 5 commits into
mainfrom
t3code/metadata-language-preferences
Jul 31, 2026
Merged

Quick104 merged 5 commits into
mainfrom
t3code/metadata-language-preferences

Conversation

@Quick104

@Quick104 Quick104 commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Part of #135

Profiles currently have one fixed metadata-language preference. That cannot express either of these common policies:

  • present every item in its own original language
  • keep one fallback for most of the catalog, but use a different target for items whose original language is Norwegian, Japanese, or another chosen language

The same preference also needs to resolve consistently for movies, series, seasons, episodes, batched catalog reads, and Jellyfin-compatible responses.

Approach

  • add the valid private-use BCP 47 tag x-silo-original to the existing open catalog.metadata_language setting; the server resolves it to each item's concrete original language before localization or AI-translation decisions
  • add a separate profile-scoped catalog.metadata_language_overrides object mapping canonical original-language codes to a target BCP 47 tag, so older clients can continue editing the fallback without discarding per-language exceptions
  • resolve the fallback and exceptions through the access scope used by catalog, season, episode, batch-detail, and jellycompat paths
  • derive season and episode targets from the parent series original language and bulk-load those languages for list/batch paths
  • bump the settings contract to revision 3, add the object schema and conformance case, and keep language values open rather than introducing a validation allowlist
  • replace the web metadata picker with a fallback selector plus per-original-language exception rows
  • enrich metadata suggestions with original languages observed in the viewer's accessible libraries, while preserving exact custom targets such as pt-BR

The requested example is represented as fallback en plus { "no": "x-silo-original" }.

Testing

  • make test — all Go packages passed; web: 250 files and 1,606 tests passed
  • /home/dev/go/bin/golangci-lint run --new-from-merge-base=origin/main ./... — 0 issues.
  • cd web && pnpm run lint — 0 errors; 157 existing warnings
  • cd web && pnpm run format:check — passed
  • cd web && pnpm run build — passed
  • make verify-settings-bindings-all verify-local-paths — passed
  • make lint — executed; the repository-wide baseline still reports 305 existing findings, while changed-lines lint is clean
  • git diff --check origin/main...HEAD — passed

Runtime/browser verification on exact commit cd1f45650b454880d9ab009e2d828db3ba824242:

  • deployed under the shared backend lock; all 31 changed-file hashes matched the remote source manifest (ee556bfe53ae7a96ba9ae555ced046f55883f6d0a3a50eaf3738bd813ed797b6)
  • /api/v1/health and /api/v1/ready returned ok; the live settings capability reported revision 3
  • Playwright saved and reloaded global Original language, then English plus a Norwegian → Original language exception
  • the source picker included catalog-observed Icelandic, and an existing custom pt-BR target remained selectable and exact
  • real movie, season, and episode detail requests each resolved the sentinel to concrete pending_translation_language: "no"
  • feature-route activity was entirely 200/204 with no matching warning/error logs; forced reload auth-bootstrap 401s all retried successfully, with no page errors or unrecovered requests
  • the admin profile was restored to its original catalog.metadata_language = "en" row with no override row
  • current 1440×1000 settings screenshot captured and visually inspected

Risks and follow-up

  • This is additive for existing clients: the fallback key and its response type are unchanged, and exceptions live under a new key. Clients that do not understand the sentinel should hide that newly introduced option by contract revision.
  • Apple and Android still need coordinated UI/contract adoption before users can edit these preferences from those clients; their existing fallback behavior remains compatible.
  • An unknown or empty item original language falls back to the library metadata language rather than exposing the sentinel downstream.

AI Disclosure

  • Tool(s): Codex in T3 Code
  • Model(s): gpt-5.6-sol
  • Involvement: fully AI-generated
  • Adversarial review: Re-reviewed the rebased diff against merged PR feat(settings): add shared language option catalogs #521. The review found that uncommon original languages observed in accessible libraries were missing from metadata suggestions and that an existing custom BCP 47 override target outside the advisory catalog could become unselectable. Both integration gaps were fixed, covered by tests, and verified in the deployed browser flow; no remaining material findings were identified.

Checklist

  • I ran an adversarial AI review of the diff and summarized findings above.
  • I ran the repo verify commands: make lint, cd web && pnpm run lint, cd web && pnpm run format:check, and relevant go test ./... coverage through make test.

Summary by CodeRabbit

  • New Features

    • Added configurable metadata language preferences with fallback and per-original-language overrides.
    • Added an option to preserve original metadata language.
    • Added suggestions based on available catalog languages.
    • Applied preferences consistently across movies, series, seasons, and episodes.
  • Bug Fixes

    • Improved language normalization and handling of invalid or custom settings.
    • Improved localization consistency and batch processing.
    • Added rollback when preference updates fail.

UX follow-up — exception row appears without refresh

Commit f548cddb makes exception edits optimistic while the profile write is pending and rolls the row back if the save fails. Final PR head 2b2cc929 adds the required browser evidence only; that documentation-only commit was also deployed, with the runtime image fully cached from the verified code commit.

Metadata language settings with the new Arabic exception row visible immediately

Raw verification output

Focused regression and rollback tests:

 RUN  v4.1.0 /home/dev/.t3/worktrees/silo-server/t3code-d7d7423a/web

 Test Files  1 passed (1)
      Tests  5 passed (5)

Full web suite:

 Test Files  250 passed (250)
      Tests  1608 passed (1608)

Changed-lines Go lint and touched Go package:

0 issues.
ok  	github.com/Silo-Server/silo-server/internal/settingscontract	(cached)

Playwright against the deployed bundle at https://silo.arkyncdn.net:

{
  "target": "https://silo.arkyncdn.net",
  "sourceName": "Arabic",
  "putStatus": 200,
  "targetDropdownCount": {
    "immediateBeforeResponse": 1,
    "after1s": 1,
    "afterReload": 1
  },
  "restored": {
    "source": "profile",
    "value": {
      "en": "x-silo-original",
      "nl": "x-silo-original"
    }
  },
  "restoreStatus": 200,
  "pageErrors": 0
}

The three reload-time 401 resource responses were the expected access-token bootstrap and all retried successfully; the activity log recorded 58 successful effective-setting responses and both override writes as HTTP 200. The final server remained healthy and ready at settings contract revision 3. Local and deployed hashes matched for every changed code file and the screenshot.

Mobile responsiveness follow-up

Commit 57b80ba6 fixes the narrow-screen clipping found after the immediate-row UX change. Below sm, each exception now presents its source and remove action on the first line with a full-width target selector beneath it; the new-exception selector and Add action also stack at full width. The existing compact desktop layout is unchanged from sm upward.

The screenshot uses a read-only browser fixture for the two populated exception rows so the layout could be exercised without writing over a profile that was actively being edited. The fallback and available-language data still came from the deployed server, and the browser recorded no setting PUT or DELETE.

Metadata language exceptions fitting a 375px mobile viewport

Mobile verification output

Focused component tests:

Test Files  1 passed (1)
     Tests  5 passed (5)

Repository web test gate:

Test Files  250 passed (250)
     Tests  1608 passed (1608)

The additional unfiltered Vitest run found only the repository's existing excluded failures: 3 SeasonContent tests without a QueryClientProvider and 3 ServerStorageStep tests without ResizeObserver. Its remaining 254 files and 1,653 tests passed. pnpm run lint completed with 0 errors and 157 existing warnings; pnpm run format:check, pnpm run build, make verify-local-paths, and git diff --check passed.

Playwright against the deployed bundle at https://silo.arkyncdn.net, using a read-only populated-response fixture:

{
  "target": "https://silo.arkyncdn.net",
  "viewports": [
    {
      "width": 320,
      "documentWidth": 320,
      "controlBounds": { "left": 48, "right": 272 },
      "targetSelectorBounds": { "left": 48, "right": 272 },
      "removeActionBounds": { "left": 236, "right": 272, "width": 36 }
    },
    {
      "width": 375,
      "documentWidth": 375,
      "controlBounds": { "left": 48, "right": 327 },
      "targetSelectorBounds": { "left": 48, "right": 327 },
      "removeActionBounds": { "left": 291, "right": 327, "width": 36 }
    },
    {
      "width": 412,
      "documentWidth": 412,
      "controlBounds": { "left": 48, "right": 364 },
      "targetSelectorBounds": { "left": 48, "right": 364 },
      "removeActionBounds": { "left": 328, "right": 364, "width": 36 }
    },
    {
      "width": 768,
      "documentWidth": 768,
      "controlBounds": { "left": 266, "right": 696 },
      "targetSelectorBounds": { "left": 436.546875, "right": 656 },
      "removeActionBounds": { "left": 664, "right": 696, "width": 32 }
    }
  ],
  "pageErrors": [],
  "consoleErrors": [],
  "failedRequests": [],
  "serverErrors": [],
  "settingsWrites": [],
  "fixtureRequestCount": 1
}

The same deployed pass without response injection verified the real empty saved state and the source/Add controls at all four widths. Selecting a source enabled Add immediately without clicking it or writing a setting. Both source and target pickers stayed within the viewport.

Deployment evidence for exact commit 57b80ba646ad0e3933a506bf27db8feaf55ad34a:

local component sha256:  007e3dfc58b3d5e067030db73919f24b984b312bc6a0e63531471526392ed073
remote component sha256: 007e3dfc58b3d5e067030db73919f24b984b312bc6a0e63531471526392ed073
/api/v1/health: {"status":"ok",...}
/api/v1/ready:  {"status":"ok"}
settings contract revision: 3

The shared backend lock was held continuously from deploy through both browser passes, log inspection, and the final health/readiness probes. Feature requests after profile selection were HTTP 200. The only browser bootstrap 401/400 responses retried successfully; no metadata-setting write came from the verification sessions. Recent unrelated Jellyfin session warnings and a Plex webhook failure predated/ran independently of this settings flow.

AI Disclosure — mobile remediation

  • Tool(s): Codex in T3 Code
  • Model(s): gpt-5.6-sol
  • Involvement: reproduced the clipping, implemented the responsive layout, generated the screenshot, ran static/browser/deployment verification, and updated this evidence
  • Adversarial review: final Standards and Spec reviews found no code or behavior findings; Standards confirmed the committed and linked screenshot resolves the remaining evidence requirement

ISO language-name follow-up

Commit b811996b replaces browser-dependent and hand-written language-name fallbacks with one bundled English CLDR resolver. ISO 639-1, ISO 639-3, region, and script tags now have deterministic English labels while their exact BCP 47 wire values remain unchanged. Semantic aliases are de-duplicated, the exact stored value still wins, and unassigned tags are labeled explicitly instead of appearing as bare codes.

This presentation change does not require another settings-contract revision: the contract continues to transport open language_tag values, and its existing design assigns display-name localization to client CLDR/ICU data. Revision 3 still represents the new override setting and schema.

Metadata language picker showing English names for uncommon ISO language tags

ISO language-name verification output

Focused regression coverage:

Test Files  6 passed (6)
     Tests  74 passed (74)

Final repository web gate:

Test Files  251 passed (251)
     Tests  1615 passed (1615)

make test passed the complete Go suite and web gate before the final one-test regression addition. pnpm run lint completed with 0 errors and 157 existing warnings; pnpm run format:check, pnpm run build, make verify-local-paths, and git diff --check passed after the final change.

Playwright against the deployed bundle used a read-only response fixture to exercise catalog-observed values without changing the active profile:

{
  "target": "https://silo.arkyncdn.net",
  "labels": [
    "Sanskrit",
    "Northern Sami",
    "Samoan",
    "Shona",
    "Somali",
    "Cantonese",
    "Brazilian Portuguese",
    "Serbian (Latin)",
    "Unknown language (xx)"
  ],
  "viewports": [320, 375, 412, 768, 1440],
  "pageErrors": [],
  "consoleErrors": [],
  "failedRequests": [],
  "serverErrors": [],
  "settingsWrites": []
}

Deployment evidence for exact commit b811996bbbe5681816000550b446d0bab923a9ba:

local language resolver sha256:  44e643eb3a35c989878aaacbf9f07815709f90d62c5705ea23298f150e676953
remote language resolver sha256: 44e643eb3a35c989878aaacbf9f07815709f90d62c5705ea23298f150e676953
/api/v1/health: {"status":"ok",...}
/api/v1/ready:  {"status":"ok"}
settings contract revision: 3

The shared backend lock was held from deployment through source-hash comparison, browser verification, log inspection, and final health/readiness probes. The deployed browser produced no settings writes or errors. Recent warnings were unrelated Jellyfin session, metadata repair, and active scanner activity; no new panic, fatal, migration failure, or feature-path error appeared.

AI Disclosure — ISO language names

  • Tool(s): Codex in T3 Code
  • Model(s): gpt-5.6-sol
  • Involvement: reproduced the browser ICU fallback, centralized deterministic English CLDR naming, added regression coverage, tested desktop/mobile, deployed, and updated this evidence
  • Adversarial review: initial review found locale-dependent raw labels and alias duplication; final review caught a readable free-form language-name regression, which was fixed and covered before both Standards and Spec passed with no hard findings

@coderabbitai

coderabbitai Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds profile-scoped metadata language overrides. Contracts define the new object and schema. Backend resolution propagates canonical overrides into catalog localization. API handlers provide original-language suggestions. Web settings manage fallback and per-language targets.

Changes

Metadata language override flow

Layer / File(s) Summary
Settings contract and validation
contracts/settings/v1/*, internal/settingskeys/keys.go, internal/settingscontract/contract_test.go, web/src/lib/settingsContract.ts, web/src/lib/settingsConformance.json
Settings revision 3 defines catalog.metadata_language_overrides as a profile-scoped object with schema validation and conformance coverage.
Preference normalization and scope propagation
internal/access/*, internal/policy/viewer_resolver.go, internal/jellycompat/access_filter.go, internal/jellycompat/access_filter_test.go
Profile settings normalize language aliases and targets, preserve x-silo-original, and propagate overrides through access scopes and filters.
Source-aware catalog localization
internal/catalog/access_filter.go, internal/catalog/detail.go, internal/catalog/detail_*_test.go
Item, season, and episode localization resolve per-source targets, inherit parent-series languages, batch lookups by target, and update translation detection.
API localization and language suggestions
internal/api/handlers/catalog_resources.go, internal/api/handlers/items.go, internal/api/handlers/settings_values.go, internal/jellycompat/content_direct.go
Handlers localize seasons and episodes in batches, reuse localized models, propagate overrides, and list accessible original-language suggestions.
Web metadata language controls
web/src/components/settings/MetadataLanguageSetting.*, web/src/lib/metadataLanguagePreferences.*, web/src/pages/settings/PlaybackSettings.*
The settings UI manages fallback language and per-original-language exceptions, including normalization, saving, resetting, and custom target display.
Shared language naming utilities
web/src/lib/languageNames.ts, web/src/lib/languageOptions.ts, web/src/player/utils/languageNames.ts, web/src/pages/ItemDetail/components/versionFormatUtils.ts, web/src/lib/languageDisplay.ts
Shared utilities canonicalize language tags and provide display names for settings, player options, and item details.

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

Sequence Diagram(s)

sequenceDiagram
  participant ProfileSettings
  participant ResolveViewerPreferences
  participant access.Scope
  participant catalog.AccessFilter
  participant DetailService
  participant CatalogRepository
  ProfileSettings->>ResolveViewerPreferences: read metadata language preferences
  ResolveViewerPreferences->>access.Scope: return canonical overrides
  access.Scope->>catalog.AccessFilter: apply MetadataLanguageOverrides
  catalog.AccessFilter->>DetailService: request source-aware localization
  DetailService->>CatalogRepository: fetch parent languages and localized rows
  CatalogRepository-->>DetailService: return language and localization data
  DetailService-->>catalog.AccessFilter: return localized catalog models
Loading

Possibly related PRs

Suggested labels: v1

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.00% 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
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 Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: adding original-language metadata preferences.
✨ 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/metadata-language-preferences

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

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

Actionable comments posted: 1

🧹 Nitpick comments (6)
web/src/components/settings/MetadataLanguageSetting.test.tsx (1)

37-52: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for the add-exception and fallback paths.

The suite covers removal and the disabled add button. It does not assert that choosing a source and clicking "Add exception" calls onOverridesChange with the sentinel target, and it does not assert that the fallback select calls onFallbackChange with null for "Library default". Both are the primary write paths of this component.

🤖 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 `@web/src/components/settings/MetadataLanguageSetting.test.tsx` around lines 37
- 52, Add tests in the MetadataLanguageSetting suite covering both write paths:
select an original language and click “Add exception,” then assert
onOverridesChange receives the selected source mapped to the sentinel target;
also select “Library default” in the fallback control and assert
onFallbackChange receives null. Reuse the existing languageOptions and component
setup.
internal/api/handlers/settings_values_test.go (1)

882-905: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add negative coverage for the wantsMetadata gate.

The test proves the positive path. It does not prove that ListOriginalLanguages stays uncalled when CatalogMetadataLanguage is absent from resolved. That gate prevents an extra catalog query on every effective-settings read. Record the call on the stub and assert it.

💚 Proposed test addition
 type recordingLanguageSuggestionSource struct {
 	filters  catalog.BrowseFilters
 	original []string
+	calls    int
 }
 
 func (s *recordingLanguageSuggestionSource) ListOriginalLanguages(
 	_ context.Context, filters catalog.BrowseFilters,
 ) ([]string, error) {
 	s.filters = filters
+	s.calls++
 	return s.original, nil
 }

Then add a subtest that passes an unrelated key and asserts source.calls == 0.

🤖 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 `@internal/api/handlers/settings_values_test.go` around lines 882 - 905, Add a
negative subtest to
TestObservedLanguageSuggestionsIncludesAccessibleOriginalLanguages that invokes
observedLanguageSuggestions with an unrelated setting key, then assert the
recordingLanguageSuggestionSource call count remains zero. Ensure the stub
records ListOriginalLanguages invocations so the test verifies the wantsMetadata
gate prevents the catalog query when CatalogMetadataLanguage is absent.
internal/catalog/detail.go (2)

1111-1186: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider extracting the group-by-target-language logic.

loadItemLocalizations (Lines 999-1055), LocalizeSeasonModels, and LocalizeEpisodeModels (Lines 1207-1254) repeat the same five steps: resolve the base, compute a per-row target, group row IDs by target, sort the target languages, and merge per-language repository rows into one map. A generic helper parameterized over the row type and the batch fetch function would remove the duplication and keep the three paths from drifting. This is optional and can be deferred.

🤖 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 `@internal/catalog/detail.go` around lines 1111 - 1186, Optionally extract the
repeated target-language grouping and batched localization-fetch flow shared by
loadItemLocalizations, LocalizeSeasonModels, and LocalizeEpisodeModels into a
reusable generic helper. Parameterize it with the row type and repository fetch
function while preserving base-language resolution, per-row target calculation,
sorted language batches, merged results, and existing behavior; defer this
change if it would expand scope unnecessarily.

1211-1266: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Align LocalizeEpisodeModels with the item and season batch paths.

Two differences remain between this function and its siblings:

  1. Clone parity. LocalizeItemModels and LocalizeSeasonModels return clones for every row, including rows that receive no localization. This function returns the caller's own *models.Episode pointers on the early-return paths (Lines 1213, 1224, 1250) and in the final loop (Line 1258). LocalizeEpisodeModel also clones. A caller that mutates a returned episode therefore mutates the repository result only on the batch path.
  2. Deduplication parity. The item and season paths guard idsByLanguage with a seenByLanguage set. This function appends unconditionally, so a duplicated ContentID in the input produces a duplicated ID in the GetByEpisodeIDs argument.

Neither difference breaks a current caller. Aligning them keeps the three batch paths interchangeable.

♻️ Proposed change for clone parity
 	localized := make([]*models.Episode, len(episodes))
 	for i, ep := range episodes {
-		localized[i] = ep
+		localized[i] = cloneEpisode(ep)
 		if ep == nil {
 			continue
 		}
🤖 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 `@internal/catalog/detail.go` around lines 1211 - 1266, Update
LocalizeEpisodeModels to match the batch-path behavior of LocalizeItemModels and
LocalizeSeasonModels: clone every non-nil episode before returning, including
all early-return paths and episodes without localization, while preserving nil
entries and existing localization behavior. Add per-language ContentID
deduplication via a seenByLanguage set before appending to idsByLanguage, so
each GetByEpisodeIDs call receives unique IDs.
internal/api/handlers/catalog_resources.go (1)

231-235: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Batch localization failures fall back silently at three new call sites. Each site calls a Localize*Models method, and each discards both locErr and a length mismatch without a log. The response then serves default-language metadata, and a persistent localization failure produces no signal. LocalizeSeasonModels and LocalizeEpisodeModels return a repository error for a failed GetBySeasonIDs/GetByEpisodeIDs call, so this hides a real database failure.

  • internal/api/handlers/catalog_resources.go#L231-L235: add a slog.WarnContext(r.Context(), ...) call in the failure branch of the season localization guard, with component, the series id, and the error.
  • internal/jellycompat/content_direct.go#L838-L842: add the same warning in the failure branch of the season localization guard, using ctx and seriesID.
  • internal/jellycompat/content_direct.go#L925-L929: add the same warning in the failure branch of the episode localization guard, using ctx, seriesID, and seasonNumber.

Keep the fallback behavior. Only add the log.

🤖 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 `@internal/api/handlers/catalog_resources.go` around lines 231 - 235, Add
slog.WarnContext logging to the failure branches of the LocalizeSeasonModels and
LocalizeEpisodeModels guards while preserving their existing fallback behavior.
Update internal/api/handlers/catalog_resources.go lines 231-235 with
r.Context(), component, the series ID, and locErr; update
internal/jellycompat/content_direct.go lines 838-842 with ctx, component,
seriesID, and locErr; and lines 925-929 with ctx, component, seriesID,
seasonNumber, and locErr. No other behavior changes are needed.
internal/api/handlers/items.go (1)

1481-1492: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove the unused seriesID parameter from toSeasonResponseFromEpisodes. Update all three callers in internal/api/handlers/items.go and internal/api/handlers/catalog_resources.go. The configured linter list does not include unparam or revive, but the parameter is still unused.

🤖 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 `@internal/api/handlers/items.go` around lines 1481 - 1492, Remove the unused
seriesID parameter from seasonResponseFromEpisodes and update all three call
sites in ItemsHandler and catalog resource handlers to match the revised
signature, without changing the existing response 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.

Inline comments:
In `@web/src/lib/metadataLanguagePreferences.ts`:
- Around line 17-35: Validate metadata-language override targets in both
normalization and addition using the existing rule that accepts only
x-silo-original or valid BCP 47 tags; reject other strings while preserving
valid entries. In web/src/lib/metadataLanguagePreferences.test.ts lines 11-29,
add coverage for a valid source paired with an invalid string target. In
internal/settingscontract/contract_test.go line 1572, replace the invalid source
key with a valid source key so the test specifically verifies target-value
rejection.

---

Nitpick comments:
In `@internal/api/handlers/catalog_resources.go`:
- Around line 231-235: Add slog.WarnContext logging to the failure branches of
the LocalizeSeasonModels and LocalizeEpisodeModels guards while preserving their
existing fallback behavior. Update internal/api/handlers/catalog_resources.go
lines 231-235 with r.Context(), component, the series ID, and locErr; update
internal/jellycompat/content_direct.go lines 838-842 with ctx, component,
seriesID, and locErr; and lines 925-929 with ctx, component, seriesID,
seasonNumber, and locErr. No other behavior changes are needed.

In `@internal/api/handlers/items.go`:
- Around line 1481-1492: Remove the unused seriesID parameter from
seasonResponseFromEpisodes and update all three call sites in ItemsHandler and
catalog resource handlers to match the revised signature, without changing the
existing response behavior.

In `@internal/api/handlers/settings_values_test.go`:
- Around line 882-905: Add a negative subtest to
TestObservedLanguageSuggestionsIncludesAccessibleOriginalLanguages that invokes
observedLanguageSuggestions with an unrelated setting key, then assert the
recordingLanguageSuggestionSource call count remains zero. Ensure the stub
records ListOriginalLanguages invocations so the test verifies the wantsMetadata
gate prevents the catalog query when CatalogMetadataLanguage is absent.

In `@internal/catalog/detail.go`:
- Around line 1111-1186: Optionally extract the repeated target-language
grouping and batched localization-fetch flow shared by loadItemLocalizations,
LocalizeSeasonModels, and LocalizeEpisodeModels into a reusable generic helper.
Parameterize it with the row type and repository fetch function while preserving
base-language resolution, per-row target calculation, sorted language batches,
merged results, and existing behavior; defer this change if it would expand
scope unnecessarily.
- Around line 1211-1266: Update LocalizeEpisodeModels to match the batch-path
behavior of LocalizeItemModels and LocalizeSeasonModels: clone every non-nil
episode before returning, including all early-return paths and episodes without
localization, while preserving nil entries and existing localization behavior.
Add per-language ContentID deduplication via a seenByLanguage set before
appending to idsByLanguage, so each GetByEpisodeIDs call receives unique IDs.

In `@web/src/components/settings/MetadataLanguageSetting.test.tsx`:
- Around line 37-52: Add tests in the MetadataLanguageSetting suite covering
both write paths: select an original language and click “Add exception,” then
assert onOverridesChange receives the selected source mapped to the sentinel
target; also select “Library default” in the fallback control and assert
onFallbackChange receives null. Reuse the existing languageOptions and component
setup.
🪄 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: ee1063a7-3a77-47cb-a951-4b816d3a3af5

📥 Commits

Reviewing files that changed from the base of the PR and between d70b291 and cd1f456.

📒 Files selected for processing (31)
  • contracts/settings/v1/conformance.json
  • contracts/settings/v1/manifest.json
  • contracts/settings/v1/schemas/metadata-language-overrides.json
  • internal/access/metadata_language_test.go
  • internal/access/resolver.go
  • internal/access/resolver_test.go
  • internal/access/types.go
  • internal/access/viewer_preferences.go
  • internal/api/handlers/catalog_resources.go
  • internal/api/handlers/items.go
  • internal/api/handlers/settings_values.go
  • internal/api/handlers/settings_values_test.go
  • internal/catalog/access_filter.go
  • internal/catalog/detail.go
  • internal/catalog/detail_batch_equivalence_test.go
  • internal/catalog/detail_metadata_language_test.go
  • internal/jellycompat/access_filter.go
  • internal/jellycompat/access_filter_test.go
  • internal/jellycompat/content_direct.go
  • internal/policy/viewer_resolver.go
  • internal/policy/viewer_resolver_test.go
  • internal/settingscontract/contract_test.go
  • internal/settingskeys/keys.go
  • web/src/components/settings/MetadataLanguageSetting.test.tsx
  • web/src/components/settings/MetadataLanguageSetting.tsx
  • web/src/lib/metadataLanguagePreferences.test.ts
  • web/src/lib/metadataLanguagePreferences.ts
  • web/src/lib/settingsConformance.json
  • web/src/lib/settingsContract.ts
  • web/src/pages/settings/PlaybackSettings.test.tsx
  • web/src/pages/settings/PlaybackSettings.tsx

Comment on lines +17 to +35
for (const [source, target] of Object.entries(value)) {
const sourceCode = normalizeLanguageCode(source);
if (!/^[a-z]{2,3}$/.test(sourceCode) || typeof target !== "string" || !target.trim()) {
continue;
}
normalized[sourceCode] = target.trim();
}
return normalized;
}

export function withMetadataLanguageOverride(
overrides: MetadataLanguageOverrides,
source: string,
target: string,
): MetadataLanguageOverrides {
const sourceCode = normalizeLanguageCode(source);
if (!/^[a-z]{2,3}$/.test(sourceCode) || !target.trim()) return overrides;
return { ...overrides, [sourceCode]: target.trim() };
}

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Validate metadata-language override targets consistently.

The target must be x-silo-original or a valid BCP 47 tag. The current web helper retains arbitrary non-empty strings, and the current tests do not prove that invalid string targets are rejected.

  • web/src/lib/metadataLanguagePreferences.ts#L17-L35: reject invalid target strings in both normalization and addition.
  • web/src/lib/metadataLanguagePreferences.test.ts#L11-L29: add cases for a valid source with an invalid string target.
  • internal/settingscontract/contract_test.go#L1572-L1572: use a valid source key so this test proves target-value rejection.
📍 Affects 3 files
  • web/src/lib/metadataLanguagePreferences.ts#L17-L35 (this comment)
  • web/src/lib/metadataLanguagePreferences.test.ts#L11-L29
  • internal/settingscontract/contract_test.go#L1572-L1572
🤖 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 `@web/src/lib/metadataLanguagePreferences.ts` around lines 17 - 35, Validate
metadata-language override targets in both normalization and addition using the
existing rule that accepts only x-silo-original or valid BCP 47 tags; reject
other strings while preserving valid entries. In
web/src/lib/metadataLanguagePreferences.test.ts lines 11-29, add coverage for a
valid source paired with an invalid string target. In
internal/settingscontract/contract_test.go line 1572, replace the invalid source
key with a valid source key so the test specifically verifies target-value
rejection.

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

Caution

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

⚠️ Outside diff range comments (1)
web/src/components/settings/MetadataLanguageSetting.tsx (1)

44-92: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Overlapping override edits can briefly hide a still-pending change.

changeOverrides captures pending.base from the overrides prop at call time (Line 85). If a second override edit starts before the first one's onOverridesChange call settles, and the first call succeeds and updates the overrides prop first, the equality check on Line 58 (overridesEqual(overrides, optimisticOverrides.base)) fails for the second, still-pending edit. currentOverrides then falls back to the real overrides prop, which does not yet include the second edit, so its row visually disappears until its own save settles and the prop catches up.

The final state converges correctly in this component (each call reads currentOverrides at invocation time, so payloads are cumulative), so this is a transient display glitch rather than data loss. Nothing currently prevents two rows (or add + edit) from being changed concurrently: only the external disabled prop gates the controls, not an in-flight state local to this component.

Add a local "saving" flag that disables the override rows and the add-exception control while any changeOverrides call is outstanding. This removes the possibility of overlapping calls entirely.

🩹 Proposed fix to serialize override edits
+  const [isSaving, setIsSaving] = useState(false);
   const currentOverrides =
     optimisticOverrides !== null && overridesEqual(overrides, optimisticOverrides.base)
       ? optimisticOverrides.value
       : overrides;
@@
   const changeOverrides = async (next: MetadataLanguageOverrides) => {
     const pending = { base: overrides, value: next };
     setOptimisticOverrides(pending);
+    setIsSaving(true);
     try {
       await onOverridesChange(next);
     } catch {
       setOptimisticOverrides((current) => (current === pending ? null : current));
+    } finally {
+      setIsSaving(false);
     }
   };

Then pass disabled={disabled || isSaving} to the per-row SelectTrigger/remove Button (Lines 145, 163), and to the new-exception SelectTrigger/Button (Lines 184, 200).

🤖 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 `@web/src/components/settings/MetadataLanguageSetting.tsx` around lines 44 -
92, Add an isSaving state to MetadataLanguageSetting and set it while
changeOverrides is awaiting onOverridesChange, clearing it in a finally block so
failures also re-enable controls. Use disabled || isSaving for each override
row’s SelectTrigger and remove Button, plus the new-exception SelectTrigger and
Button, preventing concurrent edits while preserving existing disabled 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 `@web/src/components/settings/MetadataLanguageSetting.tsx`:
- Around line 44-92: Add an isSaving state to MetadataLanguageSetting and set it
while changeOverrides is awaiting onOverridesChange, clearing it in a finally
block so failures also re-enable controls. Use disabled || isSaving for each
override row’s SelectTrigger and remove Button, plus the new-exception
SelectTrigger and Button, preventing concurrent edits while preserving existing
disabled behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4302875c-26d0-43a0-b558-5c1ef75fc335

📥 Commits

Reviewing files that changed from the base of the PR and between cd1f456 and f548cdd.

📒 Files selected for processing (4)
  • internal/settingscontract/contract_test.go
  • web/src/components/settings/MetadataLanguageSetting.test.tsx
  • web/src/components/settings/MetadataLanguageSetting.tsx
  • web/src/pages/settings/PlaybackSettings.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • web/src/pages/settings/PlaybackSettings.tsx
  • internal/settingscontract/contract_test.go

@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: f548cddbd0

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

SETTING_KEYS.PLAYBACK_AUTO_SKIP_INTRO,
SETTING_KEYS.PLAYBACK_AUTO_SKIP_RECAP,
SETTING_KEYS.CATALOG_METADATA_LANGUAGE,
SETTING_KEYS.CATALOG_METADATA_LANGUAGE_OVERRIDES,

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 Gate the revision-3 key before querying older servers

When this web build connects to a revision-2 backend, adding this key makes the entire batched GET /settings/values/effective request fail with 404 unknown_setting because HandleGetEffective rejects any unknown key rather than omitting it. The page then renders contract defaults for every playback control, not merely hiding the unsupported exceptions editor. Use the capabilities revision to exclude this key and component until the server reports revision 3; useContractIsAheadOfServer already exists but is not used by this page.

AGENTS.md reference: AGENTS.md:L118-L119

Useful? React with 👍 / 👎.

@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: 2b2cc929fc

ℹ️ 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 +808 to +810
if sameMetadataLanguage(target, access.OriginalMetadataLanguage) {
if original != "" {
return original

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 Serve the stored title for original-language preferences

When an item's base metadata was fetched in a library language such as English but original_language is ja, this resolves the sentinel to ja and then only looks for a media_item_localizations row in that language. The normal ingestion path fetches the configured/default library languages, so such a row commonly does not exist even though media_items.original_title already contains the Japanese title; localizeItemModelWith consequently returns the English base model unchanged. This makes “Original language” ineffective on browse cards and other responses that do not expose original_title, so the original-target path should at least apply the stored original title (and use richer localization data when available).

Useful? React with 👍 / 👎.

Comment on lines +1044 to +1046
localizations := make(map[string]*models.MediaItemLocalization)
for _, language := range languages {
rows, err := s.itemLocRepo.GetByContentIDs(ctx, idsByLanguage[language], language)

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 Read episode localizations from the episode table

When /api/v1/catalog/query uses the episode media scope, episodeCatalogSelectBody hydrates episode IDs into models.MediaItem values and catalogItemResponses sends them through this method. The lookup here always queries media_item_localizations, but translated episode titles and overviews are stored in episode_localizations; therefore an original-language rule or exception resolves a target correctly but episode catalog cards remain in the base language. Split episode rows out and load them through episodeLocRepo.GetByEpisodeIDs, as the dedicated episode list paths already do.

Useful? React with 👍 / 👎.

Comment on lines +1045 to +1046
for _, language := range languages {
rows, err := s.itemLocRepo.GetByContentIDs(ctx, idsByLanguage[language], language)

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 Batch mixed-language localization in one query

For a profile using global “Original language,” every distinct source language represented on a catalog page becomes a separate target, and this loop performs those database requests sequentially. A mixed international page can therefore add dozens of round trips to a single browse request (the schema permits up to 256 exceptions), making latency and database load scale with language diversity rather than page count. Fetch the required (content_id, language) pairs in one query, or at least use a bounded batched query, so this preference remains predictable under load.

AGENTS.md reference: AGENTS.md:L12-L14

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot added the v1.0 Silo v1 scope - auto-adds to the Silo v1 project label Jul 31, 2026

@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: 57b80ba646

ℹ️ 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 +1833 to +1834
ProfilePreferredLanguage: scope.PreferredMetadataLanguage,
MetadataLanguageOverrides: scope.MetadataLanguageOverrides,

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 metadata preferences through the shared filter

When a profile with Original language or a per-language exception requests a managed download manifest, downloads.go builds it with requestAccessFilter, which still drops both scope.PreferredMetadataLanguage and scope.MetadataLanguageOverrides; ManifestBuilder.build then passes that incomplete filter to GetItemDetail. Unlike item endpoints using the mapping here, offline manifests therefore retain base-language titles, overviews, and artwork. Add these fields to the shared requestAccessFilter mapping as well.

Useful? React with 👍 / 👎.

return nil, nil
}
language, err := s.resolvePresentationLanguage(ctx, filter)
language, err := s.resolvePresentationLanguage(ctx, filter, item.OriginalLanguage)

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 Hydrate original languages in filtered catalog rows

When POST /api/v1/catalog/query returns media items, HandlePostCatalogQuery constructs them with filterItemColumns, which does not select or scan original_language; this new call therefore always receives an empty item.OriginalLanguage on that route. A global Original language preference consequently falls back to the library/base language, and every per-original-language exception is skipped, so filtered catalog cards do not honor the new preferences. Include original_language in that query and scan.

Useful? React with 👍 / 👎.

@Quick104
Quick104 merged commit 73488d1 into main Jul 31, 2026
4 checks passed
@Quick104
Quick104 deleted the t3code/metadata-language-preferences branch July 31, 2026 19:23
Quick104 added a commit that referenced this pull request Aug 1, 2026
…anguage scans

GET /settings/values/effective computed suggested language values with
three sequential full-catalog scans on every request. On a 439k-item
deployment that took ~25s, dominated by the subtitle listing whose UNION
deduplicated ~5M unnested track rows.

- Deduplicate each subtitle arm before merging (UNION ALL of two
  DISTINCT arms instead of UNION across all rows) and bound the result
  with the facet LIMIT: 22.8s -> ~8.5s of per-arm work on that catalog.
- Cache the observed lists per (list kind, access scope) for 15 minutes
  and collapse concurrent misses with singleflight.
- Run the three lookups concurrently, and cap a cold-cache wait at 2s:
  the response ships with the contract floor while the detached scan
  finishes and fills the cache for the next request.

Part of the device settings screen work; the regression itself shipped
in #526.

Co-Authored-By: Claude Fable 5 <[email protected]>
Quick104 added a commit that referenced this pull request Aug 1, 2026
* feat(settings): let users manage device settings across their devices

Adds the server half of the user-facing device settings screen: a viewer can
see the devices they watch on and change settings for any of them from
whichever device they are holding, and the household parent can do the same for
everyone on the account.

No schema change. user_devices and user_setting_values are already keyed
(user_id, profile_id, device_id), and both list queries are already
account-wide, so this is authorization plus routes.

Two identity widenings on the canonical settings API, each behind a guard:

- A caller may name a device_id other than the request's own. Authorized
  against user_devices for that profile, which is why DeviceExists lands
  first: completeIdentity validated an identity's shape but never that the
  device belonged to the caller, safe only while the id came from the header.
- A household parent may name a profile_id other than their own. Guarded by
  canManageHousehold, extracted from ProfileHandler so profile management and
  settings management cannot drift apart. Existence resolves through the
  caller's own store, so a foreign profile is 404 and the cross-account
  boundary holds for free.

Both default to today's behavior when the parameter is absent, so existing
clients need no change.

New self-service routes: GET /devices, DELETE /devices/{id}, and
DELETE /devices/{id}/settings. The list filters to the calling profile in the
handler — ListDevices is account-wide by construction in both backends (no
WHERE at all in the per-user SQLite), so a passthrough would have shown every
household member's devices to everyone. ?scope=household is opt-in and guarded.

Also fixes a bug the widening exposed: registerWritingDevice fired on every
device write, so writing to another device — or on another profile's behalf —
would have registered the actor's browser under the target, inventing a device
nobody holds.

Cross-profile and admin mutations are audited. The record carries identity
only, never the value, for the same reason user_settings.changed does: admins
receive other accounts' events. Ordinary self-service writes are not audited —
a trail that records everything answers nothing.

Part of #215

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* feat(settings): add the user-facing device settings screen

Adds "Your devices" under Settings: a searchable device list and an editable
detail pane, so someone can fix how Silo behaves on any device they watch on
without borrowing that device. The household parent gets an "Everyone" switch
covering every profile on the account.

Layout is master-detail, and holds at eleven devices: fixed-height rows
carrying a name, when it was last used, and the one number that matters — how
many settings differ there. A device with nothing changed shows a dash rather
than a zero, so "which one did I change?" is answerable by scanning. Rows group
by recency, or by person in the household view.

Settings are grouped by what they affect — Picture, Sound, Subtitles,
Episodes — rather than in manifest order, and no raw key is ever shown: labels,
descriptions, controls, bounds and options all come from the contract. A test
asserts every device-scoped key lands in exactly one group or is deliberately
hidden, so a key added to the manifest cannot silently vanish from the screen.

Values round-trip as typed JSON rather than through strings, unlike the admin
console: a slider re-parsed from text is a hazard on a screen a viewer drives.

Policy caps are explained rather than hidden. A capped setting renders only the
permitted options and says which value the household limit displaced; a locked
one says so instead of presenting a disabled control with no reason.

Acting for someone else is stated, never implied — a persistent banner, and
reset actions that name the person ("Use Robin's setting"). The household view
also states what it does not show: this is how Silo is set up per device, not
what anyone watched.

Two fixes the work turned up:

- effectiveSettingsQueryKey was namespaced by active profile only, so reading
  another device's values would have collided with the current device's cache
  entry and served one device's settings as another's.
- The settings shell caps content at max-w-3xl, which is right for a single
  column of rows and squeezes a two-pane page. Pages that manage their own
  layout now opt out.

Part of #215

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* feat(settings): filter the household device list by profile

Adds profile chips above the device list in the household view: Everyone, then
one per person, each with a device count. Picking a person narrows the list to
their devices; picking the active chip again clears it.

The chips only appear in the household view, where more than one profile is on
screen. A viewer looking at their own devices has exactly one profile, so a
filter with a single option would be chrome that explains nothing.

Three details the interaction needs to be honest:

- Counts come from the unfiltered list, so a chip keeps saying how many devices
  it would reveal instead of collapsing to zero once another chip is active.
- Grouping falls back to recency once a person is chosen, because a person
  heading would only repeat the chip above it.
- The detail pane follows the filter. Leaving someone else's device open while
  the list shows another person would make the list and the pane disagree about
  whose settings are being edited — the one thing this screen cannot be vague
  about. Leaving the household view clears the filter for the same reason.

The chip's count sits in its own element, so its accessible name is set
explicitly: without it a screen reader announces "Everyone3".

Part of #215

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(settings): lead the profile filter with the viewer's own chip

Seeding a realistic eight-profile household made the ordering problem obvious:
chips were in device-arrival order, which put the person actually using the
screen last. Their own profile now comes first and the rest sort by name, so a
chip stays where it was last seen rather than moving as devices are used.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(settings): make the device screen work on a phone

The screen was built two-pane and stacked those panes vertically on narrow
viewports, which is the wrong shape for a phone: the device list ran past a
thousand pixels before the first setting, so reaching "turn HDR off" meant
scrolling through every other device to get there. The whole page measured 4726
CSS pixels — 5.6 screens — for four devices.

Below xl the list and the settings are now two screens rather than two panes.
Picking a device swaps to it and a back control returns; the page header and
scope switch belong to the list screen, and the detail screen's own header says
which device it is about. The list page is 1050px, and scroll position resets on
each swap so a tap does not land mid-settings.

Touch targets were 32-36px throughout. Rows, chips, the scope switch, the reset
link and the header actions now clear 44px on a phone and keep their compact
desktop sizing from xl. Device rows carry a chevron below xl, because there they
navigate rather than select in place. The device search input goes to 16px on
mobile — iOS Safari zooms the viewport for anything smaller and does not zoom
back out.

Profile chips wrapped to three lines at eight profiles and pushed the list off
screen; they scroll horizontally on one line instead, the same trade the
settings shell's own mobile tab bar makes. Switches now sit beside their labels
rather than below, saving a row on each of ~18 toggles, while selects and
sliders still take the full width they need.

Two fixes the pass turned up, neither mobile-specific:

- playback.max_bitrate_kbps is declared as an integer range with a select
  control and no members, so it rendered as a dropdown with one blank entry —
  unusable, and silent about the value it was storing. It now offers real
  bandwidth choices bounded by the definition's own range, and keeps a
  non-preset stored value selectable.
- Select triggers had no accessible name, announcing as bare comboboxes.

Forget is destructive and rare, so it no longer sits as a full-width sibling of
the common action.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(settings): keep the device list usable at hundreds of devices

A real account carries 260 devices; the test fixtures had 14. Every browser
profile, private window, reinstall and test build registers a device identity
and nothing prunes them, so the list grew without limit — 13,681 CSS pixels,
sixteen screens, and the settings themselves never came into view. That is the
same failure the mobile pass just fixed, at a scale the fixtures never showed.

Three changes:

- The list is a bounded scroll area rather than an unbounded column. The page
  is now ~1,300px whatever the device count, and section headings stick while
  scrolling so the recency or person grouping stays legible.
- Devices nobody has used for 90 days that carry no settings of their own
  collapse behind "Show N unused devices". Over half of the real fleet is that:
  one-off sessions that never changed anything. The current device and anything
  with settings always stay visible, however old.
- Search spans everything including the hidden tail, because searching means
  looking for something specific and hiding a device from its own name would
  read as the device having vanished.

The 90-day threshold matches the settings contract's own rule for removing
empty device records, which is specified but not yet implemented server-side —
until it is, this keeps the screen usable.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(settings): offer the whole bandwidth range the contract allows

The bandwidth cap stopped at 40 Mbps because the ladder behind it was a
hardcoded list I wrote, not anything the contract said. The definition allows
up to 200,000 kbps, and remuxed 4K HDR or an untouched Blu-ray rip needs well
past 40 — so the picker was silently capping people below what their own server
could already send them.

The ladder now runs to the definition's own ceiling. Its low end mirrors the
in-player quality switcher, so a cap chosen here lines up with what the player
offers mid-playback, and entries outside a definition's declared range are
filtered out as before.

Also stops duplicating the label format a third time: the player's
formatQualityBitrate is now exported and reused, since both surfaces pick from
the same ladder and should not disagree about how to spell a number.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* style(settings): use the app's overlay scrollbar in the device list

The bounded device list kept the browser's default scrollbar, which reads as a
heavy grey slab against a rounded dark panel. The app already has
.overlay-scroll for exactly this — a thin, low-contrast thumb over a
transparent track — and it now sits in the panel's gutter rather than flush
against the rounded edge.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* perf(settings): stop effective-values from stalling on live catalog language scans

GET /settings/values/effective computed suggested language values with
three sequential full-catalog scans on every request. On a 439k-item
deployment that took ~25s, dominated by the subtitle listing whose UNION
deduplicated ~5M unnested track rows.

- Deduplicate each subtitle arm before merging (UNION ALL of two
  DISTINCT arms instead of UNION across all rows) and bound the result
  with the facet LIMIT: 22.8s -> ~8.5s of per-arm work on that catalog.
- Cache the observed lists per (list kind, access scope) for 15 minutes
  and collapse concurrent misses with singleflight.
- Run the three lookups concurrently, and cap a cold-cache wait at 2s:
  the response ships with the contract floor while the detached scan
  finishes and fills the cache for the next request.

Part of the device settings screen work; the regression itself shipped
in #526.

Co-Authored-By: Claude Fable 5 <[email protected]>

* refactor(settings): replace track-language catalog scans with picker free entry

Deployment-observed suggestions now decorate catalog.metadata_language
only — original_language is one indexed DISTINCT scan (~0.2s on a 439k
item catalog) and feeds the metadata-exceptions panel, where observed
data is load-bearing. The audio and subtitle track listings (up to tens
of seconds of media-file walking) are no longer queried for settings at
all, which also removes the TTL cache and singleflight added to manage
them.

Those pickers keep the contract's authored floor and gain an explicit
escape hatch instead: a shared LanguageSelect with an "Other…" entry
that accepts a BCP 47 tag, previews the resolved language name, and
refuses invalid tags. The settings are open language_tag values, so a
typed tag needs no server change, and a stored off-floor value already
renders through the current-value merge. The device screen hides the
free entry when policy pins permitted_values.

The browse facet queries keep the subtitle UNION ALL rewrite from the
previous commit; catalog browse still lists observed track languages.

suggested_values on playback.audio_language and
playback.subtitle_language now returns only the contract floor plus the
stored value — Android and Apple pickers need the same free-entry
affordance as follow-up.

Co-Authored-By: Claude Fable 5 <[email protected]>

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v1.0 Silo v1 scope - auto-adds to the Silo v1 project

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant