Skip to content

feat(collections): one Smart page for create and edit, with a live poster preview - #1943

Merged
Quick104 merged 7 commits into
feat/collections-revampfrom
feat/collection-editor-smart
Oct 5, 2026
Merged

Quick104 merged 7 commits into
feat/collections-revampfrom
feat/collection-editor-smart

Conversation

@Quick104

@Quick104 Quick104 commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: #192
Validation tasks: changes #194 A1–A3 and #195 W2, W4–W7 (W7 still needs #1615; all Not run, each needs a walk on a running build before merge); changes Silo-Server/silo-apple#20 C7, Silo-Server/silo-apple#21 C7, Silo-Server/silo-android#5 C7, and Silo-Server/silo-android#6 C7 (they check collections written by the new web editor); changes #193 S3 (the personal Smart editor now shows preview posters from POST /api/v2/collections/preview; re-check them as a restricted profile after merge); reaches #193 S4 (Partial) with no server change, and #192 AC5 (parent criterion)

Smart collections are created in one place and edited in another, and neither matches the editor page that Manual collections moved to in #1939. Create goes through a form (CollectionForm for admins, UserCollectionForm for profiles) with its own Simple/Advanced rule builder and a text list of 12 matches. Edit opens a two-step wizard (SmartCollectionWizard) built on the catalog filters. This PR moves Smart collections, server and personal, create and edit, onto the editor page. Contents is the Home rows rule sentence with the libraries inside it, then an Order block, and a live preview shows the posters the unsaved rules match. The wizard, the older builder and both forms are deleted.

Stacked on #1940 (fix(web): name the libraries in the rule sentence).

Approach

  • ManualCollectionEditor becomes CollectionEditor and takes the collection type. Smart uses the same draft, save bar, conflict handling, header, Details and Where it shows panels as Manual. Rules and Order are draft fields: the save bar says "Rules not saved" and adds "The preview already shows them." A library change counts once, as Libraries. The header shows a Smart tag, the title count and "Updates itself as titles are added". Below 1024px the panel switcher reads Rules / Details / Where it shows.
  • Rules use the Home rows RuleBuilder. Its new optional props (context, librariesRequired, allLibrariesLabel, librariesId) default to the Home rows behaviour, so Home rows doesn't change.
    • A server collection needs at least one library, so the sentence offers no "all libraries" choice. Create and Save wait for a library and say "Pick at least one library." (or "Pick its libraries, then create it.") in the save bar.
    • A personal collection with no library picked reads "from all my libraries" and matches every library the profile can see, as before.
    • Rules about the viewer, such as Watched, are offered only on personal collections.
    • A rule the builder can't show stays as a "Not editable here" line and is saved unchanged unless someone removes it.
    • CollectionGuidedRulesEditor stays because the catalog filters use it.
  • The Order block has sort, direction (labelled to match the sort: A–Z, Newest first, Highest first) and max titles, which keeps the old handling of blank and non-positive values.
    • A Smart collection can carry a stored default sort in sort_config that wins over the rules' sort. The Order block names it ("A saved default sort, Title A–Z, wins over this Order.") with Clear. Changing the sort or direction clears it too, so the new Order takes effect. Clearing drops only field and order and keeps any other sort_config key. An untouched stored sort is sent back as it was.
    • The old Manual Pins choice is gone. The server stores {"mode":"manual_pins"} but never orders by it, and the editor sends a stored mode back unchanged.
  • The preview reads "Live preview · N titles match · showing 24" over a poster grid that uses the poster_url from feat(api): include poster URLs in personal smart previews #1892. It sends the whole draft rules across every chosen library, 300 ms after the last edit, and keeps the last result on screen while the next one loads. The count is a polite live region. Zero matches shows ghost posters with "No titles match yet", and Save still works. useScopePreview in hooks/queries/collectionScope.ts replaces hooks/queries/collectionPreviews.ts.
  • The old admin edit wizard had a Featured switch. In this redesign a collection is pinned from the Arrange view (a later PR) and collections made in the editor start unpinned, so the Smart editor has no switch. Server create still sends featured: false, and the PATCH now leaves featured out, so saving keeps an existing pin.
  • Personal Smart collections get the Description field; create and PATCH send description, which feat(api): accept a description when creating a personal collection #1888 added to the API.
  • Until the New collection picker lands, the admin Add Collection chooser's Smart card opens the editor page with ?type=smart, and personal /collections/new with no type shows a two-choice Manual / Smart picker that opens the editor page. Saved Smart collections open the editor page. Synced lists keep their current editors.
  • Leaving an uncreated collection now asks before discarding any changed draft field or picked titles. Before, a Manual create asked only about the name, description, picked titles or artwork, so changing only the libraries or a switch now prompts too. After a Smart Create, focus moves to the libraries control in the rule sentence; Manual still moves it to the title search.
  • docs/architecture/collection-editor.md gains a section on Smart rules, the preview and the stored default sort.

