From 951d9ca6e70da8c0cea3cac15dc4c90eed7d5973 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20B=C3=B6hm?= Date: Sat, 7 Nov 2026 10:14:37 +0000 Subject: [PATCH] Add "my dish": one guaranteed, veto-proof dish per person and round (26.11.30) Against sibling dynamics: everyone who eats along can make one own wish per round their dish. No veto removes it and the suggestion puts these first; with too few slots, whoever went without last round comes first. The same own dish that made it into the plan cannot be chosen in the next round. A veto against a protected dish is refused, and one that becomes protected later no longer counts. Children and teens see vetoes without names. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HUc2nv7rJVU2gp3Bgtha3q --- CLAUDE.md | 15 ++++- OlaresManifest.yaml | 4 +- app/(app)/page.tsx | 4 +- app/(app)/wuenschen/page.tsx | 4 +- app/api/wishes/mine/route.ts | 22 +++++++ components/plan/plan-board.tsx | 2 +- components/wishes/wish-board.tsx | 67 ++++++++++++++++++-- db/migrations/0019_my_dish.sql | 9 +++ docs/entscheidungen.md | 18 ++++++ e2e/kinder.spec.ts | 19 +++++- e2e/plan.spec.ts | 4 +- lib/plan.ts | 4 +- lib/suggest.ts | 28 +++++++-- lib/wishes.ts | 64 +++++++++++++++++-- messages/de.json | 22 +++++-- messages/en.json | 22 +++++-- messages/es.json | 22 +++++-- messages/fr.json | 22 +++++-- olares/Chart.yaml | 4 +- olares/OlaresManifest.yaml | 4 +- olares/markt/26.11.30.md | 5 ++ tests/my-dish.test.ts | 104 +++++++++++++++++++++++++++++++ tests/suggest.test.ts | 32 ++++++++++ 23 files changed, 454 insertions(+), 47 deletions(-) create mode 100644 app/api/wishes/mine/route.ts create mode 100644 db/migrations/0019_my_dish.sql create mode 100644 olares/markt/26.11.30.md create mode 100644 tests/my-dish.test.ts diff --git a/CLAUDE.md b/CLAUDE.md index 0c59fcf..dcb8984 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -7,7 +7,7 @@ > **Plattform:** Olares One (Kubernetes), Repo und CI auf Gitea — kein Supabase, > kein Vercel (E-0001). Eigene Gestaltung, nicht AImighty (E-0002). > Verteilung über den Markt, Repo öffentlich (E-0005). -> **Status:** 26.11.29 — alle neun Arbeitspakete aus `docs/PROJEKTSTART.md` sind gebaut: +> **Status:** 26.11.30 — alle neun Arbeitspakete aus `docs/PROJEKTSTART.md` sind gebaut: > Anmeldung (Passkeys, Kinder mit Gerät + PIN), Gerichte (Link, Kochbuchfoto, AI über den > Olares Router), Wünschen, Plan, Einkaufsliste (Echtzeit, offline), Kochmodus mit > Bewertung, Web-App; Einzahl bei Stück-Mengen (26.11.15), Preise und Kosten mit Ampel @@ -16,7 +16,7 @@ > Produkte je Gericht (26.11.21), Veto mit Gegenvorschlag (26.11.22), > bis zu 5 Fotos je Gericht (26.11.23), Gerichte einsprechen (26.11.24), Kassenbons (V2b, 26.11.25), > Führung (26.11.27), Präsentationsmodus und Küchendisplay (26.11.28), -> lange Bons und Aldi (26.11.29). Offen ist der +> lange Bons und Aldi (26.11.29), „Mein Gericht“ (26.11.30). Offen ist der > Magic Link (braucht SMTP). > **Letzte Aktualisierung:** 7. November 2026 @@ -404,6 +404,17 @@ Vorlagen ersetzt. `tests/seed.test.ts` prüft die Dateien. Ein Haushalt übersprungen, ausgeblendet, „Fertig“ gesehen) und `members.seen_intro` (Migration 0017). - Tests auf „Heute“ greifen Inhaltskarten über `main article h2`, nicht die erste h2. +## Mein Gericht (seit 26.11.30, Kai und Mike, E-0012) + +- `wishes.is_mine` (Migration 0019, eins je Person und Runde, nie an einem Veto oder + Gegenvorschlag). `setMine` in `lib/wishes.ts`: nur ein eigener Wunsch; nicht dasselbe + wie in der Vorrunde, wenn es dort in den Plan kam (`lastMine`, Fehler `repeat`). +- Kein Veto dagegen (`protected`); ein Veto, das nachträglich ein eigenes Gericht trifft, + zählt nicht mehr im Budget. `suggest` setzt eigene Gerichte zuerst (Grund `mine`), + bei zu wenig Slots zuerst, wer in der Vorrunde leer ausging (`owed`). +- `roundWishes(c, round, viewer)`: Für Kinder und Jugendliche kommt ein fremdes Veto + ohne Namen an — wer ein Veto eingelegt hat, sehen nur `admin` und `member`. + ## Präsentation und Küchendisplay (seit 26.11.28) - `/praesentieren/[id]` (außerhalb von `(app)`, ohne Leiste): jedes Rezept groß, hochkant diff --git a/OlaresManifest.yaml b/OlaresManifest.yaml index 601d6aa..5fbc8b0 100644 --- a/OlaresManifest.yaml +++ b/OlaresManifest.yaml @@ -21,7 +21,7 @@ metadata: title: What's cooking? description: The family decides together what's for dinner — and the shopping list writes itself. Runs entirely on your own box. icon: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png - version: 26.11.29 + version: 26.11.30 categories: - Applications @@ -61,7 +61,7 @@ permission: appData: true spec: - versionName: '26.11.29' + versionName: '26.11.30' featuredImage: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png promoteImage: diff --git a/app/(app)/page.tsx b/app/(app)/page.tsx index d45e3e5..e9136cc 100644 --- a/app/(app)/page.tsx +++ b/app/(app)/page.tsx @@ -37,7 +37,7 @@ export default async function TodayPage() { const round = await currentRound(c); if (round && round.status !== "open") return { round, slots: await planSlots(c, round.id) }; if (!round) return { round }; - const entries = await roundWishes(c, round.id); + const entries = await roundWishes(c, round.id, { memberId: session.memberId, adult: can(PLANNERS, session.role) }); const titles = new Map( (await c.query("select id, title from dishes where id = any($1)", [[...new Set(entries.map((e) => e.dishId))]])).rows.map((r) => [r.id, r.title]), ); @@ -163,6 +163,7 @@ async function FamilyWishes({ const wishes = entries.filter((e) => !e.isVeto); if (!wishes.length) return

