feat: pantry notes/categories, ingredient-alias matching, cook-log edit/delete, fork-list popover (v0.83.0)

Pantry: notes + category fields (collapsible grouping like the shopping list), a "Merge duplicates" cleanup action, and fixed quantity display precision (was showing raw decimal(10,4) strings like "0.3333 kg" everywhere — pantry, shopping list, print views, Markdown exports).

Ingredient-alias matching: the ingredients table (canonical name + aliases) existed but was never populated or used. Seeded ~10 bilingual EN/FR staples and wired resolution into pantry add/edit, can-cook scoring, auto-deduct-on-cook, and shopping-list pantry-awareness, so "sel"/"sel fin"/"table salt" are recognized as the same ingredient.

Cook log: entries from "Mark cooked" can now be edited and deleted (previously log-only, no fix-a-mistake path). The "Cooked N times" text is a hover tooltip listing every date and opens a full manage sheet on click.

Also: the "Forked by N others" backlink is now a click-to-open popover instead of an always-inline list.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Arnaud
2026-07-24 15:13:33 +02:00
parent a488b544dc
commit 93936eae10
37 changed files with 7255 additions and 117 deletions
+13 -6
View File
@@ -1,3 +1,5 @@
import { resolveIngredientKey, type IngredientAliasIndex } from "./ingredient-match";
export const EXPIRING_WITHIN_DAYS = 3;
export function isExpiringSoon(expiresAt: Date | null): boolean {
@@ -10,23 +12,28 @@ type ScorableRecipe<T> = T & { ingredients: { rawName: string }[] };
export function scoreRecipesAgainstPantry<T>(
recipesList: ScorableRecipe<T>[],
pantry: { rawName: string; expiresAt: Date | null }[]
pantry: { rawName: string; expiresAt: Date | null }[],
aliasIndex?: IngredientAliasIndex
) {
const pantryKeys = new Set(pantry.map((p) => p.rawName.toLowerCase()));
// With no alias index, this resolves to a plain lowercase compare —
// same behavior as before aliases existed.
const keyOf = (name: string) => (aliasIndex ? resolveIngredientKey(name, aliasIndex) : name.trim().toLowerCase());
const pantryKeys = new Set(pantry.map((p) => keyOf(p.rawName)));
const expiringSoonKeys = new Set(
pantry.filter((p) => isExpiringSoon(p.expiresAt)).map((p) => p.rawName.toLowerCase())
pantry.filter((p) => isExpiringSoon(p.expiresAt)).map((p) => keyOf(p.rawName))
);
return recipesList
.filter((r) => r.ingredients.length > 0)
.map((recipe) => {
const matched = recipe.ingredients.filter((ing) => pantryKeys.has(ing.rawName.toLowerCase())).length;
const matched = recipe.ingredients.filter((ing) => pantryKeys.has(keyOf(ing.rawName))).length;
const missing = recipe.ingredients
.filter((ing) => !pantryKeys.has(ing.rawName.toLowerCase()))
.filter((ing) => !pantryKeys.has(keyOf(ing.rawName)))
.map((ing) => ing.rawName)
.slice(0, 5);
const usesExpiring = recipe.ingredients
.filter((ing) => expiringSoonKeys.has(ing.rawName.toLowerCase()))
.filter((ing) => expiringSoonKeys.has(keyOf(ing.rawName)))
.map((ing) => ing.rawName);
const total = recipe.ingredients.length;
return { recipe, matched, total, pct: Math.round((matched / total) * 100), missing, usesExpiring };