From 8dad430650ca9347435eebc3a2b7b7f0e734f747 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Mon, 30 Nov 2026 12:48:42 +0000 Subject: [PATCH] feat(recipe): add step quantities and appliance settings --- COOKING_OPERATIONS.md | 70 +++++ .../Domain/Recipe/RecipeIngredientHtml.vue | 5 +- .../Recipe/RecipeIngredientListItem.vue | 4 +- .../Domain/Recipe/RecipeIngredients.test.ts | 13 + .../Domain/Recipe/RecipeIngredients.vue | 22 +- .../Domain/Recipe/RecipePage/RecipePage.vue | 8 +- .../RecipePageParts/CookTime.test.ts | 10 +- .../RecipePage/RecipePageParts/CookTime.vue | 21 +- .../RecipePageInstructions.test.ts | 68 +++++ .../RecipePageInstructions.vue | 71 ++++- .../Domain/Recipe/RecipePrintContainer.vue | 4 +- .../Domain/Recipe/RecipePrintView.test.ts | 76 +++++ .../Domain/Recipe/RecipePrintView.vue | 27 +- .../Recipe/RecipeStepAllocationEditor.test.ts | 49 +++ .../Recipe/RecipeStepAllocationEditor.vue | 72 +++++ .../Recipe/RecipeStepAllocationSummary.vue | 40 +++ .../Domain/Recipe/RecipeStepCooking.test.ts | 59 ++++ .../Domain/Recipe/RecipeStepCooking.vue | 114 +++++++ .../Recipe/RecipeStepOperationDetails.test.ts | 91 ++++++ .../Recipe/RecipeStepOperationDetails.vue | 288 ++++++++++++++++++ .../__tests__/use-recipe-ingredients.test.ts | 16 +- .../recipes/use-recipe-ingredients.ts | 11 +- frontend/app/lang/messages/en-US.json | 110 +++++++ frontend/app/lib/api/types/household.ts | 70 +++++ frontend/app/lib/api/types/recipe.ts | 70 +++++ .../app/lib/recipe/instruction-merge.test.ts | 27 +- frontend/app/lib/recipe/instruction-merge.ts | 46 ++- .../app/lib/recipe/step-ingredients.test.ts | 71 +++++ frontend/app/lib/recipe/step-ingredients.ts | 72 +++++ frontend/pnpm-workspace.yaml | 5 + ...42c6d50a10_add_step_ingredient_quantity.py | 23 ++ ...-00.00.01_c981d7e62b11_add_step_cooking.py | 23 ++ ...0_e274a9d13c50_fractional_step_duration.py | 32 ++ ....01_d3f629aa71b4_step_allocation_intent.py | 42 +++ mealie/db/models/recipe/instruction.py | 17 +- mealie/schema/recipe/__init__.py | 18 +- mealie/schema/recipe/recipe.py | 28 +- mealie/schema/recipe/recipe_step.py | 237 +++++++++++++- .../steps/enrich_instructions.py | 18 +- mealie/services/recipe/recipe_service.py | 60 +++- mealie/services/recipe/step_review.py | 61 ++++ .../test_recipe_create_from_mealie_export.py | 74 ++++- .../test_recipe_step_duration.py | 12 +- .../user_recipe_tests/test_step_operations.py | 199 ++++++++++++ .../test_step_operations_migration.py | 104 +++++++ .../test_enrich_instructions.py | 22 +- ...test_fractional_step_duration_migration.py | 52 ++++ tests/unit_tests/test_recipe_step_duration.py | 16 +- tests/unit_tests/test_step_cooking_schema.py | 47 +++ .../test_step_metadata_migrations.py | 50 +++ tests/unit_tests/test_step_operations.py | 107 +++++++ 51 files changed, 2775 insertions(+), 77 deletions(-) create mode 100644 COOKING_OPERATIONS.md create mode 100644 frontend/app/components/Domain/Recipe/RecipePage/RecipePageParts/RecipePageInstructions.test.ts create mode 100644 frontend/app/components/Domain/Recipe/RecipePrintView.test.ts create mode 100644 frontend/app/components/Domain/Recipe/RecipeStepAllocationEditor.test.ts create mode 100644 frontend/app/components/Domain/Recipe/RecipeStepAllocationEditor.vue create mode 100644 frontend/app/components/Domain/Recipe/RecipeStepAllocationSummary.vue create mode 100644 frontend/app/components/Domain/Recipe/RecipeStepCooking.test.ts create mode 100644 frontend/app/components/Domain/Recipe/RecipeStepCooking.vue create mode 100644 frontend/app/components/Domain/Recipe/RecipeStepOperationDetails.test.ts create mode 100644 frontend/app/components/Domain/Recipe/RecipeStepOperationDetails.vue create mode 100644 frontend/app/lib/recipe/step-ingredients.test.ts create mode 100644 frontend/app/lib/recipe/step-ingredients.ts create mode 100644 mealie/alembic/versions/2026-11-30-00.00.00_b742c6d50a10_add_step_ingredient_quantity.py create mode 100644 mealie/alembic/versions/2026-11-30-00.00.01_c981d7e62b11_add_step_cooking.py create mode 100644 mealie/alembic/versions/2026-12-01-00.00.00_e274a9d13c50_fractional_step_duration.py create mode 100644 mealie/alembic/versions/2026-12-01-00.00.01_d3f629aa71b4_step_allocation_intent.py create mode 100644 mealie/services/recipe/step_review.py create mode 100644 tests/integration_tests/user_recipe_tests/test_step_operations.py create mode 100644 tests/integration_tests/user_recipe_tests/test_step_operations_migration.py create mode 100644 tests/unit_tests/test_fractional_step_duration_migration.py create mode 100644 tests/unit_tests/test_step_cooking_schema.py create mode 100644 tests/unit_tests/test_step_metadata_migrations.py create mode 100644 tests/unit_tests/test_step_operations.py diff --git a/COOKING_OPERATIONS.md b/COOKING_OPERATIONS.md new file mode 100644 index 000000000..a5b911021 --- /dev/null +++ b/COOKING_OPERATIONS.md @@ -0,0 +1,70 @@ +# Fork-specific cooking operations + +Optional native data; no appliance, scales or cooking mode is executed by +Mealie. Device interpretation and supported wire values belong to integrations. +Existing recipes need no appliance information. + +## Ingredient references + +`quantityKind` distinguishes `full`, `partial`, `remaining`, `unknown`, +`prepared`, `asNeeded` and `referenceOnly`. Missing kinds preserve the legacy +null/full and numeric/explicit behavior. A partial portion requires a number, +including an explicit zero. + +Non-numeric kinds store a zero **compatibility sentinel** in `quantity` so older +clients cannot inherit the recipe total. Current clients use the kind instead: +unknown/prepared/qualitative/reference-only associations have no numeric amount. +A remainder is calculated only when unambiguous and never persisted as a fixed +portion. + +`weighing` is unspecified (including null/missing), `manual` or `weigh`; grams +alone never authorize scales. Unknown or non-allocation references cannot request +weighing. `role`, `destination`, `quantityMinimum`, `quantityMaximum`, +`approximate`, `containerCount` and `sourceText` preserve allocation context. +Quantities use the ingredient's unit and are per-container when a count exists. + +The editor checks the whole allocation ledger, including inherited quantities, +container counts and repetitions, and warns about ambiguous remainders. +Shopping lists still use recipe totals. Display scaling does not rewrite native +quantities or machine settings. Stable allocation IDs keep completion independent. + +## Operation settings + +`durationSeconds` accepts finite positive seconds with millisecond precision; +legacy zero remains unspecified. Exact seconds and the existing minute shortcut +are both editable. + +The existing optional `cooking` object adds: + +- `actionType`, `timerType`, `applianceInstance`: generic action/appliance context. +- `accessories`: named items with installed/removed/unknown/conditional/open/closed + states, including lid context; no installation is inferred from prose. +- `durationKind`, `durationRangeSeconds`, `durationCondition`: fixed, ranged, + user-selected or condition-controlled time. +- `speedKind`, `speedRange`, `speedProgression`: retain ranges and ordered ramps + independently of an existing fixed/selected `speed`. +- `modeParameters`: named text, number, boolean or range parameters, with units. + Source labels such as thickness or doneness remain unchanged. +- `optional`, `condition`, `requiresConfirmation`, `repetitions`, + `repetitionRange`, `dependsOnStepIds`: declarative execution context, not a + workflow engine. Dependencies must belong to this recipe and be acyclic. +- `reviews`: categorized evidence, candidate ingredient IDs, resolution, approved + native content and history. Linking a candidate starts with an unknown amount. + Resolution requires an explanation; subsequent edits reopen approved reviews. + Omitting reviews cannot erase their provenance. Bridge extras are untouched. + +Native JSON, duplication, editing and printing preserve these fields. +Duplication/import remap identities and dependencies together. Unsafe merges +are refused; undo restores safe merges. + +## Deployment + +Back up the database and deploy backend/frontend together. Migrations +`e274a9d13c50` (fractional duration) and `d3f629aa71b4` (allocation context) retain +legacy values. Duration downgrade refuses fractional data; allocation downgrade +removes the new columns and requires an export/backup. + +Use the existing lockfile and pinned pnpm version. Schema/types are generated +with the project's tooling. Validation-only tools need not become application +dependencies. Repository-wide pre-existing TypeScript debt is outside this +feature change. diff --git a/frontend/app/components/Domain/Recipe/RecipeIngredientHtml.vue b/frontend/app/components/Domain/Recipe/RecipeIngredientHtml.vue index e89c08240..6c5d7f24d 100644 --- a/frontend/app/components/Domain/Recipe/RecipeIngredientHtml.vue +++ b/frontend/app/components/Domain/Recipe/RecipeIngredientHtml.vue @@ -17,14 +17,15 @@ import { useIngredientTextParser } from "~/composables/recipes"; interface Props { ingredient?: RecipeIngredient; scale?: number; + showZero?: boolean; } -const { ingredient, scale = 1 } = defineProps(); +const { ingredient, scale = 1, showZero = false } = defineProps(); const { useParsedIngredientText } = useIngredientTextParser(); const baseText = computed(() => { if (!ingredient) return ""; - const parsed = useParsedIngredientText(ingredient, scale); + const parsed = useParsedIngredientText(ingredient, scale, true, undefined, showZero); return [parsed.quantity, parsed.unit, parsed.name].filter(Boolean).join(" ").trim(); }); diff --git a/frontend/app/components/Domain/Recipe/RecipeIngredientListItem.vue b/frontend/app/components/Domain/Recipe/RecipeIngredientListItem.vue index f5773e053..76296b62e 100644 --- a/frontend/app/components/Domain/Recipe/RecipeIngredientListItem.vue +++ b/frontend/app/components/Domain/Recipe/RecipeIngredientListItem.vue @@ -45,10 +45,12 @@ interface Props { // off by default: the shopping list and the add-to-list dialog reuse this row, and a menu // button is noise in both. the recipe renderer opts in showSubstitutions?: boolean; + showZero?: boolean; } const props = withDefaults(defineProps(), { scale: 1, showSubstitutions: false, + showZero: false, }); const route = useRoute(); const auth = useMealieAuth(); @@ -56,7 +58,7 @@ const groupSlug = computed(() => route.params.groupSlug || auth.user?.value?.gro const { useParsedIngredientText } = useIngredientTextParser(); const parsedIng = computed(() => { - return useParsedIngredientText(props.ingredient, props.scale, true, groupSlug.value.toString()); + return useParsedIngredientText(props.ingredient, props.scale, true, groupSlug.value.toString(), props.showZero); }); diff --git a/frontend/app/components/Domain/Recipe/RecipeIngredients.test.ts b/frontend/app/components/Domain/Recipe/RecipeIngredients.test.ts index af9f734b4..0802e3299 100644 --- a/frontend/app/components/Domain/Recipe/RecipeIngredients.test.ts +++ b/frontend/app/components/Domain/Recipe/RecipeIngredients.test.ts @@ -98,4 +98,17 @@ describe("RecipeIngredients", () => { const labels = wrapper.findAll("input[type='checkbox']").map(input => input.attributes("aria-label")); expect(labels).toEqual(["2 cups flour", "salt to taste"]); }); + + test("tracks separate portions independently while keeping legacy references shared", async () => { + const first = mountIngredients([ingredients.curryPaste]); + await first.setProps({ portionKey: "step-a", portionReferenceIds: [ingredients.curryPaste.referenceId] }); + await first.find(".checkbox").trigger("click"); + const second = mountIngredients([ingredients.curryPaste]); + await second.setProps({ portionKey: "step-b", portionReferenceIds: [ingredients.curryPaste.referenceId] }); + expect(second.find(".checkbox").attributes("aria-pressed")).toBe("false"); + first.unmount(); + const restored = mountIngredients([ingredients.curryPaste]); + await restored.setProps({ portionKey: "step-a", portionReferenceIds: [ingredients.curryPaste.referenceId] }); + expect(restored.find(".checkbox").attributes("aria-pressed")).toBe("true"); + }); }); diff --git a/frontend/app/components/Domain/Recipe/RecipeIngredients.vue b/frontend/app/components/Domain/Recipe/RecipeIngredients.vue index 2f7328ca5..4d08cd214 100644 --- a/frontend/app/components/Domain/Recipe/RecipeIngredients.vue +++ b/frontend/app/components/Domain/Recipe/RecipeIngredients.vue @@ -32,7 +32,7 @@