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 @@