Repository navigation
fix(collections): keep smart collection rules and limits when editing - #1851
Conversation
The web editors rewrote saved smart collections without saying so. They defaulted the item limit to 100 and capped it at 500, although the server has left smart collections uncapped since #340 and stores a 10,000,000 sentinel for "no limit", so saving any uncapped collection cut it to 500. The Guided view rebuilds the definition from its own form state, so a toolbar sort or media change, or any Guided edit, dropped the rules it cannot show: negated rules, OR groups, repeated actor or director rules. A blank Max items field now means no limit and is left out on save, and an explicit limit passes through unchanged. A definition that Guided cannot reproduce opens in Advanced with Guided switched off and a short note, the toolbar changes only the sort and media scope, and the Filters count includes every rule. The wizard lets a collection with no matches continue to Details, and the Advanced Media Scope lists Movies & Series and Manga. Collections that earlier saves already truncated stay truncated. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…types The Catalog page rebuilds its filters from the URL on every change, and the URL reads a decimal such as 7.5 back as text and a number-like value such as the genre 1917 as a number. The Guided check compared value types, so typing an IMDb minimum of 7.5 flipped the Filters sheet to Advanced, disabled Guided and hid the badges. Compare numbers as text so a type change alone no longer counts as a rule Guided can't show. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Toolbar media changes now patch the definition instead of rebuilding it through Guided, which also stopped removing narrator rules on a scope change. The server rejects narrator rules for the ebook scope, so switching an audiobook view with a narrator filter to Ebooks returned an error. Remove narrator rules, and any group they leave empty, only on that switch; every other rule stays. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Entering 0 or a negative number in Max items cleared the limit, which made the collection uncapped without saying so. Only a blank field means no limit now; any other entry that isn't a positive number keeps the current limit. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The Filters button count now comes from the badges or the rules, so nothing calls countActiveFilters. 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. |
|
Major change — #1252 C1 (Series — Web, build The Suggested replacement: 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: f250a6830d
ℹ️ 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".
| return limit > 0 && limit < SMART_COLLECTION_NO_LIMIT_SENTINEL | ||
| ? query | ||
| : { ...query, limit: undefined }; |
There was a problem hiding this comment.
Preserve explicit limits above the sentinel
When a stored smart collection has an explicitly chosen limit above 10,000,000, this predicate treats it as the no-limit sentinel and omits it on save. ApplySmartCollectionItemLimit in internal/catalog/query_definition.go honors every positive explicit limit but replaces an omitted limit with 10,000,000, so editing a collection limited to 20,000,000 silently halves its possible membership. Only the exact sentinel, nonpositive values, and absent values should be cleared.
AGENTS.md reference: AGENTS.md:L13-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in d050797. Only an absent limit, a non-positive one, or exactly 10,000,000 (the value ApplySmartCollectionItemLimit fills in) now reads as blank. An explicit limit above it, such as 20,000,000, passes through and is saved unchanged. The helper test covers that case and fails on the previous commit.
…ault The editor treated any limit at or above 10,000,000 as the server's no-limit default and dropped it on save. The server honors every explicit positive limit and only fills in 10,000,000 when none is set, so a collection limited to 20,000,000 lost its limit when edited. Only the exact default now reads as blank. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Validation line updated to |
Problem
Related issue: #192
Validation tasks: changes #194 A2, #195 W4, #1252 C1, #1256 C1, and the #199 Browse criterion
When someone edits a smart collection in the web app, the editor can quietly change what the collection contains: it caps the item limit and drops rules it can't display. This affects admins editing server collections and users editing their own. The catalog and library browse filters share the same code and lose rules the same way. With this change, a save keeps the stored rules and limit unless the person edits them.
The browse change is deliberate. On the catalog and library browse pages (#1252 C1, #1256 C1, #199 Browse), a toolbar sort or media change used to drop any filter the Guided view can't show, without telling the viewer. It now keeps those filters, and the filter sheet opens them in Advanced. Sorting and filtering otherwise work as before, and the cases' criteria are unchanged, so #1252 C1 (recorded in a rehearsal on an earlier build) and #1256 C1 need a re-test after merge.
Approach
Validation
make test-webexclusions.pnpm run lintreports no errors, and the warnings in changed files predate this branch.pnpm run format:checkandpnpm run buildpass, andpnpm run budget:checkis within budget.make verify-apiv2-web-types,make verify-settings-bindings-webandmake verify-local-pathspass./api/v2or OpenAPI files. There is no page-level Catalog test, becauseCatalog.test.tsxis on the known-failure list. No one has walked Collections — Web admin #194 A2, Collections — Web #195 W4 or the browse filters in a running app.Risks
Checklist
AI Disclosure
countActiveFiltershad no callers left (removed).🤖 Generated with Claude Code
Note
Fix smart collection editing to preserve advanced rules and remove the 500-item limit cap
isGuidedRepresentablein guidedRepresentable.ts. It detects query definitions Guided cannot losslessly edit, opens them in Advanced, disables the Guided toggle, and shows a shared unavailable messagenormalizeSmartCollectionLimitin smartCollectionLimits.tsquerySortScopeForMediaScopehelper in querySortOptions.tscreateCollectionBuilderValuein CollectionBuilder.tsx and the wizard's query-change handler in SmartCollectionWizard.tsx, which no longer re-normalizes limits on every query editMacroscope summarized d050797.