Repository navigation
feat(collections): pick rule values from your libraries and simplify the editor - #1991
Conversation
searchCatalogFacet scanned every title in scope on each keystroke (SELECT DISTINCT UNNEST ... LIKE prefix), 180-310 ms at 500k titles, and the prefix was not escaped. Genre, studio, network, country, original_language and content_rating now read a per-scope list of values with title counts, built with one GROUP BY query and cached in process for two minutes. The cache key is a hash of the exact scope SQL and arguments, so viewers with different access never share a list. Concurrent misses share one build, which runs on (with a 30 s timeout) when the request that started it is canceled, since the next keystroke needs the same list; a failed or timed-out build caches nothing. Lists are evicted least recently used once the cache holds 500,000 values. A scope with more distinct values than that is searched in SQL with an escaped match. History searches without a snapshot round "now" up to the next minute so their scope, and so their cache key, is stable between keystrokes. v2 matching is case-insensitive on the whole value or any word in it, ranks whole-value matches first, then by title count, then A-Z, and an empty q returns the most common values. The response adds values with counts next to matches, CatalogFiltersInput adds library_ids (narrowed to the viewer's libraries), and getCatalogSearchCapabilities advertises facet_value_search. The v1 bridge keeps prefix-only A-Z answers. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Genre, studio, network, country and content rating rules match exactly and case-sensitively, so a typed value with a typo made an empty collection or row. Their value is now a picker: it opens on the most common values in the rule's libraries and kind of titles with title counts, searches as you type, and still accepts text no title has yet with a note saying so. A saved value missing from the list stays pinned. Older servers without facet_value_search get prefix search on typed text. Rule rows also read as words: "is at least/at most/above/below/between", Yes/No for switches, Movies/Shows for Type, a kbps unit on bitrate (the unit media_files stores). Dates take date inputs, and "in the last" a number and unit that write the same "30d" value; saved values the controls can't read stay as text. Fields are grouped (Title, People, File, You, Library); Status and genre "contains" appear only for saved rules that use them. Adding a rule focuses its value, and the max titles box is drawn like the selects beside it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A new server Smart collection showed ghost posters until a library was picked, while the rule value picker already counted matches across every library, so the picker said "3 titles" and the preview showed none. The preview now runs across every library meanwhile and says so; Create and Save still wait for a library. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The editor was a two-column grid with a phone section switcher, and its
artwork sat inside Details as two stacked controls per image. It is now
one column, at most 768px wide, the same at every width, in the order a
collection is made: Name and description, the type's contents (Smart:
Rules, then Live preview), Where it shows, then Look.
Where it shows is a settings list with one row each: Libraries (named, or
"Not picked yet", with Change moving focus to the libraries control),
Shelf (with Arrange once it exists), the Collections tab switch, and Rows
that show it. Before the collection is created that last row is one line
instead of a disabled Add as a row button. Personal collections keep the
sharing switch, the Collections tab switch and their own rows.
Look starts closed as one line with small thumbnails and a summary
("Poster: a collage of its titles · Backdrop: none") and opens to a tile
per image. Each tile has one pencil menu: Upload image…, Paste a link…
(the link field shows only then), and Use the collage or Remove backdrop.
Choices stay staged until Save, as before, and the requests are the same.
Look opens by itself when an image couldn't be saved, so Retry is shown.
Before Create, the save bar says what's still missing in page order: the
name, then the libraries, then for a Smart collection how many titles
match now ("38 titles match now. New ones join on their own."). It used
to keep saying "Name it, then create it." after the name was filled.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
With no poster the header kept a blank 64px column, so the title sat indented from the cards below. The column now appears only when there is a poster. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A personal collection without an uploaded or imported poster now shows a collage of its first titles' posters, as a server collection does. The collage follows the viewer: another profile's shared collection shows only titles both the owner and the viewer can access. The server collage flow is shared between both kinds of collection. Personal collages live in user_personal_collection_poster_variants with the same key scheme, background build queue, collector reservation and retirement. Reads serve a stored collage or none while one builds; creates, edits, membership changes, poster removal and syncs start a build. Only /api/v2 reads show collages. /api/v2 adds poster_is_collage on personal and admin collections and poster_collages on getCollectionCapabilities, and reports artwork: false for personal collections when the server has no artwork storage. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The editor header and the Look card show the collage the server returns
and say so ("Poster: a collage of its titles"). Without a poster yet the
Look card says a collage comes once the titles have posters, and a
server Smart collection's poster reads as none. Use the collage is
disabled while the collage is in use. After a change, the editor reads
the list again for a short while until the collage arrives.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Profiles may always build their own rule rows ("Titles matching rules")
on Home and library pages. The "Let profiles add rule rows" switch and
the sections.allow_profile_custom_sections setting behind it are gone.
The server no longer reads the setting. custom_filter and genre are no
longer admin-only recipes. A profile that is not an admin still can't add
a new Editor's picks row (403 custom_disabled, as before), but keeps and
can change the ones already saved on its page, so a page holding one is
never refused. The web drops the More menu switch, its confirm dialog,
the Add row note and the page lock with its "Delete rule rows" flow, and
the layout import now skips only Editor's picks rows for such profiles.
/api/v2 removes getAdminSectionSettings and updateAdminSectionSettings
(approved pre-lock removals). getProfileSectionFlags keeps
allow_profile_custom_sections, always true and marked deprecated. The
frozen /api/v1 routes keep working: both reads answer true, and the
admin PUT checks the body and changes nothing. A stored setting row is
left in place and ignored.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Major change: revalidate silo-server #193 S3 and S6 after merge. The v2 list path now returns a server-composed, profile-specific collage for personal collections without assigned posters. S3’s prior pass covered member and stream access, not this new image output; verify each collage uses only titles the viewer and owner may access. S6’s server artwork evidence covered assigned posters, not these collage URLs, and its native URL-resolution checks have not been run. The existing #1616 reorder blocker is unchanged. The PR must explain why this previously validated API-visible poster behavior is changing, and S3/S6 need re-validation after merge. Suggested fix: connect the intended poster-response change to the prior behavior in the PR rationale, then re-test collage output with restricted-profile and native-client fixtures. No code diff is suggested. Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
|
Updated the body: the collage section now explains the change to S3/S6 poster behavior, and the Validation tasks line marks #193 S3 and S6 for re-validation after merge. |
|
The PR changes two previously exercised #193 paths and needs revalidation. S3's access checks did not exercise derived poster content; The Suggested line: Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dc28b7de90
ℹ️ 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".
| for _, c := range smart { | ||
| src, seen := byDefinition[c.QueryDefinition] | ||
| if !seen { | ||
| var err error | ||
| src, err = p.smartSources(ctx, c.QueryDefinition, access) |
There was a problem hiding this comment.
Defer smart collage source lookups
When a profile can see many Smart collections without assigned posters, every v2 collection-list read runs smartSources/PreviewPage serially for every distinct definition, even when the requested collage is already stored. Since ListCollections has no collection limit, dozens or hundreds of Smart collections create an unbounded query chain on a normal page load, increasing request latency and database load linearly and potentially timing out the page. Cache, batch, or move these source lookups off the synchronous list path.
AGENTS.md reference: AGENTS.md:L73-L75
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed the call path at 96fdb93. listCollections, getLibraryCollections and listLibraryUserCollections all reach Posters → ListSources, which runs PreviewPage (LIMIT 12) once per distinct smart definition, one after another, before it looks up any stored row. Server collections avoid this because a live-query collection gets no collage there. I didn't measure it. Any cache for the sources needs the viewer's access filter in its key, because each variant is built from the titles that viewer can see.
There was a problem hiding this comment.
Fixed in 916e648: list reads no longer run smart queries. A background refresh reads the matches, builds the collage, and records it per collection and viewer-access hash (with a definition hash) in a new user_personal_collection_smart_collages table; the read serves those records with one statement and queues a refresh when a record is missing, made for another definition, or older than 15 minutes. Measured with a statement-counting tracer: 8 smart collections went from 9 statements (8 serial smart queries + collage lookup) to 1; pinned in scripts/ci/db-pins.txt as TestPersonalCollectionCollageListReadsSkipSmartQueriesDB.
| SyncScheduleEditable bool `json:"sync_schedule_editable" doc:"updateCollection accepts sync_schedule on a synced list; false when imports is false" example:"true"` | ||
| ContainsItem bool `json:"contains_item" doc:"listCollections accepts contains_item and marks the acting profile's own manual collections with contains" example:"true"` | ||
| PreviewPosters bool `json:"preview_posters" doc:"previewCollection items carry poster_url when the title has a poster" example:"true"` | ||
| PosterCollages bool `json:"poster_collages" doc:"A collection with no uploaded or imported poster shows a collage of its first titles the acting profile can see in poster_url, marked by poster_is_collage, on listCollections, getLibraryCollections and listLibraryUserCollections, once the server has built it. False when the server has no artwork storage or the acting account's store keeps no artwork" example:"true"` |
There was a problem hiding this comment.
Expose collage markers on library collection responses
When this capability is true, it promises poster_is_collage on getLibraryCollections and listLibraryUserCollections, but those endpoints serialize LibraryCollectionCard and UserCollection, neither of which defines that field, and their mappers discard the distinction. A client following the advertised capability therefore receives a generated collage URL with no way to identify it. Plumb the marker through both response types or narrow the capability contract to the endpoints that actually return it.
AGENTS.md reference: AGENTS.md:L249-L254
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in b669462: LibraryCollectionCard (getLibraryCollections groups/ungrouped, listServerCollections) and UserCollection (listLibraryUserCollections) now carry poster_is_collage, set from the viewer's collage for personal and server collections and false whenever poster_url is empty. Additive on /api/v2 only; the /api/v1 shapes are unchanged. OpenAPI, fixtures and web types regenerated; verify-apiv2-contract passes against the base branch.
| onChange={(e) => | ||
| onChange(fieldDef.inputType === "number" ? Number(e.target.value) : e.target.value) | ||
| } |
There was a problem hiding this comment.
Preserve an empty numeric rule value
When someone clears a single-value numeric rule such as Year, IMDb rating, or Bitrate, Number("") immediately converts the empty input to 0. The controlled input consequently repopulates with zero, so the user cannot leave the field blank while editing and can accidentally save a zero-valued rule. The range control above already preserves ""; this path should do the same.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in dccd3e0: clearing a single-value number rule now stores "" (as the range inputs already did) instead of Number("") = 0, so the field stays empty; covered by a FilterRuleEditor test.
| } else if (event.key === "Enter") { | ||
| event.preventDefault(); | ||
| const option = options[active]; | ||
| if (option) onPick(option.value); |
There was a problem hiding this comment.
Do not accept stale facet results on Enter
If the user types a search and presses Enter before the 150 ms debounce or the new request completes, options still contains the previous query's values because keepPreviousData is enabled. This branch selects the first stale option even though current is false, so a fast keyboard interaction can silently choose an unrelated common value instead of the text just entered. Enter should not select server options until they correspond to the current text, or it should select the typed option while results are stale.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed at 96fdb93. current (line 155) only drives the status text and aria-busy, and active goes back to 0 on each keystroke, so Enter picks options[0] from the previous query. To reproduce: open the genre picker, where the empty search shows "Drama" first, type "comedy" and press Enter within 150 ms. The rule saves as Drama. Picking the typed option while current is false would fix it.
There was a problem hiding this comment.
Fixed in 38edfe3: while the list does not answer the typed text, Enter picks the typed text instead of the stale first option (an option the user moved to is still honored); covered by a FacetValuePicker test that presses Enter before the debounce.
|
Took the suggested Validation tasks line, keeping S3 and S6 marked for re-validation after merge; the body already explains the collage change. |
Quick104
left a comment
There was a problem hiding this comment.
Review of 96fdb93 with /silo code-review (high). Eight findings are inline. Two more are in the existing Codex threads on personal_collection_collages.go:181 and facet-value-picker.tsx:200; I confirmed both and replied there.
I'd fix the two date-rule bugs in FilterRuleEditor.tsx before merge. Three findings are contract questions that need your call: the v1 facet sort order, v2 matches changing meaning, and the always-true allow_profile_custom_sections.
Validation tasks line. I couldn't read the board because my token lacks read:project. The validation issue bodies suggest the line lists cases that haven't passed. In #193 only S3 shows Pass (S6 is Partial, S7 Not run), and every listed case in #194, #195 and #1141 shows Not run. #193 S1, S2 and S5 show Pass and aren't listed. Please recheck the line against the board.
Smaller items, not commented inline:
library_idssent in a different order builds a second cached list, becauseapiv2/catalog_items.gokeeps request order. The web client sorts its IDs, so only other clients hit this.- After a personal collection gets an uploaded poster, nothing retires its old collage rows and objects until the collection is deleted. Server collages behave the same at the base.
- A
Refreshalready queued when a poster is uploaded doesn't recheckPosterURL, so it can save one more variant. - Cleanup:
facet_values.gohand-rolls single-flight with awaitersfield that only tests read, whilegolang.org/x/sync/singleflightis used elsewhere in the repo.FacetValuePickerand the olderFacetSearchSelectnow both call the facet search endpoint.PersonalCollectionCollages.Preparehas no production caller. The collage-refresh guard is copied inusercollections/sync.goandcollections_lifecycle_service.go.
These findings come from reading the code at this head. I ran no tests.
AI disclosure: Claude Code in T3 Code, model claude-opus-5-5, with Claude subagents (claude-opus-5-5 and Claude Sonnet) for the search and verification passes.
| } | ||
| return ["", ""]; | ||
| } | ||
| if (Array.isArray(value)) { |
There was a problem hiding this comment.
Bug: switching a date rule from "is between" to "in the last" carries the start date into the duration.
This branch returns value[0] before the date-shape check below it runs. With between ["2020-01-01", "2021-01-01"], switching to "in the last" gives "2020-01-01". InLastInput can't parse that and falls back to a text box, and the rule saves as {op: "in_last", value: "2020-01-01"}. parseDurationSpec then rejects it as an invalid duration. The Risks section says this switch clears the value, which holds for the other date conditions but not for "between".
Fix: run the date check on value[0] as well, or move this branch below it for date fields.
There was a problem hiding this comment.
Already fixed in 35ce54b: the start of a range now goes through the same date check as any other value, so it stays for "after" or "before" and is cleared for "in the last". FilterRuleRow.test.tsx covers between → in the last (cleared) and between → after (kept). No other path carries a date into "in the last": a new field resets to its default value, and the guided editor writes its own spans.
| const units = unit === "h" ? [["h", "hours"] as const, ...IN_LAST_UNITS] : IN_LAST_UNITS; | ||
| const write = (nextAmount: string, nextUnit: string) => { | ||
| setUnitDraft(nextUnit); | ||
| onChange(/^\d+$/.test(nextAmount) ? `${Number(nextAmount)}${nextUnit}` : ""); |
There was a problem hiding this comment.
Bug: the "in the last" amount accepts 0. /^\d+$/ passes "0" and writes "0d"; min={1} only limits the spinner. The rule saves, because definition validation checks only the field and condition. When the collection runs, query_builder.go rejects amount <= 0 as an invalid duration, and the in-memory resolver matches nothing. I didn't trace whether the user sees a 400 or a 500.
Fix: require Number(nextAmount) >= 1 here.
There was a problem hiding this comment.
Fixed in 6400a43: an amount below 1 now writes nothing, like a blank amount, so a rule can no longer save as 0d. Test: FilterRuleRow.test.tsx "writes nothing for an amount below 1".
| matched = append(matched, e) | ||
| } | ||
| } | ||
| slices.SortFunc(matched, compareFacetNames) |
There was a problem hiding this comment.
Needs your call (frozen v1): /api/v1/catalog/filters/search used to sort with ORDER BY LOWER(name) under the database collation (en_US in the default compose image) and query live. It now sorts by byte order here and reads from the two-minute cache.
Example: with the genres "Science Fiction" and "Sci-Fi", ?facet=genre&q=sci&limit=1 used to return "Science Fiction" and now returns "Sci-Fi". Accented values such as "Comédie" now sort after every unaccented "Com…" value. Values are also trimmed now, so " Drama" and "Drama" merge. The PR body says v1 keeps prefix-only A to Z answers and discloses the lag, but not the order change. A literal % or _ in q also changes on v1: both used to act as wildcards and now match literally, which reads as a fix.
If v1 should answer exactly as before, keep the old live query for the v1 handler. Otherwise note the change in docs/architecture/v1-scope.md.
There was a problem hiding this comment.
Fixed in 5a1a544: /api/v1/catalog/filters/search answers exactly as before again. SearchFacetV1 runs the queries v1 shipped with, live: ORDER BY LOWER(name) under the database collation, names trimmed after DISTINCT, and % and _ in q acting as LIKE wildcards (internal/catalog/facet_search_v1.go). The v2 typeahead keeps the cache. TestSearchFacetV1AnswersTheFrozenQuery seeds "Science Fiction"/"Sci-Fi", "Comédie"/"Comedy", " Drama"/"Drama" and literal %/_ values, and checks v1 against the old query text on the same database; it fails on the cached path.
| } | ||
| if rec.Definition().AdminOnly && !isAdmin && !allowCustom { | ||
| return apiError(http.StatusForbidden, "custom_disabled", "this server does not allow profiles to build custom sections") | ||
| if rec.Definition().AdminOnly && !isAdmin { |
There was a problem hiding this comment.
Needs your call: allow_profile_custom_sections now answers true everywhere, but this gate still refuses a non-admin a new Editor's picks row with custom_disabled and the message "this server does not allow profiles to build custom sections".
At the base, the flag meant "non-admin profiles may add admin-only recipes": the v2 field doc said so, and the web used role === "admin" || flag. That is now always false while the field says true. A third-party v1 or v2 client that follows the old rule offers Editor's picks to every profile and gets this 403 each time, with a message that blames a setting that no longer exists. Web, Apple and Android don't read the flag, so first-party clients are unaffected.
Option: point the deprecation note at the per-recipe admin_only field as the rule clients should follow, and reword the message to say only admins add Editor's picks, keeping the custom_disabled code. The v1 meaning change could go in the v1-scope removals table next to the admin routes.
There was a problem hiding this comment.
Fixed in 971f681. The v1 and v2 routes share SaveProfileOverrides, but v2 maps the error in its own adapter, so the message branches cleanly: v2 now answers 403 permission_denied with "Only an admin can add an Editor's picks row.", and v1 keeps custom_disabled with its frozen message. The allow_profile_custom_sections deprecation note now tells clients to follow each recipe's admin_only in listSectionRecipes, and docs/architecture/v1-scope.md records that the v1 flag no longer means profiles may add admin-only recipes, next to the admin settings routes.
| limit = catalogFacetSearchMaxLimit | ||
| } | ||
| column, isColumn := facetColumns[facet] | ||
| if q == "" && (!isColumn || mode != FacetSearchRanked) { |
There was a problem hiding this comment.
Needs your call (v2 contract): existing searchCatalogFacet callers get different matches with no opt-in. Column facets now rank by title count instead of A to Z, include word-start matches (q=bros finds "Warner Bros. Pictures"), and return the top values for an empty q instead of []. facet_value_search lets a client detect the change but doesn't keep the old answers.
v2 isn't locked, so this is allowed today. It is the kind of change the additive rules forbid after 1.0, and breaking-approvals.json has no entry for it because oasdiff only compares schemas. A shape that already fits those rules: keep matches prefix-only and A to Z, and give the ranked, word-start and empty-q behavior only to the new values field. web/src/hooks/queries/facetValues.ts already reads values when the capability is on.
There was a problem hiding this comment.
Fixed in 5a1a544: matches is the prefix answer again, values that start with q, A to Z, and [] for an empty q, with has_more speaking for it. The ranked, word-start and empty-q answer lives only in values, with a new values_has_more. facet_value_search describes values. The rule value picker reads values and values_has_more; FacetSearchSelect and the catalog filter sheet keep reading matches. Docs, OpenAPI, fixtures and web types are regenerated. Tests: a DB test (q=war: matches holds only "Warner Bros.", values adds "Time Warner"; q=t: matches A to Z, values by title count), resolver routing tests, the v2 mapping test, and a picker test for values_has_more.
|
|
||
| - `listCollections`, `getLibraryCollections` and `listLibraryUserCollections` return the | ||
| collage in `poster_url`, and `listCollections` marks it with `poster_is_collage: true`. | ||
| `getCollection` and `updateCollection` carry no `poster_url`; clients take the poster from |
There was a problem hiding this comment.
Docs don't match the code: getCollection and updateCollection do return poster_url for an uploaded or imported poster; collectionViews presigns it. What they leave out is the collage, because collagesForRead runs only when WithNativeAPIV2 is set, and only the three list adapters set it. A collage collection therefore has an empty poster_url on detail and a collage on the list. The OpenAPI doc for poster_is_collage (internal/apiv2/personal_collections.go:50) repeats the same sentence.
Either correct the sentence (detail carries an uploaded poster but not the collage) or set the flag on every v2 collection operation so detail matches the list. The second removes the inconsistency.
There was a problem hiding this comment.
Addressed in 517cd49, differently from the suggestion. getCollection and updateCollection don't return poster_url for an uploaded or imported poster either: PersonalCollectionEditor clears it, because that body is the editor state behind a strong ETag and a presigned URL expires (#193 S6 records the same: "the single-collection editor responses leave poster_url empty on purpose"). So detail carries no poster of any kind, and adding the collage there would put a presigned URL back behind the strong validator. I kept that and fixed the rest: the editor state now also clears poster_is_collage (it was true under a v2 context with an empty URL), personalCollectionOf marks a collage only when poster_url is set, and docs/collections-api.md and the poster_is_collage description say detail carries no poster for any kind and why. Tests: the handler DB test checks the editor state carries no poster, and an apiv2 test checks the flag needs a poster_url.
| collectionHandler.CollectionOwners = collectionOwners | ||
| collectionHandler.Collages = personalCollages | ||
| if deps.UserCollectionSync != nil { | ||
| deps.UserCollectionSync.Collages = personalCollages |
There was a problem hiding this comment.
Race at startup: this line writes UserCollectionSync.Collages while the router is built, but cmd/silo/main.go starts the task manager (taskMgr.Start, around line 3177) before api.NewRouter (around line 3311). When the last sync is older than its interval, the interval trigger fires with no delay, and Service.refreshCollage reads s.Collages while this line writes it. -race would flag it, and syncs in that window build no collage. The next read builds one, so users only see a delay.
Fix: construct PersonalCollectionCollages in main.go next to usercollections.NewService and pass it to both through Dependencies. TraktCollections and TMDBLists are wired the same way after start, so the pattern predates this PR.
There was a problem hiding this comment.
Fixed in 7a18361: cmd/silo/main.go builds PersonalCollectionCollages next to usercollections.NewService, before the task manager starts, and hands it to the sync service and the router through Dependencies.PersonalCollectionCollages; the router no longer writes UserCollectionSync.Collages. The generator still needs the router's poster signer, so the router supplies it with SetCollageGenerator, an atomic store; until then the service builds nothing, as before. TestPersonalCollectionCollagesGeneratorArrivesWhileRefreshing runs refreshes while the generator is set and passes under -race.
| return false; | ||
| } | ||
| waitingSince.current ??= Date.now(); | ||
| return Date.now() - waitingSince.current < COLLAGE_WAIT_MS ? COLLAGE_POLL_MS : false; |
There was a problem hiding this comment.
Polling can stop for good: waitingSince resets only when a poster arrives, the item count drops to 0, or awaitCollage turns false. A save doesn't reset it. If the first wait passes 15 s without a collage (a busy build queue, or titles without posters yet), later edits in the same editor never poll again. The invalidated refetch reruns refetchInterval, finds an old waitingSince, and returns false, so the new collage shows only after a focus refetch or a reload.
I haven't reproduced this. A hook test that keeps poster_url empty past 15 s and then invalidates the list would confirm it. Fix: reset waitingSince when the collection is saved.
There was a problem hiding this comment.
Fixed in e9f08fa (with a38acba for a null wait tsc caught): the wait now belongs to the saved version the editor holds, its ETag, so a save starts a new 15-second wait even after an earlier one ran out. The hook test "waits again after a save, even once an earlier wait gave up" keeps poster_url empty past the wait, moves the version, invalidates the list, and expects reads to resume; it failed before the fix.
Clearing a single-value number rule such as Year or IMDb rating wrote
Number("") = 0, so the field refilled with zero and could be saved as a
zero-valued rule. It now stays empty, as the range inputs already did.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…rs it Pressing Enter in the value picker before the debounced search returned picked the first option of the previous search's list. While the list does not answer the typed text, Enter now uses the typed text, unless an option was moved to with the keyboard or mouse. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 38edfe32bc
ℹ️ 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 (Array.isArray(value)) { | ||
| // Leaving "between" keeps where the range started. | ||
| return value[0] ?? getDefaultRuleValue(field, op); |
There was a problem hiding this comment.
Reset date ranges before switching to “in the last”
When an Added or Release date rule currently uses between, changing its condition to in_last returns the range's first ISO date here before the date-specific normalization runs. The editor then shows that date as an unrecognized text value, and saving fails because the server requires a duration such as 30d. Preserve the first endpoint only for date-comparison operators and clear it when switching to in_last.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 35ce54b: the range's first value now goes through the date normalization instead of returning early, so it stays for after/before and is cleared for "in the last"; covered by two FilterRuleRow tests.
| value={String(rule.value ?? "")} | ||
| onChange={(v) => onChange({ value: v })} | ||
| onChange={onChange} | ||
| scope={valueScope} |
There was a problem hiding this comment.
Pass the advanced filter scope to facet pickers
When the advanced catalog filter sheet selects particular libraries or a media scope, its CollectionRulesEditor invokes FilterRuleEditor without a valueScope, so this picker searches every title visible to the profile. It can therefore suggest genres, studios, and other exact values that do not occur in the selected scope, producing an unexpectedly empty result after selection. Thread the query definition's library_ids and media_scope into these picker rows.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 832a08d: FilterRuleEditor takes a valueScope and passes it to its rows, and CollectionRulesEditor (the advanced catalog filter sheet) passes the query's library_ids and media_scope; a test checks the facet search sends type and library_ids.
| const artworkSlots = capabilities?.artwork === false ? [] : scope.artworkSlots; | ||
| // Without its own poster a collection shows a collage of its titles, except | ||
| // a server Smart collection, whose titles come from its rules. | ||
| const collages = isServer ? !smart : personalCapabilities.data?.poster_collages !== false; |
There was a problem hiding this comment.
Require the collage capability before enabling its fallback
When the capabilities request fails or the web client is used with an older backend that omits poster_collages, undefined !== false enables the new feature anyway. Personal collection editors then claim a collage is forthcoming and poll the collection list even though that server cannot provide one; capability absence must be treated as unsupported by checking for === true.
AGENTS.md reference: AGENTS.md:L149-L150
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in da39b1d: the personal editor now requires poster_collages === true, so a failed capabilities read or an older server shows "Remove poster" and does not wait for a collage; covered by a CollectionForms goldens test with the capability absent.
…eir queries A list read ran every smart personal collection's query, one after another, to find its collage sources, so a profile with many smart collections paid one smart query per collection on every page load (8 collections: 9 statements). A background refresh now reads a smart collection's matches, builds their collage, and records it in user_personal_collection_smart_collages, keyed by collection and a hash of the viewer's access filter, with a hash of the query definition. A list read serves those records with one statement and queues a refresh when a record is missing, made for another definition, or older than 15 minutes. A record goes with its collection, and with its collage when that is retired as unused. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
getCollectionCapabilities poster_collages promises poster_is_collage on getLibraryCollections and listLibraryUserCollections, but their LibraryCollectionCard and UserCollection entries had no such field, so a client got a collage URL it could not tell from an uploaded poster. Both now carry poster_is_collage, for personal and server collections alike, and listServerCollections cards carry it too. The frozen /api/v1 shapes do not change. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…e last" Switching an Added or Release date rule from "between" to "in the last" kept the range's first ISO date, which the editor showed as unreadable text and the server rejected on save. The range's start now goes through the same date normalization as any other value: it stays for "after" or "before" and is cleared for "in the last". Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… and scope The advanced catalog filter sheet's rule value pickers searched every title the profile can see, so they could suggest genres or studios that no title in the picked libraries or media scope has. CollectionRulesEditor now passes the query's library_ids and media_scope to the pickers, as the home row rule builder already does. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The personal collection editor treated a missing poster_collages capability, from a failed capabilities request or an older server, as support: it offered "Use the collage" and polled the list for a collage that server cannot build. It now requires poster_collages to be true. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Typing 0 as the amount of an "in the last" rule wrote "0d", which saved but made the collection fail when it ran, because the server rejects a span of 0. An amount below 1 now writes nothing, like a blank amount. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: da39b1d5ed
ℹ️ 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".
| f = &facetFlight{done: make(chan struct{})} | ||
| c.flights[key] = f | ||
| go c.fly(context.WithoutCancel(ctx), key, f, load) |
There was a problem hiding this comment.
Bound concurrent facet cache fills
When many distinct viewer or library scopes miss the cache together—especially after a node restart—each key starts a detached load with no global concurrency limit, and each load can materialize up to 500,001 values before storeLocked applies the cache budget. A busy multi-tenant node can therefore run several roughly 50–100 MB scans concurrently, exhausting memory and database capacity even though the completed cache claims a 500,000-value cap; add a shared semaphore or otherwise budget in-flight fills.
AGENTS.md reference: AGENTS.md:L13-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 2b5661f: a node now builds at most four facet value lists at once. Other builds wait for a slot within the same 30-second load timeout, outlive a canceled caller as before, and cache nothing if they time out or fail. The per-key flights now use golang.org/x/sync/singleflight. TestFacetValueCacheBoundsConcurrentFills holds the only slot and checks a second scope times out before its load runs, then builds once the slot frees; the cache tests pass under -race.
| CreatorProfileID *string `json:"creator_profile_id,omitempty" doc:"Present on a personal collection: the profile that made it"` | ||
| PosterIsCollage bool `json:"poster_is_collage" doc:"poster_url is the acting profile's collage of the collection's first titles it can see, composed by the server because the collection has no uploaded, template or imported poster. False for an uploaded, template or imported poster and whenever poster_url is empty. See getCollectionCapabilities poster_collages" example:"false"` |
There was a problem hiding this comment.
Expose collage state on full curated entries
Fresh evidence after the prior fix is that getLibraryCollections still serializes its top-level collections[] as CuratedCollection, which has no poster_is_collage; only the grouped and ungrouped LibraryCollectionCard shape gained the marker here. Since those full entries receive the same viewer-specific server collage URL and the advertised capability names the whole endpoint, clients consuming collections[] still cannot distinguish generated artwork, so add and map the field on CuratedCollection as well.
AGENTS.md reference: AGENTS.md:L251-L252
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 4de0049: CuratedCollection, the full collections[] entry of getLibraryCollections, now has poster_is_collage, true only when poster_url is the server's collage, as on the cards. Test: TestLibraryCollectionCardsMarkCollages.
| waitingSince.current ??= Date.now(); | ||
| return Date.now() - waitingSince.current < COLLAGE_WAIT_MS ? COLLAGE_POLL_MS : false; |
There was a problem hiding this comment.
Restart collage polling after later changes
When a collection with titles remains posterless for the full 15-second window, this branch stops polling but leaves waitingSince at the expired timestamp. If a later save changes its members or rules and the immediate invalidation fetch occurs before the delayed collage build, the interval still sees the old timestamp and never polls again, so the newly generated collage remains absent until the page is reopened; reset or version the wait when a new build-triggering change begins.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The value picker's search changed what existing callers of the facet typeahead got back. /api/v1/catalog/filters/search, which is frozen, read cached lists in byte order with trimmed values and literal % and _, and v2 searchCatalogFacet's matches started ranking by title count, matching word starts and answering an empty q. v1 now runs the queries it shipped with again: a live read, ordered by LOWER(name) under the database collation, with LIKE wildcards. On v2, matches is again the values that start with q, A to Z, with nothing for an empty q, and has_more speaks for it. The ranked, word-start and empty-q answer lives only in values, with a new values_has_more. The rule value picker reads values_has_more; the older catalog filter search keeps reading matches. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
searchCatalogFacet kept library_ids in request order, so a client that sent the same libraries in a different order built and cached a second copy of the scope's value list. The server now sorts the ids and drops repeats before it builds the scope. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Each scope that missed the facet value cache started its own detached list build, with no limit across scopes. After a restart, a busy node could run many of these scans at once, each holding up to 500,000 values before the cache budget turned it away. A node now builds at most four lists at once; other builds wait for a slot within the same 30-second load timeout and cache nothing if they time out. The per-key flights now use golang.org/x/sync/singleflight instead of a hand-rolled map. A build still outlives a canceled caller, a failed or panicking build caches nothing, and a flight that starts just after another stored the list reuses it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
allow_profile_custom_sections now answers true everywhere, but a profile that is not an admin still cannot add a new Editor's picks row, and v2 refused it with a message that blamed the server setting that no longer exists. v2 replaceProfileSectionOverrides now says only an admin can add an Editor's picks row; v1 keeps its frozen code and message. The flag's deprecation note now points clients at each recipe's admin_only in listSectionRecipes, and v1-scope.md records that the v1 flag no longer means profiles may add admin-only recipes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
getLibraryCollections marked a collage poster on the cards in groups and ungrouped, but not on the full collections[] entries, which carry the same viewer-specific collage URL. CuratedCollection now has poster_is_collage too, set the same way: true only when poster_url is the server's collage. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
getCollection and updateCollection answer the editor state behind a strong ETag, so they never carry a presigned poster_url, whether the poster is uploaded, imported or a collage; clients take the poster from the list. The docs and the poster_is_collage description now say so plainly, and the editor state no longer marks a collage it doesn't carry: poster_is_collage is false whenever poster_url is empty. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The handler and the import sync each checked the same conditions before asking for a personal collection's collage: a collage service, no uploaded or imported poster, and a Postgres user store. Both now call usercollections.RefreshCollage, and the handlers build a collection's collage definition with usercollections.CollectionDefinition. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The task manager starts before the API router is built, and the router then wrote the collage service onto the import sync service, so a sync that ran on startup could read that field while it was written, and built no collage. main.go now builds the personal collection collage service beside the sync service and hands it to both through Dependencies. The router supplies the collage generator once its poster signer exists, through an atomic SetCollageGenerator; until then the service builds nothing, as before. PersonalCollectionCollages.Prepare had no production caller; it moves into the tests that used it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The editor reads the collection list for 15 seconds while a collection with titles shows no poster, to pick up the collage the server builds. That wait never restarted: once one ran out, a later save in the same editor didn't poll again, so its new collage showed only after a reload. The wait now belongs to the saved version the editor holds (its ETag), and a save starts a new one. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Check the facet value flight's result type instead of asserting it, and pick a facet search's base relation with catalogBaseRelationForScope. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
useListedPoster read a null wait when no version was passed, and tsc -b rejected it. A wait now always starts when there is none. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Follow-up on the smaller items in the review of 96fdb93:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2af2e7cbd9
ℹ️ 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".
| select: (data) => data.collections.find((entry) => entry.id === id), | ||
| refetchInterval: (query) => { | ||
| const entry = query.state.data?.collections.find((c) => c.id === id); | ||
| if (!awaitCollage || !entry || entry.poster_url || !entry.item_count) { |
There was a problem hiding this comment.
Keep polling when a display filter hides every item
When a personal collection contains poster-bearing titles but its display filter currently yields zero visible results (for example, “show only unwatched” after everything has been watched), item_count is zero even though the collage builder deliberately ignores that display filter. This condition therefore stops polling before the background build can return the valid collage, leaving the editor on its placeholder until another cache invalidation or page reload. Do not use the display-filtered count as proof that no collage can be generated.
Useful? React with 👍 / 👎.
Problem
Related issue: #192
Validation tasks: changes #193 S3, S6 (re-validate after merge); reaches #193 S1, S2, S4, S5 (recorded Pass or Partial; this PR doesn't change what they check); reaches (not run) #193 S7, #194 A1, A2, A3, #195 W1, W2, W3, W4, W5, W7, #1140 C2, #1141 C1, #1142 C2, Silo-Server/silo-apple#20 C1, Silo-Server/silo-apple#21 C1, Silo-Server/silo-android#5 C1, Silo-Server/silo-android#6 C1
Building a Smart collection or a rule row was error-prone and the editor around it was hard to follow:
>=and<for conditions, True/False,movie/series, bare text boxes for dates and "in the last", and a max titles box that rendered as two grey labels.GET /api/v2/catalog/filters/search, which rescans every title in scope on each call: 180 to 310 ms per keystroke on a 500,000-title library. Its prefix also went toLIKEunescaped.The repository owner tried these changes together on a sandbox and asked for them in one pull request.
Approach
Faster value search (
internal/catalog)GROUP BYquery builds the scope's whole value list with title counts, using the same FROM and WHERE as before. The list is cached in memory for two minutes.qreturns the most common values. Author, narrator and series keep their prefix search, now escaped.searchCatalogFacet:values: [{value, count}]withvalues_has_morecarry the ranked answer;matchesandhas_morekeep their prefix-only, A to Z answer with nothing for an emptyq, read from the cache. Also alibrary_idsfilter intersected with the viewer's allowed libraries (sorted and deduplicated, so one set of libraries shares one cached list), andfacet_value_search: trueongetCatalogSearchCapabilities./api/v1/catalog/filters/searchdoesn't use the cache. It runs the queries it shipped with, live:LOWER(name)order under the database collation, and%and_inqas wildcards.Rule rows
facet_value_search.30d-style value, and an amount below 1 writes nothing. A saved value these controls can't read stays as editable text.Editor layout
Collage posters for personal collections
poster_urlonly for an assigned poster, and now return a collage for a collection without one. The owner asked for personal collections to match server collections, which already show a collage. S3 (restricted profiles) and S6 (artwork URLs, including native clients) need re-validation after merge: each collage must use only titles both the viewer and the owner may access, and its URL must resolve in the apps.internal/catalog/collection_collages.go).user_personal_collection_poster_variants(migration20261005145809_personal_collection_collages), with the same key scheme, background build queue, artwork path reservation, retirement and delete trigger as server collages.user_personal_collection_smart_collages(migration20261005172417_personal_collection_smart_collages). A list serves those records with one query however many Smart collections it has, and refreshes a record in the background when it is missing, was made for other rules, or is older than 15 minutes.main.gobuilds the collage service beside the import sync service, before scheduled syncs start, and the router gives it its generator once the poster signer exists.poster_is_collageon personal and admin collections, on the fullcollections[]entries and the cards ofgetLibraryCollections, and onlistLibraryUserCollectionsandlistServerCollections, andposter_collagesongetCollectionCapabilities.artworkon that document is now false when the server has no artwork storage, as on the admin document. The SQLite user store reportsposter_collages: false.getCollectionandupdateCollectionstill carry noposter_urlof any kind, since their body is the editor state behind a strongETag; clients take the poster from the list./api/v1is unchanged.Rule rows for every profile
403 permission_deniedsaying only an admin can add an Editor's picks row; v1 keeps403 custom_disabledand its frozen message. Saved Editor's picks rows keep working. The deprecated flag's description points clients at each recipe'sadmin_onlyinlistSectionRecipes, anddocs/architecture/v1-scope.mdrecords that the v1 flag no longer means profiles may add admin-only recipes.GET/PUT /api/v2/admin/settings/sections(getAdminSectionSettings,updateAdminSectionSettings) are removed, with entries incontracts/api/v2/breaking-approvals.jsonfor the repository owner to approve here.getProfileSectionFlagskeepsallow_profile_custom_sections, alwaystrueand deprecated. The frozen/api/v1routes keep answeringtrue; the v1 PUT changes nothing. Both v1 admin routes are recorded as pre-lock removals indocs/architecture/v1-scope.mdand the migration ledger.Docs:
docs/catalog-api.md(facet typeahead),docs/collections-api.md,docs/architecture/collection-posters.md,docs/admin-api.md,docs/architecture/api-contract.md,docs/architecture/v1-scope.md.Clients: every API change is additive except the two admin operations, which neither silo-apple nor silo-android calls. Apps that show
poster_urlget personal collages with no change. Optional follow-ups for both apps (not filed yet): usevalues,values_has_moreandlibrary_idswhenfacet_value_searchis true, and label collages withposter_is_collage.matcheskeeps its old answer, so apps that read it see no change. jellycompat does not expose personal collections or rule rows, so it needs no change.Validation
-race) cover ranking, word starts, literal%and_, emptyq,has_more, key separation, TTL, shared builds, cancellation, failures, eviction, the four-build limit and the over-budget path. DB tests cover the list query, the escaped fallback,library_idsnarrowing a restricted profile's scope, v2matchesstaying prefix-only A to Z beside rankedvalues, and v1 answering exactly what its original query answers (collation order, untrimmed duplicates, LIKE wildcards).scripts/ci/db-pins.txt, pins a list of eight Smart collections at one statement (nine before, one Smart query each) and covers a new match reaching the collage once its record is due. Both migrations applied, rolled back and reapplied. A-racetest sets the collage generator while syncs refresh collages, and a handler test checks the editor state carries no poster.falsesetting, keeping a saved Editor's picks row, being refused a new one, and the v1 routes. The section scenario acceptance tests pass.values_has_more), rule row wording and inputs (including an "in the last" amount of 0), the preview before libraries, the editor column order, Look and each artwork menu item, Where it shows, the save bar hint, collage states and the collage wait restarting after a save, and Add row offering rule rows to every profile.make test-web(7995 tests),pnpm run lint,format:check,tsc -b,build,budget:check: pass.go build ./...,go vet,make lint-changed,verify-apiv2-openapi,verify-apiv2-fixtures,verify-apiv2-web-types,verify-apiv2-contract(additive changes plus the two approved removals),TestCommittedArtifactMatchesRouter,verify-route-inventory,verify-migration-ledger,verify-scenario-catalogs,verify-settings-bindings-all,verify-offline-routes,verify-local-paths,migrate-validate: pass.TestOrphanCleanupAfterPlexTableDropPostgres,TestSyncMergeStepsAfterPlexTableDropPostgres,TestAdminSubtitleListPageDBandTestCatalogTransferPersistsJobsAndSignedLinkfail locally the same way on the base commit.Risks
/api/v1/catalog/filters/searchkeeps its live query, so v1 clients still pay 180 to 310 ms per keystroke on a 500,000-title library.Checklist
AI Disclosure
🤖 Generated with Claude Code
Note
Add collection poster collages and ranked facet-value search, and redesign the collection editor
collageSet, and v2 responses mark collages viaposter_is_collage/poster_collageswhile the v1 bridge is frozen. Backed by new tables in 20261005145809 and 20261005172417.library_idsfiltering andvalues_has_morepagination. The v1 prefix search is preserved via a separate live-query path in facet_search_v1.go. New FacetValuePicker consumes it in the web rule editor.allow_profile_custom_sections=true. Non-admins may keep and change existing admin-only rows (e.g. Editor's picks) but get 403custom_disabledwhen adding one; the custom-filter recipe is no longer admin-only.SearchFacetreportedly assigns a time value to Go's built-innewinstead of a type, so the catalog package does not compile as written — check that statement first.Macroscope summarized 2af2e7c.