Repository navigation
feat: a menu can use another menu as one of its meals - #609
Merged
Merged
Conversation
Member
|
That's just brilliant! Recursive all the way! |
`- @./Brunches/Sunday.menu{}` in a menu names a whole menu the way a
meal names a recipe (cooklang#385). The shopping list, `cook shopping-list` and
`cook doctor` already followed such a reference; the rest of the server
treated it as a recipe:
- The menu page links it to the menu's page (`/recipe/<path>.menu`, and
`menu/<path>.html` in a static site, where the `.menu.html` it linked
to does not exist), labels it without `.menu`, and tags it Menu.
- `GET /api/menus/{path}` reported `path: "./Brunches/Sunday.menu.cook"`;
it now gives the `.menu` file and adds `"menu": true` (left out for
recipes, so existing responses are unchanged).
- `add_menu` drops a nested menu's reference back to the menu being
added: the shopping list follows each nested entry in a request of its
own, so a cycle A -> B -> A counted A's contents twice there, unlike
`cook shopping-list`.
- The editor's Add recipe, in a menu, offers menus as well as recipes
(never the menu being edited); a recipe's Recipe reference still
offers recipes only.
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/menu-in-menu
branch
from
October 10, 2026 10:45
df14542 to
ee42888
Compare
LeMyst
marked this pull request as ready for review
October 10, 2026 11:10
4 tasks
dubadub
pushed a commit
that referenced
this pull request
Nov 24, 2026
A menu added to the shopping list keeps its meals as entries of their own, and a menu used as one of them (`B` in `A`) is expanded from there, on its own. Only a reference straight back to `A` was dropped, so with three menus in a ring, `A` → `B` → `C` → `A`, B's expansion went on through `C` into `A` and counted A's recipes a second time. The CLI already counted them once. A recipe expanded from a menu entry now names that menu (`within` in core's `ExtractOptions`, `menu` in a `POST /api/shopping_list` entry), and the menu heads the chain of ancestors the cycle check walks: the reference back to `A` is refused, however long the ring. The shopping list page sends it, and so does the server when it rebuilds the stored list to compact ticks. An entry without it is expanded as before. Since menus could be meals of each other, d99192b (#609). Claude-Session: https://claude.ai/code/session_01MmrM91dHzvQoaerCcR9wra Co-authored-by: Claude Opus 5.5 <[email protected]>
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 #385 (step 3 of the proposal: a whole menu as a day's meal).
A menu can use another menu as one of its meals, the way it uses a recipe:
What happened before
On upstream
main, a menuWeek.menureferencing@./Brunches/Sunday.menu{4%servings}(a menu withservings: 2) and@./Brunches/Sunday{2}:resolve_referencecooklang-findfinds the.menuwith or without the extensioncook shopping-list Week.menucook doctor validateadd_menu+ shopping listGET /api/menus/Week.menu"path": "./Brunches/Sunday.menu.cook"and"./Brunches/Sunday.cook""path": "./Brunches/Sunday.menu","menu": true(left out for recipes)/recipe/Brunches/Sunday.menuor/recipe/Brunches/Sunday(a recipe of the same name would win); labelBrunches › Sunday.menu; incook build web,recipe/Brunches/Sunday.menu.html, which does not exist/recipe/Brunches/Sunday.menu,menu/Brunches/Sunday.htmlin a static site; label without.menuand a Menu tag@./Weekly Plan.menu{}. Recipe reference in a recipe still offers recipes onlyScaling is the recipes' rule:
{2}multiplies,{4%servings}scales against the referenced menu'sservings, and the menu page links it with?servings=like a recipe.Design
RecipeInfo(util::menu_scale) learnsis_menu; the menu page, the menu API andadd_menualready resolve every reference through it.reference_path/reference_labelinweb::templatesbuild the link and label, somenu.htmlno longer spells them twice.add_menuto flatten a nested menu's recipes into the list, then checked the old behaviour and found the totals already right through the core expansion; that rewrite is not in this PR. Only the cycle filter is.@../Xreferences to/recipe/../X(separate bug, needs its own issue).Screenshots
Tests
tests/menu_in_menu_test.rs(isolated config): the menu API (menu,path,scale, recipes unchanged), the page links, the shopping list totals for a menu used twice (with and without.menu), an A → B → A cycle counted once,cook shopping-list,cook doctor validate.reference_path/reference_labelfor recipes, menus, static sites.menu-editor.spec.ts— the picker offers other menus in a menu and inserts.menu; never in a recipe.cargo fmt,cargo clippy --all-targets(and--no-default-features: only the warnings already onmain),cargo testclean. Full chromium run: all pass exceptshopping-list-live(passes with--workers=1) andrecipe-scaling › should send the scale when adding to shopping list, which is flaky onmaintoo (fails 1 run in 3 against a build without this change: the route is registered after the scale navigation).🤖 Generated with Claude Code
https://claude.ai/code/session_01RXA3hAKY9Q8hLCZGeokLPK