fix(review): Create title no silent fail; gate enables content LLM
Create title used to look enabled while review echoed a pre-typed title when species/primary were missing from taxonomy (no error). Persist wood cats before the deterministic build, return title_built / title_build_missing from review, and surface a Create-title nudge like Create desc. WooSetupGate now turns on content_llm_enabled when inference URL+key are set (Call 2 / Create desc). Call 1 stays out. Create-desc gate also requires inference URL+key so empty Settings show a clear missing list.
This commit is contained in:
+27
-6
@@ -184,12 +184,23 @@ async def review_slab(slab_id: str, payload: dict[str, Any] | None = None) -> di
|
||||
# they are produced by the deterministic build below, not persisted from the
|
||||
# payload (so the review POST can't clobber the owner's Create workflow).
|
||||
cats, terms = _taxonomy_lookup(conn)
|
||||
primary_id = payload.get("primary_wood_category_id")
|
||||
|
||||
def _as_cat_id(v):
|
||||
if v is None or v == "":
|
||||
return None
|
||||
try:
|
||||
return int(v)
|
||||
except (TypeError, ValueError):
|
||||
return None
|
||||
|
||||
primary_id = _as_cat_id(payload.get("primary_wood_category_id"))
|
||||
wood_cats = slab.get("wood_category_ids") or []
|
||||
if not primary_id:
|
||||
primary_id = wood_cats[0] if wood_cats else None
|
||||
primary_leaf = cats.get(primary_id, {}) if primary_id else {}
|
||||
species_name = cats.get(slab.get("species_id"), {}).get("name", "") if slab.get("species_id") else ""
|
||||
primary_id = _as_cat_id(wood_cats[0]) if wood_cats else None
|
||||
# Taxonomy rows use integer PKs; coerce so string JSON ids still resolve.
|
||||
primary_leaf = cats.get(primary_id, {}) if primary_id is not None else {}
|
||||
species_id = _as_cat_id(slab.get("species_id"))
|
||||
species_name = cats.get(species_id, {}).get("name", "") if species_id is not None else ""
|
||||
figure_term_ids = slab.get("figure_term_ids") or []
|
||||
figure = terms.get(figure_term_ids[0], {}).get("name") if figure_term_ids else None
|
||||
|
||||
@@ -210,14 +221,22 @@ async def review_slab(slab_id: str, payload: dict[str, Any] | None = None) -> di
|
||||
# Deterministic title / short_description, re-derived from the current
|
||||
# metadata on every review (the Create button's source of truth).
|
||||
# #98: pass synced terms so Live Edge comes from the edge term, not any id.
|
||||
# title_built tells the client whether the Create-title path actually ran
|
||||
# (vs echoing a pre-typed title when species/primary are missing from taxonomy).
|
||||
title_build_missing: list[str] = []
|
||||
if not species_name:
|
||||
title_build_missing.append("species")
|
||||
if not primary_leaf:
|
||||
title_build_missing.append("primary_wood_category")
|
||||
title_built = not title_build_missing
|
||||
title = (
|
||||
build_title(slab, figure, species_name, primary_leaf, terms)
|
||||
if (primary_leaf and species_name)
|
||||
if title_built
|
||||
else slab.get("title") or None
|
||||
)
|
||||
short_desc = (
|
||||
build_short_description(slab, figure, species_name, primary_leaf, terms)
|
||||
if (primary_leaf and species_name)
|
||||
if title_built
|
||||
else slab.get("short_description") or None
|
||||
)
|
||||
|
||||
@@ -227,6 +246,8 @@ async def review_slab(slab_id: str, payload: dict[str, Any] | None = None) -> di
|
||||
"ready": ready, "missing": missing, "title": title, "short_description": short_desc,
|
||||
"price": price, "price_suggestion": price_suggestion(conn, slab),
|
||||
"primary_wood_category_id": primary_id,
|
||||
"title_built": title_built,
|
||||
"title_build_missing": title_build_missing,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user