Skip to content

fix(sections): keep rule rows intact and create only the rows admins ask for - #1852

Merged
Quick104 merged 3 commits into
feat/collections-revampfrom
fix/section-filter-rows
Oct 4, 2026
Merged

Quick104 merged 3 commits into
feat/collections-revampfrom
fix/section-filter-rows

Conversation

@Quick104

@Quick104 Quick104 commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: changes #1141 C1-C2, #1137 AC1; may reach #194 A2, #195 W4 (shared rules editor)

Editing a row could break it without any warning, and the gallery could create rows the admin didn't ask for. This affected admins on Admin > Sections and profiles editing custom rows in Settings > Home Screen. The section editor's Easy filter mode rewrote rows with more than one rule group and saved rules the server rejects or can't run. On the Admin Sections Home tab, "Apply to all libraries" created library-page rows instead of a Home row. A fast double click on the gallery's "Add section" could create the row twice, and the single-row admin endpoints saved an Editor's Picks row with no titles. This change removes Easy mode, offers the bulk option only on the Library tab, disables "Add section" while its request runs, and has admin create and update check the config against the section type's own rules.

  • Switching a row with more than one rule group to Easy showed no rules. Any edit then saved one group holding only the new rule and dropped the rest.
  • Easy offered Cast, Library, Language, Runtime and Keyword, which the server doesn't support, and defaulted the operator to contains, which only genre accepts, so admin saves failed with a 400. It saved "Has been watched" and between values as text, so the row failed when it loaded.
  • On the Home tab, "Apply to all libraries" asked which libraries to use and then created library-scope rows, never a Home row.
  • Admin single create and update ran only the config check every section type shares. Bulk create and profile saves also run the section type's own check, which rejects an Editor's Picks row with no titles.

Approach

  • Custom-filter rows now always use the rules editor that was already behind the Advanced toggle, shown once. The toggle, the duplicate Media Scope and Libraries controls, and the Easy components are gone. The editor now offers personalized rules and sorts such as "Watched" and "Date Viewed". Easy offered "Watched" too, and the server accepts these on rows: rows resolve per viewer, and rows with personalized rules already skip the shared row cache.
  • The shared rules editor shows a rule its controls can't represent as a read-only "Not editable here" row with the raw rule and a Remove button, and saves the rule unchanged unless it is removed. These rules used to appear as blank selects. This covers rules Easy saved. It also covers rules in smart collections and the catalog filter sheet that the Guided view writes for fields the Advanced field list lacks, such as original_language and author. Many of these rules are valid, so the label doesn't call them broken.
  • The gallery form shows "Apply to all libraries" only on the Library tab.
  • "Add section" stays disabled until its create request settles.
  • /api/v2 admin create runs the section type's own config check. Update runs it only when the merged type or config differs from the stored one, so a row saved before this change can still be renamed, moved or disabled, including from the admin editor, which sends the unchanged type and config back with every save. A failed check returns validation_failed (422), which both operations already document. The check is opt-in on the shared service, and only the /api/v2 adapter requests it, so the frozen /api/v1 single create and update routes behave as before. docs/architecture/api-contract.md now says when the check runs.

Validation

  • Go: go build ./..., gofmt, go vet and make lint-changed are clean. go test passes for internal/api/handlers, internal/api, internal/apiv2, internal/sections/... and cmd/silo, including new tests that /api/v2 create and update request the check and that admin create rejects an empty Editor's Picks row. The full make test-go was not run.
  • DB-backed tests on a local PostgreSQL 18: admin update rejects emptying an Editor's Picks row, still allows disabling an already-empty row when the editor echoes its unchanged config, and /api/v1 create and update still store an empty row. These fail on the previous commit and pass now.
  • API contract: make verify-apiv2-openapi, make verify-apiv2-contract, make verify-apiv2-fixtures and TestCommittedArtifactMatchesRouter pass. The OpenAPI artifact is unchanged.
  • Web tests: make test-web passes. New tests cover an untouched rule row saving byte-identical config in admin and profile modes, personalized rules staying editable, read-only rules being kept or removed, no bulk option on the Home tab, and a double click sending one create request.
  • Web build and lint: pnpm run lint reports no errors; its warnings in changed files are on exports that already existed. pnpm run format:check, pnpm run build and pnpm run budget:check pass.
  • make verify-local-paths passes.
  • References: no siloserver.org page describes Easy mode, the bulk option or the rules editor, so the manual needs no update. GitHub code search finds no admin section calls in silo-apple or silo-android. Code search covers default branches only.
  • No one has walked these flows in a running app.

Risks

  • /api/v2 clients that create or edit admin sections now get validation_failed for configs that used to be accepted.
  • Rows Easy already saved with rules the server rejects or can't run still fail when they load. The editor now shows those rules so an admin can remove them; nothing rewrites stored rows.

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: one independent reviewer agent read the diff against the task and ran the changed Go and web tests, tsc -b, ESLint and Prettier. It found one minor issue: the shared rules editor labelled valid rules it can't edit "Unsupported rule", for example Guided-view original_language or author rules in smart collections, which could lead users to delete working filters. The label now reads "Not editable here", and a test checks that a Guided-view rule isn't called unsupported. It also noted that the v1 bridge routes now ran the section type's check. After the PR opened, an automated review flagged the same v1 change and that the editor's echoed config still blocked saves on legacy rows; both are fixed: the check is opt-in for /api/v2 only and runs only when the type or config actually changes.

