Handoff: CreatorTrack food-log chat box (#5) + photo-stage (#6)¶
For: an Opus remote worker. Repo: ~/creatortrack (note: ~/forge-suite is a symlink to
the same tree; the systemd creatortrack-dev/creatortrack-prod serve from it).
Base: main (quick-wins + barcode already merged at a2f8fe9).
Work isolation (MANDATORY)¶
- New worktree + branch:
git -C ~/creatortrack worktree add ~/creatortrack-wt/foodlog-chat -b feat/meals-foodlog-chat mainthencp -al ~/creatortrack/node_modules ~/creatortrack-wt/foodlog-chat/node_modules(hardlink; a symlink breaks Turbopack). Worktree dev MUST usenext dev --webpack(turbopack symlink note). - Commit OFTEN; merge to main ONCE at the end (--no-ff) (parallel dev).
Do NOT rebuild the engine (critical)¶
The AI food-logging engine ALREADY EXISTS: lib/chat.ts (tools get_meals, search_food,
log_food, log_food_batch, update_food, delete_food) + app/api/chat/route.ts (system prompt
already identifies + logs food from PHOTOS; image attachments supported). Text + photo logging work
today in the workspace chat. Your job is to SURFACE and (optionally) add a staging variant, not
duplicate the engine (single-source doctrine).
#5 Chat box on the food log (primary)¶
- Add a compact launcher on the Meals Day view (
components/apps/meals/DayView.tsx), pinned ABOVE the calorie summary card (.ml-calcard). Tapping/submitting opens the EXISTING workspace chat and seeds its input. - Wiring: chat visibility lives in
components/workspace/WorkspaceShell.tsx(chatView/setChatView,chatExpanded,exitChat).ChatProvider(components/workspace/ChatContext.tsx,useChat()→setInput/send/messages) wraps the shell. Apps render as WorkspaceShellchildren, so add a small context (e.g.WorkspaceChatContext) provided by WorkspaceShell exposingopenChat(seedText?)→ setschatView=true(+chatExpandedon desktop as appropriate) and seedsuseChat().setInput. Consume it in DayView. Behavior: chat AUTO-LOGS (keep as-is); the box is an entry point + seed, not a new flow. - CSS in
components/apps/meals/meals.css(.ml-*conventions; theme tokens only).
#6 Photo-stage button (optional; photo already auto-logs via chat)¶
- Only the STAGING variant is new. A photo/camera button in DayView → new endpoint
app/api/apps/meals/vision/route.ts(session-authed likefoodsearch/route.ts) that takes an image and returnsFoodSearchResult[]WITHOUT logging → call DayView's existingstageFood(food)(already implemented, commit a2f8fe9) for each, so the user confirms with Add. - Vision call: reuse the model/sub path in
lib/llm/anthropic.ts+ howlib/chatinvokes it; force strict JSON. Fail loud on quota/parse (no fabricated food). - Already built to reuse:
DayView.stageFood(food, meal?), Composerstagedprop,BarcodeScanner.
Verify before merge¶
npx tsc --noEmit -p tsconfig.json→ 0 errors;npx eslint <changed files>→ no NEW errors (a pre-existingset-state-in-effectat Composer's search debounce is known; don't touch it).- Drive the preview server (Justin has one running; or start your own per dev testing): tap the chat box on Meals → Day, confirm the chat opens + logs; photo button stages a food.
- Merge to main --no-ff, then notify Justin's origin chat with the result + branch.