User report 2026-06-05: 'webui Meal Planner page is empty' on Friday
morning after the Friday email went out. Root cause: the orchestrator
keyed plans by the most-recent-Friday while the frontend's isoMonday()
returned the most-recent-Monday — a 7-day mismatch on Fridays.
Fixes (one semantic across the stack):
- runner._current_week_start() returns the upcoming Monday (today if
Mon, else the next Mon). The Friday email subject
('Meal plan for week of <date>') automatically picks up the new
value via run.week_start_date.
- frontend isoMonday -> upcomingMonday (same logic; renamed for
intent). isoMonday kept as a deprecated alias.
- New WeekRangeNav component (Dashboard + ShoppingList share it).
Renders [<] Jun 8 - Jun 14 [>] with clickable chevrons and a
clickable range label that jumps to the upcoming week. Replaces
the Sprint 5 inline segmented control on both pages.
- New formatWeekRange(mondayIso) helper (UTC-stable; uses
timeZone: 'UTC' so the rendered date matches the stored ISO date
regardless of viewer TZ; closes a latent bug in formatIsoDate too).
- New SQL fix script that retargets the user's 3-pending-items plan
from 2026-06-05 (Friday-keyed) to 2026-06-08 (upcoming Monday).
Idempotent + transaction-wrapped. Optional block for 2026-05-29.
No backend migration. No new dependencies. Deploy is git pull +
run the SQL fix + docker compose up -d --build backend frontend.
See Review/sprint7-verification.md for the full deploy + smoke flow.
Files:
- backend/app/services/orchestrator/runner.py:20-35
- backend/scripts/fix_2026_06_05_to_2026_06_08.sql (new)
- frontend/src/lib/utils.ts:43-130
- frontend/src/components/WeekRangeNav.tsx (new)
- frontend/src/pages/Dashboard.tsx (3 call sites + 1 segmented control)
- frontend/src/pages/ShoppingList.tsx (5 call sites + 2 segmented controls)
- Review/{sprint7-verification,ui-nielsen-audit,handoff-ui-audit}.md
- fix-ui-audit.md
- docs/HANDOFF.md
- .agent/{plan,context}.md
40 KiB
Fix Plan — UI/UX Audit (Nielsen 10 Heuristics)
Goal
Resolve the 14 issues (5 P0, 6 P1, 3 P2) from Review/ui-nielsen-audit.md in three sprints, ending each sprint with a deployable, demonstrable improvement on http://100.108.208.56:8082/.
Scope boundaries
- In: frontend React/TS fixes in
frontend/src/. Backend one-off data migrations only when required (B8 aisle normalization, B4/Recommended route). - Out: New features (bulk add, keyboard shortcuts, onboarding tour) — those are future work, listed in §Future.
- Reuse:
components/ErrorBoundary.tsxalready exists (verified).components/ui/*(Button, Card, Select, Input, EmptyState, Badge, Skeleton, LoadingSpinner) are the building blocks — use them, don't roll new ones. - Stack confirmed: React 18 + TS + Vite + Tailwind + react-router-dom 6 + @tanstack/react-query + react-hot-toast + @hello-pangea/dnd + lucide-react + framer-motion. No new deps in Sprint 1/2. Sprint 3 may add
react-joyrideonly if approved (defer to §Future).
Conventions
- One commit per task:
fix(ui): <short>/feat(ui): <short>/refactor(frontend): <short>. - Before each commit:
cd frontend && npm run lint && npm run build(thebuildscript runstscfirst — type-checks the project). - After each task, re-screenshot the affected page in the same playwright session and diff against
/tmp/opencode/mp-review/screenshots/. Save new shots in/tmp/opencode/mp-review/screenshots/fix-sprintN/. - All UI text in sentence case. New copy matches existing
lib/toast.tsstyle. - Type updates go in
frontend/src/types/index.ts; do not duplicate shapes inline.
Sprint 1 — Stop the bleeding (P0s)
Goal: Every P0 bug is gone. Each is independently demoable on the live deployment.
S1.1 · B1 — RecipeDetail ingredients: drop .trim() so unit + name don't fuse
- File:
frontend/src/pages/RecipeDetail.tsx:161 - Change: Replace
with
{ing.qty != null && `${ing.qty} ${ing.unit || ''} `.trim()}followed by a literal{ing.qty != null && `${ing.qty}${ing.unit ? ` ${ing.unit}` : ''}`}' 'before{ing.name}. - Verify: Open
/recipes/eae6591f...(Black Bean Tacos). Ingredient row reads2 can Black Beans, Canned(with space). Re-runnpm run build.
S1.2 · B2 — MealDetail ingredients: align field name with backend (qty)
- Files:
frontend/src/types/index.ts,frontend/src/pages/MealDetail.tsx:249-252 - Change:
- In
types/index.tsconfirmMealIngredientshape; align to backendqty/unit. If the type currently hasquantity, rename toqty(single source of truth). - In
MealDetail.tsx:249-252, switch reads toing.qty/ing.unit. Keep the existing null-guard soqty == nullis skipped cleanly.
- In
- Verify: Open
/meals/<any>(e.g./meals/f28...Pork Stir-Fry). Row reads1 lb Pork Chops, Bone-Innotlb Pork Chops.npm run buildclean.
S1.3 · B3 — MealDetail cost: fix $N/A per serving
- File:
frontend/src/pages/MealDetail.tsx:191 - Change:
{item.estimated_cost != null ? `$${item.estimated_cost.toFixed(2)} per serving` : 'No price estimate yet'} - Verify: Reload
/meals/f28.... Price line reads either$X.XX per servingorNo price estimate yet— never$N/A.
S1.4 · B4 — /recommended blank page: add * NotFound + alias
- Files:
frontend/src/App.tsx, newfrontend/src/pages/NotFound.tsx - Change:
- Create
pages/NotFound.tsx— friendly card withAlertTriangleicon, message "We can't find that page.", primary<Button>→/, secondary → back. Reusecomponents/ui/EmptyState.tsxif it fits. - In
App.tsx:- Add
import { Navigate } from 'react-router-dom'. - Insert
<Route path="/recommended" element={<Navigate to="/recipes/recommended" replace />} />. - Append
<Route path="*" element={<NotFound />} />after the existing routes.
- Add
- Add a
// TODO(seo): audit email/share links for/recommendedreferencescomment.
- Create
- Verify:
- Visit
http://100.108.208.56:8082/recommended→ redirects to/recipes/recommended, renders the Recommended page. - Visit
http://100.108.208.56:8082/this-does-not-exist→ renders NotFound. npm run buildclean.
- Visit
S1.5 · B5 — Mobile dashboard: always show empty meal slots
- File:
frontend/src/pages/Dashboard.tsx(lines ~164, ~219) - Change: Audit every
hidden md:flex/hidden md:block/hidden md:inlineinsideDayColumnand the empty-slot JSX. Remove thehiddenclass on the empty-slot CTAs (theEmpty+Generateplaceholder block). For decorative chrome (e.g. day-of-week abbreviations), keephidden md:flexonly if there's a separate mobile-friendly label. - Verify: Re-screenshot at 390 px width. Empty slots are tappable; tapping Generate fires the same query as on desktop.
npm run buildclean.
S1.6 · Sprint 1 verification gate
cd frontend && npm run lint && npm run build→ both 0 errors / 0 warnings.- Re-run playwright walkthrough; capture
screenshots/fix-sprint1/*.pngfor: recipe detail (Black Bean Tacos), meal detail (Pork Stir-Fry),/recommended,/this-does-not-exist, mobile dashboard. - Manual smoke: tap Generate on a mobile viewport, confirm a new meal lands in the slot.
- Done when: All five P0 bugs absent in the re-captured screenshots AND lint/build pass.
Sprint 2 — Trust the data (P1s)
Goal: No more silent data corruption in the UI. Every displayed value is consistent across pages and either present-and-correct or explicitly absent.
Status (2026-06-02): ✅ All six P1s + the bonus S3.3 mobile stat-grid fix are implemented. npm run build green. Ready to commit and deploy.
S2.1 · B6 — Dashboard MealCard title: 2-line clamp instead of 1-line truncate
- File:
frontend/src/pages/Dashboard.tsx:87 - Change: Replaced
truncatewithline-clamp-2(already used elsewhere in the codebase — Tailwind 3.4+ has it in core). Image shrinks to 40×40 on<md(was 56×56 always) to give the title more room. Addedleading-tightto tighten line-height for 2 lines. - Verify: Trigger Generate on the dashboard. New card title is fully visible across 2 lines (no
B..truncation). Build clean.
S2.2 · B7 — MealDetail hero overlap + description clamp + marketing-copy strip
- Files:
frontend/src/pages/MealDetail.tsx:168-197,frontend/src/lib/utils.ts - Change (3 sub-steps, one commit):
- Hero reworked: image is in normal flow, content panel uses
relative -mt-16 sm:-mt-20instead ofabsolute bottom-0. Title is in normal flow with the description below it; the gradient now haspointer-events-noneand goes fromfrom-black/80to prevent overlap obscuring. - Description rendered via
cleanDescription(recipe.description)withline-clamp-2. - Client-side trim helper
cleanDescription(input, maxLen=280)inlib/utils.tswith a list of regex patterns that strip spoonacular marketing boilerplate (Featured In Group…,users who liked this recipe also liked…,For $X.XX per serving, this recipe covers…,It is brought to you by Foodista., etc.) and trims to the last sentence within 280 chars. - Raw
recipe.descriptionmoved to a "Notes from source" disclosure below Instructions (using a state toggle in the page component).
- Hero reworked: image is in normal flow, content panel uses
- Verify: Reload
/meals/<id>. Title readable, description is 1-2 lines, "Featured In Group…" gone, full text in disclosure. Build clean.
S2.3 · B8 — Pantry aisle: free-text → canonical select
- Files:
frontend/src/pages/Pantry.tsx,frontend/src/types/index.ts, backend migration - Frontend change: Replaced aisle
<Input>with<Select>populated fromPANTRY_AISLESintypes/index.ts:Also converted Unit to aexport const PANTRY_AISLES = [ 'Produce', 'Meat & Seafood', 'Dairy & Eggs', 'Pantry', 'Frozen', 'Bakery', 'Beverages', 'Spices', 'Other', ] as const; export type PantryAisle = (typeof PANTRY_AISLES)[number];<Select>with the canonical unit list. Added*to "Ingredient name" label as a required-field marker. - Backend migration (
backend/alembic/versions/0015_normalize_pantry_aisles.py):- Revises
0014. Runs in a single upgrade step. - Creates a
TEMPbackup table for each ofingredient.aisleandgrocery_item.aisle(so a DBA can recover viaSELECT * FROM pg_temp.ingredient_aisle_backupif needed). UPDATEs both columns via a generatedCASE LOWER(COALESCE(aisle,'')) WHEN ... ENDmapping. Mapped variants:canned goods/canned→Pantry,freezer/frozen→Frozen,dairy/eggs/cheese/milk/yogurt→Dairy & Eggs,meat/seafood/fish/chicken/beef/pork/meat_seafood→Meat & Seafood,bakery/bread→Bakery,beverage/beverages/drinks→Beverages,spice/spices/seasoning→Spices,pantry/dry/snack/snacks→Pantry, anything else →Other. NULL stays NULL.- Downgrade: raises
NotImplementedError— operator must restore from a pre-migration snapshot. Documented in migration docstring.
- Revises
- Dry-run SQL helper (
backend/scripts/dry_run_aisle_migration.sql): standalone SQL that counts rows that would change per table, no writes. Run viadocker compose exec -T db psql -U mealplanner -d mealplanner -f /dev/stdin < backend/scripts/dry_run_aisle_migration.sql(no host psql needed; the db runs in a container). - Persistent backup helper (
backend/scripts/persist_aisle_backup.sql): createspublic.ingredient_aisle_backup_0015andpublic.grocery_item_aisle_backup_0015permanent tables. Run BEFORE the migration if you want a recoverable record beyond the migration's session. - Verify (on dev DB):
Add a new item with aisle "pantry" → stored as
# Persistent backup (optional, recommended) docker compose exec -T db psql -U mealplanner -d mealplanner \ -f /dev/stdin < backend/scripts/persist_aisle_backup.sql # Dry-run docker compose exec -T db psql -U mealplanner -d mealplanner \ -f /dev/stdin < backend/scripts/dry_run_aisle_migration.sql # Apply docker compose exec backend alembic upgrade headPantry. Open Pantry list → all rows show sentence-case canonical labels. Frontendnpm run buildclean.
S2.4 · B9 — ShoppingList aisle labels: human-readable map
- File:
frontend/src/pages/ShoppingList.tsx - Change: Added
AISLE_LABELmap covering all backend aisle keys (snake_case and singular variants) at the top of the file, plus a tinyaisleDisplay(key)helper. Section header is now<h3>{aisleDisplay(aisle)}</h3>— unknown keys fall back to the raw key (no silent data loss). Also collapsed the S3.3 mobile stat-card grid into this edit since the file was already open. - Verify: Reload
/shopping-list. Section headers readMeat & Seafood,Produce,Pantry,Dairy & Eggs— nomeat_seafoodliteral. Build clean.
S2.5 · B10 — Mobile pantry table: scroll hint
- File:
frontend/src/pages/Pantry.tsx:236 - Change: Wrapped
overflow-x-autoin arelativecontainer. Addedrole="region" aria-label="Pantry items, scroll horizontally to see all columns". Right-edge gradient overlay (pointer-events-none absolute inset-y-0 right-0 w-8 bg-gradient-to-l from-white to-transparent md:hidden,aria-hidden) hints at overflow on mobile only. - Verify: Screenshot at 390 px. The Expires + Actions columns are reachable via swipe, and a subtle right-edge fade hints at overflow. Build clean.
S2.6 · B11 — Recipes filters: Apply / Reset / active count
- File:
frontend/src/pages/Recipes.tsx - Change:
- Lifted filter state into a single
appliedobject (query-bound) and apendingobject (form-bound). Form fields mutatepending; the query usesapplied. - Added
activeCount = Object.values(applied).filter(Boolean).length. - The Filters button now shows
{activeCount > 0 && <Badge>{activeCount}</Badge>}plusaria-expanded={showFilters}. - Added a Reset and "Apply filters" button at the bottom of the filter panel, separated by a top border. Apply commits
pending → applied; Reset clears both. - The filter panel is now wrapped in a
<div role="region" aria-label="Filters">(Card doesn't forward extra HTML attrs).
- Lifted filter state into a single
- Verify: Open
/recipes, apply 2 filters, collapse panel → button showsFilters (2). Click Reset → all cleared, badge gone. Build clean.
S2.7 · Sprint 2 verification gate
npm run lint && npm run buildpass.- Backend migration run on dev DB; row counts logged to
Review/sprint2-migration-log.md. - Re-screenshot pantry, shopping list, recipes, meal detail, dashboard (new meal card width).
- Done when: All six P1s visually absent in the new screenshots, no regression in Sprint 1 fixes.
Sprint 3 — Polish (P2s + a11y)
Goal: A daily-driver app — no jarring native dialogs, no mobile wrap, no 44 px-target misses, no silent crashes on bad routes.
Status (2026-06-03): ✅ All P2s and a11y sweep items implemented. npm run build green. Ready to commit and deploy.
S3.1 · B12 — Undo-toast replaces confirm() for delete
- Files:
frontend/src/pages/Dashboard.tsx,Pantry.tsx,lib/toast.tsx - Change (committed, ready for deploy):
lib/toast.tsx— renamed from.ts(needed for JSX). NewshowToast.undo(message, onUndo, ms=5000)helper renders a custom toast with an inline "Undo" button that firesonUndoand dismisses the toast. Note:react-hot-toast2.6'sToastOptionsdoesn't exposeonClose/onDismiss, so the helper does NOT run a callback on expiry — the Undo button is the only path to recovery. This is honest UX, equivalent in spirit to aconfirm()declined.- Dashboard
handleDelete(itemId)captures the fullMealPlanItem(day_of_week, meal_type, recipe_id) before the DELETE, thenshowToast.undowhose Undo handler re-firesmeals.generateItem(planId, dayOfWeek, mealType)to refill the slot with a (possibly different) recipe. The plan R4 caveat applies: the exact recipe isn't restored, but the slot is filled. - Pantry
handleRemove(item)is fully reversible. Undo callspantry.add({ingredient_id, quantity, unit})with the original values. Per-row loading state via newremoveIdstate so only the clicked row's button shows the spinner. confirm()deleted in both call sites.
- Verify: Delete a meal → toast appears "Meal deleted" with Undo. Click Undo within 5s → slot refills. Same flow on Pantry: click Remove, click Undo → item returns. Build clean.
- Verify: Delete a meal → toast appears "Meal removed" with Undo. Click Undo within 5s → meal re-appears. Build clean.
S3.2 · B13 — Mobile nav: whitespace-nowrap on link text
- File:
frontend/src/App.tsx:30-33 - Change (committed): Added
whitespace-nowrapto thelinkClasshelper return string; reducedpx-3topx-2 sm:px-3. All 4 links fit on one line down to 360 px. - Verify: Screenshot at 360 px. All 4 links on one line. Build clean.
S3.3 · B14 — Mobile shopping-list stat cards: 3-col compact
- File:
frontend/src/pages/ShoppingList.tsx - Change (committed in Sprint 2): Replaced the 3 stacked full-width tiles with
grid grid-cols-3 gap-2 sm:gap-4. CardBody padding reduces top-3 sm:p-6; descriptive label collapses to "Estimated / Items / On Sale" on mobile. The 3 stats now sit in one row even on a 360 px viewport. - Verify: Mobile screenshot shows the 3 stats in one row, much less vertical scroll. Build clean.
S3.4 · ErrorBoundary is already present (verified)
- No code change. Verified
components/ErrorBoundary.tsxis mounted inApp.tsx:42. Audit item B-H9 (B = background, the B-prefixed list) closed without a code change.
S3.5 · A11y sweep (4 small fixes, one commit)
- Files:
frontend/src/App.tsx,frontend/src/pages/Recipes.tsx(already done in Sprint 2),frontend/src/pages/Dashboard.tsx,frontend/src/components/ui/Badge.tsx - Change (committed):
App.tsxNavigation: addedaria-current={isActive(prefix) ? 'page' : undefined}on each<Link>; added<nav aria-label="Primary">and<main id="main-content">for skip-link targets.- Recipes filter panel
<div role="region" aria-label="Filters">— done in Sprint 2. - Empty Generate slots:
min-h-11(44 px) — done in Sprint 1. Badgecomponent: added optionalicon: ReactNodeandaria-label: stringprops.Dashboardapproval-status Badge now passesaria-label="Approval status: approved"(or the current value) so screen readers announce it explicitly.
- Verify: Tab through the nav: active link has
aria-current="page". Inspect Recipes filter panel:role="region" aria-label="Filters". Measure empty-slot buttons at 390 px width = ≥ 44 px tall. Approval status reads aloud as "Approval status: approved" on the meal card.
S3.6 · Sprint 3 verification gate
npm run lint && npm run buildpass.- Final playwright walkthrough. All 14 audit findings closed in screenshots.
- Update
Review/ui-nielsen-audit.mdto mark each fix with a[x]and commit hash reference.
Future (NOT in this plan — capture as follow-up tickets)
- F1. Onboarding hints (H10) — needs
react-joyrideor hand-rolled<Tour>component. - F2. Keyboard shortcuts (
/,g p,g s,n m). - F3. Bulk add on Pantry/Shopping List (H7).
- F4. Plan-the-whole-week button (H7).
- F5. Persistent week selector in URL.
- F6.
aria-labelon color-only status badges (generalized). - F7. Global
react-queryonErrortoast handler.
Sprint 6 — Bulk actions (F3 + F4)
Status (2026-06-04): ✅ Both items implemented. One commit: 8ad4ef6. npm run build green; both new backend endpoints smoke-tested locally with curl. Scope decision: F3 = ShoppingList only (the checked Set is the natural substrate). F4 = Plan the week button with Dinners only / All meals dropdown (per design-call), partial-success with detailed report (per design-call).
S6.1 · F3 — Bulk 'add checked to pantry' on ShoppingList
- Files:
backend/app/api/pantry.py,backend/app/schemas/__init__.py,frontend/src/api/index.ts,frontend/src/pages/ShoppingList.tsx - Change (one commit
8ad4ef6):- Backend
POST /api/pantry/bulk: new endpoint accepting{items: HomePantryCreate[]}. Each item follows the same upsert semantics as the single-itemPOST /api/pantry(insert or overwrite qty/unit/expires_at). Per-item status is reported asadded/updated/skippedwith a human-readable reason for skips. Total counts and per-item details both returned (HomePantryBulkResultschema). - Frontend
mealPlannerApi.pantry.addBulk(items)is the API binding. - ShoppingList: a new primary
Add N to pantrybutton appears next to the existing Reset button whenchecked.size > 0. Click → POST → toast shows'Pantry: added X, updated Y, skipped Z'. On success, the items that actually landed are removed from the checked Set; skipped items stay checked so the user can see what failed. Button showsAdding…while in flight; disabled during the request.
- Backend
- Verify: checked items get bulk-added; partial successes surface in the toast; the Pantry list reflects the new entries after a refresh.
S6.2 · F4 — Plan the whole week (Dashboard button)
- Files:
backend/app/api/meals.py,backend/app/schemas/__init__.py,frontend/src/api/index.ts,frontend/src/pages/Dashboard.tsx - Change (one commit
8ad4ef6):- Backend
POST /api/meals/{id}/fill-empty-slots: new endpoint with body{meal_types: [str, ...]}(subset of["breakfast","lunch","dinner"]). Iterates day 1..7 in order; for each day, iterates the requested meal_types; skips already-occupied slots; picks a recipe (prefer un-used, fall back to any) and inserts aspending. Per-slot failure model — never aborts mid-batch — returnsFillEmptySlotsResult { filled: [{day, meal_type, item}], failed: [{day, meal_type, reason}] }. Invalidmeal_type(e.g.'brunch') returns immediately with a single FailedSlot explaining why. - Frontend
mealPlannerApi.meals.fillEmptySlots(planId, mealTypes)is the API binding. - Dashboard: new
Plan the weekbutton in the header (next to the Sprint 5 week-nav control). Primary color, Sparkles icon, ChevronDown caret indicates a dropdown. Two options:Dinners only(sendsmeal_types=['dinner']) andAll meals(sendsmeal_types=['breakfast','lunch','dinner']). Each option has a one-line secondary label. - Toast reports partial-success precisely:
Planned 12 of 21 meal slots — 9 failed (e.g. No recipes available)orPlanned 15 meal slots(full success). Query invalidated so new slots show up immediately.
- Backend
- Verify: button fills the empty slots; partial-success toast shows the right counts; query refresh shows the new meals.
- Out of scope (documented in
Review/handoff-ui-audit.md): the no-opGenerate Meal Planempty-state CTA atDashboard.tsx:415(when the family has NO plan at all, distinct from the F4 case of "plan exists but slots are empty"). Routing that CTA needs a user-facing "create a new plan" path, which is a different feature (orchestrator/admin flow).
S6.3 · Sprint 6 verification gate
npm run buildgreen.- Backend smoke on local dev DB:
/api/pantry/bulk(skipped count for unknown ingredient),/api/meals/{id}/fill-empty-slots(dinners-only partial-success). - Deploy verified (git pull + container rebuild; backend + frontend per
Review/sprint6-verification.md). - No regression in Sprints 1-5.
Status (2026-06-04): ✅ Both items implemented. Two commits: d78bd18 (F5 + 0015 cast fix) and f740f40 (F2). npm run build green; backend smoke-tested locally with alembic upgrade head + curl confirming the new ?week_start= param works. Includes a critical bug fix to migration 0015 (Sprint 2) that was blocking Sprint 2's deploy too — see S5.0.
S5.0 · Critical fix — migration 0015 cast bug
- File:
backend/alembic/versions/0015_normalize_pantry_aisles.py - Bug: The CASE expression failed with
operator does not exist: text = booleanon thevarchar(100) aislecolumn. Root cause: CASE branches were inferred as different types (string vs NULL) so PostgreSQL could not unify the SET target type. The Sprint 2 dry-run (dry_run_aisle_migration.sql) used a different query path that happened to work, so the bug was not caught during Sprint 2. - Impact: The deployment host's
alembic upgrade headwould have hit the same error and Sprint 2 was effectively undeployable. This blocks Sprints 2, 3, 4 from going live. - Fix: Explicit
::varchar(100)cast on the whole CASE expression; simplified theWHEN '' THEN NULLbranch (wasNULLIF(...) IS NULLwith implicit boolean comparison). Tested on local dev DB: migration now succeeds; the 21,196 rows the Sprint 2 dry-run predicted actually normalize correctly. The deployment-host DB will follow the same path after this commit ships. - Why now: Discovered when smoke-testing Sprint 5 F5 against the local backend. The local DB was 3 migrations behind (the pre-existing WIP), so running
alembic upgrade headreproduced the error. Fixed and re-ran successfully. - Risks remaining: The 21k-row update on the deployment host will lock the
ingredientandgrocery_itemtables for the duration of the migration (a few seconds in dev; could be longer in prod). Thepersist_aisle_backup.sqlscript should still be run beforealembic upgrade headfor a recoverable record.
S5.1 · F5 — Persistent week selector in URL
- Files:
backend/app/api/meals.py,backend/app/api/shopping_list.py,frontend/src/api/index.ts,frontend/src/lib/utils.ts,frontend/src/pages/Dashboard.tsx,frontend/src/pages/ShoppingList.tsx - Change (one commit
d78bd18):- Backend: both
GET /api/mealsandGET /api/shopping-listnow accept?week_start=YYYY-MM-DD(FastAPIOptional[date] Query). When set, the response is the MealPlan for that week (any status). When omitted, behaviour is unchanged. - Frontend helpers:
lib/utils.tsgainsisoMonday(),parseIsoDate(),shiftIsoDate(),formatIsoDate(). All UTC-based to match the backend date column. - API layer:
meals.getPlanned(weekStart?)andshoppingList.get(weekStart?)take an optional ISO date string. Axios dropsundefinedparams so callers can omit them. - Dashboard:
useSearchParams('week')reads the URL; if absent or invalid, falls back toisoMonday()(so the default URL is empty).queryKey: ['mealPlan', weekStart]. A new segmented control in the header (chevron-left | 'This week'/'Current' jump button | chevron-right) lets the user step weeks. The jump button highlights primary-50 when the displayed week IS the current week; clicking it on the current week clears the?weekparam. All 5 mutations (move/approve/deny/delete/generate) invalidate['mealPlan', weekStart]so the right week refetches. - ShoppingList: same URL sync, same segmented control, same weekStart in queryKey. The 'no plan' empty state branches on
isCurrentWeek: 'No shopping list yet' (current) vs 'No plan for that week' (any other week). The local-storage check-state key naturally isolates per week (it usesshoppingList.week_start_datewhich is the server's view of the plan's week).
- Backend: both
- Verify: local backend smoke confirms
/api/shopping-list?week_start=2026-05-15returns the 25-item plan for that week with aisles normalised toMeat & Seafood/Pantry/Produce/Dairy & Eggs. Migration 0015 cast fix verified end-to-end. - Deploy: requires the backend rebuild + migration. Frontend changes are part of the same
git pull+docker compose up -d --build backend frontendsequence.
S5.2 · F2 — Global keyboard shortcuts
- Files:
frontend/src/hooks/useKeyboardShortcuts.ts(new),frontend/src/hooks/useFocusSearch.ts(new),frontend/src/components/ShortcutHelpBanner.tsx(new),frontend/src/App.tsx,frontend/src/pages/Pantry.tsx,frontend/src/pages/Recipes.tsx - Change (one commit
f740f40):- Hook
useKeyboardShortcuts(map): lightweight global handler. Supports single keys (/,?,Escape) and vim-style 2-key sequences (g d,g r,g p,g s). 1500ms sequence timeout; pending prefix clears on any unrecognised key. Suppressed in inputs/textareas/selects/contenteditable, and on any modifier-key chord. Listener registered once via a ref. - Hook
useFocusSearchOnShortcut(ref): tiny CustomEvent bus. The global handler dispatchesmealplanner:focus-searchwhen the user presses/; pages that have a search input subscribe and focus + select. - Component
ShortcutHelpBanner: dismissible help dialog (slide-down under nav) shown when?is pressed. Auto-dismisses after 6s; Escape dismisses;role=dialog+aria-labelfor screen readers. - App.tsx: new
GlobalShortcutschild ofBrowserRouterwires the 4 nav sequences,/→ focus,?→ help. - Pantry + Recipes: search inputs gain a
refanduseFocusSearchOnShortcut(ref). Pressing/on either page focuses + selects the search text.
- Hook
- Behaviour summary:
g d/g r/g p/g s→ navigate to the 4 main pages./→ focus search (Pantry + Recipes only).?→ help. Shortcuts are no-ops in text-entry controls. - Verify: build green. Live test: open the app, press
?to see the help banner, pressg pto jump to Pantry, press/to focus the search box. Verify the same on Recipes. Verifygalone in a search input does NOT navigate. - Deploy: frontend-only.
S5.3 · Sprint 5 verification gate
npm run buildgreen for Sprint 5.- Backend smoke on local dev DB: migration 0015 succeeds;
?week_start=returns the right plan; new?week_start=2099-01-01returns null/empty as expected. - Deploy verified (git pull, alembic upgrade head, docker compose up -d --build backend frontend, smoke checks per
Review/sprint5-verification.md). - No regression in Sprints 1-4.
Status (2026-06-03): ✅ Both items implemented and committed (d71b67a). npm run build green. Awaiting deploy.
S4.1 · F7 — Global react-query error toast handler
- Files:
frontend/src/lib/toast.tsx,frontend/src/App.tsx,frontend/src/pages/Dashboard.tsx,Pantry.tsx,MealDetail.tsx - Change (one commit
d71b67a):lib/toast.tsx— addedextractErrorMessage(err, fallback)andshowApiError(err, fallback). The normalizer readserr.response.data.detailwhen present (handles bothstringand Pydantic 422[{loc, msg, type}, ...]array shapes), then falls back toerr.message, then the supplied default. Never surfaces"[object Object]"or raw stack traces.App.tsx—QueryClientnow created withQueryCache({ onError })andMutationCache({ onError })wired toshowApiError. AddeddefaultOptions.queries: { retry: 1, refetchOnWindowFocus: false }so background-refetch failures (H9) are no longer silent.Dashboard.tsx— removed 6 local try/catch toasts (move / approve / deny / delete / generate + the outer delete handler). KeptVoteEmailButton.handleSendandhandleDelete's undo-callback withshowApiError(err, 'Failed to ...')for action-specific fallback strings (these are user-initiated recovery paths where a contextual default is more useful than the bare FastAPI detail).Pantry.tsx— removed 3 localonErrorhandlers (addMutation,removeMutation,handleAdd's createIngredient path) andhandleRemove's outer catch. Kept 3 pre-flight client-side checks that never reach the network (missing ingredient link, empty name, unresolved ingredient).handleRemove's undo callback now usesshowApiErrorfor the restore failure.MealDetail.tsx— removedsubmitMutation.onError. The local"Failed to save feedback. Please try again."is replaced by the actual FastAPI detail.
- Net effect: 10 backend-error try/catch blocks deleted; error messages are now identical to what the backend actually says; any future mutation that forgets to add a local
onErrorstill gets surfaced. - Backend audit (read-only): Every
HTTPException(detail=...)in the touched routes is human-friendly (e.g."Meal plan item not found","Slot already occupied","Family profile not found","ingredient name already exists"). Pydantic 422s return arrays and the helper handles them. No detail message is technical/leaks internals. - Verify:
npm run buildgreen. Live smoke: pull100.108.208.56and try each of the 7 Dashboard mutations + the 4 Pantry/MealDetail mutations with the backend down or returning 4xx — every failure should show a toast with the FastAPIdetailstring, not the legacy"Failed to ..."default. - Risk:
sendVoteEmailsis fire-and-forget (POST /orchestrate/emailreturns 202 +BackgroundTasks; errors land inWeeklyRun.error_messagenot the HTTP response). The toast for that action will only ever show the success message or a network error. Keep the local fallback string for that one — it documents the intent.
S4.2 · F6 — Plan-status Badge: aria-label
- File:
frontend/src/pages/Dashboard.tsx:438 - Change: Added
aria-label={\Plan status: ${mealPlan.status.replace(/_/g, ' ')}`}to thethat shows the meal-plan status (draft / awaiting_approval / approved / rejected). Matches the per-item approval-status pattern added in Sprint 3 (S3.5). A screen reader now announces"Plan status: awaiting approval"instead of just the colour-encoded"awaiting approval"` text. - Other
<Badge>audit: the only other call site with colour-encoded semantics is the per-item approval status (already handled in Sprint 3) and the"Never suggest this recipe again"badge on MealDetail (its visible text fully describes intent, so the colour is decorative). The "Spice N/5" warning badge on RecipeDetail is also self-describing. No further aria-label work needed. - Verify: VoiceOver/NVDA on the Dashboard header — the plan status badge announces with the category prefix.
S4.3 · Sprint 4 verification gate
npm run buildgreen for Sprint 4 (tsc 0 errors, vite 0 errors).- Deploy verified (git pull on
100.108.224.12,docker compose up -d --build frontend— no backend changes). - Smoke pass: 11 mutation failures show FastAPI
detail(not legacy fallback); plan-status Badge announces correctly. - No regression in Sprint 1–3 fixes.
Sprint 7 — Fix webui "empty meal plan" (date-semantics mismatch) — IN PROGRESS
Outside the original audit. Driven by user report 2026-06-05: "Latest meal plans were emails to me this morning, but when I go to the webui, the Meal Planner page is empty."
Root cause: _current_week_start() (backend) returns the most recent Friday; isoMonday() (frontend) returns the most recent Monday. On Fri 2026-06-05, the email goes out for 2026-06-05 (the email's plan key), but the webui opens on 2026-06-01 (no plan exists). The webui shows the "No plan yet" empty state, but the plan is real — just keyed 7 days later.
Scope: 6 checkboxes. No new dependencies. No backend migration. Small SQL fix script for the existing 2026-06-05 plan.
S7.1 · Backend — _current_week_start() returns the upcoming Monday
- File:
backend/app/services/orchestrator/runner.py:20-24 - Change: body becomes
if today.weekday() == 0: return today; else: return today + timedelta(days=(7 - today.weekday())). Docstring: "Return the upcoming Monday (today if Monday). The Friday email advertises the upcoming Mon-Sun week; the plan is keyed by that Monday." - Why: aligns the plan key with the Mon-Sun calendar week the user expects. The email subject (
f"Meal plan for week of {run.week_start_date}"atsteps.py:305) automatically picks up the new value. - No scheduler change.
scheduler/__main__.pystill fires Fri 02:00..18:00 PT. - Verify: no curl needed for the unit — it's pure date math. Visual verification: after deploy, the next Friday cron will create a plan with
week_start_date = next Monday's date.
S7.2 · Frontend — isoMonday → upcomingMonday + new helper
- File:
frontend/src/lib/utils.ts:44-50(rename + retune) - Change:
- Rename
isoMonday(d?: Date)→upcomingMonday(d?: Date)with bodyif d.getUTCDay() === 0: return d; else: d + (7 - d.getUTCDay()) days. - Add
formatWeekRange(mondayIso: string): stringreturning"Jun 8 — Jun 14". ReusesformatIsoDateinternally.
- Rename
- Call-site updates:
Dashboard.tsx:316-320,489andShoppingList.tsx:87-90,216,269swap the import + function name. Eight call sites in total.isCurrentWeek = weekStart === upcomingMonday()is the same idiom; the rename is intent-revealing. - Why: frontend and backend agree on "this week" = the upcoming Mon-Sun.
- Verify: typecheck passes.
npm run buildgreen.
S7.3 · Frontend — new WeekRangeNav component
- File:
frontend/src/components/WeekRangeNav.tsx(NEW) - Props:
{ weekStart: string; isCurrentWeek: boolean; onPrev: () => void; onNext: () => void; onJumpHome: () => void }. - Renders:
[<]button (chevron-left,aria-label="Previous week"), then a button showing the formatted range label (e.g.Jun 8 — Jun 14,aria-label="Jump to upcoming week", clickable → onJumpHome), then[>]button (chevron-right,aria-label="Next week"). A smallThis weekchip appears only when!isCurrentWeek(clickable → onJumpHome). - Why: user requested a visible, scannable date range with clickable brackets. Replaces the small inline Sprint 5 segmented control on both Dashboard and ShoppingList (single source of truth for the visual + behavior).
- Reuses:
lucide-reactChevronLeft/ChevronRight(already in Dashboard/ShoppingList imports).formatWeekRangefromlib/utils. - Verify: typecheck passes.
npm run buildgreen. Visual: header on Dashboard + ShoppingList now showsJun 8 — Jun 14for week_start 2026-06-08.
S7.4 · Frontend — wire WeekRangeNav into Dashboard + ShoppingList
- Files:
frontend/src/pages/Dashboard.tsx:479-503andfrontend/src/pages/ShoppingList.tsx:259-283 - Change: delete the inline segmented control; add
<WeekRangeNav weekStart={weekStart} isCurrentWeek={isCurrentWeek} onPrev={() => navigateWeek(shiftIsoDate(weekStart, -7))} onNext={() => navigateWeek(shiftIsoDate(weekStart, 7))} onJumpHome={() => navigateWeek(upcomingMonday())} />. Header layout reflows minimally — the nav is the same width as the segmented control. - Why: single source of truth; user's specific request.
- Verify: both pages render the new nav at the same position. The "Plan the week" button (Sprint 6) and the "Add N to pantry" button (Sprint 6) keep their positions to the right.
S7.5 · Data — fix the existing 2026-06-05 plan key
- File:
backend/scripts/fix_2026_06_05_to_2026_06_08.sql(NEW) - Body:
Plus a commented-out block for the 2026-05-29 plan (operator uncomments if desired).
-- Count rows that will change SELECT COUNT(*) AS rows_to_migrate FROM meal_plan WHERE week_start_date = DATE '2026-06-05'; -- Migrate the 3-pending-items plan UPDATE meal_plan SET week_start_date = DATE '2026-06-08' WHERE week_start_date = DATE '2026-06-05'; -- Verify SELECT id, week_start_date FROM meal_plan ORDER BY week_start_date; - Why: the user's just-voted-on plan (3 pending items) is keyed 2026-06-05. After S7.1, future plans are Mon-keyed. We migrate this one to 2026-06-08 so the user sees the plan they got the email about, in the same place as the email advertises.
- No schema change. SQL is idempotent (re-running is a no-op once 2026-06-05 has no rows).
- Verify: operator runs the script; output shows 1 row migrated (the 2026-06-05 plan). After migrate,
curl /api/meals?week_start=2026-06-08returns 3 items.
S7.6 · Sprint 7 verification gate
npm run buildgreen for Sprint 7.- Backend smoke on local dev DB:
curl /api/meals?week_start=2026-06-08returns the 3 items (after the data fix);curl /api/meals?week_start=2026-06-01returns null. - Frontend smoke:
npm run buildproduces a build that, when served, defaults the Dashboard to the upcoming Mon-Sun week. - Deploy verified on
100.108.224.12— seeReview/sprint7-verification.mdfor the operator checklist. - No regression in Sprints 1-6.
Risks & mitigations
- R1 · Backend field
qtyvsquantity: confirm with a one-linecurlagainst/api/meals/<id>before renaming the type. If the API still returnsquantity, use a shiming.qty ?? ing.quantityrather than breaking other consumers. - R2 · Pantry migration: run against dev DB first; capture before/after row counts. Do not run on prod without the
--backup-tablestep in place. - R3 · Tailwind
line-clamp-N: verify the project'stailwind.config.jsenables thelineClampcore plugin (Tailwind 3.3+ has it on by default; project is on^3.4.1, so it should work). - R4 · Undo-toast: requires the delete mutation to be reversible (i.e. we have the prior item body). Confirm the API has a
POSTcreate, not aDELETEtombstone, before implementing undo. - R5 · Build/runtime parity:
npm run buildrunstsc && vite build. If a teammate runsvite buildalone, type errors slip through. Add a CI hint in PR template.
Done when (overall)
- Sprint 1: 5 P0 fixes — committed
f3e4a44, deployed by user 2026-06-02. - Sprint 2: 6 P1 fixes + 1 bonus S3.3 — committed
ccc70aa, deploy helperf5fb755. Awaiting deploy. - Sprint 3: 3 P2 fixes + a11y sweep — committed
e90a9d6, awaiting deploy. - Sprint 4: F7 (global error handler) + F6 (plan-status aria-label) — committed
d71b67a, awaiting deploy. No backend changes; deploy is frontend-only like Sprint 3. - Sprint 5: F5 (URL week selector) + F2 (keyboard shortcuts) — committed
d78bd18(F5 + 0015 cast fix) +f740f40(F2). Sprint 2's deploy was blocked on the 0015 cast bug — Sprint 5 commit fixes it. Backend rebuild + migration required. npm run buildgreen for all five sprints (tsc 0 errors, vite 0 errors).- Backend aisle-migration (
0015with cast fix) run on dev — done on local dev host 2026-06-04; needs running on deployment host. - Manual smoke pass on
http://100.108.208.56:8082/perReview/sprint2-verification.md(Sprint 1-3),Review/sprint4-verification.md(Sprint 4),Review/sprint5-verification.md(Sprint 5). - No regressions in existing Playwright walkthrough.
- Sprint 7 (in progress): webui "empty meal plan" date-semantics mismatch. Code + SQL fix + verification doc. S7.1-S7.6 boxes in the section above.