🤖 Generated with Claude Code

Note

Add recipe config validation for admin section writes and remove FilterEasyMode UI

  • Adds opt-in recipe-specific validation to SectionHandler.CreateAdminSection and UpdateAdminSection in admin_sections_service.go. The v2 adapters set ValidateRecipe: true; the frozen /api/v1 routes keep the old no-check behavior. Updates run the check only when section_type or config actually changes.
  • Replaces the Easy/Advanced mode toggle in the custom-filter editor with a single CollectionRulesEditor in SectionEditorDrawer.tsx. Rules the editor cannot safely represent render read-only via canEditRule and stay in the config until explicitly removed.
  • Deletes the FilterEasyMode component set and its conversion module (filterEasyMode.ts and components under web/src/components/FilterEasyMode/).
  • Guards RecipeConfigDrawer.handleAdd against double submission: the Add section button disables while the create promise is pending and re-enables after it settles.
  • The recipe drawer offers bulk apply only when the Library tab is active in AdminSections.tsx.
  • Behavioral Change: admin section creates and PATCHes through /api/v2 now reject invalid recipe configs with a 400; PATCHes that only change other fields or echo unchanged definition fields still succeed.

Macroscope summarized 62e79b5.

Quick104 and others added 2 commits October 3, 2026 17:49
…ask for

The section editor's Easy filter mode replaced a multi-group rule row with
one group on the first edit, and offered fields and operators the server
rejects. Custom-filter rows now always use the rules editor the drawer
already had, shown once, with personalized rules and sorts enabled because
rows resolve per viewer. Rules the editor cannot represent, such as ones
Easy saved, appear as labelled unsupported rules that stay as saved until
removed. Easy, its quick-start templates and the unused preview box are gone.

On the Admin Sections Home tab, "Apply to all libraries" created library
rows instead of a Home row; it now shows only on the Library tab. The
gallery "Add section" button is disabled while the create is in flight, so
a double click no longer creates two rows.

Admin single create and update skipped the recipe's own config check that
bulk create, preview and profile saves run, so an empty Editor's Picks row
could be saved. Create and any update that writes the type or config now
run it; an update that writes neither leaves older rows editable.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The shared rule editor labelled every rule its controls cannot represent
"Unsupported rule". Smart collections and the catalog filter sheet use the
same editor, and their guided mode writes rules the server accepts, such as
original language, author, narrator and series. Switching to Advanced then
called those working rules unsupported and offered Remove, inviting users to
delete a valid filter. The server also accepts the value shapes the editor
cannot show, so the editor cannot tell a broken rule from a valid one.

The row now reads "Not editable here" and still shows the rule, keeps it as
saved, and offers Remove.

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

coderabbitai Bot commented Oct 3, 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: a4287501-9bb5-4acf-a8fc-991c0bf048a4

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 3, 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-03T22:51:59.874853Z 62e79b5 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.

@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: 15f6c8fb44

ℹ️ 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 +84 to +86
if msg, ok := validateRecipeConfig(sections.SectionType(req.SectionType), req.Config); !ok {
return none, apiError(http.StatusBadRequest, "bad_request", msg)
}

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 Preserve the frozen v1 create behavior

This service also backs POST /api/v1/admin/sections/, so the unconditional recipe check changes the frozen v1 route: a request such as an empty admin_curated_list, which the route previously stored, now returns 400. Keep this new validation in the v2 adapter or otherwise preserve the published bridge behavior rather than tightening both API versions through the shared service.

AGENTS.md reference: AGENTS.md:L226-L227

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 62e79b5. The recipe check is now opt-in on the shared service (ValidateRecipe, json:"-"), and only the /api/v2 adapter sets it, so POST/PUT /api/v1/admin/sections store what they stored before. A DB test pins v1 create and update of an empty Editor's Picks row, and an apiv2 test checks that v2 create and update request the check.

Comment on lines +421 to +423
if req.SectionType != "" || len(req.Config) > 0 {
if msg, ok := validateRecipeConfig(existing.SectionType, existing.Config); !ok {
return none, apiError(400, "bad_request", msg)

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 Validate actual recipe changes instead of echoed fields

When an existing row has recipe-invalid legacy config, the admin UI still cannot rename, move, or disable it: buildAdminSectionPayload and updateAdminSection always echo both section_type and config, even when the user changes only another field, so this condition revalidates the unchanged config and rejects the save. Compare the merged type/config with originalType/originalConfig, or make the UI submit a genuinely sparse PATCH, so the compatibility path described above this condition works in the primary editor.

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 62e79b5. Update now runs the recipe check only when the merged type or config differs from the stored row (jsonConfigEqual against the original), so the editor's echoed section_type and config no longer block renaming, moving or disabling a legacy row. The DB test now disables an empty Editor's Picks row while echoing its unchanged type and config; it fails on the previous commit.

The recipe check on admin section create and update ran in the service
that the frozen /api/v1 routes share with /api/v2, so v1 started
rejecting configs it used to store. The check is now opt-in through a
request field only the /api/v2 adapter sets.

An update also re-ran the check whenever the request carried a type or
config, but the admin editor echoes both on every save, so a legacy row
with an invalid config still couldn't be renamed or disabled. The check
now runs only when the merged type or config differs from the stored one.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@Quick104
Quick104 merged commit 34bbd49 into feat/collections-revamp Oct 4, 2026
18 checks passed
@Quick104
Quick104 deleted the fix/section-filter-rows branch October 4, 2026 05:06
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