Differences from the approved design, for the owner to accept or reject:

  • Preview posters are labelled by title only. The design asks for "Title (Year)", but the preview API returns no year.
  • Rules about the viewer keep their current labels, such as "Watched"; the design reads "Watched by me…".
  • A locked rule uses the existing dashed "Not editable here" line with a Remove button, not the design's lock icon with ×.

No API change. jellycompat and the Apple and Android clients need no change. The user manual's collections page needs lines saying the Smart page replaces the two-step wizard, uses the same rule sentence as Home rows and shows a live preview. That siloserver.org issue is not filed yet.

Validation

  • Web: lint (no errors; the changed files add no warnings), format:check, build, budget:check, tsc -b and make test-web (807 files, 7,493 tests) pass.
  • Page tests cover the preview request (every chosen library, limit 24, follows rule edits), posters from poster_url, the count announced once in a polite live region, a locked rule kept on save, zero matches still saving, viewer rules only on personal collections, the stored default sort (sent back untouched; cleared by an Order change or Clear with other keys kept), Create staying on the editor and moving focus, a server collection that can't be created or saved with no library, the read-only redirect, "all my libraries" on personal collections, and the layout at 1023, 1024, 1279 and 1280px. A hook test with the real debounce checks that a burst of edits inside 300 ms sends one request while the earlier posters stay shown. The wizard and builder tests were ported to the page; RuleBuilder, the Order block and the draft helpers have their own tests.
  • The saved-request goldens from test(web): pin what the collection pages and editors save today #1912 change on purpose in two places: the admin Smart PATCH leaves out featured, and personal Smart create and PATCH send description. The Smart limit goldens (no limit, the sentinel, 250) for both scopes now run through the page.
  • Not checked on a running build: Collections — Web admin #194 A2, A3 and Collections — Web #195 W4, W5 have not been walked, and the page has not been compared with the design in a browser.
  • make verify-local-paths passes. No Go, contract or migration files changed, so the Go and contract checks were not run. make verify-case-collisions does not exist on this base.

Risks

  • Until the Arrange PR adds Pin, the web has no way to pin or unpin a Smart server collection. Existing pins stay as they are.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.

AI Disclosure

  • Harness: Claude Code (in T3 Code)
  • Tool(s): Claude Code subagents (implementer, independent reviewer)
  • Model(s): claude-opus-5-5[1m]
  • Involvement: Fully AI-generated, human review pending
  • Adversarial review: An independent reviewer subagent checked the diff against the redesign plan and the approved mockup, ran the focused tests, and broke three behaviours in a scratch copy: a server Smart collection offering viewer rules, the stored sort not clearing when Order changes, and the draft rules dropping library_ids. The tests caught the first two but not the third, which is only a safety net. It approved once one major finding was fixed: an admin could save a saved server Smart collection with every library unticked, which the old wizard blocked, and the PATCH then failed the legacy library foreign key with a generic "Couldn't save". Save now waits for a library and says why, with a test. Also fixed: focus dropped to the page after a Smart Create; the 300 ms debounce had no test; a zero-match preview was announced twice; a module left holding one pass-through function was removed; and the header now shows the title count, as the mockup does.

🤖 Generated with Claude Code

Note

