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
+6 -2
View File
@@ -11,6 +11,7 @@ import { scoreRecipesAgainstPantry } from "@/lib/pantry-match";
import { dishExpiresAt, daysUntil, isLeftoverExpiringSoon } from "@/lib/leftover-match";
import { getPublicUrl } from "@/lib/storage";
import { getFeatureFlagMatrix, isFeatureAvailableAnyTier, type Tier } from "@/lib/feature-flags";
import { loadIngredientAliasIndex } from "@/lib/ingredient-match";
export const metadata: Metadata = {};
@@ -22,7 +23,7 @@ export default async function PantryPage() {
const markdownExportLocked = !featureFlags.markdown_export[viewerTier];
const markdownExportAvailable = isFeatureAvailableAnyTier(featureFlags, "markdown_export");
const [items, candidateRecipes, cookedDishes] = await Promise.all([
const [items, candidateRecipes, cookedDishes, aliasIndex] = await Promise.all([
db.query.pantryItems.findMany({
where: eq(pantryItems.userId, session.user.id),
orderBy: asc(pantryItems.rawName),
@@ -38,6 +39,7 @@ export default async function PantryPage() {
recipe: { columns: { id: true, title: true } },
},
}),
loadIngredientAliasIndex(),
]);
const mappedItems = items.map((i) => ({
@@ -45,10 +47,12 @@ export default async function PantryPage() {
rawName: i.rawName,
quantity: i.quantity,
unit: i.unit,
notes: i.notes,
aisle: i.aisle,
expiresAt: i.expiresAt?.toISOString() ?? null,
}));
const suggestions = scoreRecipesAgainstPantry(candidateRecipes, items)
const suggestions = scoreRecipesAgainstPantry(candidateRecipes, items, aliasIndex)
.filter((s) => s.usesExpiring.length > 0)
.slice(0, 3)
.map((s) => {
+13 -23
View File
@@ -14,6 +14,7 @@ import { PrintButton } from "@/components/recipe/print-button";
import { ShareRecipeButton } from "@/components/recipe/share-recipe-button";
import { SaveOfflineButton } from "@/components/recipe/save-offline-button";
import { VersionHistoryButton } from "@/components/recipe/version-history-button";
import { ForkedByPopover } from "@/components/recipe/forked-by-popover";
import { DeleteRecipeButton } from "@/components/recipe/delete-recipe-button";
import { ForkRecipeButton } from "@/components/recipe/fork-recipe-button";
import { NutritionPanel } from "@/components/recipe/nutrition-panel";
@@ -109,7 +110,7 @@ export default async function RecipePage({ params }: Params) {
db.query.cookingHistory.findMany({
where: and(eq(cookingHistory.recipeId, id), eq(cookingHistory.userId, session.user.id)),
orderBy: desc(cookingHistory.cookedAt),
columns: { batchDishId: true, cookedAt: true },
columns: { id: true, batchDishId: true, cookedAt: true, servings: true, notes: true },
}),
getFeatureFlagMatrix(),
getFeaturePrefs(session.user.id),
@@ -156,9 +157,9 @@ export default async function RecipePage({ params }: Params) {
// Non-batch cook log — batch-cook recipes track this per-dish instead
// (dishCookedAtMap above), logged via BatchCookDishes, not this list.
const plainCookLog = dishCookLog.filter((l) => !l.batchDishId);
const cookCount = plainCookLog.length;
const lastCookedAt = plainCookLog[0]?.cookedAt.toISOString() ?? null;
const plainCookLog = dishCookLog
.filter((l) => !l.batchDishId)
.map((l) => ({ id: l.id, cookedAt: l.cookedAt.toISOString(), servings: l.servings, notes: l.notes }));
const avgScore = ratingData[0]?.avgScore ? parseFloat(ratingData[0].avgScore) : null;
const ratingCount = ratingData[0]?.total ?? 0;
@@ -209,24 +210,14 @@ export default async function RecipePage({ params }: Params) {
</Link>
)}
{visibleForks.length > 0 && (
<div className="text-sm text-muted-foreground">
<p>
{visibleForks.length === 1
<ForkedByPopover
label={
visibleForks.length === 1
? m.recipe.forkedByCountSingular
: formatMessage(m.recipe.forkedByCountPlural, { count: visibleForks.length })}
</p>
<div className="flex flex-wrap gap-x-3 gap-y-1 mt-1">
{visibleForks.map((f) => (
<Link
key={f.child.id}
href={`/recipes/${f.child.id}`}
className="hover:text-foreground underline-offset-2 hover:underline"
>
{f.child.title}
</Link>
))}
</div>
</div>
: formatMessage(m.recipe.forkedByCountPlural, { count: visibleForks.length })
}
forks={visibleForks.map((f) => ({ id: f.child.id, title: f.child.title }))}
/>
)}
<TooltipProvider>
<div className="flex items-center gap-2 overflow-x-auto pb-0.5 [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden">
@@ -563,8 +554,7 @@ export default async function RecipePage({ params }: Params) {
<MarkCookedSection
recipeId={id}
baseServings={recipe.baseServings}
cookCount={cookCount}
lastCookedAt={lastCookedAt}
initialLogs={plainCookLog}
/>
</>
)}
+4 -2
View File
@@ -6,6 +6,7 @@ import { eq } from "@epicure/db";
import { getPublicUrl } from "@/lib/storage";
import { CanCookContent } from "@/components/recipe/can-cook-content";
import { scoreRecipesAgainstPantry } from "@/lib/pantry-match";
import { loadIngredientAliasIndex } from "@/lib/ingredient-match";
export const metadata: Metadata = {};
@@ -13,7 +14,7 @@ export default async function CanCookPage() {
const session = await auth.api.getSession({ headers: await headers() });
if (!session) return null;
const [userRecipes, pantry] = await Promise.all([
const [userRecipes, pantry, aliasIndex] = await Promise.all([
db.query.recipes.findMany({
where: eq(recipes.authorId, session.user.id),
with: {
@@ -24,9 +25,10 @@ export default async function CanCookPage() {
db.query.pantryItems.findMany({
where: eq(pantryItems.userId, session.user.id),
}),
loadIngredientAliasIndex(),
]);
const scored = scoreRecipesAgainstPantry(userRecipes, pantry).map((s) => {
const scored = scoreRecipesAgainstPantry(userRecipes, pantry, aliasIndex).map((s) => {
const cover = s.recipe.photos?.find((p) => p.isCover) ?? s.recipe.photos?.[0];
return {
...s,