← back to index

U6 followup — nameKh + categoryId hydrationPROD

Two latent useState("") hydration bugs in product-detail-client.tsx matching the U6 isHidden pattern. Re-opening a product with a Khmer name or non-default category showed empty fields, and saving without re-entering blanked them in the DB.

Summary

Status
12/12 prod · 51/51 regression · shipped to nix-cafe karouna-dev
Commits
nix-cafe 51714da
Files
3 modified · 27 ins / 3 del · ~25 LOC net · no migration · no backend · no schema
Source
Spawned followup chip during U6 (2026-05-26); recovered as memo 2026-05-27 (project_u6_followup_hydration_bugs.md).

The fix

  const [name, setName] = useState(template.name);
- const [nameKh, setNameKh] = useState("");
- const [categoryId, setCategoryId] = useState("");
+ const [nameKh, setNameKh] = useState(template.nameKh ?? "");
+ const [categoryId, setCategoryId] = useState(template.categoryId ?? "");

updateProductAction already accepted + persisted both fields, so the save path was fine. The load path returned them as undefined because the two DAOs (getTemplateWithLinesById + listTemplatesWithLines) didn't SELECT them. The fix threads both columns through the DAOs + the TemplateRow interface + the createTemplateAction shape + the client hydration.

What shipped

No migration needed — both columns already exist on cafe.product_template (added by H4-X as bridge cols when cafe.products became a view).

12/12 prod checks

Seed category + product on prod lumiere via DAO probe (captures templateId)
SSO login on lumiere-coffee.nixtech.app
Navigate to /cafe/products/{templateId} — page renders
Initial form state: nameKh + category both empty (fresh row from seed)
Fill Khmer name (សាកល្បង U6F …) + pick seeded category + Save
DB verification #1: name_kh + category_id match UI input via direct Supabase SELECT
Reload — nameKh hydrates from saved value (the load-path fix under test)
Reload — categoryId hydrates from saved value
Round-trip the other way: change Khmer name + clear category + Save
DB verification #2: name_kh updated, category_id NULL
Reload — nameKh hydrates with new string, category dropdown shows "" (Uncategorized)
No 5xx during the suite

Screenshots

Regression sweep — 51/51

12/12 + 51/51 = 63/63 prod tests green on the karouna-dev branch.
test-phase1-prod.mjs11/11
test-phase2-sso-outdoor-prod.mjs6/6
test-m1-prod.mjs10/10
test-r7-prod.mjs14/14
test-r8-prod.mjs4/4
test-phase2-cafe-multishop-prod.mjs (solo)6/6