Skip to content

fix(server): keep the ticks on aisle names when a recipe is removed - #655

Merged
LeMyst merged 1 commit into
cooklang:mainfrom
LeMyst:fix/checked-compact-common-names
Oct 9, 2026
Merged

LeMyst merged 1 commit into
cooklang:mainfrom
LeMyst:fix/checked-compact-common-names

Conversation

@LeMyst

@LeMyst LeMyst commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Closes #654

Problem

Removing a recipe from the shopping list unticked items still on the list. Since 7700032 (#318), the remove drops the ticks of ingredients no longer on the list, comparing them with the names the recipes write (eggs). But POST /api/shopping_list shows the list, and the page ticks it, under the aisle file's common names (egg for egg | eggs). So a ticked egg was dropped while another recipe still needed eggs.

Seed repro: add Easy Pancakes and Mexican Style Burrito (both @eggs), tick egg and butter, remove the pancakes. checked went from ["egg","butter"] to ["butter"]; butter, written the same in both recipes, kept its tick.

Fix

aggregate_current_ingredient_names returns each name both as the recipes write it and as its common name in the aisle file. The common name is what the page ticks. The recipe name is kept too, so a tick made under it (before the aisles page grouped it, say) still counts. Compaction only ever drops ticks, so a longer list of names to keep can only keep more.

This covers the remove and POST /api/shopping_list/compact, the two callers. Reading the aisle file moves to read_aisle_file, shared with the list itself.

Tests

Appended to tests/shopping_list_remove_test.rs. The fixture gains two recipes using eggs and a config/aisle.conf with egg | eggs.

Test Without the fix With it
a tick on the aisle name (egg) survives the remove fails passes
a tick on the recipe name (eggs) survives passes passes
a tick on an ingredient gone from the list (milk) is dropped, egg kept fails passes
  • cargo fmt --check, cargo clippy --all-targets: clean.
  • cargo test --no-fail-fast: 1166 passed, 0 failed.
  • The seed repro above with curl against the fixed server: checked stays ["butter","egg"], and POST /api/shopping_list answers with both.

No overlap with #648 (template only).

🤖 Generated with Claude Code

Removing a recipe from the shopping list drops the ticks of ingredients no
longer on it. It compared the ticks with the names the recipes write
(`eggs`), but the list is shown, and ticked, under the aisle file's
common names (`egg`), so a ticked `egg` was dropped while another recipe
still needed eggs. This has been so since 7700032 (cooklang#318); the aisles page's
grouping makes such synonyms more common.

The names to keep are now the recipes' own names and their common names,
for the remove and for `POST /api/shopping_list/compact`. Reading the
aisle file moves to `read_aisle_file`, shared with the list itself.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@LeMyst
LeMyst marked this pull request as ready for review October 9, 2026 20:02
@LeMyst
LeMyst merged commit ae06d8f into cooklang:main Oct 9, 2026
6 checks passed
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: removing a recipe unticks items shown under an aisle name

1 participant