feat: batch-cook shopping list (already worked) + leftover expiry reminders
Shopping list add already worked generically for batch-cook recipes — no code needed there. New: mark a specific batch-cook dish as "cooked today", track its fridge expiry (cookingHistory.batchDishId), surface a "Leftovers expiring soon" widget on the pantry page, and send a daily push+email reminder via a new /api/internal/cron/leftover-reminders endpoint (mirrors the weekly-digest cron pattern; doesn't use the social notifications table, which requires a non-null actor and isn't built for self-reminders). Also fixes, from user-reported bugs: - Recipe cards showed no batch-cook badge/dish-count/prep-time in some views — added dishCount + prepMins/cookMins (now generated by the AI and persisted) to the card component and /recipes query. - Batch-cook descriptions occasionally contained raw markdown (**bold**) — added explicit "plain prose only" prompt instructions and a stripMarkdown() defensive fallback at render time. - Truncated/cut-off descriptions — the generateObject call had no maxOutputTokens set, so long structured responses could get cut off mid-field; now capped explicitly at 8000. - Generate dialogs (batch-cook + the main AI dialog) could show buttons unreachable once the progress bar appeared mid-generation — restructured so the action row is pinned outside the scrollable content area, not affected by content height changes. - /api/internal/* routes were being redirected to /login by middleware before their own CRON_SECRET check ever ran (pre-existing bug, affected the weekly-digest cron too) — added to PUBLIC_PATHS. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,14 +4,16 @@ import { resolveModel, type AiConfig } from "../factory";
|
||||
|
||||
const BatchCookSchema = z.object({
|
||||
title: z.string().max(150),
|
||||
description: z.string().max(300),
|
||||
description: z.string().max(300).describe("Plain prose only — no markdown formatting (no **bold**, no bullet points, no headers)."),
|
||||
prepMins: z.number().int().min(0).max(300).describe("Total hands-on prep time for the whole session, in minutes."),
|
||||
cookMins: z.number().int().min(0).max(300).describe("Total passive cook/bake/simmer time for the whole session, in minutes."),
|
||||
dishes: z.array(z.object({
|
||||
name: z.string().max(100),
|
||||
description: z.string().max(200),
|
||||
description: z.string().max(200).describe("Plain prose only — no markdown formatting."),
|
||||
fridgeDays: z.number().int().min(1).max(7),
|
||||
freezerFriendly: z.boolean(),
|
||||
freezerNote: z.string().max(150).optional(),
|
||||
dayOfInstructions: z.string().max(300),
|
||||
dayOfInstructions: z.string().max(300).describe("Plain prose only — no markdown formatting."),
|
||||
})).min(1).max(6),
|
||||
ingredients: z.array(z.object({
|
||||
rawName: z.string().describe("Ingredient name only — never include the quantity or unit here."),
|
||||
@@ -72,7 +74,11 @@ Dishes must be genuinely distinct — different techniques and flavor profiles (
|
||||
|
||||
Every dish needs: fridgeDays, freezerFriendly, and a freezerNote if applicable (duration + thawing tip). dayOfInstructions must name the exact reheat method and time, AND a concrete fresh finishing touch (stir in cream, cook fresh grain, add a fresh side, sear a protein, grate cheese) — never generic ("reheat and enjoy" is unacceptable).
|
||||
|
||||
For ingredients: quantity is a number only, unit is a separate string. Never combine them. Respond in ${lang}.`;
|
||||
For ingredients: quantity is a number only, unit is a separate string. Never combine them.
|
||||
|
||||
Estimate prepMins (total hands-on active work across the whole session) and cookMins (total passive oven/stovetop/simmer time) for the whole session, in minutes.
|
||||
|
||||
Write every description and instruction as plain prose — never use markdown formatting (no **bold**, no bullet lists, no headers, no asterisks). Keep every field within its stated length limit; a shorter, complete sentence is always better than a longer one that gets cut off. Respond in ${lang}.`;
|
||||
|
||||
const systemPromptWithContext = systemPrompt + (config?.userContext ? `\n\nUser preferences and context:\n${config.userContext}` : "");
|
||||
|
||||
@@ -80,6 +86,7 @@ For ingredients: quantity is a number only, unit is a separate string. Never com
|
||||
model,
|
||||
schema: BatchCookSchema,
|
||||
system: systemPromptWithContext,
|
||||
maxOutputTokens: 8000,
|
||||
prompt: [
|
||||
`Generate a batch-cooking session covering ${mealParts.join(" and ") || `${totalDishes} meals`}.`,
|
||||
`Design exactly ${totalDishes} distinct dishes, each for ${servings} servings.`,
|
||||
|
||||
Reference in New Issue
Block a user