Repository navigation
feat: add some days of a meal plan to the shopping list - #611
Merged
Merged
Conversation
This was referenced Oct 1, 2026
LeMyst
force-pushed
the
feat/plan-shopping-range
branch
2 times, most recently
from
October 3, 2026 19:05
af278f6 to
03471a9
Compare
4 tasks
A meal plan's page gets a checkbox on each day, All / Next 7 days / None
shortcuts, and "Add days to shopping list". Only those days' recipes go
on the list, at the menu's factors times the page's servings, and the
ingredients written straight into those days (`@almonds{50%g}`) go on as
free-hand items, merged by name.
A menu entry cannot carry a choice of days: the list reads a menu entry
as the whole menu plus its listed recipes, so every day's free-hand
ingredients would come along. The chosen days are therefore stored with
what the `.shopping-list` format already has: recipe lines, as if each
recipe had been added on its own, and top-level free-hand lines such as
`almonds{100%g}`, which the Cooklang apps also read and write.
- `POST /api/shopping_list/add_menu` takes optional `dates`; without it
the whole menu is one entry, byte for byte as before.
- `ShoppingListStore::add_all`, `load_free_hand`, `remove_free_hand`
and `FreeHandItem`; core's `add_extra_item` merges one into an
ingredient list like the CLI's `--extra`.
- `GET /api/shopping_list/extra_items`,
`POST /api/shopping_list/remove_extra_item`; `POST /api/shopping_list`
accepts `{name, quantity}` elements; compaction counts free-hand items.
- The shopping list page lists them under "Extra items", each with
Remove, and sends them along when generating the list.
- Strings in all 9 locales; docs/server.md, docs/api.md.
A day's sections are found as the calendar finds them
(`web::plan::section_date`): a `YYYY-MM-DD` anywhere in the name, so a
`= 2026-10-08 Dinner` section is that day too.
Part of cooklang#385.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RXA3hAKY9Q8hLCZGeokLPK
LeMyst
force-pushed
the
feat/plan-shopping-range
branch
from
November 7, 2026 05:28
03471a9 to
0ff5056
Compare
LeMyst
marked this pull request as ready for review
November 7, 2026 05:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #671. One commit on
main(#596 has been merged). A plan is any menu dated on two days or more, and a date counts anywhere in a section name (= 2026-10-08 Dinneris that day's dinner).Step 3a of the proposal: put some days of a meal plan on the shopping list — this week of a fortnight, or just the days until the next shop.
What changes
@almonds{50%g}), merged by name (two days of 50 g almonds →almonds{100%g}).tests/menu_api_test.rspasses untouched).How the days are stored, and why
A menu entry can't hold a choice of days.
.shopping-listreads./Plan.menufollowed by its recipes as "the whole menu plus these recipes". The page then adds the menu itself withincluded_references: []to pick up its free-hand ingredients, which would bring every day's almonds and bread back in. Filtering that entry would mean new syntax in a file the Cooklang apps share.So the chosen days are stored with what the format already has:
add_menuruns for a whole menu (cooklang-find'sMenuwithresolve_scales, the Recipe endpoints and /api/static follow symlinks out of the collection #698 containment checks, nested-menu back references dropped). Withdates, that loop only skips the sections not dated one of them. An optional recipe (@?./Cake{}) stays off, as for the whole menu.cooklang::shopping_list::IngredientItem) for items typed in by hand.cook shopping-listand the apps already read them, and before this the server silently dropped them.The trade-off: once added, the days aren't grouped under the plan's name in the sidebar, and they're removed recipe by recipe and item by item rather than as one plan. I think that's right for a partial plan: you're shopping for those meals, not the menu. A grouped form would need a format change upstream in cooklang-rs.
API
POST /api/shopping_list/add_menutakes an optionaldates: ["YYYY-MM-DD", …]. I extended this endpoint rather than adding a sibling: it's the same operation, scaling and reference resolution, and withoutdatesnothing changes.400for an empty list, more than 400 dates, or something that isn't a date. A date the menu doesn't have adds nothing.GET /api/shopping_list/extra_itemsreturns[{name, quantity?}].POST /api/shopping_list/remove_extra_itemwith{name, quantity?}removes the first match and compacts the checked log likeremovedoes. It's covered by the existingEditListsprefix in the authWRITEStable.POST /api/shopping_listalso accepts{name, quantity}elements (untagged next to{recipe, …}), merged into the required ingredients through core's newadd_extra_item, the same path as the CLI's--extra.docs/api.mdis regenerated fromsrc/web/api_docs.rs.In core:
FreeHandItem,ShoppingListStore::{add_all, load_free_hand, remove_free_hand}(add_allwrites recipes and items in one atomic write), andshopping_list::add_extra_item.Screenshots
Monday, Wednesday and Thursday are ticked. Tuesday's curry and bread stay off, and the almonds of Wednesday and Thursday become one 100 g extra item.
Tests
add_allorder and bytes, free-hand lines another app wrote (top level only),remove_free_handmatching name and amount,removeleaving a free-hand line of the same text alone,FreeHandItem::spec.tests/plan_shopping_test.rs, isolated config): the exact.shopping-listfor two of three days at ×2, the list it generates, the whole menu unchanged withoutdates, removing an extra item, bad dates → 400, an absent date → nothing.tests/e2e/plan-shopping.spec.ts): tick days, add, check the request, sidebar and generated list, remove an extra item; the three shortcuts; Add All still one entry; axe on the plan.cargo fmt,cargo clippy --all-targets(and--no-default-features: only the warnings already onmain),cargo testall clean.meal-plan,menu-scaleand theshopping-list*specs: all pass with--workers=1..shopping-list(shopping-list-copy,shopping-list-live, onerecipe-scalingadd); they all pass with one worker.Not in this PR
Rebased onto main (d1455f4), 2026-11-07
add_menuwas rewritten upstream aroundutil::menu::load_menu(cooklang-findMenuItems), so the day filter is now a per-section check (on_a_chosen_day, sameweb::plan::section_dateas the calendar) inside that loop. The free-hand items of the chosen days still come from the Cooklang parse of the menu at the page's scale, so their amounts add up by unit as before.? name{qty}lines, feat(shopping-list): leave optional ingredients out unless --include-optional #592's split):recipe_itemwrites them for bothaddandadd_all. Free-hand items go intorequired, in the generated list and in the tick compaction.json_error. The new messages are inel-GRtoo.cargo fmt,cargo clippy --workspace --all-targetsclean;cargo test --workspace --no-fail-fast: all 56 binaries pass. Full chromium Playwright with--workers=1: 331 passed, 5 skipped, 3 failed (and 4 that did not run after them in serial blocks), allspawn target/debug/cook ENOENTbecause my build used a private target dir (static-file-search,sign-in-notice, the "does not parse" pantry test).plan-shopping.spec.tsand everyshopping-list*spec pass.🤖 Generated with Claude Code
https://claude.ai/code/session_01RXA3hAKY9Q8hLCZGeokLPK