Unify Smart and Manual collection create/edit into one editor page with live poster preview

  • Replaces the old Smart wizard and Manual form paths with a single CollectionEditor component that handles create and edit for both kinds (CollectionEditor.tsx, CollectionEditorPage.tsx)
  • Smart collections get editable rules, sort, and limits via SmartRulesPanel and a new interactive smart mode in OrderBlock, which now requires libraries for non-personal scope
  • Adds a debounced live preview (useScopePreview, 300ms, 24-item limit) that keeps the previous results while a new preview loads, rendered by CollectionPreviewPane with loading, empty, error, and refreshing states
  • Draft comparison for Smart rules no longer double-reports library changes as both Libraries and Rules; library IDs live only on the draft's libraryIds field
  • Large test refactor: legacy wizard/form suites are removed, and new integration tests cover the unified editor for Manual and Smart in personal and admin scopes
  • Risk: SmartCollectionWizard and CollectionForm are removed; any references outside web/src/pages/adminCollectionsShared.tsx and the deleted suites must be gone. Admin Smart unchanged PATCH bodies no longer send featured, and personal Smart requests now include description (see collectionBodies.ts)

Macroscope summarized 629daf6.

Quick104 and others added 3 commits October 4, 2026 16:59
…ster preview

Smart collections now open on the collection editor page, like Manual ones,
for server and personal collections and for create and edit. The two-step
SmartCollectionWizard and the Simple/Advanced builder are gone: Contents is
the Home rows rule sentence with the libraries in it, then an Order block,
and a live preview shows the posters the unsaved rules match across every
chosen library. A rule the builder can't show stays as a locked line and is
saved unchanged; rules about the viewer are offered only on personal
collections. A stored default sort is named with Clear, and changing Order
clears it so the new order takes effect. Editor saves leave out
`featured` and personal saves send the description, as Manual already does.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
An admin could untick every library on a saved server collection and press
Save; the empty library list fails the legacy library foreign key and the
admin got only "Couldn't save". Save now waits for a library and says why,
as Create already did, and the preview names the same reason.

Also from review: after creating a Smart collection, focus moves to the
libraries in the rule sentence instead of dropping to the page; a zero-match
preview is announced once; the header shows the title count, as the approved
mockup does; and the preview's debounce has its own test.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
userCollectionsShared.tsx held only a pass-through wrapper once the old
collection form left it.

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

coderabbitai Bot commented Oct 4, 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: 9cbb0bfc-8beb-42d4-a05c-f89dd4503900

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 4, 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-04T23:55:30.376166Z 629daf6 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 4, 2026

Copy link
Copy Markdown

Major validation impact: #194 A1–A3, #195 W4–W5, and the cross-client C7 cases. Smart CRUD, rules, Order, and artwork now use the shared editor/draft-save path; the live preview uses a new debounced query path, and changing Order can clear a stored sort. The native refresh code is unchanged, but C7 verifies the collection state produced by this new web writer. These cases are currently Not run, so no recorded pass is invalidated; the PR should explain why the existing Smart workflow/data path is changing. They need a live walk before acceptance, and any evidence accepted from a pre-merge build must be re-validated after merge.

Minor changes: #195 W2 and W6 now start at the Manual/Smart chooser; W7 sees the sharing switch in the shared “Where it shows” panel. The switch’s behavior is unchanged, and W7 still depends on #1615. For W5, #1618 was already closed by #1702 on the base; #1616’s cross-profile collection-list ordering is separate and this PR does not change it. #193 S4 remains Partial: the saved-membership service and library-scan path are unchanged; this PR adds an unsaved-rules preview. #1141 C1 has no behavior change because RuleBuilder’s Home-row defaults preserve its existing query behavior.

Suggested Validation tasks: line:
Validation tasks: changes #194 A1–A3; changes #195 W2, W4–W7 (W7 still needs #1615); changes Silo-Server/silo-apple#20 C7, Silo-Server/silo-apple#21 C7, Silo-Server/silo-android#5 C7, and Silo-Server/silo-android#6 C7.

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

Posted via Macroscope — v1 validation impact

Base automatically changed from fix/rule-sentence-libraries to feat/collections-revamp October 4, 2026 23:12
…at/collection-editor-smart

# Conflicts:
#	web/src/components/homeRows/addRow/RuleBuilder.tsx
#	web/src/pages/CollectionEditorPage.tsx
@Quick104

Quick104 commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Updated the Validation tasks line to add #194 A1, #195 W2/W6/W7, and the apple/android C7 cases from the Macroscope check.

