Commit Graph

69 Commits

Author SHA1 Message Date
Sven (AAMOS AI) f86a37dd33 S5: onboarding → minne + smaksignaler (user_stated) 2026-08-11 04:43:43 +07:00
Sven (AAMOS AI) 74f95daab2 feat(3d): meal-box merge, stored mutations, undo, mobile undo UI + i18n ×12
- Merge leftovers into existing meal_box when same recipeId + cookedAt date + frozen + available.
- Store mealBoxMutations JSONB on cooking_sessions for deterministic undo.
- Undo decrements portions/remaining, discards box at zero, appends correction ledger rows.
- Mobile: undo button in cooking/[id].tsx after-flow and meal-boxes.tsx within 24h window.
- i18n undo strings across all 12 locales; parity test green.
- 6 new integration tests: merge, no cross-date merge, frozen split, undo restore, undo discard, ledger invariant.
- Update FAS3 audit doc with 3d semantics.

Closes Fas 3d
2026-08-07 17:04:42 +07:00
Sven (AAMOS AI) 0078084a2b field-fix: POST/PUT/PATCH without body sends '{}' in mobile api helper
- api() in apps/mobile/src/lib/api.ts now sends JSON.stringify({}) for
  methods with a body slot when no body is provided, instead of sending
  undefined with content-type: application/json.
- Fixes scan start crash (POST /v1/scans/:id/start) and latent
  resend-verification crash (POST /v1/auth/resend-verification).
- Server strictness left intact; uploadImage unchanged.
- Added unit tests for GET/HEAD/POST/PUT body behaviour.
2026-08-07 15:39:46 +07:00
Sven (AAMOS AI) 8637eaa6c3 3c-fix: partial consumption now deducts eaten + leftovers
- consumptionPortions = min(planned, actualPortionsEaten + leftoverEstimatePortions).
  Meal boxes are a subset of leftovers; raw inventory is only retained for
  portions that were never cooked.
- Added validation leftoverEstimatePortions >= mealBoxPortions with localized
  400 error (cooked.leftoverLessThanBox) in server i18n + all 12 locales.
- Removed unused COOKING_SESSION_STATUSES / MEAL_BOX_STATUSES imports from
  apps/api/src/lib/cooking.ts.
- Hardened test cleanup to delete mealBoxes/meals/recipeCooks/cookingSessions
  by household before dropping storageLocations.
- New regression tests: meal-box double-counting, eaten+leftover split, and
  leftover < box rejection.
- Updated FAS3-COOKING-SESSIONS-AUDIT.md with corrected physics semantics.
2026-08-07 15:35:25 +07:00
Sven (AAMOS AI) cb493010d0 3c: partial consumption + undo for cooking sessions
- Append-only undo via correction transactions tied to cookingSessionId.
- POST /v1/cooking-sessions/:id/undo with 24h UTC window (409 + i18n after expiry).
- Complete undo scope: meals removed, meal boxes discarded, recipe_cooks
deleted, cookCount decremented; activation milestones left intact.
- Deterministic assumption-profile rollback via lastSessionAnswers.sessionId;
profile deleted when observationCount reaches 0.
- New status 'undone' as TEXT validated against COOKING_SESSION_STATUSES.
- Analytics event cooking_session_undone + domain events MEAL_BOX_DISCARDED,
MEAL_REMOVED, COOKING_SESSION_UNDONE.
- Partial consumption uses actualPortionsEaten/plannedPortions factor.
- i18n coverage for cooked.undoWindowExpired across all 12 locales + server.
- Invariant tests: computeBalance(transactions) === item.quantity after
complete, undo, and undo + new complete; transaction count increases on undo.
- Migration 0014_expand_event_types.sql adds new enum values.
- Updated FAS3-COOKING-SESSIONS-AUDIT.md with chosen semantics.
2026-08-07 05:47:54 +07:00
Sven (AAMOS AI) bbe7526ef3 fix(3b): delad kompletteringsväg för legacy /cook + deterministiska cooking-assumptions
- cookRecipeInputSchema utökas med actualPortionsEaten, leftoverEstimatePortions, leftoverNote
- completeCookingSession-wrapper i apps/api/src/lib/cooking.ts hanterar summavalidering,
  persistens av svar, profiluppdateringar och analytics (started+completed) för båda vägarna
