Skip to content

feat(collections): pick rule values from your libraries and simplify the editor - #1991

Merged
Quick104 merged 29 commits into
feat/collections-revampfrom
feat/rule-value-picker
Oct 5, 2026
Merged

Quick104 merged 29 commits into
feat/collections-revampfrom
feat/rule-value-picker

Conversation

@Quick104

@Quick104 Quick104 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • Rules on genre, studio, network, country and content rating took free text, but the server matches those values exactly and case-sensitively. A typo or different capitalization ("warner bros") silently made an empty collection, and nothing showed which values exist. The rest of the rule row read poorly: >= 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.
  • The values the server could offer came from 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 to LIKE unescaped.
  • A new server Smart collection showed no preview until a library was picked, while the value picker already counted matches across every library.
  • The editor used two columns, a section switcher on phones, and a Details panel with two cramped controls per image. Where it shows ran its facts together ("None yet Change"), and the save bar kept saying "Name it, then create it." after the name was filled.
  • A personal collection without a poster showed only its name, while server collections get a collage of their titles.
  • Profiles could only add rule rows to their Home when an admin turned on "Let profiles add rule rows", which was off by default and, once turned off, locked any page that already held one.

The repository owner tried these changes together on a sandbox and asked for them in one pull request.

Approach

Faster value search (internal/catalog)

  • For genre, studio, network, country, original_language and content_rating, one GROUP BY query 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.
  • The cache key is a hash of the exact SQL and arguments, so library scope, disabled libraries, maturity limits and personal sources are part of it and viewers with different access never share a list.
  • Concurrent misses share one build, which keeps running (30 s timeout) after the request that started it is canceled, because the next keystroke needs the same list. A failed build caches nothing. A node builds at most four lists at once; other builds wait for a slot within the same timeout.
  • The cache holds at most 500,000 values (about 50 MB) and evicts the least recently used list. A scope with more distinct values is searched in SQL with an escaped match that ranks the same way.
  • The new ranked answer ignores case and matches the start of the value or of any word in it ("bros" finds "Warner Bros. Pictures"). Whole-value matches come first, then by title count, then A to Z. An empty q returns the most common values. Author, narrator and series keep their prefix search, now escaped.
  • API additions on v2 searchCatalogFacet: values: [{value, count}] with values_has_more carry the ranked answer; matches and has_more keep their prefix-only, A to Z answer with nothing for an empty q, read from the cache. Also a library_ids filter intersected with the viewer's allowed libraries (sorted and deduplicated, so one set of libraries shares one cached list), and facet_value_search: true on getCatalogSearchCapabilities.
  • The frozen /api/v1/catalog/filters/search doesn't use the cache. It runs the queries it shipped with, live: LOWER(name) order under the database collation, and % and _ in q as wildcards.

Rule rows

  • Genre, studio, network, country and content rating rules use a value picker. It opens on the most common values in the rule's libraries and kind of titles, with counts, and searches as you type. Typed text that matches nothing can still be used and is marked "No titles have this yet". A saved value missing from the list stays shown. It works with the keyboard and inside the Add row dialog, and falls back to prefix search on a server without facet_value_search.
  • Conditions read as words ("is at least", "is between"); switches show Yes/No; Type shows Movies/Shows; bitrate shows kbps. Stored values do not change.
  • Dates use date inputs; "in the last" is a number and a unit, written as the same 30d-style value, and an amount below 1 writes nothing. A saved value these controls can't read stays as editable text.
  • The field picker is grouped (Title, People, File, You, Library). Status and genre "contains" are no longer offered for new rules but stay editable on saved ones.
  • Add rule moves focus to the new rule's value. Max titles looks like the selects beside it.
  • The live preview runs before a server collection has libraries, across every library, and says so. Create still waits for a library.

Editor layout

  • One column, at most 768px wide, on every screen size: header, Name and description, the type's contents (Smart: Rules then Live preview), Where it shows, then Look. The phone section switcher is gone.
  • Where it shows is a settings list: Libraries ("Not picked yet" or the names, with Change), Shelf, the Collections tab switch, and Rows that show it. Personal collections keep their sharing switch and rows.
  • Look holds the artwork. Closed, it is one line ("Poster: a collage of its titles · Backdrop: none"); open, each image has one menu: Upload image…, Paste a link…, and Use the collage or Remove backdrop. The link field appears only after Paste a link…. Changes still wait for Save and send the same requests.
  • Before Create, the save bar names what's missing in page order (name, then libraries), then for Smart "38 titles match now. New ones join on their own."
  • The header shows a poster only when there is one.