@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: 85b41015eb

ℹ️ 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 +58 to +61
function parsedLimit(text: string, current: number | undefined): number | undefined {
if (text.trim() === "") return undefined;
const parsed = Number.parseInt(text, 10);
return parsed > 0 ? parsed : current;

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 Reject decimal max-title values instead of truncating

When a user enters a decimal or exponent-form value such as 2.5 or 1e2 in the Max titles field, the browser permits it for this type="number" input, but parseInt silently converts it to 2 or 1 and saves that unintended limit. Since this field is documented as accepting only positive whole numbers, validate the complete numeric string and keep the previous value (or show an error) for non-integer input rather than truncating it.

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 ff9ad44: only whole digits change the limit now; 2.5 and 1e2 keep the previous value (covered in OrderBlock.test.tsx).

@macroscopeapp

macroscopeapp Bot commented Oct 4, 2026

Copy link
Copy Markdown

One additional major validation impact: #193 S3. The new personal Smart editor calls POST /api/v2/collections/preview, and CollectionPreviewPane renders the returned poster_url values. PR #1892 specifically tied preview posters to the restricted-profile S3 check. The endpoint applies the viewer access filter and signs posters only for returned matches, but the existing API result does not cover this new visible consumer. The PR should call out this intentional poster-display path and add #193 S3 to Validation tasks; re-check the preview as a restricted profile after merge before relying on the earlier result.

Suggested addition: changes #193 S3 (re-check personal Smart preview posters under restricted profiles after merge).

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

Posted via Macroscope — v1 validation impact

Quick104 and others added 2 commits October 4, 2026 19:42
…at/collection-editor-smart

# Conflicts:
#	web/src/components/collections/editor/CollectionMetaLine.tsx
#	web/src/pages/Collections.tsx
parseInt read "2.5" as 2 and "1e2" as 1, so a non-integer entry saved an
unintended limit. Only whole digits now change the limit.

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

Quick104 commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Added #193 S3 to the Validation tasks line: the personal Smart editor's live preview shows posters, so S3 needs a restricted-profile re-check after merge.

…at/collection-editor-smart

# Conflicts:
#	web/src/components/collections/editor/CollectionEditor.tsx
#	web/src/pages/AdminCollectionEditor.tsx
#	web/src/pages/AdminCollections.test.tsx
#	web/src/pages/CollectionEditorPage.snapshot.test.tsx
#	web/src/pages/SmartCollectionWizard.artwork.test.tsx
#	web/src/pages/SmartCollectionWizard.rules.test.tsx
#	web/src/pages/SmartCollectionWizard.tsx

@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

<LegacyPersonalEditor
snapshot={snapshot as EditorSnapshot<Collection>}
onSaved={editor.rebase}
/>

P2 Badge Preserve an editor fallback for unknown synced collection types

collectionKindOf deliberately classifies every collection type other than manual and smart as synced, but this branch now always renders ImportedCollectionEditor, which assumes the value is one of mdblist, tmdb, or trakt and indexes an undefined SOURCE_THEMES entry for any legacy or future synced type. Opening such a personal collection will therefore fail while rendering instead of showing an editor or a controlled unsupported-state page; keep the previous type guard/fallback or make the imported editor handle unknown sources.

ℹ️ 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 +1379 to +1380
// Only synced lists open here; Manual and Smart collections use the editor page.
if (!isMDBListCollection && !isTMDBCollection && !isTraktCollection) return null;

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 render a blank admin page for unknown synced types

collectionKindOf maps any non-manual/non-smart value to synced, so an existing legacy or future synced type reaches CollectionEditForm; this new guard returns null for anything outside the three known import types. Editing that collection in the admin UI now produces a blank page with no fallback, whereas the previous generic form handled non-import collections.

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.

Not a change in behavior: the only caller, AdminCollectionEditor, renders CollectionEditForm only when isListBackedCollectionType(collection.collection_type) is true (mdblist, tmdb, trakt), and it gated it the same way before this PR. So the old CollectionForm fallback inside CollectionEditForm was already unreachable for any other type, and the null branch here is too. The v2 schema also limits collection_type to manual, smart, mdblist, tmdb and trakt.

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