Skip to content

fix(server): name shopping list entries by their recipe title - #625

Merged
LeMyst merged 1 commit into
cooklang:mainfrom
LeMyst:fix/shopping-list-titles
Oct 5, 2026
Merged

LeMyst merged 1 commit into
cooklang:mainfrom
LeMyst:fix/shopping-list-titles

Conversation

@LeMyst

@LeMyst LeMyst commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator

Closes #624.

The shopping list's "Selected recipes" panel named every entry by its file name. Since 7700032 (#318), .shopping-list stores no name, so GET /api/shopping_list/items derived one from the path. With the seed, lamb-chops.cook (title: Sicilian-style Scottadito Lamb Chops) showed as lamb-chops.

What changes

  • get_shopping_list_items resolves every entry's name through cookcli_core::recipe::read. That covers recipes, menus and the recipes nested in a menu. read is the existing rule cook recipe uses: metadata title, else the file stem. When a file is missing, unreadable or has a path that isn't safe, the entry keeps today's recipe_display_name().
  • Sub-recipes: StoredEntry gets a display-only included_reference_names, in the same order as included_references. Each reference is resolved with resolve_reference from the entry's directory, so ../ references work. The field is never stored: None on load and ignored when adding.
  • templates/shopping_list.html uses those names for the sub-recipe links and falls back to the last path segment as before.
  • API docs (api_docs.rs, regenerated docs/api.md): describe the title rule and the new field. The example now uses the seed's real titles.

Titles are resolved when the list is served rather than stored, so lists written before this, and recipes retitled later, show the current title.

Screenshot

Seed collection with lamb-chops, Risotto (×2) and the 2 Day Plan menu added:

Selected recipes panel showing Sicilian-style Scottadito Lamb Chops and Classic Risotto alla Milanese, also inside the 2 Day Plan menu

Tests

  • New tests/shopping_list_titles_test.rs (server spawned via common::with_isolated_config) covers:
    • a titled recipe and its titled sub-recipe;
    • a ../ reference;
    • an untitled recipe and a missing file, which keep the file name;
    • a titled menu with its nested recipes.
  • cargo fmt, cargo clippy --all-targets clean; cargo test --workspace: 1507 passed, 0 failed.

🤖 Generated with Claude Code

The "Selected recipes" panel named each entry by its file name: the
`.shopping-list` format introduced in 7700032 (cooklang#318) stores no name, so
`/api/shopping_list/items` derived one from the path. Before that the
recipe page posted its title. A recipe declaring `title:` showed as
`lamb-chops` instead of "Sicilian-style Scottadito Lamb Chops".

`get_shopping_list_items` now reads each entry, nested menu recipe and
sub-recipe reference through `cookcli_core::recipe::read` and uses its
title, keeping the file name when there is none or the file can't be
read. Sub-recipe names go in a new `included_reference_names`, parallel
to `included_references`, which the page uses for the link labels.
Resolved on the way out, so existing lists and later retitles are shown
correctly too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@LeMyst
LeMyst marked this pull request as ready for review October 5, 2026 18:22
@LeMyst
LeMyst merged commit 5db3066 into cooklang:main Oct 5, 2026
6 checks passed
@LeMyst
LeMyst deleted the fix/shopping-list-titles branch October 5, 2026 20:50
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.

Shopping list shows recipe file names instead of their titles

1 participant