Collage posters for personal collections

  • This changes poster behavior Collections — Server #193 S3 and S6 validated: v2 personal collection lists used to return poster_url only 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.
  • A personal collection without an uploaded or imported poster gets a collage of its first four titles with posters, built by the server collage code (now shared in internal/catalog/collection_collages.go).
  • The titles are the ones the viewer may see: for a collection another profile shares, titles both the owner and the viewer can access, with maturity limits and disabled libraries applied.
  • Collages live in a new table, user_personal_collection_poster_variants (migration 20261005145809_personal_collection_collages), with the same key scheme, background build queue, artwork path reservation, retirement and delete trigger as server collages.
  • Reads never compose: lists serve a stored collage, or no poster while one builds. Create, edit, title changes, poster removal and a finished sync start a build about two seconds later.
  • Lists never run a Smart collection's query either. A background refresh reads its first matches, builds the collage, and records which collage each viewer's access sees in user_personal_collection_smart_collages (migration 20261005172417_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.go builds the collage service beside the import sync service, before scheduled syncs start, and the router gives it its generator once the poster signer exists.
  • API additions: poster_is_collage on personal and admin collections, on the full collections[] entries and the cards of getLibraryCollections, and on listLibraryUserCollections and listServerCollections, and poster_collages on getCollectionCapabilities. artwork on that document is now false when the server has no artwork storage, as on the admin document. The SQLite user store reports poster_collages: false. getCollection and updateCollection still carry no poster_url of any kind, since their body is the editor state behind a strong ETag; clients take the poster from the list. /api/v1 is unchanged.

Rule rows for every profile

  • Profiles can always add rule rows ("Titles matching rules"). The admin switch, its confirm dialog and the Settings > Home Screen page lock are removed. The stored setting is ignored; there is no migration.
  • A profile that isn't an admin still can't add a new Editor's picks row, matching the web, which offers it to no one for new rows. v2 answers 403 permission_denied saying only an admin can add an Editor's picks row; v1 keeps 403 custom_disabled and its frozen message. Saved Editor's picks rows keep working. The deprecated flag's description points clients at 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.
  • GET/PUT /api/v2/admin/settings/sections (getAdminSectionSettings, updateAdminSectionSettings) are removed, with entries in contracts/api/v2/breaking-approvals.json for the repository owner to approve here. getProfileSectionFlags keeps allow_profile_custom_sections, always true and deprecated. The frozen /api/v1 routes keep answering true; the v1 PUT changes nothing. Both v1 admin routes are recorded as pre-lock removals in docs/architecture/v1-scope.md and 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_url get personal collages with no change. Optional follow-ups for both apps (not filed yet): use values, values_has_more and library_ids when facet_value_search is true, and label collages with poster_is_collage. matches keeps 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

  • Facet search: unit tests (with -race) cover ranking, word starts, literal % and _, empty q, 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_ids narrowing a restricted profile's scope, v2 matches staying prefix-only A to Z beside ranked values, and v1 answering exactly what its original query answers (collation order, untrimmed duplicates, LIKE wildcards).
  • Benchmark, studio facet, 500,000 synthetic titles and about 99,000 studios, local PostgreSQL 18: before, 178 to 314 ms per keystroke; after, about 300 ms for the first call in a scope, then 0.01 to 0.8 ms.
  • Collages: DB tests cover sources following owner and viewer access, maturity limits and a viewer with no libraries; reads serving no poster while a build runs; builds after reorder, rule changes and sync; deletion queuing the objects; and a PG viewer and the owner getting their own collages through the v2 handlers, in collection lists and the library Collections tab. A query-count test, added to 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 -race test sets the collage generator while syncs refresh collages, and a handler test checks the editor state carries no poster.
  • Rule rows: Go tests cover a profile adding a rule row with a stored false setting, keeping a saved Editor's picks row, being refused a new one, and the v1 routes. The section scenario acceptance tests pass.
  • Vitest: the value picker (including 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, TestAdminSubtitleListPageDB and TestCatalogTransferPersistsJobsAndSignedLink fail locally the same way on the base commit.
  • The repository owner tried the rule picker, the preview and the editor layout on a sandbox built from this branch. Not checked in a browser: a real personal collage build, the personal editor layout, and the picker on narrow screens.

Risks

  • Value search results and counts can lag catalog changes by up to two minutes per node; rule evaluation is unaffected. A title listing the same value twice counts twice.
  • The value cache uses up to about 50 MB per server process.
  • /api/v1/catalog/filters/search keeps its live query, so v1 clients still pay 180 to 310 ms per keystroke on a 500,000-title library.
  • A collage appears a few seconds after a change, and the editor briefly says "a collage once its titles have posters" meanwhile. A collection's display filter doesn't narrow its collage.
  • A Smart collection's collage can lag new matching titles by up to 15 minutes plus one list read.
  • After a personal collection gets an uploaded poster, its old collage rows and objects stay until the collection is deleted, and a refresh already queued when the poster arrives can save one more collage. Server collages behave the same on the base branch.
  • A server that had the rule rows switch on no longer lets profiles add new Editor's picks rows.
  • Switching a date rule between a date and "in the last" clears its value. A pasted poster link is staged on Use link, not while typing.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern. It carries six related changes to the collections editor at the repository owner's request, as one commit each, plus review fixes.

AI Disclosure

  • Harness: Claude Code (in T3 Code)
  • Tool(s): Claude Code subagents (implementers and an independent review of the facet cache)
  • Model(s): claude-opus-5-5[1m]
  • Involvement: Fully AI-generated, human review pending
  • Adversarial review: a separate review agent read the facet cache for access leaks through the cache key, concurrency and SQL. It found history searches never hitting the cache and canceled requests keeping a cold cache from warming; both are fixed. The other parts had no separate adversarial review.

🤖 Generated with Claude Code

Note

Add collection poster collages and ranked facet-value search, and redesign the collection editor

  • Personal collections now get a viewer-specific poster collage generated in the background from accessible titles, with refresh triggers on create/update/add/reorder/remove/sync. Server and personal collages share one machinery in collageSet, and v2 responses mark collages via poster_is_collage / poster_collages while the v1 bridge is frozen. Backed by new tables in 20261005145809 and 20261005172417.
  • Adds v2 facet-value search: ranked, counted, case-insensitive typeahead over a cached facet list (2-minute TTL, 500k-value budget), with library_ids filtering and values_has_more pagination. 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.
  • The collection editor page becomes a single-column layout with a collapsible Look card for artwork, new paste-link and tile-menu artwork flows, and reworked Where-it-shows settings rows.
  • Removes the v2 admin section-settings endpoints (approved breaking changes in breaking-approvals.json); v1 routes always return allow_profile_custom_sections=true. Non-admins may keep and change existing admin-only rows (e.g. Editor's picks) but get 403 custom_disabled when adding one; the custom-filter recipe is no longer admin-only.
  • Risk: catalog_resolver.go SearchFacet reportedly assigns a time value to Go's built-in new instead of a type, so the catalog package does not compile as written — check that statement first.

Macroscope summarized 2af2e7c.

Quick104 and others added 8 commits October 5, 2026 09:14
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]>
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 585f1edb-0d0a-4bc5-9126-9f5363ef6869

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-05T18:49:00.649990Z 2af2e7c New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@macroscopeapp

macroscopeapp Bot commented Oct 5, 2026

Copy link
Copy Markdown

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

@Quick104

Quick104 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

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.

@macroscopeapp

macroscopeapp Bot commented Oct 5, 2026

Copy link
Copy Markdown

The PR changes two previously exercised #193 paths and needs revalidation. S3's access checks did not exercise derived poster content; /api/v2/collections now returns viewer-scoped collages for personal collections without assigned posters. S6's artwork evidence covered uploaded posters, while personal collection list and library-tab reads now return generated collage URLs. The PR must explain why these validated behaviors have new output, and S3 and S6 need re-validation after merge. The separate cross-profile ordering finding #1616 is not addressed by this diff.

The Validation tasks: line also omits the unrun personal-Smart web case W4 and the Collections client C1 cases. Apple and Android library Collections cards render poster_url, so the new collage URLs change what those screens receive. These cases are not run; include them as reached, not as passed.

Suggested line:
Validation tasks: changes #193 S3, S6; reaches #193 S7, #194 A1, A2, A3, #195 W2, W3, W4, W5, W7, Silo-Server/silo-apple#20 C1, Silo-Server/silo-apple#21 C1, Silo-Server/silo-android#5 C1, Silo-Server/silo-android#6 C1, #1141 C1, #1140 C2, #1142 C2 (not run)

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 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".

Comment on lines +177 to +181
for _, c := range smart {
src, seen := byDefinition[c.QueryDefinition]
if !seen {
var err error
src, err = p.smartSources(ctx, c.QueryDefinition, access)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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"`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread web/src/components/FilterRuleEditor.tsx Outdated
Comment on lines +418 to +420
onChange={(e) =>
onChange(fieldDef.inputType === "number" ? Number(e.target.value) : e.target.value)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment on lines +197 to +200
} else if (event.key === "Enter") {
event.preventDefault();
const option = options[active];
if (option) onPick(option.value);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@Quick104

Quick104 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Took the suggested Validation tasks line, keeping S3 and S6 marked for re-validation after merge; the body already explains the collage change.

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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_ids sent in a different order builds a second cached list, because apiv2/catalog_items.go keeps 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 Refresh already queued when a poster is uploaded doesn't recheck PosterURL, so it can save one more variant.
  • Cleanup: facet_values.go hand-rolls single-flight with a waiters field that only tests read, while golang.org/x/sync/singleflight is used elsewhere in the repo. FacetValuePicker and the older FacetSearchSelect now both call the facet search endpoint. PersonalCollectionCollages.Prepare has no production caller. The collage-refresh guard is copied in usercollections/sync.go and collections_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)) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread web/src/components/FilterRuleEditor.tsx Outdated
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}` : "");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread internal/catalog/catalog_resolver.go Outdated
limit = catalogFacetSearchMaxLimit
}
column, isColumn := facetColumns[facet]
if q == "" && (!isColumn || mode != FacetSearchRanked) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread docs/collections-api.md Outdated

- `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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread internal/api/router.go Outdated
collectionHandler.CollectionOwners = collectionOwners
collectionHandler.Collages = personalCollages
if deps.UserCollectionSync != nil {
deps.UserCollectionSync.Collages = personalCollages

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Quick104 and others added 2 commits October 5, 2026 13:21
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]>

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 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".

Comment thread web/src/components/FilterRuleEditor.tsx Outdated
Comment on lines +118 to +120
if (Array.isArray(value)) {
// Leaving "between" keeps where the range started.
return value[0] ?? getDefaultRuleValue(field, op);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Quick104 and others added 6 commits October 5, 2026 13:40
…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]>

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 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".

Comment thread internal/catalog/facet_values.go Outdated
Comment on lines +254 to +256
f = &facetFlight{done: make(chan struct{})}
c.flights[key] = f
go c.fly(context.WithoutCancel(ctx), key, f, load)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment on lines 127 to +128
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"`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment on lines +73 to +74
waitingSince.current ??= Date.now();
return Date.now() - waitingSince.current < COLLAGE_WAIT_MS ? COLLAGE_POLL_MS : false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in e9f08fa (with a38acba): the collage wait is now versioned by the editor's ETag, so a save that changes members or rules starts a new wait even after an earlier one expired. Same root cause as the thread on this line from the /silo review; the hook test covers it.

Quick104 and others added 3 commits October 5, 2026 14:17
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]>
Quick104 and others added 9 commits October 5, 2026 14:22
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]>
@Quick104

