fix(web): label section recipes from their saved config - #729
fix(web): label section recipes from their saved config#729Tobechukwu-Njoku wants to merge 1 commit into
Conversation
recipeLabel returned found.presets[0].display_name for any section of a given type, ignoring the config the section was actually saved with. The presets of one recipe differ only by their default_params, so every variant rendered as whichever preset is registered first. trending_discover is where this was reported: a section created from "TMDB Trending This Week" showed a "TMDB Trending Today" badge. It is not specific to trending. 10 of the 33 registered recipe types ship more than one preset, so 28 of their 38 presets render the wrong label — the same defect for award_winners, mood_collection, format_showcase and the rest. Fixing recipeLabel covers all of them. Sections do not persist which preset created them; `sections` carries only section_type and a config jsonb. So the preset is identified by matching its default_params against that config, scoring by how many params match and requiring all of them to agree, which keeps tmdb/week distinct from trakt/week where a single-key check would not. Falls back to presets[0] whenever nothing matches, so sections saved before a preset existed keep their current label. Both render sites already had the section in scope and now pass section.config. Fixes Silo-Server#586 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe web UI now matches shared recipe types to presets using saved section configuration. Section badges and drag overlays use the resolved preset label. Tests cover parameter matching, fallback behavior, unrelated keys, missing catalog entries, and raw type labels. ChangesRecipe label resolution
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This localized labeling change is merge-ready after normal checks and review; no actionable merge-blocking risk remains. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
Flagging a mechanical blocker rather than asking for priority. The CI workflow on this PR is sitting at Re-checked against
The full gate results, and the comparison showing the pre-existing |
Fixes #586.
What happened
recipeLabelresolves a section's badge by finding its recipe definition and returningfound.presets[0].display_name— the first registered preset — without ever looking at the config the section was saved with (web/src/components/sections/EditableSectionRows.tsx:25before this change).The presets of one recipe differ only by their
default_params, so the first preset is not a stand-in for the rest.trending_discoverregisters three (internal/sections/recipes/trending_discover.go:52-54):default_paramstdisc_tmdb_day{"source":"tmdb","window":"day"}tdisc_tmdb_week{"source":"tmdb","window":"week"}tdisc_trakt{"source":"trakt","window":"week"}All three rendered as "TMDB Trending Today". That confirms the suspicion in the issue that Trakt Trending is mislabeled the same way — it is, and there's now a test for it.
This is not trending-specific
Worth flagging, since the issue reads as a single-section problem. Enumerating the registry, 10 of the 33 registered recipe types ship more than one preset:
That's 38 presets across those types, of which the 28 non-first ones all render the wrong label.
trending_discoveris just where it was noticed. FixingrecipeLabelrather than special-casing trending covers all of them in one change, which is why the diff is a bit larger than the report implies.Approach
Sections don't record which preset created them —
sectionscarriessection_typeand aconfigjsonb and nothing else (migrations/sql/001_schema.sql:613), and there's no preset-key column anywhere. So the preset has to be recovered by matching itsdefault_paramsagainst that config.presetMatchScorerequires every one of a preset'sdefault_paramsto agree with the config and scores by how many matched, so the most specific preset wins. Requiring all of them is what separatestmdb/weekfromtrakt/week— matching on the distinguishing key alone would not. Extra config keys the section carries (media_scope,item_limit, …) are ignored.It falls back to
presets[0]whenever nothing matches, so sections saved before a preset existed, or with hand-edited config, keep exactly the label they have today.Both render sites already had the section in scope, so they just pass
section.config.I left
SectionEditorDrawer.tsx:398alone: it usespresets[0]to name a section type in a picker where no section config exists yet, which is a different question from labeling a saved section.Tests
New
web/src/components/sections/EditableSectionRows.test.ts, 8 cases against the realtrending_discoverpreset shape: each variant labeled from its config, Trakt-vs-TMDB on the same window, extra config keys ignored, and four fallback paths (no config, unmatched config, unknown type, no catalog).Three fail before the change and pass after:
The five fallback cases pass both before and after — they pin the behavior this change is meant not to alter.
Gate
pnpm exec tsc --noEmit— cleanpnpm exec eslinton both changed files — 0 errors. The onereact-refresh/only-export-componentswarning onEditableSectionRows.tsxis pre-existing (recipeLabelwas already an exported non-component); verified identical on a clean baseline, it just moved from line 25 to 79.make test-web— compared against a cleanmainworking tree:mainIdentical failure counts; the delta is exactly this PR's one new file and its 8 passing tests. The 36 pre-existing failures are in
storage.test.ts,useTheme.test.ts,appearanceCacheOwnership.test.tsxandsettingValuesRealtime.test.tsx— untouched by this change, and I did not add anything toWEBTEST_KNOWN_FAILURES.No Go files touched.
Note
Written with AI assistance (Claude), per CONTRIBUTING. I've read the change, run the gate above, and can explain the reasoning and alternatives.
Summary by CodeRabbit
New Features
Tests