Skip to content

Add update_food_entry tool to edit or move a logged entry - #76

Open
paultristanwagner wants to merge 1 commit into
rwestergren:mainfrom
paultristanwagner:edit-diary-entry
Open

paultristanwagner wants to merge 1 commit into
rwestergren:mainfrom
paultristanwagner:edit-diary-entry

Conversation

@paultristanwagner

Copy link
Copy Markdown

All code in this PR was written by an AI agent (Claude Opus 5.5) working with me; I directed it and tested the results on my own account. Feel free to take, change or drop any part of it.

Part of #73.

Adds an update_food_entry tool: change a logged entry's amount or
measure, or move it to another meal. Until now the only way was to remove
the entry and log it again.

The app changes an amount with POST /api/v2/edit_serving, sending the whole serving back with the
new grams:

{"serving": {"servingId": …, "day": …, "order": 65537, "foodId": …,
             "measureId": …, "grams": 400.0, …},
 "auth": {…}, "config": {"call_version": 2}}

The meal group lives in the high bits of order, as add_serving already
builds it ((group << 16) | position). The app moves an entry with a
separate POST /api/v2/update_order {"diaryEntries": [<serving with new order>]}, but edit_serving accepts a new order too, so one call does
both. Verified against the live API on 1900-01-02: amount, meal and both at
once.

Changes:

  • client: update_serving(serving_id, day, *, grams, measure_id, diary_group) reads the serving from get_diary, changes the given
    fields and sends it back. A moved entry goes to the end of its new meal;
    staying in the same meal keeps its position. Arguments are validated
    before any request.
  • server: update_food_entry tool. The meal-name map that
    add_food_entry built inline is now a module constant both tools use.
  • README: tool table row.

https://claude.ai/code/session_01MCJFDo71qoSqTRtcGfkpXJ

The app changes a serving's amount with /api/v2/edit_serving, re-sending
the whole serving. The meal group lives in the high bits of `order`, and
edit_serving accepts a new order too, so one call changes the amount,
the measure and the meal.

Claude-Session: https://claude.ai/code/session_01MCJFDo71qoSqTRtcGfkpXJ

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant