Food log + Personal Contacts batch (2026-07-08)¶
Repo: ~/creatortrack. Meals app = components/apps/meals/ (PG-backed, the real food log; the
Flask components/apps/fitness/FoodView is legacy). Decisions locked with Justin: quick wins as
one PR first, then AI; Google Contacts = two-way; AI backend = claude2 sub (reuse the
CT chat-agents OAuth, no new API cost).
Shipped this session (typechecked clean, NOT yet eyeballed in a running app)¶
- #1 Persistent quantity-scaling
Composer.tsxdbBaseFrom(): editing a saved item's qty now rescales cal/macros/micros from the entry's own logged (quantity, macros). No schema change. -
#3b Richer item breakdown
NutritionSheet.tsxItemInsights/MiniRing+.ml-impact*/.ml-miniring*CSS: item scope now shows Impact-on-Targets rings (this food's % of each daily goal) + a Carb breakdown (carbs/fiber/net/sugars/added vs goal), above the existing tabs. -
#4 Unlabeled macro fields
Composer.tsx+meals.css.ml-field: Cal/Protein/Carbs/Fat/Qty/Unit used placeholders as their only labels, so the label vanished once filled (the bare 100/10/5/3). Wrapped each in a persistent<label>; composer row nowalign-items: flex-end. - #1a Rename Personal CRM → Personal Contacts (
lib/apps.ts:107+ calendar name incrm-calendar.ts+ two calendar UI strings). Code comments left as-is. - #3a Weekly nutrition dashboard in meals
TrendsView(WeeklyNutrition+.ml-week*CSS): current Sunday-week, 4 metric rows (Cal/P/F/C) of 7 test-tube bars vs goal, Consumed/Remaining toggle, today-vs-goal right rail. Threaded fullgoalsinto TrendsView (MealsClient:450).
Remaining¶
Phase 2 AI/logging engine (Justin confirmed B; wants speed + barcode)¶
All four share ONE food-JSON shape {name, qty, unit, calories, protein, carbs, fat, ...} that
pre-fills the Composer (and sets dbBase so scaling works):
- #5/B Text logging agent — chat box atop DayView with tools (add_food, lookup_nutrition,
delete_entry) hitting the meals API; claude2 sub. "add 2 eggs and toast" → entries.
- #2 Photo ID — single vision call → food-JSON → pre-fill. claude2 sub vision.
- Barcode scan (NEW, Justin 2026-07-08) — cheapest: UPC via device camera → food DB lookup
(Open Food Facts / USDA), NO AI. Same food-JSON. Add scanner button in Composer/DayView.
- Persistent quantity-scaling (NEW, Justin 2026-07-08) — Composer.setQuantity (L160) already
rescales macros from dbBase, but dbBase is in-memory only and NOT saved on the entry, so
editing a logged item's qty ("1 bag" → "2 bags") does NOT rescale. FIX: persist per-serving
base (per-unit macros) on FoodEntry (schema add), and have setQuantity fall back to the
stored base when the in-memory one is absent. Makes qty edits rescale forever, on any item.
pick() (history, L177) currently wipes the base on purpose — revisit once base is persisted.
Other¶
- #3b Better item breakdown — enhance
NutritionSheet.tsx(opened by the row info button,DayView:372onOpenBreakdown{kind:"item"}). Add MacroFactor parity: "Impact on Targets" ring row (this item's % of each daily goal) + a "Carb Breakdown" block (carbs/fiber/net/sugars vs goal bars). Data already onFoodEntry(fiber/sugar/addedSugar/satFat...). - #5 AI chat box atop food log — top of
DayView, aboveml-calcard. OPEN DESIGN FORK: (a) compact launcher that focuses the existing workspaceChatThread(ChatProvider already wraps the shell), (b) full embeddedChatThread variant, or (c) a food-scoped mini-agent that can log food from chat. Needs Justin's pick before building. - #2 AI photo food ID (phase 2) — single vision call: photo → structured {name,qty,macros} JSON
→ pre-fill Composer. New endpoint under
app/api/, camera/upload button in Composer/DayView, claude2 sub vision (Haiku/Sonnet). One call, no round-trips = the MacroFactor speed trick. - #1b Google Contacts two-way sync (phase 2) — People API scope on the CT Google OAuth project
(
reference_creatortrack_google_oauth_project), import + write-back with conflict handling, sync timer likesales-gmail-sync. Contacts live in thecrm.peoplesystem collection.
Verify before calling shipped¶
Drive the meals app: edit-food form shows field labels when filled; Trends → Weekly nutrition card
renders + toggle flips; rename shows in App Library + calendar. creatortrack-dev per
reference_creatortrack_dev_testing (WORKSPACE_DEV_AUTH=1).