From d2df4c51eb1f637eaf12aa210534fb04ab785ef0 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Sun, 20 Sep 2026 08:44:20 +0200 Subject: [PATCH] Record why the gate's delivery prefill must set the dish's grams as its basis Co-Authored-By: Claude Opus 5 (1M context) --- app/lib/services/kuchnia_spread.dart | 10 +++++++--- app/pubspec.yaml | 2 +- docs/DOCS-kuchnia-wikinga.md | 9 +++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/lib/services/kuchnia_spread.dart b/app/lib/services/kuchnia_spread.dart index 9d55282..615ca84 100644 --- a/app/lib/services/kuchnia_spread.dart +++ b/app/lib/services/kuchnia_spread.dart @@ -87,9 +87,13 @@ List dishesInSlotOrder( /// Returns `(portionGrams, (kcal, protein, carbs, fat))` as form strings. /// -/// Mirrors `_kuchnia_spread.dish_field_values`. Formatted here rather than in -/// the widget so the numeric formatting is covered by a test that needs no -/// display. +/// Phone-only, deliberately: this form logs the fields as typed, so writing +/// the dish's whole-portion macros into them is correct. The PC gate's form +/// scales its macros from a "per" basis to the amount eaten, so it goes +/// through `_kuchnia_log.dish_nutrition` (basis = the dish's own grams) +/// instead -- filling its fields this way logged 3.5x the calories. +/// Formatted here rather than in the widget so the numeric formatting is +/// covered by a test that needs no display. /// /// Python uses `f"{value:g}"`, which drops a trailing `.0`; Dart's /// `toStringAsFixed` would keep it and `toString` would render `435.0`. So a diff --git a/app/pubspec.yaml b/app/pubspec.yaml index cac0b49..4f7aac1 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -2,7 +2,7 @@ name: diet_guard_app description: "Companion phone app for diet_guard: log meals on the go." publish_to: 'none' -version: 1.0.88+1 +version: 1.0.89+1 environment: sdk: ^3.12.2 diff --git a/docs/DOCS-kuchnia-wikinga.md b/docs/DOCS-kuchnia-wikinga.md index b97b372..4e764ba 100644 --- a/docs/DOCS-kuchnia-wikinga.md +++ b/docs/DOCS-kuchnia-wikinga.md @@ -85,6 +85,15 @@ This was proven, not assumed: 4·protein + 4·carbs + 9·fat reproduces the stat payload and would silently skew every logged meal by a factor of several, so the parser refuses rather than importing a plausible-looking lie. +The same mix-up has a second home: the PC gate's form. Its macro fields are a +*reference* scaled from the "per" basis to the amount eaten, so the delivery +prefill must go through `_apply_reference` with `_kuchnia_log.dish_nutrition` +(basis = the dish's own grams). Writing the macros straight into the fields +left the basis at `_clear_inputs`'s 100 g default and logged grams/100 times +too much while the fields still read correctly (350 g owsianka: 448 shown, +1568 logged; every gate-logged delivery 2026-08-23 to 2026-09-20). The phone's +`dishFieldValues` has no such basis and is correct as is. + ## Credentials Three files under `~/.config/diet_guard/`, all mode 600. They are outside