fix: include menu freehand ingredients in web shopping list#324
Conversation
When a menu was added to the shopping list, only its nested recipe
references were sent to /api/shopping_list — freehand ingredients
written directly in the .menu file (e.g. `@coffee{1%cup}`) were
silently dropped, causing the web UI's output to differ from the
CLI's `cook shopping-list foo.menu`.
The frontend now also emits a request for the menu path itself
with an empty `included_references` list. extract_ingredients
adds the menu's non-reference ingredients via add_recipe and
skips every recipe reference (handled by the per-recipe requests).
Code ReviewSummary: Clean, focused fix for a real discrepancy between the CLI and web UI shopping list. The root cause diagnosis is correct and the implementation is well-reasoned. What the fix doesWhen a Positives
One gap to be aware of (pre-existing, not introduced here)
Minor nit (no change required)The implicit convention of // included_references: [] → backend skips all recipe references,
// adding only the menu's own freehand ingredients.
const menuFreehand = {
recipe: item.path,
scale: item.scale,
included_references: []
};VerdictApprove. The fix is correct, well-scoped, and matches the documented test results. The gap in |
Summary
.menufiles (e.g.@coffee{1%cup}directly in a menu), causing it to diverge fromcook shopping-list foo.menutemplates/shopping_list.html, also emit a request for the menu path itself withincluded_references: []—extract_ingredientsthen adds the menu's non-reference ingredients and skips every recipe reference (already covered by the per-recipe requests)Test plan
cook shopping-list "2 Day Plan.menu"already produces freehand items (maple syrup,coffee,bread,soy sauce,oats,sugar,orange juice,green salad)/api/shopping_listwith old payload shape+bread +coffee +green salad +maple syrup +oats +orange juice +soy sauce +sugar)