Skip to content

feat(ui): open a menu's recipes at the scale the menu asks for #560

Closed

Description

@LeMyst

Problem

A menu reference such as @./Risotto{2%servings} is scaled on the menu page: the menu builder turns it into a factor (here ×0.5 for a 4-serving risotto), multiplied by the menu's own ?scale=. It is the same factor the menu API and "add to shopping list" use, and the page shows it as a (×0.5) badge.

The link next to that badge ignores it: templates/menu.html links every reference to /recipe/{path} with no scale, so the recipe opens at ×1. Someone cooking from the menu sees different quantities than the menu asked for, and "add to shopping list" on that recipe page adds the wrong amounts.

Proposal

  • In templates/menu.html (both reference-link branches), append ?scale={factor} whenever the factor is not 1. The recipe page already takes ?scale= (RecipeQuery).
  • Static exports (cook build web, static_mode) link to .html files that cannot scale from a query string, so they keep plain links.
  • Format the factor instead of printing the raw f64, both in the URL and in the badge, which today can read (×0.3333333333333333).
  • The recipe page's scale stepper (min="0.5" step="0.5") cannot represent such factors: 0.333 is below its minimum and off its step. It should accept the scale it was opened at, so the field isn't shown as invalid and "−" doesn't jump up to 0.5.

Tests

  • Extend html_menu_page_agrees_with_the_menu_api (tests/menu_api_test.rs): its regex only matches links without a query string. It should also check that each link's ?scale= matches the factor the API reports (none for ×1), at menu scale 1 and 2.
  • A static-mode check that exported menu links carry no query string.
  • Playwright: follow a scaled reference from a seed menu and check the recipe page opens at that scale.

Activity

  1. added 2 commits that reference this issue on Sep 28, 2026
    587b8d3
    7228a6c
  2. added a commit that references this issue on Sep 28, 2026
    4c46135
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions