Repository navigation
feat(ui): create and edit menus with a recipe picker - #558
Merged
Merged
Conversation
A "New Menu" button next to "New Recipe" opens the new-file form with
`kind=menu`, which creates a `.menu` file with a first day and meal and
opens it in the editor. `kind=recipe` (or none) still makes a `.cook`
file; any other kind is refused with 400. Name sanitising, the path
checks, `create_new` and the CSRF check are shared by both kinds, and
error redirects keep the kind.
The editor toolbar gets a menu mode for `.menu` files:
- Day adds `== Day N ==`, or `== Saturday (2026-03-07) ==` when a date
is picked (the date then moves on a day);
- Meal is a menu button listing Breakfast, Lunch, Dinner and Snacks,
and inserts `Meal: \` with a bullet under it;
- Add recipe opens a recipe picker and inserts `- @./Path/Name{N%servings}`
under the current meal, adding the ` \` the menu page needs to keep the
bullet in that meal.
The picker searches `/api/search` (300 ms, 2 characters, like the header
search) and otherwise lists the `/api/recipes` tree, never menus. Its
servings field defaults to the menu's `servings`; left empty it inserts
`{}`. In the recipe editor, a Recipe reference button uses the same
picker to insert `@./Path/Name{}` inline.
Closes cooklang#538
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The new-menu form, the menu toolbar and the recipe picker, in German, Spanish, Basque, French, Italian, Dutch and Swedish. Italian had no editor toolbar strings yet, so only the new ones are added there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`create_recipe` wrote the starter content through a tokio `File` and redirected as soon as `write_all` returned. A tokio `File` hands writes to a background task, so the redirect could reach the browser, and the editor load the file, while it was still empty. The new menu test caught it on CI, reading `""` back right after the redirect. The unflushed write came in with 7343753 (fix(editor): address code review feedback for recipe creation), when `tokio::fs::write` was replaced by `create_new` + `write_all`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The listing links menus without their extension (`/recipe/Week`), and the menu page's Edit button keeps that path, so the editor got `/edit/Week`. The file resolved to `Week.menu`, but the toolbar mode came from the requested path, so the page showed the recipe toolbar. The editor now redirects a bare name to the file's full name (`/edit/Week.menu`, or `.cook` for a recipe). The toolbar mode, the page title and the save, delete and picture calls then all name the file. Co-Authored-By: Claude Opus 5.5 <[email protected]>
In menu mode the toolbar showed every recipe button next to the menu helpers, and wrapped onto a second row at laptop width. Cookware and timers are dropped by the menu page, notes are not rendered either, and Day does what Section does, so a menu now gets two groups: [ Day date Meal Add recipe ] [ Ingredient Comment Metadata ] It fits on one row at 1280 px, and takes three rows at phone width instead of five. The recipe toolbar is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A meal only holds together while every line but the last ends with
` \`; without it, the next line is joined to the previous one. Bullets
typed by hand never got one, so
Petit-déjeuner: \
- @./Dessert/Baklava{2%servings}
- @coffee{} \
rendered "Baklava - coffee" as a single item.
In a menu, Enter at the end of a meal header or bullet now works like a
list in a Markdown editor: the line gets its ` \` and the next one
starts with `- `. Enter on an empty bullet ends the meal, dropping the
bullet and the ` \` before it and leaving a blank line. Anywhere else,
and in recipes, Enter is unchanged; autocompletion still takes Enter
while its list is open.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
LeMyst
force-pushed
the
feat/menu-editor
branch
from
September 28, 2026 05:08
29f05bf to
490c713
Compare
LeMyst
marked this pull request as ready for review
September 28, 2026 06:46
Collaborator
Author
dubadub
approved these changes
Sep 28, 2026
This was referenced Sep 30, 2026
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.

Closes #538. Builds on the editor toolbar from #540.
The menu file stays the source of truth: as #538 explains, the menu JSON API is lossy and there is no menu → text writer. So this adds insert helpers on top of the text editor instead of a form.
Creating a menu
new_recipe_url(new_menu_urlonRecipesTemplate). The header row now wraps so the three controls fit at phone width.NewPageQueryandNewRecipeFormtakekind:recipe(the default) ormenu.create_recipepicks the extension and the starter content from it, redirects to/edit/{path}.menu, and error redirects keep&kind=menu. An unknown kind gets 400 and creates nothing. Name sanitising, the path-traversal checks,create_newand CSRF are unchanged and shared by both kinds.new.html: the title, labels, placeholder, submit button and.cook/.menusuffix followkind, which is also sent as a hidden field.Menu mode in the editor
edit_pagesetsis_menufor.menufiles, and the toolbar rendersdata-mode="menu"with two groups on one row:Cookware, Timer, Note and Section are left out in menu mode. The menu page drops cookware and timers (
_ => {}in the menu builder), notes are not rendered either, and Day replaces Section. The recipe toolbar is unchanged apart from Recipe reference./edit/{name}without an extension redirects to the file's full name (/edit/Week.menu). The listing links menus without their extension, so the menu page's Edit button used to open the recipe toolbar.The menu group:
== Day N ==(N = sections + 1). If the date field next to it holds a date:== Saturday (2026-03-07) ==, the formatextract_date/ today's-menu banner read. The date then moves on one day, ready for the next click.Meal: \+-on the next line.- @./Path/Name{N%servings}Line continuation: the new bullet goes under the meal at the cursor: it fills an empty
-, joins the meal above a blank line, or goes under the current line. A meal header or bullet above it that has no\gets one in the same transaction. A bullet inserted between two lines of the same meal carries the\on.Enter continues the meal. In a menu, Enter at the end of a meal header or bullet adds the
\and starts the next line with-, like a list in a Markdown editor. Enter on an empty bullet ends the meal: the bullet and the\before it go, and a blank line follows. Without this, a hand-typed bullet after- @./Baklava{…}was joined to it and rendered as one item ("Baklava - coffee"). Elsewhere, and in recipes, Enter is unchanged; autocompletion keeps Enter while its list is open.Why a menu button rather than a
<select>: on Windows/Linux, arrowing through a closed<select>fireschange, which would insert a meal on every keypress.Recipe picker (both editors)
aria-activedescendant). Empty or 1-character query: the wholeGET /api/recipestree. From 2 characters:GET /api/search?q=, debounced 300 ms, like the header search..menuresults and the file being edited are never offered. Paths lose.cookand gain./.servingsfrontmatter; left empty it inserts{}.@./Path/Name{}inline, cursor in the braces.Fix: new files were not flushed before the redirect
The first CI run failed
a_recipe_is_still_the_default: it read""back right afterPOST /newredirected.create_recipewrites through a tokioFile, which hands the bytes to a background task. Without aflush(), the redirect (and the editor loading the file) can beat the write. This predates the PR and affects recipes too. It came in with 7343753, which replaced a synchronousstd::fs::writewithcreate_new+write_all. (The commit message of ecfbc70 saystokio::fs::write; it wasstd::fs::write.) Fixed in ecfbc70;new_menu_testthen passed 30 runs in a row locally.i18n
All new strings are translated into every locale (second commit). Italian never received the #540 toolbar strings, so its toolbar is still half English; that is left for a separate change.
Tests
tests/new_menu_test.rs(throughcommon::with_isolated_config):kind=menucreatesX.menuwith the starter content and redirects to the editor, which opens in menu mode.kind=recipeand nokindstill create.cookfiles.report,"",../menu,MENU) are refused with 400 and create nothing.../../Escapestays inside the collection.kind=menu.tests/e2e/menu-editor.spec.ts:{}, no menus, keyboard, focus trap./recipe/…menu, then the file is deleted. Every other test interceptsPUT.editor-toolbar.spec.ts: the recipe toolbar now has 8 buttons.Checked locally:
cargo fmt --check: clean.cargo clippy --all-targets: no warnings.cargo test: all suites pass, including the 7 new tests.npx playwright test --project=chromium: 210 passed, 5 skipped.POST /api/shopping_list/add_menu: 200.🤖 Generated with Claude Code