- Legacy POST /v1/recipes/:id/cook använder wrappern med emitStartedEvent
- GET /v1/recipes/:id/cooking-assumptions väljer deterministiskt bland icke-valfria ingredienser
- i18n: nyckel cooked.portionsSumExceedsPlanned i samtliga 12 lokaler + server-i18n
- Nya tester för legacy /cook och cooking-assumptions med valfri första ingrediens

Refs: steg 3b-fix, granskningsrunda 2026-08-07
2026-08-07 05:13:35 +07:00
Sven (AAMOS AI) e46281b9b5 Fas 3 steg 3b: minimala efterfrågor + hushållsantagandeprofiler per ingrediens 2026-08-07 03:56:41 +07:00
Sven (AAMOS AI) 4a4f448e1c Fas 2 steg 5: Scan-to-scan-diff + konfliktlösning, samt buggfix depleted-transaktion i reconciliation 2026-08-07 01:30:31 +07:00
Sven (AAMOS AI) 218bc44d08 Fas 2 steg 4: Quick Reconciliation (motor, API, app + 12-språks i18n) 2026-08-07 01:02:08 +07:00
Sven (AAMOS AI) 4385fe5125 Fas 2 steg 3: Household Trust Score (admin + i18n status i appen) 2026-08-06 23:45:28 +07:00
Sven (AAMOS AI) dd66ebedbf Bugfix: what-to-eat utan hushall ger forslag; onboarding mal kan valjas multi 2026-08-06 21:32:32 +07:00
Sven (AAMOS AI) 8e6b780480 Lagg till custom Metro-resolver for .js->ts samt react-native-web for SDK 54 2026-08-06 20:51:30 +07:00
Sven (AAMOS AI) a837283a2e Migrera mobilappen fran Expo SDK 57 till SDK 54 2026-08-06 19:54:28 +07:00
Sven (AAMOS AI) 03e30755dc Förberedelse fas 2: testmiljö fix + analytics tracker i mobilappen 2026-08-06 16:46:30 +07:00
Sven (AAMOS AI) bd8df59138 Fas 1b punkt 6: First Scan Coach + aktiveringsmätning 2026-08-06 04:14:49 +07:00
Sven (AAMOS AI) 2f3cdf8016 FAS 1b: Progressive onboarding (3-layer flow)
- Add PROGRESSIVE_ONBOARDING feature flag to KNOWN_FLAGS
- Add onboarding_step column to users table (a/b/c)
- New backend endpoints:
  - GET /v1/onboarding/status – check current step + feature flag
  - POST /v1/onboarding/quick-start – complete Step A (goal + precision)
  - POST /v1/onboarding/complete-b – complete Step B (diet, allergens, household)
  - POST /v1/onboarding/complete-c – complete Step C (health profile)
  - POST /v1/onboarding/skip – GDPR-friendly skip
- Refactor mobile onboarding screen into 3 progressive layers
- Update auth store with onboardingStep state
- Update tab layout to only block on Step A
- Update registration to set onboardingStep='a'
- Add i18n keys for Step B/C titles across all 12 locales
- Add Zod validation schemas (quickStartInputSchema, onboardingStatusSchema)
- Add tests for validation and feature flag
- Preserve existing /v1/me/onboarding for backward compatibility
- Migration: 0004_progressive_onboarding.sql
2026-08-06 00:40:59 +07:00
Sven (AAMOS AI) 1250640b1d Fas 1a: analytics tracker, ingestion endpoint, admin dashboards 2026-08-05 22:15:37 +07:00
Sven (AAMOS AI) d627014425 Fas 1a: product analytics schema + GDPR controls 2026-08-05 19:51:37 +07:00
Sven (AAMOS AI) ac5340195a Initial commit (unpacked platform) 2026-08-05 19:21:11 +07:00