Skip to content

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 main then cp -al ~/creatortrack/node_modules ~/creatortrack-wt/foodlog-chat/node_modules (hardlink; a symlink breaks Turbopack). Worktree dev MUST use next 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 WorkspaceShell children, so add a small context (e.g. WorkspaceChatContext) provided by WorkspaceShell exposing openChat(seedText?) → sets chatView=true (+ chatExpanded on desktop as appropriate) and seeds useChat().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 like foodsearch/route.ts) that takes an image and returns FoodSearchResult[] WITHOUT logging → call DayView's existing stageFood(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 + how lib/chat invokes it; force strict JSON. Fail loud on quota/parse (no fabricated food).
  • Already built to reuse: DayView.stageFood(food, meal?), Composer staged prop, BarcodeScanner.

Verify before merge

  • npx tsc --noEmit -p tsconfig.json → 0 errors; npx eslint <changed files> → no NEW errors (a pre-existing set-state-in-effect at 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.