Repository navigation
feat(metadata): add original-language preferences - #526
Conversation
📝 WalkthroughWalkthroughThe 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. ChangesMetadata language override flow
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
Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (6)
web/src/components/settings/MetadataLanguageSetting.test.tsx (1)
37-52: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd 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
onOverridesChangewith the sentinel target, and it does not assert that the fallback select callsonFallbackChangewithnullfor "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 valueAdd negative coverage for the
wantsMetadatagate.The test proves the positive path. It does not prove that
ListOriginalLanguagesstays uncalled whenCatalogMetadataLanguageis absent fromresolved. 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 valueConsider extracting the group-by-target-language logic.
loadItemLocalizations(Lines 999-1055),LocalizeSeasonModels, andLocalizeEpisodeModels(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 valueAlign
LocalizeEpisodeModelswith the item and season batch paths.Two differences remain between this function and its siblings:
- Clone parity.
LocalizeItemModelsandLocalizeSeasonModelsreturn clones for every row, including rows that receive no localization. This function returns the caller's own*models.Episodepointers on the early-return paths (Lines 1213, 1224, 1250) and in the final loop (Line 1258).LocalizeEpisodeModelalso clones. A caller that mutates a returned episode therefore mutates the repository result only on the batch path.- Deduplication parity. The item and season paths guard
idsByLanguagewith aseenByLanguageset. This function appends unconditionally, so a duplicatedContentIDin the input produces a duplicated ID in theGetByEpisodeIDsargument.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 valueBatch localization failures fall back silently at three new call sites. Each site calls a
Localize*Modelsmethod, and each discards bothlocErrand a length mismatch without a log. The response then serves default-language metadata, and a persistent localization failure produces no signal.LocalizeSeasonModelsandLocalizeEpisodeModelsreturn a repository error for a failedGetBySeasonIDs/GetByEpisodeIDscall, so this hides a real database failure.
internal/api/handlers/catalog_resources.go#L231-L235: add aslog.WarnContext(r.Context(), ...)call in the failure branch of the season localization guard, withcomponent, 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, usingctxandseriesID.internal/jellycompat/content_direct.go#L925-L929: add the same warning in the failure branch of the episode localization guard, usingctx,seriesID, andseasonNumber.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 winRemove the unused
seriesIDparameter fromtoSeasonResponseFromEpisodes. Update all three callers ininternal/api/handlers/items.goandinternal/api/handlers/catalog_resources.go. The configured linter list does not includeunparamorrevive, 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
📒 Files selected for processing (31)
contracts/settings/v1/conformance.jsoncontracts/settings/v1/manifest.jsoncontracts/settings/v1/schemas/metadata-language-overrides.jsoninternal/access/metadata_language_test.gointernal/access/resolver.gointernal/access/resolver_test.gointernal/access/types.gointernal/access/viewer_preferences.gointernal/api/handlers/catalog_resources.gointernal/api/handlers/items.gointernal/api/handlers/settings_values.gointernal/api/handlers/settings_values_test.gointernal/catalog/access_filter.gointernal/catalog/detail.gointernal/catalog/detail_batch_equivalence_test.gointernal/catalog/detail_metadata_language_test.gointernal/jellycompat/access_filter.gointernal/jellycompat/access_filter_test.gointernal/jellycompat/content_direct.gointernal/policy/viewer_resolver.gointernal/policy/viewer_resolver_test.gointernal/settingscontract/contract_test.gointernal/settingskeys/keys.goweb/src/components/settings/MetadataLanguageSetting.test.tsxweb/src/components/settings/MetadataLanguageSetting.tsxweb/src/lib/metadataLanguagePreferences.test.tsweb/src/lib/metadataLanguagePreferences.tsweb/src/lib/settingsConformance.jsonweb/src/lib/settingsContract.tsweb/src/pages/settings/PlaybackSettings.test.tsxweb/src/pages/settings/PlaybackSettings.tsx
| 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() }; | ||
| } |
There was a problem hiding this comment.
🎯 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-L29internal/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.
There was a problem hiding this comment.
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 winOverlapping override edits can briefly hide a still-pending change.
changeOverridescapturespending.basefrom theoverridesprop at call time (Line 85). If a second override edit starts before the first one'sonOverridesChangecall settles, and the first call succeeds and updates theoverridesprop first, the equality check on Line 58 (overridesEqual(overrides, optimisticOverrides.base)) fails for the second, still-pending edit.currentOverridesthen falls back to the realoverridesprop, 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
currentOverridesat 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 externaldisabledprop 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
changeOverridescall 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-rowSelectTrigger/removeButton(Lines 145, 163), and to the new-exceptionSelectTrigger/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
📒 Files selected for processing (4)
internal/settingscontract/contract_test.goweb/src/components/settings/MetadataLanguageSetting.test.tsxweb/src/components/settings/MetadataLanguageSetting.tsxweb/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
There was a problem hiding this comment.
💡 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, |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
💡 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".
| if sameMetadataLanguage(target, access.OriginalMetadataLanguage) { | ||
| if original != "" { | ||
| return original |
There was a problem hiding this comment.
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 👍 / 👎.
| localizations := make(map[string]*models.MediaItemLocalization) | ||
| for _, language := range languages { | ||
| rows, err := s.itemLocRepo.GetByContentIDs(ctx, idsByLanguage[language], language) |
There was a problem hiding this comment.
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 👍 / 👎.
| for _, language := range languages { | ||
| rows, err := s.itemLocRepo.GetByContentIDs(ctx, idsByLanguage[language], language) |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
💡 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".
| ProfilePreferredLanguage: scope.PreferredMetadataLanguage, | ||
| MetadataLanguageOverrides: scope.MetadataLanguageOverrides, |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 👍 / 👎.
…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]>
* 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]>
Problem
Part of #135
Profiles currently have one fixed metadata-language preference. That cannot express either of these common policies:
The same preference also needs to resolve consistently for movies, series, seasons, episodes, batched catalog reads, and Jellyfin-compatible responses.
Approach
x-silo-originalto the existing opencatalog.metadata_languagesetting; the server resolves it to each item's concrete original language before localization or AI-translation decisionscatalog.metadata_language_overridesobject mapping canonical original-language codes to a target BCP 47 tag, so older clients can continue editing the fallback without discarding per-language exceptionspt-BRThe requested example is represented as fallback
enplus{ "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 warningscd web && pnpm run format:check— passedcd web && pnpm run build— passedmake verify-settings-bindings-all verify-local-paths— passedmake lint— executed; the repository-wide baseline still reports 305 existing findings, while changed-lines lint is cleangit diff --check origin/main...HEAD— passedRuntime/browser verification on exact commit
cd1f45650b454880d9ab009e2d828db3ba824242:ee556bfe53ae7a96ba9ae555ced046f55883f6d0a3a50eaf3738bd813ed797b6)/api/v1/healthand/api/v1/readyreturnedok; the live settings capability reported revision 3pt-BRtarget remained selectable and exactpending_translation_language: "no"catalog.metadata_language = "en"row with no override rowRisks and follow-up
AI Disclosure
Checklist
make lint,cd web && pnpm run lint,cd web && pnpm run format:check, and relevantgo test ./...coverage throughmake test.Summary by CodeRabbit
New Features
Bug Fixes
UX follow-up — exception row appears without refresh
Commit
f548cddbmakes exception edits optimistic while the profile write is pending and rolls the row back if the save fails. Final PR head2b2cc929adds the required browser evidence only; that documentation-only commit was also deployed, with the runtime image fully cached from the verified code commit.Raw verification output
Focused regression and rollback tests:
Full web suite:
Changed-lines Go lint and touched Go package:
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
57b80ba6fixes the narrow-screen clipping found after the immediate-row UX change. Belowsm, 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 fromsmupward.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.
Mobile verification output
Focused component tests:
Repository web test gate:
The additional unfiltered Vitest run found only the repository's existing excluded failures: 3
SeasonContenttests without aQueryClientProviderand 3ServerStorageSteptests withoutResizeObserver. Its remaining 254 files and 1,653 tests passed.pnpm run lintcompleted with 0 errors and 157 existing warnings;pnpm run format:check,pnpm run build,make verify-local-paths, andgit diff --checkpassed.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: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
ISO language-name follow-up
Commit
b811996breplaces 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_tagvalues, and its existing design assigns display-name localization to client CLDR/ICU data. Revision 3 still represents the new override setting and schema.ISO language-name verification output
Focused regression coverage:
Final repository web gate:
make testpassed the complete Go suite and web gate before the final one-test regression addition.pnpm run lintcompleted with 0 errors and 157 existing warnings;pnpm run format:check,pnpm run build,make verify-local-paths, andgit diff --checkpassed 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: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