{t("noWishesYet")}

; const fav = favorites(entries); + const mine = new Set(entries.filter((e) => e.isMine).map((e) => e.dishId)); const byDish = new Map(); for (const e of wishes) byDish.set(e.dishId, [...(byDish.get(e.dishId) ?? []), e.memberId === me ? t("you") : e.memberName]); const rows = [...byDish].sort(([a, x], [b, y]) => y.length - x.length || (titles.get(a) ?? "").localeCompare(titles.get(b) ?? "")); @@ -174,6 +175,7 @@ async function FamilyWishes({
  • {fav.has(dishId) ? : null} + {mine.has(dishId) ? : null} {titles.get(dishId)} {names.join(", ")} diff --git a/app/(app)/wuenschen/page.tsx b/app/(app)/wuenschen/page.tsx index 0823a2e..bd5b916 100644 --- a/app/(app)/wuenschen/page.tsx +++ b/app/(app)/wuenschen/page.tsx @@ -13,12 +13,12 @@ export const dynamic = "force-dynamic"; export default async function WishPage() { const session = await requireSession(); const t = await getTranslations("wish"); + const adult = session.role === "admin" || session.role === "member"; const data = await withHousehold(session.householdId, async (c) => { const round = await currentRound(c); if (!round || round.status !== "open") return { round }; - return { round, tiles: await wishTiles(c), entries: await roundWishes(c, round.id), budget: await budget(c, round.id, session.memberId) }; + return { round, tiles: await wishTiles(c), entries: await roundWishes(c, round.id, { memberId: session.memberId, adult }), budget: await budget(c, round.id, session.memberId) }; }); - const adult = session.role === "admin" || session.role === "member"; return (
    diff --git a/app/api/wishes/mine/route.ts b/app/api/wishes/mine/route.ts new file mode 100644 index 0000000..18a5218 --- /dev/null +++ b/app/api/wishes/mine/route.ts @@ -0,0 +1,22 @@ +import { z } from "zod"; +import { guardWrite, isResponse } from "@/lib/auth/guard"; +import { fail, json, readJson } from "@/lib/auth/http"; +import { withHousehold } from "@/lib/db"; +import { setMine, WISHERS, WishRefused } from "@/lib/wishes"; + +export const dynamic = "force-dynamic"; + +// „Mein Gericht“ setzen oder zurücknehmen — jede Person, die mitisst, für sich selbst. +export async function POST(request: Request) { + const session = await guardWrite(request, [...WISHERS]); + if (isResponse(session)) return session; + const body = z.object({ dishId: z.string().uuid(), mine: z.boolean() }).safeParse(await readJson(request)); + if (!body.success) return fail("invalid", 400); + try { + await withHousehold(session.householdId, (c) => setMine(c, session.memberId, body.data.dishId, body.data.mine)); + return json({ ok: true }); + } catch (error) { + if (error instanceof WishRefused) return fail(error.reason, 409); + throw error; + } +} diff --git a/components/plan/plan-board.tsx b/components/plan/plan-board.tsx index 1f9c8a8..9dd9151 100644 --- a/components/plan/plan-board.tsx +++ b/components/plan/plan-board.tsx @@ -122,7 +122,7 @@ export function PlanBoard({ const reasonText = (r: Reason | null) => { if (!r) return null; - return r.k === "wish" ? t("reason.wish", { names: r.n.join(", ") }) : t(`reason.${r.k}`); + return r.k === "wish" || r.k === "mine" ? t(`reason.${r.k}`, { names: r.n.join(", ") }) : t(`reason.${r.k}`); }; return ( diff --git a/components/wishes/wish-board.tsx b/components/wishes/wish-board.tsx index b987287..3a1081b 100644 --- a/components/wishes/wish-board.tsx +++ b/components/wishes/wish-board.tsx @@ -1,6 +1,6 @@ "use client"; -import { Check, Crown, Ellipsis, Shuffle, ThumbsDown } from "lucide-react"; +import { Check, Crown, Ellipsis, Heart, ShieldCheck, Shuffle, ThumbsDown } from "lucide-react"; import { useRouter } from "next/navigation"; import { useTranslations } from "next-intl"; import { useMemo, useRef, useState } from "react"; @@ -29,6 +29,7 @@ export type Entry = { wantsToCook: boolean; isVeto: boolean; viaVeto?: boolean; + isMine?: boolean; }; type Budget = { tokens: number; tokensLeft: number; vetos: number; vetosLeft: number }; @@ -54,7 +55,9 @@ function applyFilter(tiles: Tile[], filter: Filter): Tile[] { } // Wünschen (Konzept, „Wünschen“): ein Tipp auf die Kachel ist der Wunsch; „…“ -// öffnet Grund, „Ich koche das“ und das Veto. Gezählt wird auf dem Server. +// öffnet Grund, „Ich koche das“, „Mein Gericht“ und das Veto. Gezählt wird auf +// dem Server. Wer ein Veto eingelegt hat, steht nur bei Erwachsenen da — für +// Kinder und Jugendliche kommt der Name leer an (lib/wishes.ts, roundWishes). export function WishBoard({ tiles, entries, @@ -85,6 +88,10 @@ export function WishBoard({ const mine = (id: string) => byDish.get(id)?.find((e) => e.memberId === me); const wishers = (id: string) => (byDish.get(id) ?? []).filter((e) => !e.isVeto); const vetoes = (id: string) => (byDish.get(id) ?? []).filter((e) => e.isVeto); + const mineOf = (id: string) => (byDish.get(id) ?? []).filter((e) => e.isMine); + const myDish = entries.find((e) => e.memberId === me && e.isMine); + const myDishTitle = myDish ? tiles.find((x) => x.id === myDish.dishId)?.title : null; + const wishedSomething = entries.some((e) => e.memberId === me && !e.isVeto); const shown = applyFilter(tiles, filter); async function call(method: string, url: string, body?: object, key = "x") { @@ -95,7 +102,7 @@ export function WishBoard({ const data = await res.json().catch(() => ({})); setBusy(null); if (!res.ok) { - setError(["noTokens", "noVetos", "noRound", "noTrial", "dish", "alternative"].includes(data.error) ? data.error : "unknown"); + setError(["noTokens", "noVetos", "noRound", "noTrial", "dish", "alternative", "protected", "repeat", "notWished"].includes(data.error) ? data.error : "unknown"); return null; } if (method === "POST" && "vibrate" in navigator) navigator.vibrate?.(15); @@ -148,6 +155,18 @@ export function WishBoard({ ))} + {myDishTitle ? ( +

    + + {t("mineChosen", { title: myDishTitle })} +

    + ) : wishedSomething ? ( +

    + + {t("mineHint")} +

    + ) : null} + {error ? {t(`errors.${error}`)} : null} {message ? (

    @@ -160,7 +179,10 @@ export function WishBoard({ {shown.map((tile) => { const own = mine(tile.id); const names = wishers(tile.id).map((e) => (e.memberId === me ? t("you") : e.memberName)); - const vetoNames = vetoes(tile.id).map((e) => (e.memberId === me ? t("you") : e.memberName)); + const vetoList = vetoes(tile.id); + const vetoNames = vetoList.map((e) => (e.memberId === me ? t("you") : e.memberName)); + const mineNames = mineOf(tile.id).map((e) => (e.memberId === me ? t("you") : e.memberName)); + const isMyDish = mineOf(tile.id).some((e) => e.memberId === me); const favorite = wishers(tile.id).length >= 2; return (

  • @@ -182,6 +204,12 @@ export function WishBoard({ ) : null} + {mineNames.length ? ( + + + {isMyDish ? t("mine") : t("mineOf", { names: mineNames.filter((n) => n !== t("you")).join(", ") })} + + ) : null} {favorite ? ( @@ -192,11 +220,12 @@ export function WishBoard({ {tile.title} {favorite ? {t("favorite")} : null} + {mineNames.length ? {isMyDish ? t("mine") : t("mineOf", { names: mineNames.join(", ") })} : null} {names.length ? {t("wishedBy", { names: names.join(", ") })} : null} - {vetoNames.length ? ( + {vetoList.length && !mineNames.length ? ( - {t("vetoBy", { names: vetoNames.join(", ") })} + {vetoNames.every(Boolean) ? t("vetoBy", { names: vetoNames.join(", ") }) : t("vetoCount", { n: vetoList.length })} ) : null} @@ -232,6 +261,12 @@ export function WishBoard({ own={mine(open.id)} budget={budget} canVeto={canVeto} + protectedDish={mineOf(open.id).length > 0} + mine={mineOf(open.id).some((e) => e.memberId === me)} + onMine={async (on) => { + const ok = await call("POST", "/api/wishes/mine", { dishId: open.id, mine: on }, open.id); + if (ok) dialog.current?.close(); + }} alternatives={tiles.filter((x) => !x.isTrial && x.id !== open.id && !(byDish.get(x.id) ?? []).length)} busy={!!busy} onCall={async (method, body) => { @@ -251,6 +286,9 @@ function WishOptions({ own, budget, canVeto, + protectedDish, + mine, + onMine, alternatives, busy, onCall, @@ -260,6 +298,9 @@ function WishOptions({ own: Entry | undefined; budget: Budget; canVeto: boolean; + protectedDish: boolean; + mine: boolean; + onMine: (on: boolean) => Promise; alternatives: Tile[]; busy: boolean; onCall: (method: string, body: object) => Promise; @@ -338,10 +379,24 @@ function WishOptions({ {wished ? t("saveWish") : t("wishWithToken")} {wished && own?.viaVeto ?

    {t("viaVetoHint")}

    : null} + {wished && !own?.viaVeto ? ( +
    + +

    {t("mineExplain")}

    +
    + ) : null} {wished ? ( + ) : protectedDish ? ( +

    + + {t("protected")} +

    ) : canVeto && budget.vetos > 0 ? (