Repository navigation
feat(ui): change a meal plan from its calendar - #610
Merged
Merged
Conversation
LeMyst
force-pushed
the
feat/planner-editing
branch
2 times, most recently
from
October 3, 2026 19:05
8d0d72f to
8d8d671
Compare
Those who may edit recipes can now change a plan without opening the
text editor:
- + beside each day's meal opens the recipe picker from the editor and
adds `- @./Folder/Recipe{2%servings}` at the end of that meal,
servings starting at the plan's own. A missing day or meal is written
for it: days in date order, meals in the order the plan's days name
them.
- ⋯ beside each line opens an ARIA menu: Move to…, Copy to…, Remove.
Move and Copy ask for a day and a meal in a small dialog. Lines can
also be dragged onto another meal; Alt, Ctrl or ⌘ copies.
The `.menu` text stays the source of truth. `POST /api/plans/{*path}`
makes one change at a time on the server (`server::plan_text`), touching
only the lines concerned: comments, notes, frontmatter and other
sections keep their bytes, Windows line endings stay, and the ` \` that
joins a meal's lines is kept right when the last line goes. Removing a
meal's only line leaves an empty bullet, as a new plan has, so the meal
keeps its slot. Days are read as the calendar reads them
(`web::plan::section_date`): a `YYYY-MM-DD` anywhere in a section name,
and a `= 2026-10-08 Dinner` section is that day's dinner.
Each change carries the SHA-256 of the text the page was showing, and
names its line by day, meal, index and text; anything else is refused
with 409, so a change never lands on a plan edited elsewhere in the
meantime. The page reloads after a change and puts focus back on the
meal's +. A meal whose lines the calendar cannot match one for one with
the file gets no line controls.
The route needs the editor role (`WRITES` table); it is in the API
reference and docs/api.md. The recipe picker markup moves to
`templates/recipe_picker.html`, shared by the editor and the plan page.
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/planner-editing
branch
from
October 4, 2026 10:53
8d8d671 to
ac84f61
Compare
LeMyst
marked this pull request as ready for review
October 4, 2026 10:57
4 tasks
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. Builds on #596, now merged; rebased onto main (27006e1). Since #596 dropped its
plan:block, a plan is now 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 2 of the proposal: a meal plan is changed from its calendar, without opening the text editor.
What changes
For those who may edit recipes (
viewer.can_edit_recipes(), not in static sites):- @./Folder/Recipe{2%servings}at the end of that meal — the same text the editor's Add recipe writes. Servings start at the plan's ownservings; emptied, the reference is{}. A missing day section or meal heading is written for it: days in date order (before the first later day, else after the last earlier one), meals in the order the plan's days name them (as the calendar orders its slots), with the\that keeps a meal's lines together.Design notes
.menutext stays the source of truth.POST /api/plans/{*path}does the text operation in Rust (src/server/plan_text.rs, unit-tested), touching only the lines concerned. Comments, notes, frontmatter and other sections keep their bytes. CRLF files stay CRLF. Removing a meal's last line drops the\from the line before it. Removing a meal's only line leaves an empty-bullet, as a new plan has, so the meal keeps its slot in the file and an add fills it again.version, the SHA-256 of the text the page rendered, and names its line by date + meal + index + text. A different version, or a line that no longer reads the same, gets409with the current version, and the page offers a reload. Nothing is ever applied to a text the user did not see. Changes are serialised by a mutex around the read-check-write.addtakes a recipe's path and builds the reference on the server, after checking the recipe exists inside the collection (recipe_file), so a request cannot write arbitrary Cooklang into the plan. Meal names that would not read back as the same meal (:, brackets,@, a leading-/=) are refused with 400./api/plansis in theWRITEStable atEditRecipes, and covered by the middleware test. Every change is logged withactivity::record, its text quoted.static/js/src/planner.jsandpicker.jsas ES modules straight from/static/js/src/rather than through the editor bundle, so the plan page doesn't pull in CodeMirror. Static sites never get the controls.templates/recipe_picker.html, included byedit.htmlandmenu.html.Screenshots
Tests
server::plan_text, 14 tests): filling a new plan's empty bullet (plan made byplan_starter), adding after a meal's last line, a missing meal placed by the plan's order, a missing day between / after days / in a plan with none, before undated sections, removing first/middle/last/only lines, aBreakfast (08:30):meal, stale index or text refused, bad meal names refused, CRLF kept, two sections of one day, a comment between lines left alone.tests/plan_edit_test.rs, 5 tests,with_isolated_config): the page's version, + buttons and line texts; add to a new day; copy then move, with the comment kept byte for byte; 409 on an old version or changed line; 400/404/422 for bad recipes, paths, meals, dates, servings and non-plans, with the file unchanged.POST /api/plans/…needsEditRecipes.docs/api.mdregenerated.tests/e2e/plan-editing.spec.ts, 6 tests): add via the picker (file checked, focus restored), remove from the menu, move with the keyboard only, Escape returns focus, a change to a plan edited elsewhere is refused, axe on the calendar and the move dialog.cargo fmt,cargo clippy --all-targets(also--no-default-features) clean,cargo test1007 passed. Full chromium Playwright: 254 passed, 5 skipped. The only 3 failures are theshopping-list-copy/shopping-list-liveticked-item tests, which are flaky in parallel here and pass with--workers=1(9/9).After the rebase,
server::plan_textreads days withweb::plan::section_date(so a= 2026-10-08 Dinnersection is that day's Dinner, editable like any meal), takes the meal order from the text (meal_order), and refuses a menu dated on fewer than two days (web::plan::is_plan). Full chromium Playwright run at 8d8d671: 257 passed, 5 skipped. Imageregistry.favier.io/cookcli:pr-610-8d8d671.🤖 Generated with Claude Code
https://claude.ai/code/session_01RXA3hAKY9Q8hLCZGeokLPK