Quick104 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up on the smaller items in the review of 96fdb93:

  • library_ids order: fixed in 050a57b. searchCatalogFacet and getCatalogFilters sort the ids and drop repeats before building the scope, so one set of libraries shares one cached list in any order.
  • Hand-rolled single-flight: replaced in 2b5661f with golang.org/x/sync/singleflight. It keeps the same behavior: the build outlives a canceled caller with a 30-second timeout, a failed or panicking build caches nothing, and a flight that starts just after another stored the list reuses it. The same commit limits a node to four list builds at once (Codex's P1).
  • PersonalCollectionCollages.Prepare: removed in 7a18361; it moved into the DB tests that used it.
  • Collage refresh guard: one copy now, usercollections.RefreshCollage, used by the handler and the import sync (f0ef1c2).
  • FacetValuePicker and FacetSearchSelect both calling the endpoint: kept. After 5a1a544 they read different answers on purpose: the picker reads ranked values and values_has_more, and the catalog filter sheet's FacetSearchSelect reads the prefix matches and has_more.
  • Old collage rows after an uploaded poster, and a queued Refresh not rechecking PosterURL: left as they are. Server collages behave the same on the base branch. Both are listed under Risks in the PR description.
  • Validation tasks line: rechecked against the case results in the issue bodies and updated in the description. Only Collections — Server #193 S3 (Pass) and S6 (Partial) change; S1, S2, S4 and S5 are reached but this PR doesn't change what they check; the rest are not run.

@Quick104
Quick104 merged commit a3db898 into feat/collections-revamp Oct 5, 2026
36 checks passed
@Quick104
Quick104 deleted the feat/rule-value-picker branch October 5, 2026 18:48

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 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) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant